18 #ifndef __VNLIterativeSparseSolverTraits_h
19 #define __VNLIterativeSparseSolverTraits_h
21 #include "vnl/vnl_vector.h"
22 #include "vnl/vnl_sparse_matrix.h"
23 #include "vnl/vnl_sparse_matrix_linear_system.h"
24 #include "vnl/algo/vnl_lsqr.h"
42 template<
typename T =
double >
90 typedef vnl_sparse_matrix_linear_system< ValueType > SparseLinearSystemType;
91 SparseLinearSystemType system(iA, iB);
94 return solver.minimize(oX);
102 bool result1 =
Solve(iA, iBx, 100000, oX);
103 bool result2 =
Solve(iA, iBy, 100000, oY);
104 bool result3 =
Solve(iA, iBz, 100000, oZ);
106 return ( result1 && result2 && result3 );
114 bool result1 =
Solve(iA, iBx, oX);
115 bool result2 =
Solve(iA, iBy, oY);
117 return ( result1 && result2 );
123 const long & iNbIter,
126 typedef vnl_sparse_matrix_linear_system< ValueType > SparseLinearSystemType;
127 SparseLinearSystemType system(iA, iB);
130 solver.set_max_iterations(iNbIter);
131 return solver.minimize(oX);
static MatrixType InitializeSparseMatrix(const unsigned int &iRow, const unsigned int &iCol)
initialize a sparse matrix of size iRow x iCol
static void AddToMatrix(MatrixType &iA, const unsigned int &iR, const unsigned int &iC, const ValueType &iV)
iA[iR][iC] += iV
vnl_sparse_matrix< ValueType > MatrixType
static VectorType InitializeVector(const unsigned int &iN)
initialize a vector of size iN
Generic interface for iterative sparse linear solver.
static MatrixType InitializeSparseMatrix(const unsigned int &iN)
initialize a square sparse matrix of size iN x iN
vnl_vector< ValueType > 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 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 &iB, const long &iNbIter, VectorType &oX)
Solve the linear systems: in N iterations.
static bool Solve(const MatrixType &iA, const VectorType &iBx, const VectorType &iBy, VectorType &oX, VectorType &oY)
Solve the linear systems: , .
static bool Solve(const MatrixType &iA, const VectorType &iB, VectorType &oX)
Solve the linear system .