0
$\begingroup$

I am working on a domain decomposition code in C that uses CHOLMOD to approximate grid values for a PDE in each sub-domain. The issue I have is that the methods use Matrix Market format, which is not an issue in general, but I already have a method that computes a 2D array which is the sparse matrix A in the Ax=b solve. I am not sure how I could either convert that into a sparse matrix using a method in CHOLMOD or if there was a way to save a Matrix Market text file on each loop call and somehow put it into A = cholmod_read_sparse or something else. Any insight would be much appreciated!

$\endgroup$
2
$\begingroup$

The most efficient way will be to directly use the C API of CHOLMOD and call it directly, without saving the matrix to disk, see my answer to this question for an example (see also CHOLMOD documentation). CHOLMOD uses the standard CRS (compressed row storage) representation. It is explained in many places, see for instance this wikipedia entry.

Clearly, it is also possible, as you suggest, to write the matrix to disk using Matrix Market format and call CHOLMOD by spawning the example program provided with it, but this will be less efficient and will require as much programming effort as calling CHOLMOD directly. If you are not programming in C/C++ or in a language that has CHOLMOD bindings, you may need to do that. The easiest solution for you will be to use the coordinate format. If performance is an issue, you may use CRS format (a little bit more programming effort). Both are explained here.

$\endgroup$
0
$\begingroup$

I do hope that your A that you assemble is a sparse matrix. Otherwise the use of sparse cholesky factorizations would not make sense. Then, if you didn't do this during the assembling process, you should turn it into a sparse matrix format as soon as possible.

Then -- and not knowing in what environment you are so that I can only guess -- it will be more efficient to pass the matrix directly to cholmod which will convert it for you (at least in the python interface) without doing the saving/loading step using the matrix market format.

$\endgroup$
  • $\begingroup$ It is indeed a sparse matrix. It results from a mid-point discretization for a finite difference method. My question is how to turn it into a sparse matrix format. My intentions were to do this using matrix market seeing as they have a type for sparse matrices and this is the format that cholmod takes, but I am unsure how to format it such that cholmod will indeed take it. $\endgroup$ – user20973 Aug 8 '16 at 13:31
  • $\begingroup$ This will depend on your programming language... $\endgroup$ – Jan Aug 8 '16 at 13:34
  • $\begingroup$ I have C tagged, although I have not explicitly written it in the post, I will edit this. I understand how to make a sparse matrix with matrix market, you just put the i, j indices with values but I am unsure how to use the stdout from this step to use it for my Ax=b linear solve in cholmod $\endgroup$ – user20973 Aug 8 '16 at 13:37
  • $\begingroup$ OK, I don't know C. But there are many formats of sparse matrices and there are definitely routines out there for your problem. Maybe you reformulate your question a bit towards how to construct a sparse matrix in C (for use in CHOLMOD) $\endgroup$ – Jan Aug 8 '16 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.