oILAB
Loading...
Searching...
No Matches
RationalLatticeDirection.cpp
Go to the documentation of this file.
1/* This file is part of gbLAB.
2 *
3 * gbLAB is distributed without any warranty under the MIT License.
4 */
5
6
7#ifndef gbLAB_RationalLatticeDirection_cpp_
8#define gbLAB_RationalLatticeDirection_cpp_
9
10#include <LatticeModule.h>
12
13namespace gbLAB
14{
15 /**********************************************************************/
16 template <int dim>
18 /* init */,
19 dir(_dir)
20 {
21 }
22
23 /**********************************************************************/
24 template <int dim>
29
30 /**********************************************************************/
31 template <int dim>
33 /* init */ rat(Rational<IntScalarType>(IntegerMath<IntScalarType>::gcd(v), 1)),
34 /* init */ dir(v)
35 {
36 }
37
38 /**********************************************************************/
39
40 template <int dim>
42 {
43 return dir.cartesian() * rat.asDouble();
44 }
45
46 /**********************************************************************/
47 template <int dim>
52
53 /**********************************************************************/
54 template <int dim>
59
60 /**********************************************************************/
61 template <int dim>
66
67 /**********************************************************************/
68 template <int dim>
70 {
71 assert(&dir.lattice == &other.dir.lattice && "Rational Lattice Vector Type belong to different Lattices.");
72 //const VectorDimI temp(rat.n * other.rat.d * dir + other.rat.n * rat.d * other.dir);
73 const VectorDimI temp(rat.n * other.rat.d * dir.latticeVector() + other.rat.n * rat.d * other.dir.latticeVector());
75 const LatticeVector<dim> v((temp/gcd).eval(), dir.lattice);
76 return RationalLatticeDirection<dim>(Rational(gcd, rat.d * other.rat.d), LatticeDirection<dim>(v));
77 }
78
79 /**********************************************************************/
80 template <int dim>
82 {
83 assert(&dir.lattice == &other.dir.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
84 //const VectorDimI temp(rat.n * other.rat.d * dir - other.rat.n * rat.d * other.dir);
85 const VectorDimI temp(rat.n * other.rat.d * dir.latticeVector() - other.rat.n * rat.d * other.dir.latticeVector());
87 const LatticeVector<dim> v((temp / gcd).eval(), dir.lattice);
88 return RationalLatticeDirection<dim>(Rational(gcd, rat.d * other.rat.d), LatticeDirection<dim>(v));
89 }
90
91 /**********************************************************************/
92 template <int dim>
94 {
95 assert(&dir.lattice == &other.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
98 }
99
100 /**********************************************************************/
101 template <int dim>
103 {
104 assert(&dir.lattice == &other.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
106 return this->operator-(RationalLatticeDirection<dim>(Rational<IntScalarType>(gcd, 1), LatticeDirection<dim>(other)));
107 }
108
109 /**********************************************************************/
110 template <int dim>
112 {
113 //return dir.squaredNorm() * std::pow(rat.asDouble(), 2);
114 return dir.latticeVector().squaredNorm() * std::pow(rat.asDouble(), 2);
115 }
116
117 template<int dim>
122
123 template struct RationalLatticeDirection<1>;
125 template struct RationalLatticeDirection<2>;
127 template struct RationalLatticeDirection<3>;
129 template struct RationalLatticeDirection<4>;
131 template struct RationalLatticeDirection<5>;
133
134} // end namespace
135#endif
LatticeVector class.
const Lattice< dim > & lattice
OperatorSum< E1, E2, dim > operator+(const Operator< E1, dim > &u, const Operator< E2, dim > &v)
Definition Operator.h:65
LatticeVector< dim > operator*(const typename LatticeVector< dim >::IntScalarType &scalar, const LatticeVector< dim > &L)
LatticeDirection class.
LatticeCore< dim >::VectorDimI VectorDimI
RationalLatticeDirection< dim > operator/(const IntScalarType &scalar) const
Rational< IntScalarType > dot(const ReciprocalLatticeVector< dim > &other) const
LatticeCore< dim >::VectorDimD VectorDimD
RationalLatticeDirection< dim > operator*(const IntScalarType &scalar) const
RationalLatticeDirection(const Rational< IntScalarType > &_rat, const LatticeDirection< dim > &_dir)
const LatticeDirection< dim > dir
RationalLatticeDirection< dim > operator+(const RationalLatticeDirection< dim > &other) const
LatticeCore< dim >::IntScalarType IntScalarType
const Rational< IntScalarType > rat
RationalLatticeDirection< dim > operator-(const RationalLatticeDirection< dim > &other) const