cholmod (SuiteSparce)

What is cholmod?

cholmod is a library of sparse supernodal Cholesky factorization, GPL licence. A part of SuiteSparce library. This software is so cool. One of the author's web is here. (There are many cool linear system solver libraries on the Web. )

Related links

compilation memo

cholmod_sparse stype

In the example page in Section 3, cholmod_sparse::stype seems set automatically. But if you construct your matrix by yourself, you should tell to cholmod that the symmetric type of your matrix before factorize it. You may have a matrix which is not symmetric, and construct positive definite matrix out of it, constructed matrix type seems to be specified by the programmer.

For example, assume non symmetric matrix A, then M is defined by M = A' * A. Then stype := 1 (store the upper triangle part). If you did not this, the solve returns strange result.

  // Example: using triplet form to set up your matrix
  // triplet A, is not symmetric, so initialize by stype == 0.
  stype = 0;
  cholmod_triplet* triA = cholmod_allocate_triplet(row, col, nnz, stype, CHOLMOD_REAL, &c);
  set_up_triplet(triA); // set up your matrix 
  cholmod_sparse* A   = cholmod_triplet_to_sparse(triA, nnz, &c);
  cholmod_sparse* At  = cholmod_transpose(A, 1, &c);
  cholmod_sparse* AtA = cholmod_ssmult(At, A, 0, 1, 1, &c);

  // Next is the magic.
  // This matrix is now symmetric. Store upper triangle only.
  AtA->stype = 1;   
  cholmod_factor* L = cholmod_analyze(AtA, &c);
  cholmod_factorize(AtA, L, &c);
  // .....

Copyright (C) 2006 YAMAUCHI Hitoshi
Most recent update : :