7#ifndef gbLAB_LatticeCore_cpp_
8#define gbLAB_LatticeCore_cpp_
10#include "../../include/Lattices/LatticeCore.h"
11#include "../../include/Math/BestRationalApproximation.h"
19 Eigen::Array<IntScalarType, dim, 1> nums = VectorDimI::Zero();
21 if (nd.squaredNorm() > 0.0)
23 const Eigen::Array<double, dim, 1> nda(nd.array().abs());
25 const double maxVal(nda.maxCoeff(&maxID));
28 nums = VectorDimI::Ones();
29 Eigen::Array<IntScalarType, dim, 1> dens = VectorDimI::Ones();
32 for (
int k = 0; k < dim; ++k)
42 for (
int k = 0; k < dim; ++k)
44 nums(k) *= (denProd / dens(k));
56 if ((nd - rd).norm() > roundTol)
58 std::cout <<
"nd=" << nd.transpose() << std::endl;
59 std::cout <<
"rd=" << rd.transpose() << std::endl;
60 std::cout <<
"rounding error = |nd-rd| = " << (nd-rd).norm() << std::endl;
61 throw(std::runtime_error(
"Input vector is not a lattice vector"));
63 return rd.template cast<IntScalarType>();
Eigen::Matrix< IntScalarType, dim, 1 > VectorDimI
long long int IntScalarType
Eigen::Matrix< double, dim, 1 > VectorDimD
static VectorDimI rationalApproximation(VectorDimD v)
Approximates a direction in terms of integer coordinates.
Eigen::Matrix< double, dim, dim > MatrixDimD
static VectorDimI integerCoordinates(const VectorDimD &d, const MatrixDimD &invA)
Returns the integer coordinates of a vector with respect to a lattices with structure matrix .