1 #ifndef JAMA_CHOLESKY_H
2 #define JAMA_CHOLESKY_H
111 for (
int j = 0; j < n; j++)
114 for (
int k = 0; k < j; k++)
117 for (
int i = 0; i < k; i++)
119 s += L_[k][i]*L_[j][i];
121 L_[j][k] = s = (A[j][k] - s)/L_[k][k];
123 isspd = isspd && (A[k][j] == A[j][k]);
126 isspd = isspd && (d > 0.0);
127 L_[j][j] = sqrt(d > 0.0 ? d : 0.0);
128 for (
int k = j+1; k < n; k++)
145 template <
class Real>
157 for (
int k = 0; k < n; k++)
159 for (
int i = 0; i < k; i++)
160 x[k] -= x[i]*L_[k][i];
166 for (
int k = n-1; k >= 0; k--)
168 for (
int i = k+1; i < n; i++)
169 x[k] -= x[i]*L_[i][k];
187 template <
class Real>
201 for (
int k = 0; k < n; k++) {
202 for (
int i = k+1; i < n; i++) {
203 for (
int j = 0; j < nx; j++) {
204 X[i][j] -= X[k][j]*L_[k][i];
207 for (
int j = 0; j < nx; j++) {
213 for (
int k = n-1; k >= 0; k--) {
214 for (
int j = 0; j < nx; j++) {
217 for (
int i = 0; i < k; i++) {
218 for (
int j = 0; j < nx; j++) {
219 X[i][j] -= X[k][j]*L_[k][i];
227 for (
int j=0; j< nx; j++)
229 for (
int k = 0; k < n; k++)
231 for (
int i = 0; i < k; i++)
232 X[k][j] -= X[i][j]*L_[k][i];
238 for (
int j=0; j<nx; j++)
240 for (
int k = n-1; k >= 0; k--)
242 for (
int i = k+1; i < n; i++)
243 X[k][j] -= X[i][j]*L_[i][k];
Definition: jama_cholesky.h:48
Array2D< Real > L_
Definition: jama_cholesky.h:49
int isspd
Definition: jama_cholesky.h:50
Array1D< Real > solve(const Array1D< Real > &B)
Definition: jama_cholesky.h:146
Cholesky()
Definition: jama_cholesky.h:64
Array2D< Real > getL() const
Definition: jama_cholesky.h:80
int is_spd() const
Definition: jama_cholesky.h:71
Array1D copy() const
Definition: tnt_array1d.h:176
int dim1() const
Definition: tnt_array1d.h:218
int dim1() const
Definition: tnt_array2d.h:231
int dim2() const
Definition: tnt_array2d.h:234
Array2D copy() const
Definition: tnt_array2d.h:180
Definition: jama_cholesky.h:9
Definition: tnt_array1d.h:36
float Real
Definition: types.h:69