namespace Eigen {
/** \eigenManualPage TutorialSparse Sparse matrix manipulations
\eigenAutoToc
Manipulating and solving sparse problems involves various modules which are summarized below:
Module | Header file | Contents |
\link SparseCore_Module SparseCore \endlink | \code#include \endcode | SparseMatrix and SparseVector classes, matrix assembly, basic sparse linear algebra (including sparse triangular solvers) |
\link SparseCholesky_Module SparseCholesky \endlink | \code#include \endcode | Direct sparse LLT and LDLT Cholesky factorization to solve sparse self-adjoint positive definite problems |
\link SparseLU_Module SparseLU \endlink | \code #include \endcode |
%Sparse LU factorization to solve general square sparse systems |
\link SparseQR_Module SparseQR \endlink | \code #include\endcode | %Sparse QR factorization for solving sparse linear least-squares problems |
\link IterativeLinearSolvers_Module IterativeLinearSolvers \endlink | \code#include \endcode | Iterative solvers to solve large general linear square problems (including self-adjoint positive definite problems) |
\link Sparse_Module Sparse \endlink | \code#include \endcode | Includes all the above modules |
\section TutorialSparseIntro Sparse matrix format
In many applications (e.g., finite element methods) it is common to deal with very large matrices where only a few coefficients are different from zero. In such cases, memory consumption can be reduced and performance increased by using a specialized representation storing only the nonzero coefficients. Such a matrix is called a sparse matrix.
\b The \b %SparseMatrix \b class
The class SparseMatrix is the main sparse matrix representation of Eigen's sparse module; it offers high performance and low memory usage.
It implements a more versatile variant of the widely-used Compressed Column (or Row) Storage scheme.
It consists of four compact arrays:
- \c Values: stores the coefficient values of the non-zeros.
- \c InnerIndices: stores the row (resp. column) indices of the non-zeros.
- \c OuterStarts: stores for each column (resp. row) the index of the first non-zero in the previous two arrays.
- \c InnerNNZs: stores the number of non-zeros of each column (resp. row).
The word \c inner refers to an \em inner \em vector that is a column for a column-major matrix, or a row for a row-major matrix.
The word \c outer refers to the other direction.
This storage scheme is better explained on an example. The following matrix