7#ifndef gbLAB_LatticeVector_cpp_
8#define gbLAB_LatticeVector_cpp_
10#include "../../include/Lattices/LatticeModule.h"
58 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
59 base() = other.
base();
66 assert(&lattice == &other.lattice &&
"LatticeVectors belong to different Lattices.");
67 base() = other.base();
75 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
84 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
85 base() += other.
base();
93 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
102 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
103 base() -= other.
base();
118 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
126 assert(&lattice == &other.
lattice &&
"LatticeVectors belong to different Lattices.");
134 return lattice.latticeBasis * this->
template cast<double>();
151 template<
int dim>
template<
int dm>
152 typename std::enable_if<dm==3,void>::type
155 double det= (basis[0].cross(basis[1])).dot(basis[2]);
156 assert( abs(det) > FLT_EPSILON );
157 auto normal= basis[1].cross(basis[2]);
158 input= input - floor( (
double)input.
dot(normal)/basis[0].dot(normal)-shift(0) ) * basis[0];
159 assert((
double)(input.
dot(normal))/basis[0].dot(normal)<= shift(0)+1.0 &&
160 (
double)(input.
dot(normal))/basis[0].dot(normal)>= shift(0));
161 normal= basis[2].cross(basis[0]);
162 input= input - floor( (
double)input.
dot(normal)/basis[1].dot(normal)-shift(1) ) * basis[1];
163 assert((
double)(input.
dot(normal))/basis[1].dot(normal)<= shift(1)+1.0 &&
164 (
double)(input.
dot(normal))/basis[1].dot(normal)>= shift(1));
165 normal= basis[0].cross(basis[1]);
166 input= input - floor( (
double)input.
dot(normal)/basis[2].dot(normal)-shift(2) ) * basis[2];
167 assert((
double)(input.
dot(normal))/basis[2].dot(normal)<= shift(2)+1.0 &&
168 (
double)(input.
dot(normal))/basis[2].dot(normal)>= shift(2));
171 template<
int dim>
template<
int dm>
172 typename std::enable_if<dm==3,void>::type
176 L.col(0)= basis[0].cartesian();
177 L.col(1)= basis[1].cartesian();
178 L.col(2)= basis[2].cartesian();
180 Eigen::Vector3d inputCoordinates= ((L.inverse()*input).array()-shift.array()).floor();
181 input= input - L*inputCoordinates;
185 template<
int dim>
template<
int dm>
186 typename std::enable_if<dm==2,void>::type
189 auto normal= basis[1].cross();
190 input= input - input.
dot(normal)/basis[0].dot(normal) * basis[0];
191 normal= basis[0].cross();
192 input= input - input.
dot(normal)/basis[1].dot(normal) * basis[1];
195 template<
int dim>
template<
int dm>
196 typename std::enable_if<dm==2,void>::type
202 template class LatticeVector<1>;
const Lattice< dim > & lattice
Eigen::Matrix< typename LatticeCore< dim >::IntScalarType, dim, 1 > BaseType
IntScalarType dot(const ReciprocalLatticeVector< dim > &other) const
LatticeCore< dim >::VectorDimI VectorDimI
LatticeVector< dim > & operator-=(const LatticeVector< dim > &other)
static std::enable_if< dm==2, void >::type modulo(LatticeVector< dim > &input, const std::vector< LatticeVector< dim > > &basis, const VectorDimD &shift=VectorDimD::Zero())
LatticeCore< dim >::IntScalarType IntScalarType
LatticeCore< dim >::VectorDimD VectorDimD
LatticeVector(const Lattice< dim > &lat)
LatticeVector< dim > & operator+=(const LatticeVector< dim > &other)
LatticeVector< dim > operator-(const LatticeVector< dim > &other) const
LatticeVector< dim > operator*(const IntScalarType &scalar) const
LatticeVector< dim > operator+(const LatticeVector< dim > &other) const
LatticeVector< dim > & operator=(const LatticeVector< dim > &other)
VectorDimD cartesian() const
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)