Sparse Linear System Solver¶
Solving a sparse linear system is a common operation in geometry processing. In addition to the solvers provided by scipy, PyMesh brings the power of a number of state-of-the-art sparse solvers into python.
-
class
pymesh.
SparseSolver
¶ Linear solver for solving sparse linear systems.
This class is a thin wrapper around sparse solvers supported by Eigen.
The following direct solvers are supported:
LLT
: Wrapper of Eigen::SimplicialLLT, SPD only.LDLT
: Wrapper of Eigen::SimplicialLDLT, SPD only.SparseLU
: Wrapper of Eigen::SparseLU.SparseQR
: Wrapper of Eigen::SparseQR.UmfPackLU
: Wrapper of Eigen::UmfPackLU. (Require SuiteSparse)Cholmod
: Wrapper of Eigen::CholmodSupernodalLLT. (Require SuiteSparse)PardisoLLT
: Wrapper of Eigen::PardisoLLT. SPD only. (Require Intel MKL)PardisoLDLT
: Wrapper of Eigen::PardisoLDLT. SPD only. (Require Intel MKL)PardisoLU
: Wrapper of Eigen::PardisoLU. (Require Intel MKL)
The following iterative solvers are supported:
CG
: Wrapper of Eigen::ConjugateGradient. SPD only.LSCG
: Wrapper of Eigen::LeastSquaresConjugateGradient.BiCG
: Wrapper of Eigen::BiCGSTAB.
-
supported_solvers
¶ list
ofstr
– The list of supported solvers.
-
tolerance
¶ float
– The residual error threshold for stopping iterative solvers. Default isEigen::NumTraits<Float>::epsilon()
.
-
max_iterations
¶ int
– The max iterations allowed for iterative solvers. Default is twice the number of columns of the matrix.
Example
For direct solvers:
>>> M = scipy.sparse.eye(100); # Build matrix. >>> rhs = numpy.ones(100); # build right hand side. >>> solver = pymesh.SparseSolver.create("LDLT"); >>> solver.compute(M); >>> x = solver.solve(rhs);
For iterative solvers:
>>> M = scipy.sparse.eye(100); # Build matrix. >>> rhs = numpy.ones(100); # build right hand side. >>> solver = pymesh.SparseSolver.create("CG"); >>> solver.tolerance = 1e-10; >>> solver.max_iterations = 50; >>> solver.compute(M); >>> x = solver.solve(rhs);