4 #ifndef ROOT_Math_Dsinv 5 #define ROOT_Math_Dsinv 43 template <
class T,
int n,
int idim>
48 template <
class MatrixRep>
49 inline static bool Dsinv(MatrixRep& rhs) {
57 const int arrayOffset = -1*(idim + 1);
61 if (idim < n || n <= 1) {
66 for (j = 1; j <= n; ++j) {
67 const int ja = j * idim;
68 const int jj = j + ja;
69 const int ja1 = ja + idim;
72 if (rhs[jj + arrayOffset] <= 0.) {
return false; }
73 rhs[jj + arrayOffset] = 1. / rhs[jj + arrayOffset];
74 if (j == n) {
break; }
76 for (l = j + 1; l <= n; ++l) {
77 rhs[j + (l * idim) + arrayOffset] = rhs[jj + arrayOffset] * rhs[l + ja + arrayOffset];
78 const int lj = l + ja1;
79 for (i = 1; i <= j; ++i) {
80 rhs[lj + arrayOffset] -= rhs[l + (i * idim) + arrayOffset] * rhs[i + ja1 + arrayOffset];
88 rhs[((idim << 1) + 1) + arrayOffset] = -rhs[((idim << 1) + 1) + arrayOffset];
89 rhs[idim + 2 + arrayOffset] = rhs[((idim << 1)) + 1 + arrayOffset] * rhs[((idim << 1)) + 2 + arrayOffset];
93 for (j = 3; j <= n; ++j) {
94 const int jm2 = j - 2;
95 const int ja = j * idim;
96 const int jj = j + ja;
97 const int j1 = j - 1 + ja;
99 for (k = 1; k <= jm2; ++k) {
100 s31 = rhs[k + ja + arrayOffset];
102 for (i = k; i <= jm2; ++i) {
103 s31 += rhs[k + ((i + 1) * idim) + arrayOffset] * rhs[i + 1 + ja + arrayOffset];
105 rhs[k + ja + arrayOffset] = -s31;
106 rhs[j + (k * idim) + arrayOffset] = -s31 * rhs[jj + arrayOffset];
108 rhs[j1 + arrayOffset] *= -1;
110 rhs[jj - idim + arrayOffset] = rhs[j1 + arrayOffset] * rhs[jj + arrayOffset];
116 const int jad = j * idim;
117 const int jj = j + jad;
120 for (i = jp1; i <= n; ++i) {
121 rhs[jj + arrayOffset] += rhs[j + (i * idim) + arrayOffset] * rhs[i + jad + arrayOffset];
126 const int ja = j * idim;
128 for (k = 1; k <= jm1; ++k) {
130 for (i = j; i <= n; ++i) {
131 s32 += rhs[k + (i * idim) + arrayOffset] * rhs[i + ja + arrayOffset];
134 rhs[k + ja + arrayOffset] = s32;
148 for (
int i = 0; i< n*n; ++i)
154 for (
int i = 0; i< n*n; ++i)
static bool Dsinv(MatRepSym< T, n > &rhs)
Namespace for new ROOT classes and functions.
MatRepSym Matrix storage representation for a symmetric matrix of dimension NxN This class is a templ...
Expression wrapper class for Matrix objects.
static bool Dsinv(MatrixRep &rhs)
Namespace for new Math classes and functions.