7#ifndef gbLAB_LatticeVector_cpp_
8#define gbLAB_LatticeVector_cpp_
60 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
61 base() = other.
base();
68 assert(&lattice == &other.lattice &&
"LatticeVectors belong to different Lattices.");
69 base() = other.base();
77 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
86 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
87 base() += other.
base();
95 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
104 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
105 base() -= other.
base();
120 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
128 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
136 return lattice.latticeBasis * this->
template cast<double>();
153 template<
int dim>
template<
int dm>
154 typename std::enable_if<dm==3,void>::type
157 double det= (basis[0].cross(basis[1])).dot(basis[2]);
158 assert( abs(det) > FLT_EPSILON );
159 auto normal= basis[1].cross(basis[2]);
160 input= input - floor( (
double)input.
dot(normal)/basis[0].dot(normal)-shift(0) ) * basis[0];
161 assert((
double)(input.
dot(normal))/basis[0].dot(normal)<= shift(0)+1.0 &&
162 (
double)(input.
dot(normal))/basis[0].dot(normal)>= shift(0));
163 normal= basis[2].cross(basis[0]);
164 input= input - floor( (
double)input.
dot(normal)/basis[1].dot(normal)-shift(1) ) * basis[1];
165 assert((
double)(input.
dot(normal))/basis[1].dot(normal)<= shift(1)+1.0 &&
166 (
double)(input.
dot(normal))/basis[1].dot(normal)>= shift(1));
167 normal= basis[0].cross(basis[1]);
168 input= input - floor( (
double)input.
dot(normal)/basis[2].dot(normal)-shift(2) ) * basis[2];
169 assert((
double)(input.
dot(normal))/basis[2].dot(normal)<= shift(2)+1.0 &&
170 (
double)(input.
dot(normal))/basis[2].dot(normal)>= shift(2));
173 template<
int dim>
template<
int dm>
174 typename std::enable_if<dm==3,void>::type
178 L.col(0)= basis[0].cartesian();
179 L.col(1)= basis[1].cartesian();
180 L.col(2)= basis[2].cartesian();
182 Eigen::Vector3d inputCoordinates= ((L.inverse()*input).array()-shift.array()).floor();
183 input= input - L*inputCoordinates;
187 template<
int dim>
template<
int dm>
188 typename std::enable_if<dm==2,void>::type
191 auto normal= basis[1].cross();
192 input= input - input.
dot(normal)/basis[0].dot(normal) * basis[0];
193 normal= basis[0].cross();
194 input= input - input.
dot(normal)/basis[1].dot(normal) * basis[1];
197 template<
int dim>
template<
int dm>
198 typename std::enable_if<dm==2,void>::type
204 template class LatticeVector<1>;
VectorDimD cartesian() const
static std::enable_if< dm==2, void >::type modulo(LatticeVector< dim > &input, const std::vector< LatticeVector< dim > > &basis, const VectorDimD &shift=VectorDimD::Zero())
const Lattice< dim > & lattice
LatticeVector< dim > & operator-=(const LatticeVector< dim > &other)
LatticeCore< dim >::VectorDimD VectorDimD
LatticeVector< dim > operator+(const LatticeVector< dim > &other) const
LatticeVector< dim > operator*(const IntScalarType &scalar) const
LatticeVector< dim > & operator+=(const LatticeVector< dim > &other)
IntScalarType dot(const ReciprocalLatticeVector< dim > &other) const
LatticeCore< dim >::VectorDimI VectorDimI
LatticeCore< dim >::IntScalarType IntScalarType
LatticeVector(const Lattice< dim > &lat)
LatticeVector< dim > & operator=(const LatticeVector< dim > &other)
LatticeVector< dim > operator-(const LatticeVector< dim > &other) const
Eigen::Matrix< typename LatticeCore< dim >::IntScalarType, dim, 1 > BaseType
const Lattice< dim > & lattice
LatticeVector< dim > operator*(const typename LatticeVector< dim >::IntScalarType &scalar, const LatticeVector< dim > &L)
const ReciprocalLatticeVector< dim > & reciprocalLatticeVector() const
Returns a constant reference to the base class (ReciprocalLatticeVector)