4 #ifndef ROOT_Math_Dsinv
5 #define ROOT_Math_Dsinv
31 #ifndef ROOT_Math_SMatrixDfwd
45 template <
class T,
int n,
int idim>
50 template <
class MatrixRep>
51 inline static bool Dsinv(MatrixRep& rhs) {
59 const int arrayOffset = -1*(idim + 1);
63 if (idim <
n ||
n <= 1) {
68 for (j = 1; j <=
n; ++j) {
69 const int ja = j * idim;
70 const int jj = j + ja;
71 const int ja1 = ja + idim;
74 if (rhs[jj + arrayOffset] <= 0.) {
return false; }
75 rhs[jj + arrayOffset] = 1. / rhs[jj + arrayOffset];
76 if (j ==
n) {
break; }
78 for (l = j + 1; l <=
n; ++
l) {
79 rhs[j + (l * idim) + arrayOffset] = rhs[jj + arrayOffset] * rhs[l + ja + arrayOffset];
80 const int lj = l + ja1;
81 for (i = 1; i <= j; ++i) {
82 rhs[lj + arrayOffset] -= rhs[l + (i * idim) + arrayOffset] * rhs[i + ja1 + arrayOffset];
90 rhs[((idim << 1) + 1) + arrayOffset] = -rhs[((idim << 1) + 1) + arrayOffset];
91 rhs[idim + 2 + arrayOffset] = rhs[((idim << 1)) + 1 + arrayOffset] * rhs[((idim << 1)) + 2 + arrayOffset];
95 for (j = 3; j <=
n; ++j) {
96 const int jm2 = j - 2;
97 const int ja = j * idim;
98 const int jj = j + ja;
99 const int j1 = j - 1 + ja;
101 for (k = 1; k <= jm2; ++k) {
102 s31 = rhs[k + ja + arrayOffset];
104 for (i = k; i <= jm2; ++i) {
105 s31 += rhs[k + ((i + 1) * idim) + arrayOffset] * rhs[i + 1 + ja + arrayOffset];
107 rhs[k + ja + arrayOffset] = -s31;
108 rhs[j + (k * idim) + arrayOffset] = -s31 * rhs[jj + arrayOffset];
110 rhs[j1 + arrayOffset] *= -1;
112 rhs[jj - idim + arrayOffset] = rhs[j1 + arrayOffset] * rhs[jj + arrayOffset];
118 const int jad = j * idim;
119 const int jj = j + jad;
122 for (i = jp1; i <=
n; ++i) {
123 rhs[jj + arrayOffset] += rhs[j + (i * idim) + arrayOffset] * rhs[i + jad + arrayOffset];
128 const int ja = j * idim;
130 for (k = 1; k <= jm1; ++k) {
132 for (i = j; i <=
n; ++i) {
133 s32 += rhs[k + (i * idim) + arrayOffset] * rhs[i + ja + arrayOffset];
136 rhs[k + ja + arrayOffset] = s32;
150 for (
int i = 0; i<
n*
n; ++i)
156 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.