-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLatticeConverter.cpp
More file actions
147 lines (124 loc) · 4.85 KB
/
LatticeConverter.cpp
File metadata and controls
147 lines (124 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "Delone.h"
#include "D7.h"
#include "G6.h"
#include "B4.h"
#include "LRL_Cell.h"
#include "LRL_Cell_Degrees.h"
#include "S6.h"
#include "LatticeConverter.h"
#include "LRL_MaximaTools.h"
#include "LRL_ReadLatticeData.h"
#include "LRL_ToString.h"
#include "MatS6.h"
#include "Niggli.h"
#include "Selling.h"
#include <string>
void LatticeConverter::TextOutput(const std::string& label, const std::string& lattice, const LRL_Cell& cell) const {
std::cout << label << std::endl;
std::cout << "lattice " << lattice << std::endl;
std::cout << "LRL_Cell_Degrees " << LRL_ToString(LRL_Cell_Degrees(cell)) << std::endl;
std::cout << "G6 " << LRL_ToString(G6(cell)) << std::endl;
std::cout << "D7 " << LRL_ToString(D7(G6(cell))) << std::endl;
std::cout << "S6 " << LRL_ToString(S6(cell)) << std::endl;
std::cout << "C3 " << LRL_ToString(C3(cell)) << std::endl;
}
void LatticeConverter::MaximaOutput(const std::string& label, const std::string& lattice, const LRL_Cell& cell) const {
std::cout << label << std::endl;
std::cout << "lattice " << lattice << std::endl;
std::cout << "LRL_Cell " << LRL_MaximaTools::MaximaFromString(LRL_ToString(cell)) << std::endl;
std::cout << "G6 " << LRL_MaximaTools::MaximaFromString(LRL_ToString(G6(cell))) << std::endl;
std::cout << "D7 " << LRL_MaximaTools::MaximaFromString(LRL_ToString(D7(G6(cell)))) << std::endl;
std::cout << "S6 " << LRL_MaximaTools::MaximaFromString(LRL_ToString(S6(cell))) << std::endl;
std::cout << "C3 " << LRL_MaximaTools::MaximaFromString(LRL_ToString(C3(cell))) << std::endl;
}
LatticeConverter::LatticeConverter(const eOutputType type)
: m_OutputType(type)
{
}
LRL_Cell LatticeConverter::MakePrimitiveCell(const std::string& lattice, const LRL_Cell& cell) {
const G6 g6 = G6(cell);
const MatG6 mLattice = LRL_Cell::LatSymMatG6(lattice, cell);
MatG6 m66;
G6 redVec;
return LRL_Cell(mLattice*g6);
}
void LatticeConverter::SetOutputMaxima(void) { m_OutputType = emaxima; }
void LatticeConverter::SetOutputText (void) { m_OutputType = etext; }
void LatticeConverter::Output(const std::string& label, const std::string& lattice, const LRL_Cell& cell) const {
(m_OutputType == etext) ? TextOutput(label, lattice, LRL_Cell(cell)) : MaximaOutput(label, lattice, LRL_Cell(cell));
}
LRL_Cell LatticeConverter::NiggliReduceCell(const std::string& lattice, const LRL_Cell& cell) {
const G6 g6 = G6(cell);
const MatG6 mLattice = LRL_Cell::LatSymMatG6(lattice, cell);
MatG6 m66;
G6 redVec;
const bool b = Niggli::Reduce(mLattice*g6, redVec, 0.0);
if (b) {
return LRL_Cell(redVec);;
}
else {
return LRL_Cell();
}
}
LRL_Cell LatticeConverter::NiggliReduceCell( const std::string& lattice, const LRL_Cell& cell, MatG6& mat ) {
const MatG6 mLattice = LRL_Cell::LatSymMatG6( lattice, cell );
MatG6 m66;
G6 redVec;
const bool b = Niggli::Reduce( mLattice * G6( cell ), m66, redVec, 0.0);
if (b) {
mat = m66 * mLattice;
return LRL_Cell( redVec );
} else {
return LRL_Cell( );
}
}
void LatticeConverter::NiggliReducedOutput(const std::string& label, const std::string& lattice, const LRL_Cell& cell) {
const LRL_Cell reducedCell = NiggliReduceCell(lattice, cell);
Output(label, "P", reducedCell);
}
LRL_Cell LatticeConverter::DeloneReduceCell(const std::string& lattice, const LRL_Cell& cell) {
const G6 g6 = G6(cell);
const MatG6 mLattice = LRL_Cell::LatSymMatG6(lattice, cell);
MatS6 m66;
S6 redVec;
//const bool b = Delone::Reduce(S6(mLattice*g6), m66, redVec, 0.00000001);
const bool b = Delone::Reduce(S6(mLattice*g6), redVec);
if (b) {
return LRL_Cell(redVec);;
}
else {
return LRL_Cell();
}
}
LRL_Cell LatticeConverter::SellingReduceCell(const std::string& lattice, const LRL_Cell& cell) {
const MatG6 mLattice = LRL_Cell::LatSymMatG6(lattice, cell);
MatS6 m66;
S6 redVec;
const bool b = Selling::Reduce(S6(mLattice*G6( cell ) ), redVec);
if (b) {
return LRL_Cell(redVec);;
}
else {
return LRL_Cell();
}
}
LRL_Cell LatticeConverter::SellingReduceCell( const std::string& lattice, const LRL_Cell& cell, MatS6& mat ) {
const MatG6 mLattice = LRL_Cell::LatSymMatG6( lattice, cell );
MatS6 m66;
S6 redVec;
const bool b = Selling::Reduce( S6( mLattice*G6( cell ) ), m66, redVec, 0.0 );
if (b) {
mat = m66 * mLattice;
return LRL_Cell( redVec );;
} else {
return LRL_Cell( );
}
}
void LatticeConverter::DeloneReducedOutput(const std::string& label, const std::string& lattice, const LRL_Cell& cell) {
const LRL_Cell reducedCell = DeloneReduceCell(lattice, cell);
Output(label, "P", reducedCell);
}
void LatticeConverter::SellingReducedOutput(const std::string& label, const std::string& lattice, const LRL_Cell& cell) {
const LRL_Cell reducedCell = SellingReduceCell(lattice, cell);
Output(label, "P", reducedCell);
}