I have a question about Eigen library in C++. Actually, I want to calculate inverse matrix of sparse matrix. When I used Dense matrix in Eigen, I can use .inverse() operation to calculate inverse of dense matrix. But in Sparse matrix, I cannot find inverse operation anywhere. Does anyone who know to calculate inverse of sparse matrix? help me.
相关问题
- Sorting 3 numbers without branching [closed]
- Extract matrix elements using a vector of column i
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- Mixing Scalar Types in Eigen
相关文章
- Numpy matrix of coordinates
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
You cannot do it directly, but you can always calculate it, using one of the sparse solvers. The idea is to solve
A*X=I
, where I is the identity matrix. If there is a solution, X will be your inverse matrix. The eigen documentation has a page about sparse solvers and how to use them, but the basic steps are as follows:A small extension on @Soheib and @MatthiasB's answers, if you're using
Eigen::SparseMatrix<float>
it's better to use SparseLU rather than SimplicialLLT or SimplicialLDLT, they produced wrong answers with me on float matricesIt's not mathematically meaningful.
A sparse matrix does not necessarily have a sparse inverse.
That's why the method is not available.
You can find a example about inverse of Sparse Complex Matrix
I used of SimplicialLLT class,
you can find other class from bellow
http://eigen.tuxfamily.org/dox-devel/group__TopicSparseSystems.html
This page can help you with proper class name for your work (spead, accuracy and dimmenssion of your Matrix)