18#ifndef SparseLUSolverTraits_h
19#define SparseLUSolverTraits_h
22#include ITK_EIGEN(Sparse)
23#include ITK_EIGEN(SparseLU)
37template <
typename T =
double>
43 using VectorType = Eigen::Matrix<ValueType, Eigen::Dynamic, 1>;
77 iA.coeffRef(iR, iC) = iV;
84 iA.coeffRef(iR, iC) += iV;
101 oX = solver.solve(iB);
102 return solver.info() == Eigen::Success;
118 Solve(solver, iBx, iBy, iBz, oX, oY, oZ);
119 return solver.info() == Eigen::Success;
128 Solve(solver, iBx, iBy, oX, oY);
129 return solver.info() == Eigen::Success;
136 oX = solver.solve(iB);
150 oX = solver.solve(iBx);
151 oY = solver.solve(iBy);
152 oZ = solver.solve(iBz);
160 oX = solver.solve(iBx);
161 oY = solver.solve(iBy);
Generic interface for sparse LU solver backed by Eigen::SparseLU.
static MatrixType InitializeSparseMatrix(const unsigned int &iRow, const unsigned int &iCol)
initialize a sparse matrix of size iRow x iCol
static void Solve(SolverType &solver, const VectorType &iB, VectorType &oX)
Solve the linear system reusing the factored matrix.
static void Solve(SolverType &solver, const VectorType &iBx, const VectorType &iBy, VectorType &oX, VectorType &oY)
Solve the linear systems: , reusing the factored matrix.
static bool Solve(const MatrixType &iA, const VectorType &iB, VectorType &oX)
Solve the linear system .
static void MatVecMult(const MatrixType &iA, const VectorType &iB, VectorType &oX)
oX = iA * iB
static void AddToMatrix(MatrixType &iA, const unsigned int &iR, const unsigned int &iC, const ValueType &iV)
iA[iR][iC] += iV
static VectorType InitializeVector(const unsigned int &iN)
initialize a vector of size iN
Eigen::SparseMatrix< ValueType > MatrixType
Eigen::SparseLU< MatrixType > SolverType
static MatrixType InitializeSparseMatrix(const unsigned int &iN)
initialize a square sparse matrix of size iN x iN
Eigen::Matrix< ValueType, Eigen::Dynamic, 1 > VectorType
static bool Solve(const MatrixType &iA, const VectorType &iBx, const VectorType &iBy, const VectorType &iBz, VectorType &oX, VectorType &oY, VectorType &oZ)
Solve the linear systems: , , .
static void Solve(SolverType &solver, const VectorType &iBx, const VectorType &iBy, const VectorType &iBz, VectorType &oX, VectorType &oY, VectorType &oZ)
Solve the linear systems: , , reusing the factored matrix.
static void FillMatrix(MatrixType &iA, const unsigned int &iR, const unsigned int &iC, const ValueType &iV)
iA[iR][iC] = iV
static bool IsDirectSolver()
static bool Solve(const MatrixType &iA, const VectorType &iBx, const VectorType &iBy, VectorType &oX, VectorType &oY)
Solve the linear systems: , .