cholesky factorisation of a sparse s.p.d. matrix
C_ptr = taucs_chfact(A)
:A a sparse real symmetric positive definite (s.p.d.) matrix : :C_ptr a pointer to the Cholesky factors (C,p : A(p,p)=CC’) :
This function computes a Cholesky factorization of the sparse symmetric positive definite (s.p.d.) matrix A and retrieves at the scilab level, a pointer (C_ptr) to a handle of the Cholesky factors (C,p) (the memory used for them is “outside” scilab space).
If your matrix is s.p.d. this function must be used in place of umf_lufact or in place of the scilab function chfact for a gain in speed (also as chfact uses the scilab memory for the factors the user must set the stacksize with a large value because of the fill-in occuring in computing the factor C which then may take more memory than the initial matrix A).
When such a factorisation have been computed, a linear system must be solved with taucs_chsolve. To free the memory used by the Cholesky factors, use `taucs_chdel`_(C_ptr) ;to retrieve the Cholesky factors at the scilab level (for example to display their sparse patterns), use taucs_chget; to get some information (number of non zeros in C), use taucs_chinfo. To compute an approximation of the condition number in norm 2 use cond2sp.
// Example #1 : a small linear test system
// whom solution must be [1;2;3;4;5]
A = `sparse`_( [ 2 -1 0 0 0;
-1 2 -1 0 0;
0 -1 2 -1 0;
0 0 -1 2 -1;
0 0 0 -1 2] );
b = [0 ; 0; 0; 0; 6];
Cp = taucs_chfact(A);
x = `taucs_chsolve`_(Cp,b)
// do not forget to clear memory with
`taucs_chdel`_(Cp)
// Example #2 a real example
// first load a sparse matrix
[A] = `ReadHBSparse`_(SCI+"/modules/umfpack/examples/bcsstk24.rsa");
// compute the factorisation
Cp = taucs_chfact(A);
b = `rand`_(`size`_(A,1),1); // a random rhs
// use taucs_chsolve for solving Ax=b
x = `taucs_chsolve`_(Cp,b);
`norm`_(A*x - b)
// the same with one iterative refinement step
x = `taucs_chsolve`_(Cp,b,A);
`norm`_(A*x - b)
// do not forget to clear memory
`taucs_chdel`_(Cp)