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 "../../include/Lattices/RationalLatticeDirection.h"
11#include "../../include/Lattices/LatticeModule.h"
12
13namespace oILAB {
14/**********************************************************************/
15template <int dim>
17 const Rational<IntScalarType> &_rat, const LatticeDirection<dim> &_dir)
18 : /* init */ rat(_rat)
19 /* init */,
20 dir(_dir) {}
21
22/**********************************************************************/
23template <int dim>
27
28/**********************************************************************/
29template <int dim>
31 const LatticeVector<dim> &v)
32 : /* init */ rat(
34 /* init */ dir(v) {}
35
36/**********************************************************************/
37
38template <int dim>
41 return dir.cartesian() * rat.asDouble();
42 }
43
44 /**********************************************************************/
45 template <int dim>
50
51 /**********************************************************************/
52 template <int dim>
57
58 /**********************************************************************/
59 template <int dim>
64
65 /**********************************************************************/
66 template <int dim>
68 {
69 assert(&dir.lattice == &other.dir.lattice && "Rational Lattice Vector Type belong to different Lattices.");
70 //const VectorDimI temp(rat.n * other.rat.d * dir + other.rat.n * rat.d * other.dir);
71 const VectorDimI temp(rat.n * other.rat.d * dir.latticeVector() + other.rat.n * rat.d * other.dir.latticeVector());
73 const LatticeVector<dim> v((temp/gcd).eval(), dir.lattice);
74 return RationalLatticeDirection<dim>(Rational(gcd, rat.d * other.rat.d), LatticeDirection<dim>(v));
75 }
76
77 /**********************************************************************/
78 template <int dim>
80 {
81 assert(&dir.lattice == &other.dir.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
82 //const VectorDimI temp(rat.n * other.rat.d * dir - other.rat.n * rat.d * other.dir);
83 const VectorDimI temp(rat.n * other.rat.d * dir.latticeVector() - other.rat.n * rat.d * other.dir.latticeVector());
85 const LatticeVector<dim> v((temp / gcd).eval(), dir.lattice);
86 return RationalLatticeDirection<dim>(Rational(gcd, rat.d * other.rat.d), LatticeDirection<dim>(v));
87 }
88
89 /**********************************************************************/
90 template <int dim>
92 {
93 assert(&dir.lattice == &other.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
96 }
97
98 /**********************************************************************/
99 template <int dim>
101 {
102 assert(&dir.lattice == &other.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
104 return this->operator-(RationalLatticeDirection<dim>(Rational<IntScalarType>(gcd, 1), LatticeDirection<dim>(other)));
105 }
106
107 /**********************************************************************/
108 template <int dim>
110 {
111 //return dir.squaredNorm() * std::pow(rat.asDouble(), 2);
112 return dir.latticeVector().squaredNorm() * std::pow(rat.asDouble(), 2);
113 }
114
115 template<int dim>
120
121 template struct RationalLatticeDirection<1>;
123 template struct RationalLatticeDirection<2>;
125 template struct RationalLatticeDirection<3>;
127 template struct RationalLatticeDirection<4>;
129 template struct RationalLatticeDirection<5>;
131
132 } // namespace oILAB
133#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.
Rational< IntScalarType > dot(const ReciprocalLatticeVector< dim > &other) const
const Rational< IntScalarType > rat
RationalLatticeDirection< dim > operator+(const RationalLatticeDirection< dim > &other) const
LatticeCore< dim >::IntScalarType IntScalarType
RationalLatticeDirection(const Rational< IntScalarType > &_rat, const LatticeDirection< dim > &_dir)
RationalLatticeDirection< dim > operator-(const RationalLatticeDirection< dim > &other) const
LatticeCore< dim >::VectorDimD VectorDimD
RationalLatticeDirection< dim > operator*(const IntScalarType &scalar) const
LatticeCore< dim >::VectorDimI VectorDimI
RationalLatticeDirection< dim > operator/(const IntScalarType &scalar) const
const LatticeDirection< dim > dir