29 std::vector<ttk::DiagramType> &atoms,
30 const std::vector<std::vector<double>> &vectorWeights,
31 std::vector<std::array<double, 3>> &coords,
32 std::vector<std::array<double, 3>> &trueCoords,
33 std::vector<double> &xVector,
34 std::vector<double> &yVector,
35 std::vector<double> &zVector,
37 const size_t nAtoms)
const {
41 std::array<size_t, 2> nInputs{nAtoms, 0};
42 MatrixCalculator.
setDos(
true,
true,
true);
44 const auto distMatrix = MatrixCalculator.
execute(atoms, nInputs);
46 trueCoords[0][0] = 0.;
48 trueCoords[0][0] = 0.;
49 coords[1][0] = spacing * distMatrix[0][1];
50 trueCoords[1][0] = distMatrix[0][1];
51 trueCoords[1][1] = 0.;
53 }
else if(nAtoms == 3) {
55 std::array<size_t, 2> nInputs{nAtoms, 0};
56 MatrixCalculator.
setDos(
true,
true,
true);
58 std::vector<std::vector<double>> distMatrix
59 = MatrixCalculator.
execute(atoms, nInputs);
61 trueCoords[0][0] = 0.;
63 trueCoords[0][1] = 0.;
64 coords[1][0] = spacing * distMatrix[0][1];
65 trueCoords[1][0] = distMatrix[0][1];
67 trueCoords[1][1] = 0.;
68 double distOpposed = distMatrix[2][1];
69 double firstDist = distMatrix[0][1];
70 double distAdja = distMatrix[0][2];
71 double alpha = std::acos(
72 (distOpposed * distOpposed - firstDist * firstDist - distAdja * distAdja)
73 / (-2. * firstDist * distAdja));
74 coords[2][0] = spacing * distAdja * std::cos(alpha);
75 trueCoords[2][0] = distAdja * std::cos(alpha);
76 coords[2][1] = spacing * distAdja * std::sin(alpha);
77 trueCoords[2][1] = distAdja * std::sin(alpha);
79 }
else if(nAtoms == 4) {
83 std::array<size_t, 2> nInputs{nAtoms, 0};
84 MatrixCalculator.
setDos(
true,
true,
true);
86 std::vector<std::vector<double>> distMatrix
87 = MatrixCalculator.
execute(atoms, nInputs);
89 trueCoords[0][0] = 0.;
91 trueCoords[0][1] = 0.;
92 coords[1][0] = spacing * distMatrix[0][1];
93 trueCoords[1][0] = distMatrix[0][1];
95 trueCoords[1][1] = 0.;
96 double distOpposed = distMatrix[2][1];
97 double firstDist = distMatrix[0][1];
98 double distAdja = distMatrix[0][2];
99 double alpha = std::acos((distOpposed * distOpposed
100 - firstDist * firstDist - distAdja * distAdja)
101 / (-2. * firstDist * distAdja));
102 coords[2][0] = spacing * distAdja * std::cos(alpha);
103 trueCoords[2][0] = distAdja * std::cos(alpha);
104 coords[2][1] = spacing * distAdja * std::sin(alpha);
105 trueCoords[2][1] = distAdja * std::sin(alpha);
106 double firstHeight = distMatrix[3][0];
107 double secondHeight = distMatrix[3][1];
108 double thirdHeight = distMatrix[3][2];
109 trueCoords[3][0] = (pow(firstHeight, 2) - pow(secondHeight, 2)
110 + pow(trueCoords[1][0], 2))
111 / (2 * trueCoords[1][0]);
113 = (pow(firstHeight, 2) - pow(thirdHeight, 2)
114 + pow(trueCoords[2][0], 2) + pow(trueCoords[2][1], 2)
115 - 2 * trueCoords[3][0] * trueCoords[2][0])
116 / (2 * trueCoords[2][1]);
118 = std::sqrt(pow(firstHeight, 2) - pow(trueCoords[3][0], 2)
119 - pow(trueCoords[3][1], 2));
129 std::array<size_t, 2> nInputs{nAtoms, 0};
130 MatrixCalculator.
setDos(
true,
true,
true);
132 std::vector<std::vector<double>> distMatrix
133 = MatrixCalculator.
execute(atoms, nInputs);
134 int nRow = distMatrix.size();
135 std::vector<double> matrixForProjector;
136 for(
int i = 0; i < nRow; ++i) {
137 for(
int j = 0; j < nRow; ++j) {
138 matrixForProjector.push_back(distMatrix[j][i]);
141 std::vector<std::vector<double>> coordsAtom;
142 DimProjector.
execute(coordsAtom, matrixForProjector, nRow, nRow);
144 for(
size_t i = 0; i < 3; ++i) {
145 for(
size_t j = 0; j < nAtoms; ++j) {
147 trueCoords[j][0] = coordsAtom[0][j];
149 trueCoords[j][1] = coordsAtom[1][j];
151 trueCoords[j][2] = coordsAtom[2][j];
163 std::vector<ttk::DiagramType> dictDiagrams;
164 std::vector<ttk::DiagramType> intermediateAtoms;
165 std::vector<double> lossTab;
166 std::vector<std::vector<double>> allLosses(nAtoms);
169 std::vector<std::vector<double>> tempWeights(nAtoms);
170 for(
size_t i = 0; i < tempWeights.size(); ++i) {
171 std::vector<double> weights(m, 1. / (m * 1.));
172 tempWeights[i] = std::move(weights);
177 DictionaryEncoder.
execute(atoms, atoms, dictDiagrams, tempWeights, seed,
178 m, lossTab, allLosses, 0.);
179 std::vector<std::array<double, 3>> tempCoords(3);
180 std::vector<std::array<double, 3>> tempTrueCoords(3);
182 std::array<size_t, 2> nInputs{3, 0};
183 MatrixCalculator.
setDos(
true,
true,
true);
185 std::vector<std::vector<double>> distMatrix
186 = MatrixCalculator.
execute(dictDiagrams, nInputs);
187 tempCoords[0][0] = 0.;
188 tempTrueCoords[0][0] = 0.;
189 tempCoords[0][1] = 0.;
190 tempTrueCoords[0][1] = 0.;
191 tempCoords[1][0] = spacing * distMatrix[0][1];
192 tempTrueCoords[1][0] = distMatrix[0][1];
193 tempCoords[1][1] = 0.;
194 tempTrueCoords[0][1] = 0.;
195 double distOpposed = distMatrix[2][1];
196 double firstDist = distMatrix[0][1];
197 double distAdja = distMatrix[0][2];
198 double alpha = std::acos((distOpposed * distOpposed
199 - firstDist * firstDist - distAdja * distAdja)
200 / (-2. * firstDist * distAdja));
201 tempCoords[2][0] = spacing * distAdja * std::cos(alpha);
202 tempTrueCoords[2][0] = distAdja * std::cos(alpha);
203 tempCoords[2][1] = spacing * distAdja * std::sin(alpha);
204 tempTrueCoords[2][1] = distAdja * std::sin(alpha);
205 for(
int i = 0; i < 2; ++i) {
206 for(
size_t j = 0; j < nAtoms; ++j) {
208 for(
int iAtom = 0; iAtom < 3; ++iAtom) {
210 lamb += tempWeights[j][iAtom] * tempTrueCoords[iAtom][0];
211 trueCoords[j][0] = lamb;
213 lamb += tempWeights[j][iAtom] * tempTrueCoords[iAtom][1];
214 trueCoords[j][1] = lamb;
227 std::array<size_t, 2> nInputs{nAtoms, 0};
228 MatrixCalculator.
setDos(
true,
true,
true);
230 std::vector<std::vector<double>> distMatrix
231 = MatrixCalculator.
execute(atoms, nInputs);
232 int nRow = distMatrix.size();
233 std::vector<double> matrixForProjector;
234 for(
int i = 0; i < nRow; ++i) {
235 for(
int j = 0; j < nRow; ++j) {
236 matrixForProjector.push_back(distMatrix[j][i]);
239 std::vector<std::vector<double>> coordsAtom;
240 DimProjector.
execute(coordsAtom, matrixForProjector, nRow, nRow);
242 for(
size_t i = 0; i < 2; ++i) {
243 for(
size_t j = 0; j < nAtoms; ++j) {
245 trueCoords[j][0] = coordsAtom[0][j];
247 trueCoords[j][1] = coordsAtom[1][j];
256 size_t nDiags = vectorWeights.size();
258 for(
int i = 0; i < 3; ++i) {
259 for(
size_t j = 0; j < nDiags; ++j) {
261 for(
size_t iAtom = 0; iAtom < nAtoms; ++iAtom) {
263 temp += vectorWeights[j][iAtom] * trueCoords[iAtom][0];
265 temp += vectorWeights[j][iAtom] * trueCoords[iAtom][1];
267 temp += vectorWeights[j][iAtom] * trueCoords[iAtom][2];