Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
CSL.cpp
Go to the documentation of this file.
1/* This file is part of PIL, the Particle Interaction Library.
2 *
3 *
4 * MODEL is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_CSL_cpp_
9#define model_CSL_cpp_
10
11#include <LatticeModule.h>
12#include <CSL.h>
13
14namespace model
15{
21
22 /**********************************************************************/
23 template <int dim>
24 typename CSL<dim>::MatrixDimD CSL<dim>::getLatticeBasis(const LatticeTransitionMatrix<dim> &rm,
25 const typename CSL<dim>::LatticeType &A,
26 const typename CSL<dim>::LatticeType &B,
27 const bool &useRLLL)
28 {
29 // The transition matrix is T=P/sigma, where P=rm.integerMatrix is
30 // an integer matrix and sigma=rm.sigma is an integer
31 // The integer matrix P can be decomposed as P=X*D*Y using the Smith decomposition.
32 // X and Y are unimodular, and D is diagonal with D(k,k) dividing D(k+1,k+1)
33 // The decomposition also computes the matices U and V such that D=U*P*V
34 SmithDecomposition<dim> sd(rm.integerMatrix);
35
36 // From T=inv(A)*B=P/sigma=X*D*Y/sigma=X*D*inv(V)/sigma, we have
37 // B1*(sigma*I)=A1*D
38 // where
39 // B1=B*V
40 // A1=A*X
41 // Since V and X are unimodular matrices, B1 and A1 are new bases
42 // of the lattices B and A, respectively. Moreover, since
43 // (sigma*I) and D are diagonal, the columns of B1 and A1 are
44 // proportional, with rational proportionality factors different for each column.
45 // For example, columns "i" read
46 // b1_i*sigma=a1_i*D(i,i)
47 // Therefore, the i-th primitive vectors of the CSL is
48 // c_i=b1_i*sigma/gcd(sigma,D(i,i))=a1_i*D(i,i)/gcd(sigma,D(i,i))
49 // or, in matrix form
50 // C=B1*N=A1*M, that is
51 // C=B*V*N=A*X*M
52 // where M=diag(D(i,i)/gcd(sigma,D(i,i))) and
53 // N=diag(sigma/gcd(sigma,D(i,i))) and
54
55 MatrixInt M(MatrixInt::Identity());
56 MatrixInt N(MatrixInt::Identity());
57 for (int i = 0; i < dim; ++i)
58 {
59 const IntValueType &dii = sd.matrixD()(i, i);
60 M(i, i) = dii / rm.gcd(rm.sigma, dii);
61 N(i, i) = rm.sigma / rm.gcd(rm.sigma, dii);
62 }
63
64 const MatrixDimD C1 = A.latticeBasis * (sd.matrixX() * M).template cast<double>();
65 const MatrixDimD C2 = B.latticeBasis * (sd.matrixV() * N).template cast<double>();
66 assert((C1 - C2).norm() < FLT_EPSILON && "CSL calculation failed.");
67
68 if (useRLLL)
69 {
70 return RLLL(0.5 * (C1 + C2), 0.75).reducedBasis();
71 }
72 else
73 {
74 return 0.5 * (C1 + C2);
75 }
76 }
77
78
79
80 /**********************************************************************/
81 template <int dim>
82 CSL<dim>::CSL(const typename CSL<dim>::LatticeType& A_in,
83 const typename CSL<dim>::LatticeType& B_in,
84 const bool& useRLLL) :
85 /* init */ LatticeTransitionMatrix<dim>(A_in,B_in)
86 /* init */,Lattice<dim>(getLatticeBasis(*this,A_in,B_in,useRLLL),MatrixDimD::Identity())
87 {
88
89 if (true)
90 { //verify that CSL can be obtained as multiple of A and B
91
92 const MatrixDimD tempA(A_in.reciprocalBasis.transpose() * this->latticeBasis);
93 assert((tempA - tempA.array().round().matrix()).norm() < FLT_EPSILON && "CSL is not a multiple of A");
94
95 const MatrixDimD tempB(B_in.reciprocalBasis.transpose() * this->latticeBasis);
96 assert((tempB - tempB.array().round().matrix()).norm() < FLT_EPSILON && "CSL is not a multiple of B");
97 }
98 // update(useRLLL);
99 }
100
101 template class CSL<3>;
102
103} // end namespace
104#endif
Eigen::Matrix3d M
CSL(const LatticeType &A_in, const LatticeType &B_in, const bool &useRLLL=true)
Definition CSL.cpp:82
Lattice(const MatrixDimD &A, const MatrixDimD &Q)
const MatrixDimD reciprocalBasis
const MatrixType & reducedBasis() const
initial point of the source segment B
function infiniteDisplacement syms Ax Ay Az Bx By Bz qx qy qz u L x y z real A
LatticeTransitionMatrix(const LatticeType &A_in, const LatticeType &B_in)
REAL C2[12]
REAL C1[8]
int i