Registered Member
|
Hello everyone,
I'm wondering if it is possible to use all functionalities of SuiteSparse (i.e., CHOLMOD, SparseQR, etc.), within Eigen. I'm aware of SparseLLT and SparseLU. However, these are only intended for solving linear systems, but I need other functions, such as sparse QR decomposition. Basically the question is whether it is possible to convert Eigen::SparseMatrix to a cholmod type, such as cholmod_sparse. As far as I know, they both use CCS format to store sparse matrices, so in principle it should be easy to use them together. Thanks a lot, fari |
Moderator
|
Yes they all use the same kind of storage, so wrapping suitesparse libs is not very difficult.
BTW, the SparseLLT and SparseLU class are deprecated. For examples you should rather take the devel branch, and look at, for instance CholmodSupport.h. There is for instance a viewAsCholmod() function that wraps a Eigen::SparseMatrix into a cholmod_sparse (there are overloads for selfadjoint matrices and dense objects). And for the otehrway round there is a viewAsEigen which returns a Eigen::MappedSparseMatrix<>. edit: in case you start to implement a clean wrapper around the QR lib, we would be pleased to help and include it in Eigen. |
Registered Member
|
Thanks for the reply.
I tried using the new CholmodSupport.h in the hg trunk, but I'm getting a compile error, saying that is_same is not a member of internal. I found is_same in internal namespace of Meta.h. However, I cannot link to it, apparently since it's not accessible by functions outside Meta.h, since it is in Meta.h internal namespace. Probably I'm missing something obvious. Can you please give me a hint? Thanks, fari |
Moderator
|
I don't really understand what you are trying to do, but CholmodSupport.h should not be directly included. Instead, include <Eigen/CholmodSupport> which currently is in eigen_path/unsupported.
is_same is in Eigen::internal namespaces, just like viewAsCholmod and the other helper functions. |
Registered Member
|
I see. So, viewAsCholmod is not intended to be a public API. And, that's the reason that you suggested to write a wrapper for SuiteSparse functions. Now I understand.
But, why not having a public API to return a (smart?) handle to a cholmod object, and allowing the user to directly call SuiteSparse functions on it? The reason I'm saying this is that there are so many functions in SuiteSparse that I think writing (and maintaining) a wrapper for each of them will take enormous amount of resources. Isn't is better to let the user call them directly? BTW, I think right now viewAsCholmod is in Eigen namespace, and not in Eigen::internal. See this: https://bitbucket.org/eigen/eigen/src/5 ... dSupport.h |
Moderator
|
oh, indeed it is not in Eigen::internal. Anyways, feel free to call it directly !
|
Registered Member
|
I tried using viewAsCholmod to get a cholmod_sparse type handle to work with Sparse QR. However, the Sparse QR routines are only implemented for "long" indices (i.e., matrices that work with cholmod_l_ prefix instead of cholmod_ ).
In principle it should be possible to use viewAsCholmod with SparseType with template variable _index=long (i.e., SparseType<double, ColMajor, long>. However, as of now, viewAsCholmod is only implemented for "int" index and not "long" index. Is there any fundamental reason for this? or is it just a matter of someone writing the code? If there is no fundamental reason for this, and no one else is already doing this, I may be able to write a patch for it. Thanks, fari81 |
Moderator
|
sorry for the late reply, but indeed there is no fundamental reason for that, it's just an unwelcome shortcoming that has to be solved as you suggested.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]