7#ifndef gbLAB_LatticeCore_cpp_
8#define gbLAB_LatticeCore_cpp_
22 Eigen::Array<IntScalarType, dim, 1> nums = VectorDimI::Zero();
24 if (nd.squaredNorm() > 0.0)
26 const Eigen::Array<double, dim, 1> nda(nd.array().abs());
28 const double maxVal(nda.maxCoeff(&maxID));
31 nums = VectorDimI::Ones();
32 Eigen::Array<IntScalarType, dim, 1> dens = VectorDimI::Ones();
35 for (
int k = 0; k < dim; ++k)
45 for (
int k = 0; k < dim; ++k)
47 nums(k) *= (denProd / dens(k));
59 if ((nd - rd).norm() > roundTol)
61 std::cout <<
"nd=" << nd.transpose() << std::endl;
62 std::cout <<
"rd=" << rd.transpose() << std::endl;
63 std::cout <<
"rounding error = |nd-rd| = " << (nd-rd).norm() << std::endl;
64 throw(std::runtime_error(
"Input vector is not a lattice vector"));
66 return rd.template cast<IntScalarType>();
static VectorDimI rationalApproximation(VectorDimD v)
Approximates a direction in terms of integer coordinates.
static VectorDimI integerCoordinates(const VectorDimD &d, const MatrixDimD &invA)
Returns the integer coordinates of a vector with respect to a lattices with structure matrix .
Eigen::Matrix< double, dim, dim > MatrixDimD
Eigen::Matrix< double, dim, 1 > VectorDimD
long long int IntScalarType
Eigen::Matrix< IntScalarType, dim, 1 > VectorDimI