8 #include <sparse/spMatrix.h> 19 A_(M), factored_(false),condition_computed_(false), mode_(mode),norm_(0), rcond_(0), largest_(0), pivot_thresh_(0),absolute_thresh_(0),diag_pivoting_(1),pmatrix_(nullptr)
22 assert(n == (
int)(M.
rows()));
27 std::cout <<
"In vnl_sparse_lu::vnl_sparse_lu - error in creating matrix\n";
31 spElement* pelement =
nullptr;
37 pelement = spGetElement(
pmatrix_, r+1, c+1);
38 if (pelement ==
nullptr)
40 std::cout<<
"In vnl_sparse_lu::vnl_sparse_lu - error in getting element\n";
49 std::cout <<
" Largest element in matrix = " <<
largest_ <<
'\n';
61 std::cout <<
"In vnl_sparse_lu::est_condition(..) - error in condition number calculation\n";
73 std::cout <<
"In vnl_sparse_lu::solve(..) - matrix not defined\n";
76 unsigned n = b.
size();
78 auto* rhs =
new spREAL[n+1];
79 for (
unsigned i = 0; i<n; ++i)
83 std::cout <<
"Matrix before ordering\n";
96 std::cout <<
"In vnl_sparse_lu::solve(..) - error in factoring\n";
107 std::cout <<
"Matrix after ordering\n";
113 for (
unsigned i = 0; i<n; ++i)
123 this->
solve(b, &ret);
132 std::cout <<
"In vnl_sparse_lu::solve(..) - matrix not defined\n";
135 unsigned n = b.
size();
137 auto* rhs =
new spREAL[n+1];
138 for (
unsigned i = 0; i<n; ++i)
143 std::cout <<
"Matrix before ordering\n";
155 std::cout <<
"In vnl_sparse_lu::solve(..) - error in factoring\n";
166 std::cout <<
"Matrix after ordering\n";
170 spSolveTransposed(
pmatrix_, rhs, rhs);
172 for (
unsigned i = 0; i<n; ++i)
199 spDeterminant(
pmatrix_, &exponent, &determ);
unsigned int columns() const
Get the number of columns in the matrix.
Solution of the linear system Mx = b for sparse matrices.
void * pmatrix_
The internal matrix representation.
T value() const
Returns the value pointed to by the internal iterator.
size_t size() const
Return the length, number of elements, dimension of this vector.
vnl_sparse_matrix< double > A_
void reset() const
Resets the internal iterator.
bool est_condition()
estimate the condition number.
double max_error_bound()
An estimate of maximum error in solution.
vnl_sparse_lu(vnl_sparse_matrix< double > const &M, operation mode=quiet)
Make sparse_lu decomposition of M optionally computing the reciprocal condition number.
double determinant()
Compute determinant.
operation
Modes of computation. See constructor for details.
double rcond()
Return reciprocal condition number (smallest/largest singular values).
unsigned int rows() const
Get the number of rows in the matrix.
vnl_vector< double > solve_transpose(vnl_vector< double > const &b)
Solve problem M^t x = b.
vnl_vector< double > solve(vnl_vector< double > const &b)
Solve problem M x = b.
int getrow() const
Returns the row of the entry pointed to by internal iterator.
bool next() const
Moves the internal iterator to next non-zero entry in matrix.
int getcolumn() const
Returns the column of the entry pointed to by internal iterator.