38#define G_CHOLESKY "GSparseNumeric::cholesky_numeric_analysis("\
39 "GMatrixSparse&, GSparseSymbolic&)"
42#define CS_FLIP(i) (-(i)-2)
43#define CS_MARK(w,j) { w [j] = CS_FLIP (w [j]) ; }
44#define CS_MARKED(w,j) (w [j] < 0)
77 if (
m_L != NULL)
delete m_L;
78 if (
m_U != NULL)
delete m_U;
80 if (
m_B != NULL)
delete []
m_B;
102 if (
m_L != NULL)
delete m_L;
103 if (
m_U != NULL)
delete m_U;
105 if (
m_B != NULL)
delete []
m_B;
128 for (
int i = 0; i < n.
m_n_pinv; ++i) {
137 for (
int i = 0; i < n.
m_n_B; ++i) {
166 if (
m_L != NULL)
delete m_L;
167 if (
m_U != NULL)
delete m_U;
169 if (
m_B != NULL)
delete []
m_B;
193 int* wrk_int =
new int[wrk_size];
197 double* wrk_double =
new double[wrk_size];
209 int* s = wrk_int + n;
210 double* x = wrk_double;
226 for (k = 0; k < n; ++k) {
227 Lp[k] = c[k] = cp[k];
231 for (k = 0; k < n; k++) {
235 int top =
cs_ereach(&C, k, parent, s, c);
239 for (p = Cp[k]; p < Cp[k+1]; p++) {
252 for ( ; top < n; top++) {
254 lki = x[i]/Lx[Lp[i]];
256 for (p = Lp[i]+1; p < c[i]; p++) {
257 x[Li[p]] -= Lx[p] * lki;
267 std::string msg =
"Matrix is not positive definite, the sum "+
285 delete [] wrk_double;
318 if (!parent || !s || !w) {
332 for (
int p = Ap[k]; p < Ap[k+1]; ++p) {
340 for (len = 0; !
CS_MARKED(w,i); i = parent[i]) {
353 for (
int p = top; p < n; ++p) {
383 os <<
"=== GSparseNumeric ===";
387 os << std::endl <<
" === L or V ";
388 os << *n.
m_L << std::endl;
393 os << std::endl <<
" === U or R matrix ";
394 os << *n.
m_U << std::endl;
399 os << std::endl <<
" Inverse permutation (of ";
400 os << n.
m_n_pinv <<
" elements)" << std::endl;
401 for (
int i = 0; i < n.
m_n_pinv; ++i) {
408 os << std::endl <<
" Beta[0.." << n.
m_n_B <<
"]" << std::endl;
409 for (
int i = 0; i < n.
m_n_B; ++i) {
410 os <<
" " << n.
m_B[i];
Exception handler interface definition.
GMatrixSparse cs_symperm(const GMatrixSparse &matrix, const int *pinv)
cs_symperm
Sparse matrix class definition.
std::ostream & operator<<(std::ostream &os, const GSparseNumeric &n)
Sparse matrix numeric analysis class definition.
Sparse matrix symbolic analysis class definition.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
int m_cols
Number of columns.
double * m_data
Matrix data.
int * m_colstart
Column start indices (m_cols+1)
Sparse matrix class interface definition.
int * m_rowinx
Row-indices of all elements.
Sparse matrix numeric analysis class.
virtual ~GSparseNumeric(void)
GSparseNumeric & operator=(const GSparseNumeric &n)
friend class GMatrixSparse
void cholesky_numeric_analysis(const GMatrixSparse &m, const GSparseSymbolic &s)
int cs_ereach(const GMatrixSparse *A, int k, const int *parent, int *s, int *w)
Sparse matrix symbolic analysis class.
int * m_pinv
Inverse row permutation for QR, fill reduce permutation for Cholesky.
int * m_cp
column pointers for Cholesky, row counts for QR
int * m_parent
elimination tree for Cholesky and QR
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.