1 #ifndef _utl_EquationSolver_h_
2 #define _utl_EquationSolver_h_
4 #include <utl/AugerException.h>
12 template<
typename AMatrix>
16 std::vector<size_t> indxc(n);
17 std::vector<size_t> indxr(n);
18 std::vector<size_t> ipiv(n);
19 for (
size_t i = 0; i < n; ++i) {
24 for (
size_t j = 0; j < n; ++j)
26 for (
size_t k = 0; k < n; ++k)
27 if (ipiv[k] == 0 && std::fabs(a[j][k]) >= big) {
28 big = std::fabs(a[j][k]);
36 for (
size_t l = 0; l < n; ++l)
41 if (a[icol][icol] == 0)
45 const double t = 1. / a[icol][icol];
47 for (
size_t l = 0; l < n; ++l)
49 for (
size_t ll = 0; ll < n; ++ll)
51 const double t = a[ll][icol];
53 for (
size_t l = 0; l < n; ++l)
54 a[ll][l] -= a[icol][l] * t;
59 for (
int l = n - 1; l >= 0; --l)
60 if (indxr[l] != indxc[l])
61 for (
size_t k = 0; k < n; ++k)
62 std::swap(a[k][indxr[l]], a[k][indxc[l]]);
void swap(utl::Trace< T > &t1, utl::Trace< T > &t2)
void InvertMatrix(const size_t n, AMatrix &a)
Invert A in place with Gauss-Jordan elimination and full pivoting.
Base class for inconsistency/illogicality exceptions.