46template <
class Matrix,
unsigned int n,
unsigned int idim>
47bool Dfinv(Matrix& rhs,
unsigned int* ir) {
49 if (idim <
n ||
n <= 0 ||
n==1) {
54 typename Matrix::value_type*
a = rhs.Array();
57 unsigned int nxch, i, j, k,
m, ij;
58 unsigned int im2, nm1, nmi;
59 typename Matrix::value_type s31, s34, ti;
69 a[idim + 2] = -
a[(idim << 1) + 2] * (
a[idim + 1] *
a[idim + 2]);
70 a[(idim << 1) + 1] = -
a[(idim << 1) + 1];
73 for (i = 3; i <=
n; ++i) {
74 const unsigned int ii = i * idim;
75 const unsigned int iii = i + ii;
76 const unsigned int imi = ii - idim;
77 const unsigned int iimi = i + imi;
79 for (j = 1; j <= im2; ++j) {
80 const unsigned int ji = j * idim;
81 const unsigned int jii = j + ii;
83 for (k = j; k <= im2; ++k) {
84 s31 +=
a[k + ji] *
a[i + k * idim];
85 a[jii] +=
a[j + (k + 1) * idim] *
a[k + 1 + ii];
87 a[i + ji] = -
a[iii] * (
a[i - 1 + ji] *
a[iimi] + s31);
90 a[iimi] = -
a[iii] * (
a[i - 1 + imi] *
a[iimi]);
96 for (i = 1; i <= nm1; ++i) {
97 const unsigned int ii = i * idim;
99 for (j = 1; j <= i; ++j) {
100 const unsigned int ji = j * idim;
101 const unsigned int iji = i + ji;
102 for (k = 1; k <= nmi; ++k) {
103 a[iji] +=
a[i + k + ji] *
a[i + (i + k) * idim];
107 for (j = 1; j <= nmi; ++j) {
108 const unsigned int ji = j * idim;
110 for (k = j; k <= nmi; ++k) {
111 s34 +=
a[i + k + ii + ji] *
a[i + (i + k) * idim];
113 a[i + ii + ji] = s34;
122 for (
m = 1;
m <= nxch; ++
m) {
127 const unsigned int ii = i * idim;
128 const unsigned int ji = j * idim;
129 for (k = 1; k <=
n; ++k) {
131 a[k + ii] =
a[k + ji];
Namespace for new Math classes and functions.
bool Dfinv(Matrix &rhs, unsigned int *ir)
Dfinv.