MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maiamath.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7// Copyright (C) 2024 The m-AIA AUTHORS
8//
9// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
10//
11// SPDX-License-Identifier: LGPL-3.0-only
12
13// Copyright (C) 2024 The m-AIA AUTHORS
14//
15// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
16//
17// SPDX-License-Identifier: LGPL-3.0-only
18
19
20#include "maiamath.h"
21
22#ifdef MAIA_GCC_COMPILER
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wduplicated-branches"
25#pragma GCC diagnostic ignored "-Wfloat-equal"
26#pragma GCC diagnostic ignored "-Wuseless-cast"
27#pragma GCC diagnostic ignored "-Wdeprecated-copy-dtor"
28#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
29#pragma GCC diagnostic ignored "-Wunused-result"
30#pragma GCC diagnostic ignored "-Wnull-dereference" // Required for solveSparseMatrixIterative
31#endif
32#ifdef MAIA_CLANG_COMPILER
33#pragma clang diagnostic push
34#pragma clang diagnostic ignored "-Wc99-extensions"
35#pragma clang diagnostic ignored "-Wextra-semi-stmt"
36#pragma clang diagnostic ignored "-Wfloat-equal"
37#endif
38#include <Eigen/Eigen/Eigen>
39#ifdef MAIA_GCC_COMPILER
40#pragma GCC diagnostic pop
41#endif
42#ifdef MAIA_CLANG_COMPILER
43#pragma clang diagnostic pop
44#endif
45
46namespace maia {
47namespace math {
48
50using MFloatMatrix2d = Eigen::Matrix<MFloat, 2, 2>;
51using MFloatMatrix3d = Eigen::Matrix<MFloat, 3, 3>;
52using MFloatMatrixXd = Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic>;
53template <MInt nDim>
54using MFloatMatrix = Eigen::Matrix<MFloat, nDim, nDim>;
55
56using MFloatVector2d = Eigen::Vector<MFloat, 2>;
57using MFloatVector3d = Eigen::Vector<MFloat, 3>;
58using MFloatVectorXd = Eigen::Vector<MFloat, Eigen::Dynamic>;
59template <MInt nDim>
60using MFloatVector = Eigen::Vector<MFloat, nDim>;
61using MTriplet = Eigen::Triplet<MFloat>;
62
63
65template <typename T, std::size_t N>
66Eigen::MatrixXd ConvertToEigenMatrix(std::array<std::array<T, N>, N> data) {
67 Eigen::Matrix<T, N, N> m;
68 for(std::size_t i = 0; i < N; ++i) {
69 m.row(i) = Eigen::VectorXd::Map(&data[i][0], N);
70 }
71 return m;
72}
73
74
81template <typename T, std::size_t N>
82void adjointRow(std::array<std::array<T, N>, N>& m, std::array<T, N>& A, const MInt r) {
83 Eigen::Matrix<T, N, N> m2 = ConvertToEigenMatrix(m);
84 Eigen::Matrix<T, N, N> adjMatrix(m2.adjoint());
85 for(std::size_t i = 0; i < N; i++) {
86 A[i] = adjMatrix.row(r)[i];
87 }
88}
89template void adjointRow<MFloat, 3>(std::array<std::array<MFloat, 3>, 3>& m, std::array<MFloat, 3>& A, const MInt);
90
91
96template <typename T>
97void adjoint1stRow4x4(std::array<std::array<T, 4>, 4>& m, std::array<T, 4>& A) {
98 A[0] = m[1][1] * m[2][2] * m[3][3] + m[1][2] * m[2][3] * m[3][1] + m[1][3] * m[2][1] * m[3][2]
99 - m[1][3] * m[2][2] * m[3][1] - m[1][2] * m[2][1] * m[3][3] - m[1][1] * m[2][3] * m[3][2];
100 A[1] = -m[0][1] * m[2][2] * m[3][3] - m[0][2] * m[2][3] * m[3][1] - m[0][3] * m[2][1] * m[3][2]
101 + m[0][3] * m[2][2] * m[3][1] + m[0][2] * m[2][1] * m[3][3] + m[0][1] * m[2][3] * m[3][2];
102 A[2] = m[0][1] * m[1][2] * m[3][3] + m[0][2] * m[1][3] * m[3][1] + m[0][3] * m[1][1] * m[3][2]
103 - m[0][3] * m[1][2] * m[3][1] - m[0][2] * m[1][1] * m[3][3] - m[0][1] * m[1][3] * m[3][2];
104 A[3] = -m[0][1] * m[1][2] * m[2][3] - m[0][2] * m[1][3] * m[2][1] - m[0][3] * m[1][1] * m[2][2]
105 + m[0][3] * m[1][2] * m[2][1] + m[0][2] * m[1][1] * m[2][3] + m[0][1] * m[1][3] * m[2][2];
106}
107template void adjoint1stRow4x4<MFloat>(std::array<std::array<MFloat, 4>, 4>& m, std::array<MFloat, 4>& A);
108
113template <typename T, std::size_t N>
114void adjoint1stRow(std::array<std::array<T, N>, N>& m, std::array<T, N>& A) {
115 if constexpr(N == 4) {
116 adjoint1stRow4x4(m, A);
117 } else {
118 adjointRow(m, A, 0);
119 }
120}
121template void adjoint1stRow<MFloat, 4>(std::array<std::array<MFloat, 4>, 4>& m, std::array<MFloat, 4>& A);
122template void adjoint1stRow<MFloat, 3>(std::array<std::array<MFloat, 3>, 3>& m, std::array<MFloat, 3>& A);
123
129template <typename T, std::size_t N>
130MFloat determinant(std::array<T, N>& m) {
131 constexpr MInt dim = N == 2 ? 1 : 2;
132 Eigen::Matrix<T, dim, dim> matrix(m.data());
133 return matrix.determinant();
134}
135template MFloat determinant<MFloat, 2ul>(std::array<MFloat, 2ul>&);
136template MFloat determinant<MFloat, 3ul>(std::array<MFloat, 3ul>&);
137template MFloat determinant<MFloat, 4ul>(std::array<MFloat, 4ul>&);
138
144template <typename T, std::size_t N>
145MFloat determinant(std::array<std::array<T, N>, N>& m) {
146 Eigen::Matrix<T, N, N> matrix(&m[0][0]);
147 return matrix.determinant();
148}
149template MFloat determinant<MFloat, 2ul>(std::array<std::array<MFloat, 2ul>, 2ul>&);
150template MFloat determinant<MFloat, 3ul>(std::array<std::array<MFloat, 3ul>, 3ul>&);
151template MFloat determinant<MFloat, 4ul>(std::array<std::array<MFloat, 4ul>, 4ul>&);
152
153// inline void jacobiSVD(MFloat* A, MFloat* U, MFloat* S, const MInt m, const MInt n) {
154// Eigen::Map<Eigen::MatrixXd> mA(A, m, n);
155// Eigen::Map<Eigen::MatrixXd> mU(U, m, n);
156// Eigen::Map<Eigen::VectorXd> vS(S, std::min(m, n));
157// #ifdef useEigenOld
158// Eigen::JacobiSVD<Eigen::MatrixXd> svd(mA, Eigen::ComputeThinU | Eigen::ComputeThinV);
159// #else
160// Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::ComputeThinU | Eigen::ComputeThinV> svd(mA);
161// #endif
162// vS = svd.singularValues();
163// mU = svd.matrixU();
164// mA = svd.matrixV();
165// }
166
167// inline void jacobiSVD(MFloatTensor& A, MFloatTensor& U, MFloatTensor& S) {
168// jacobiSVD(&A(0, 0), &U(0, 0), &S(0), A.dim0(), A.dim1());
169// }
170
171void invert(MFloat* A, const MInt m, const MInt n) {
172 Eigen::Map<Eigen::MatrixXd> mA(A, m, n);
173 mA = mA.inverse();
174}
175
188template <class T>
189void invert(T& A, T& AInv, const MInt m, const MInt n) {
190 if(n == 0 || m == 0) {
191 std::cerr << globalDomainId() << " Warning: empty eq. sys. (" << m << "x" << n << "), skip." << std::endl;
192 return;
193 }
194 Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic> B(m, n);
195 Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic> inv(n, m);
196 for(MInt i = 0; i < m; i++) {
197 for(MInt j = 0; j < n; j++) {
198 B(i, j) = A(i, j);
199 }
200 }
201 // if (n != m) {
202 // system is overdetermined/underdetermined
203 Eigen::CompleteOrthogonalDecomposition<Eigen::MatrixXd> orth(B);
204 inv = orth.pseudoInverse();
205 // todo labels:totest SSE optimization leads to false-positive during sanitizer run
206 // }
207 // else {
208 // inv = B.inverse();
209 // }
210 for(MInt i = 0; i < m; i++) {
211 for(MInt j = 0; j < n; j++) {
212 AInv(i, j) = inv(i, j);
213 }
214 }
215}
216template void invert<ScratchSpace<MFloat>>(ScratchSpace<MFloat>&, ScratchSpace<MFloat>&, const MInt, const MInt);
217template void invert<maia::tensor::Tensor<MFloat>>(maia::tensor::Tensor<MFloat>&, maia::tensor::Tensor<MFloat>&,
218 const MInt, const MInt);
219
220
234template <class T>
235void invert(T& A, T& weights, T& AInv, const MInt m, const MInt n) {
236 if(n == 0 || m == 0) {
237 std::cerr << globalDomainId() << " Warning: empty eq. sys. (" << m << "x" << n << "), skip." << std::endl;
238 return;
239 }
240 Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic> B(m, n);
241 Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic> inv(n, m);
242 for(MInt i = 0; i < m; i++) {
243 for(MInt j = 0; j < n; j++) {
244 B(i, j) = weights[i] * A(i, j);
245 }
246 }
247 if(n != m) {
248 // system is overdetermined/underdetermined
249 Eigen::CompleteOrthogonalDecomposition<Eigen::MatrixXd> orth(B);
250 inv = orth.pseudoInverse();
251 } else {
252 inv = B.inverse();
253 }
254 for(MInt k = 0; k < n; ++k) {
255 for(MInt i = 0; i < m; ++i) {
256 AInv(k, i) = inv(k, i) * weights(i);
257 }
258 }
259}
260template void invert<ScratchSpace<MFloat>>(ScratchSpace<MFloat>&, ScratchSpace<MFloat>&, ScratchSpace<MFloat>&,
261 const MInt, const MInt);
262template void invert<maia::tensor::Tensor<MFloat>>(maia::tensor::Tensor<MFloat>&, maia::tensor::Tensor<MFloat>&,
263 maia::tensor::Tensor<MFloat>&, const MInt, const MInt);
264
279template <class T>
280MInt invertR(T& A, T& weights, T& AInv, const MInt m, const MInt n) {
281 if(n == 0 || m == 0) {
282 std::cerr << globalDomainId() << " Warning: empty eq. sys. (" << m << "x" << n << "), skip." << std::endl;
283 return -1;
284 }
285 Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic> B(m, n);
286 Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic> inv(n, m);
287 for(MInt i = 0; i < m; i++) {
288 for(MInt j = 0; j < n; j++) {
289 B(i, j) = weights[i] * A(i, j);
290 }
291 }
292
293 Eigen::CompleteOrthogonalDecomposition<Eigen::MatrixXd> orth(B);
294 inv = orth.pseudoInverse();
295 const MInt rank = orth.rank();
296
297 for(MInt k = 0; k < n; ++k) {
298 for(MInt i = 0; i < m; ++i) {
299 AInv(k, i) = inv(k, i) * weights(i);
300 }
301 }
302 return rank;
303}
304template MInt invertR<ScratchSpace<MFloat>>(ScratchSpace<MFloat>&, ScratchSpace<MFloat>&, ScratchSpace<MFloat>&,
305 const MInt, const MInt);
306
315void solveSparseMatrix(MFloat* A_coeff, MInt** pos, const MInt n, const MInt m, MFloat* b, MFloat* x) {
316 std::vector<MTriplet> coefficients;
317 Eigen::Map<MFloatVectorXd> B(b, m);
318 Eigen::Map<MFloatVectorXd> X(x, m);
319
320 coefficients.reserve(n);
321 for(MInt i = 0; i < n; i++) {
322 coefficients.emplace_back(MTriplet(pos[i][0], pos[i][1], A_coeff[i]));
323 }
324
325 // set matrix from coefficients
326 Eigen::SparseMatrix<MFloat, Eigen::ColMajor> A(m, m);
327 A.setFromTriplets(coefficients.begin(), coefficients.end());
328
329 Eigen::SparseLU<Eigen::SparseMatrix<MFloat, Eigen::ColMajor>, Eigen::COLAMDOrdering<MInt>> slu;
330 slu.compute(A);
331
332 X = slu.solve(B);
333 MBool a_solution_exists = (A * X).isApprox(B, 1e-10);
334
335 MFloat resultA = F1B2 * X.transpose() * A * X;
336 MFloat resultB = X.transpose() * B;
337
338 MFloat result = resultA - resultB;
339
340 std::cout << "Energie norm is " << resultA << " " << resultB << " " << result << std::endl;
341
342 if(a_solution_exists) {
343 std::cerr << "SOLUTION IS CORRECT" << std::endl;
344 } else {
345 std::cerr << "SOLUTION IS NOT CORRECT" << std::endl;
346 }
347}
348
357void solveSparseMatrixIterative(MFloat* A_coeff, MInt** pos, const MInt n, const MInt m, MFloat* b, MFloat* x) {
358 std::vector<MTriplet> coefficients;
359 Eigen::Map<MFloatVectorXd> B(b, m);
360 Eigen::Map<MFloatVectorXd> X(x, m);
361
362 coefficients.reserve(n);
363 for(MInt i = 0; i < n; i++) {
364 coefficients.emplace_back(MTriplet(pos[i][0], pos[i][1], A_coeff[i]));
365 }
366
367 // set matrix from coefficients
368 Eigen::SparseMatrix<MFloat, Eigen::ColMajor> A(m, m);
369 A.setFromTriplets(coefficients.begin(), coefficients.end());
370
371 Eigen::BiCGSTAB<Eigen::SparseMatrix<MFloat, Eigen::ColMajor>> BCGST;
372 BCGST.compute(A);
373
374 X = BCGST.solve(B);
375
376 MBool a_solution_exists = (A * X).isApprox(B, 1e-10);
377
378 MFloat resultA = F1B2 * X.transpose() * A * X;
379 MFloat resultB = X.transpose() * B;
380
381 MFloat result = resultA - resultB;
382
383 std::cout << "Energie norm is " << resultA << " " << resultB << " " << result << std::endl;
384
385 if(a_solution_exists) {
386 std::cout << "SOLUTION IS CORRECT" << std::endl;
387 } else {
388 std::cout << "SOLUTION IS NOT CORRECT" << std::endl;
389 }
390}
391
400void solveDenseMatrix(MFloat* A_coeff, MInt** pos, const MInt n, const MInt m, MFloat* b, MFloat* x) {
401 Eigen::Map<MFloatVectorXd> B(b, m);
402 Eigen::Map<MFloatVectorXd> X(x, m);
403
404 MFloatMatrixXd A = MFloatMatrixXd::Zero(m, m);
405
406 for(MInt i = 0; i < n; i++) {
407 A(pos[i][0], pos[i][1]) = A_coeff[i];
408 }
409
410 Eigen::FullPivLU<MFloatMatrixXd> lu;
411 lu.compute(A);
412
413 X = lu.solve(B);
414 MBool a_solution_exists = (A * X).isApprox(B, 1e-10);
415
416 if(a_solution_exists) {
417 std::cout << "SOLUTION IS CORRECT" << std::endl;
418 } else {
419 std::cout << "SOLUTION IS NOT CORRECT" << std::endl;
420 }
421}
422
431void multiplySparseMatrixVector(MFloat* A_coeff, MInt** pos, const MInt n, const MInt m, MFloat* b, MFloat* x) {
432 Eigen::Map<MFloatVectorXd> B(b, m);
433 Eigen::Map<MFloatVectorXd> X(x, m);
434
435 MFloatMatrixXd A = MFloatMatrixXd::Zero(m, m);
436
437 for(MInt i = 0; i < n; i++) {
438 A(pos[i][0], pos[i][1]) = A_coeff[i];
439 }
440 B = A * X;
441}
442
448template <MInt nDim>
449void solveQR(std::array<std::array<MFloat, nDim>, nDim>& A_, std::array<MFloat, nDim>& b_) {
450 TRACE();
451
452 Eigen::Matrix<MFloat, nDim, nDim> A(&A_[0][0]);
453 Eigen::Vector<MFloat, nDim> b(&b_[0]);
454 b = A.colPivHouseholderQr().solve(b);
455 std::memcpy(&b_[0], b.data(), nDim * sizeof(MFloat));
456}
457template void solveQR<2>(std::array<std::array<MFloat, 2>, 2>&, std::array<MFloat, 2>&);
458template void solveQR<3>(std::array<std::array<MFloat, 3>, 3>&, std::array<MFloat, 3>&);
459
460// /// Solve linear system using QR (square matrix)
461// /// \param A system matrix
462// /// \param b rhs
463// /// \tparam nDim dimension of the matrix
464// /// \author Sven Berger
465// inline void solveQRXd(MFloatMatrixXd& A, MFloatVectorXd& b, MFloatVectorXd& x) {
466// TRACE();
467// x = A.colPivHouseholderQr().solve(b);
468// }
469
470
475void calcEigenValues(MFloat A[3][3], MFloat w[3]) {
476 Eigen::Map<Eigen::Matrix<MFloat, 3, 3>> mA(&A[0][0]);
477 Eigen::Map<Eigen::Matrix<MFloat, 3, 1>> _w(w);
478
479 // Assume matrix is symmetrical
480 Eigen::SelfAdjointEigenSolver<Eigen::Matrix<MFloat, 3, 3>> es(mA, Eigen::EigenvaluesOnly);
481 _w = es.eigenvalues().real();
482}
483
489void calcEigenValues(MFloat** A_in, MFloat* lambda_in, const MInt m) {
490 Eigen::Map<Eigen::MatrixXd> A(&A_in[0][0], m, m);
491 Eigen::Map<Eigen::VectorXd> lambda(lambda_in, m);
492
493 // Assume matrix is symmetrical
494 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(A, Eigen::EigenvaluesOnly);
495 lambda = es.eigenvalues().real();
496}
497
503void calcEigenVectors(MFloat A[3][3], MFloat Q[3][3], MFloat w[3]) {
504 Eigen::Map<Eigen::Matrix<MFloat, 3, 3>> mA(&A[0][0]);
505 Eigen::Map<Eigen::Matrix<MFloat, 3, 3>> mQ(&Q[0][0]);
506 Eigen::Map<Eigen::Matrix<MFloat, 3, 1>> _w(w);
507
508 // Assume matrix is symmetrical
509 Eigen::SelfAdjointEigenSolver<Eigen::Matrix<MFloat, 3, 3>> es(mA);
510 mQ = es.eigenvectors().real();
511 _w = es.eigenvalues().real();
512}
513
514std::vector<MFloat> svd(MFloat* const A, MFloat* const b, const MInt m, const MInt n, MFloat* const x) {
515 Eigen::Map<Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> A_eigen(A, m, n);
516
517 Eigen::Map<MFloatVectorXd> b_eigen(b, m);
518 // Eigen::Map<maia::math::MFloatVector<Eigen::Dynamic>> S_eigen(&S[0], std::min(m, n));
519
520#ifdef useEigenOld
521 Eigen::BDCSVD<Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> SVD =
522 A_eigen.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV);
523#else
524 Eigen::BDCSVD<Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>,
525 Eigen::ComputeThinU | Eigen::ComputeThinV>
526 SVD = A_eigen.bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>();
527#endif
528
529 // TODO labels:CONTROLLER this should work as well
530 MFloatVectorXd x_eigen = SVD.solve(b_eigen);
531 // Eigen::Matrix<MFloat, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> x_eigen =
532 // SVD.solve(b_eigen);
533 MFloatVectorXd S = SVD.singularValues();
534
535 for(MInt i = 0; i < n; i++) {
536 x[i] = x_eigen(i);
537 }
538
539 std::vector<MFloat> singularValues(S.size());
540 for(MInt i = 0; i < S.size(); i++) {
541 singularValues[i] = S[i];
542 }
543 return singularValues;
544}
545
546} // namespace math
547} // namespace maia
This class is a ScratchSpace.
Definition: scratch.h:758
Provides a lightweight and fast class for accessing 1D arrays as multi-dimensional tensors (up to 4D)...
Definition: tensor.h:41
MInt globalDomainId()
Return global domain id.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
Eigen::Vector< MFloat, Eigen::Dynamic > MFloatVectorXd
Definition: maiamath.cpp:58
Eigen::Vector< MFloat, 2 > MFloatVector2d
Definition: maiamath.cpp:56
void adjoint1stRow(std::array< std::array< T, N >, N > &m, std::array< T, N > &A)
Definition: maiamath.cpp:114
std::vector< MFloat > svd(MFloat *const A, MFloat *const b, const MInt m, const MInt n, MFloat *const x)
Definition: maiamath.cpp:514
Eigen::Matrix< MFloat, nDim, nDim > MFloatMatrix
Definition: maiamath.cpp:54
MFloat determinant(std::array< T, N > &m)
Definition: maiamath.cpp:130
void multiplySparseMatrixVector(MFloat *A_coeff, MInt **pos, const MInt n, const MInt m, MFloat *b, MFloat *x)
Definition: maiamath.cpp:431
Eigen::Matrix< MFloat, Eigen::Dynamic, Eigen::Dynamic > MFloatMatrixXd
Definition: maiamath.cpp:52
Eigen::Vector< MFloat, nDim > MFloatVector
Definition: maiamath.cpp:60
void adjoint1stRow4x4(std::array< std::array< T, 4 >, 4 > &m, std::array< T, 4 > &A)
Definition: maiamath.cpp:97
template MFloat determinant< MFloat, 3ul >(std::array< MFloat, 3ul > &)
Eigen::Matrix< MFloat, 2, 2 > MFloatMatrix2d
all assume dense matrix calculations
Definition: maiamath.cpp:50
void invert(MFloat *A, const MInt m, const MInt n)
Definition: maiamath.cpp:171
void solveQR(std::array< std::array< MFloat, nDim >, nDim > &A_, std::array< MFloat, nDim > &b_)
Definition: maiamath.cpp:449
Eigen::Triplet< MFloat > MTriplet
Definition: maiamath.cpp:61
template MFloat determinant< MFloat, 2ul >(std::array< MFloat, 2ul > &)
template void solveQR< 2 >(std::array< std::array< MFloat, 2 >, 2 > &, std::array< MFloat, 2 > &)
template void adjoint1stRow4x4< MFloat >(std::array< std::array< MFloat, 4 >, 4 > &m, std::array< MFloat, 4 > &A)
Eigen::Matrix< MFloat, 3, 3 > MFloatMatrix3d
Definition: maiamath.cpp:51
void calcEigenVectors(MFloat A[3][3], MFloat Q[3][3], MFloat w[3])
Definition: maiamath.cpp:503
template MFloat determinant< MFloat, 4ul >(std::array< MFloat, 4ul > &)
void solveSparseMatrix(MFloat *A_coeff, MInt **pos, const MInt n, const MInt m, MFloat *b, MFloat *x)
Definition: maiamath.cpp:315
void solveSparseMatrixIterative(MFloat *A_coeff, MInt **pos, const MInt n, const MInt m, MFloat *b, MFloat *x)
Definition: maiamath.cpp:357
template void adjointRow< MFloat, 3 >(std::array< std::array< MFloat, 3 >, 3 > &m, std::array< MFloat, 3 > &A, const MInt)
template void solveQR< 3 >(std::array< std::array< MFloat, 3 >, 3 > &, std::array< MFloat, 3 > &)
void calcEigenValues(MFloat A[3][3], MFloat w[3])
Definition: maiamath.cpp:475
template void adjoint1stRow< MFloat, 3 >(std::array< std::array< MFloat, 3 >, 3 > &m, std::array< MFloat, 3 > &A)
void adjointRow(std::array< std::array< T, N >, N > &m, std::array< T, N > &A, const MInt r)
Definition: maiamath.cpp:82
Eigen::Vector< MFloat, 3 > MFloatVector3d
Definition: maiamath.cpp:57
void solveDenseMatrix(MFloat *A_coeff, MInt **pos, const MInt n, const MInt m, MFloat *b, MFloat *x)
Definition: maiamath.cpp:400
template void adjoint1stRow< MFloat, 4 >(std::array< std::array< MFloat, 4 >, 4 > &m, std::array< MFloat, 4 > &A)
Eigen::MatrixXd ConvertToEigenMatrix(std::array< std::array< T, N >, N > data)
convert array to eigen matrix
Definition: maiamath.cpp:66
MInt invertR(T &A, T &weights, T &AInv, const MInt m, const MInt n)
Definition: maiamath.cpp:280
Namespace for auxiliary functions/classes.