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"
42template <
typename T =
double>
97 using SparseLinearSystemType = vnl_sparse_matrix_linear_system<ValueType>;
98 SparseLinearSystemType system(iA, iB);
101 return solver.minimize(oX);
115 bool result1 =
Solve(iA, iBx, 100000, oX);
116 bool result2 =
Solve(iA, iBy, 100000, oY);
117 bool result3 =
Solve(iA, iBz, 100000, oZ);
119 return (result1 && result2 && result3);
126 bool result1 =
Solve(iA, iBx, oX);
127 bool result2 =
Solve(iA, iBy, oY);
129 return (result1 && result2);
136 using SparseLinearSystemType = vnl_sparse_matrix_linear_system<ValueType>;
137 SparseLinearSystemType system(iA, iB);
140 solver.set_max_iterations(iNbIter);
141 return solver.minimize(oX);
Generic interface for iterative sparse linear solver.
static MatrixType InitializeSparseMatrix(const unsigned int &iN)
initialize a square sparse matrix of size iN x iN
static MatrixType InitializeSparseMatrix(const unsigned int &iRow, const unsigned int &iCol)
initialize a sparse matrix of size iRow x iCol
vnl_sparse_matrix< ValueType > MatrixType
static void FillMatrix(MatrixType &iA, const unsigned int &iR, const unsigned int &iC, const ValueType &iV)
iA[iR][iC] = iV
static bool Solve(const MatrixType &iA, const VectorType &iBx, const VectorType &iBy, VectorType &oX, VectorType &oY)
Solve the linear systems: , .
static void AddToMatrix(MatrixType &iA, const unsigned int &iR, const unsigned int &iC, const ValueType &iV)
iA[iR][iC] += iV
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 bool Solve(const MatrixType &iA, const VectorType &iB, const long &iNbIter, VectorType &oX)
Solve the linear systems: in N iterations.
static bool IsDirectSolver()
static bool Solve(const MatrixType &iA, const VectorType &iB, VectorType &oX)
Solve the linear system .
vnl_vector< ValueType > VectorType
static VectorType InitializeVector(const unsigned int &iN)
initialize a vector of size iN