Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
vnl_sparse_lu Class Reference

Linear system solver for Mx = b using LU decomposition of a sparse matrix. More...

#include <vnl_sparse_lu.h>

Public Types

enum  operation { quiet, verbose, estimate_condition, estimate_condition_verbose }
 Modes of computation. See constructor for details. More...
 

Public Member Functions

 vnl_sparse_lu (vnl_sparse_matrix< double > const &M, operation mode=quiet)
 Make sparse_lu decomposition of M optionally computing the reciprocal condition number. More...
 
 ~vnl_sparse_lu ()
 
void set_pivot_thresh (double pivot_thresh)
 set the relative pivot threshold should be between 0 and 1. More...
 
void set_absolute_thresh (double absolute_thresh)
 set the threshold on absolute element magnitude for pivoting. More...
 
void set_diagonal_pivoting (int diag_pivoting)
 set diagonal pivoting mode, normally 1 which gives priority to diagonal elements. More...
 
vnl_vector< double > solve (vnl_vector< double > const &b)
 Solve problem M x = b. More...
 
void solve (vnl_vector< double > const &b, vnl_vector< double > *x)
 Solve problem M x = b. More...
 
vnl_vector< double > solve_transpose (vnl_vector< double > const &b)
 Solve problem M^t x = b. More...
 
void solve_transpose (vnl_vector< double > const &b, vnl_vector< double > *x)
 Solve problem M^t x = b. More...
 
double determinant ()
 Compute determinant. More...
 
double rcond ()
 Return reciprocal condition number (smallest/largest singular values). More...
 
double max_error_bound ()
 An estimate of maximum error in solution. More...
 

Protected Member Functions

void decompose_matrix ()
 
bool est_condition ()
 estimate the condition number. More...
 

Protected Attributes

vnl_sparse_matrix< double > A_
 
bool factored_
 
bool condition_computed_
 
operation mode_
 
double norm_
 
double rcond_
 
double largest_
 
double pivot_thresh_
 
double absolute_thresh_
 
int diag_pivoting_
 

Private Member Functions

 vnl_sparse_lu (vnl_sparse_lu const &that)
 Copy constructor - privatised to avoid it being used. More...
 
vnl_sparse_luoperator= (vnl_sparse_lu const &that)
 Assignment operator - privatised to avoid it being used. More...
 

Private Attributes

void * pmatrix_
 The internal matrix representation. More...
 

Detailed Description

Linear system solver for Mx = b using LU decomposition of a sparse matrix.

Encapsulating Sparse 1.3 by Kenneth S. Kundert. The matrix is factored before solution. Any number of b vectors can be applied after the matrix is factored with out recomputation of the LU form. It is advised to construct with mode==estimate_condition and check that rcond()>sqrt(machine precision). If this is not the case the solution may be suspect. An upper bound on error is provided. The solution of M^t x = b is also available.

Definition at line 28 of file vnl_sparse_lu.h.

Member Enumeration Documentation

◆ operation

Modes of computation. See constructor for details.

Enumerator
quiet 
verbose 
estimate_condition 
estimate_condition_verbose 

Definition at line 32 of file vnl_sparse_lu.h.

Constructor & Destructor Documentation

◆ vnl_sparse_lu() [1/2]

vnl_sparse_lu::vnl_sparse_lu ( vnl_sparse_matrix< double > const &  M,
operation  mode = quiet 
)

Make sparse_lu decomposition of M optionally computing the reciprocal condition number.

constructor - controls if condition information is computed.

Definition at line 18 of file vnl_sparse_lu.cxx.

◆ ~vnl_sparse_lu()

vnl_sparse_lu::~vnl_sparse_lu ( )

Definition at line 12 of file vnl_sparse_lu.cxx.

◆ vnl_sparse_lu() [2/2]

vnl_sparse_lu::vnl_sparse_lu ( vnl_sparse_lu const &  that)
private

Copy constructor - privatised to avoid it being used.

Member Function Documentation

◆ decompose_matrix()

void vnl_sparse_lu::decompose_matrix ( )
protected

◆ determinant()

double vnl_sparse_lu::determinant ( )

Compute determinant.

Definition at line 187 of file vnl_sparse_lu.cxx.

◆ est_condition()

bool vnl_sparse_lu::est_condition ( )
protected

estimate the condition number.

Definition at line 55 of file vnl_sparse_lu.cxx.

◆ max_error_bound()

double vnl_sparse_lu::max_error_bound ( )

An estimate of maximum error in solution.

Estimated upper bound of error in solution.

Not calculated unless operation mode at construction includes estimate_condition.

Definition at line 234 of file vnl_sparse_lu.cxx.

◆ operator=()

vnl_sparse_lu& vnl_sparse_lu::operator= ( vnl_sparse_lu const &  that)
private

Assignment operator - privatised to avoid it being used.

◆ rcond()

double vnl_sparse_lu::rcond ( )

Return reciprocal condition number (smallest/largest singular values).

the reciprocal of the condition number.

As long as rcond()>sqrt(precision) the decomposition can be used for solving equations safely. Not calculated unless operation mode at construction includes estimate_condition.

Definition at line 220 of file vnl_sparse_lu.cxx.

◆ set_absolute_thresh()

void vnl_sparse_lu::set_absolute_thresh ( double  absolute_thresh)
inline

set the threshold on absolute element magnitude for pivoting.

Should be either zero or significantly smaller than the absolute value of the smallest diagonal element.

Definition at line 52 of file vnl_sparse_lu.h.

◆ set_diagonal_pivoting()

void vnl_sparse_lu::set_diagonal_pivoting ( int  diag_pivoting)
inline

set diagonal pivoting mode, normally 1 which gives priority to diagonal elements.

Definition at line 54 of file vnl_sparse_lu.h.

◆ set_pivot_thresh()

void vnl_sparse_lu::set_pivot_thresh ( double  pivot_thresh)
inline

set the relative pivot threshold should be between 0 and 1.

If set to one then pivoting is complete and slow If near zero then roundoff error may be prohibitive but computation is fast Typical values are between 0.01 and 0.1.

Definition at line 47 of file vnl_sparse_lu.h.

◆ solve() [1/2]

vnl_vector< double > vnl_sparse_lu::solve ( vnl_vector< double > const &  b)

Solve problem M x = b.

Solve least squares problem M x = b.

Definition at line 120 of file vnl_sparse_lu.cxx.

◆ solve() [2/2]

void vnl_sparse_lu::solve ( vnl_vector< double > const &  b,
vnl_vector< double > *  x 
)

Solve problem M x = b.

Solve least squares problem M x = b.

Definition at line 69 of file vnl_sparse_lu.cxx.

◆ solve_transpose() [1/2]

vnl_vector< double > vnl_sparse_lu::solve_transpose ( vnl_vector< double > const &  b)

Solve problem M^t x = b.

Definition at line 179 of file vnl_sparse_lu.cxx.

◆ solve_transpose() [2/2]

void vnl_sparse_lu::solve_transpose ( vnl_vector< double > const &  b,
vnl_vector< double > *  x 
)

Solve problem M^t x = b.

Definition at line 128 of file vnl_sparse_lu.cxx.

Member Data Documentation

◆ A_

vnl_sparse_matrix<double> vnl_sparse_lu::A_
protected

Definition at line 86 of file vnl_sparse_lu.h.

◆ absolute_thresh_

double vnl_sparse_lu::absolute_thresh_
protected

Definition at line 94 of file vnl_sparse_lu.h.

◆ condition_computed_

bool vnl_sparse_lu::condition_computed_
protected

Definition at line 88 of file vnl_sparse_lu.h.

◆ diag_pivoting_

int vnl_sparse_lu::diag_pivoting_
protected

Definition at line 95 of file vnl_sparse_lu.h.

◆ factored_

bool vnl_sparse_lu::factored_
protected

Definition at line 87 of file vnl_sparse_lu.h.

◆ largest_

double vnl_sparse_lu::largest_
protected

Definition at line 92 of file vnl_sparse_lu.h.

◆ mode_

operation vnl_sparse_lu::mode_
protected

Definition at line 89 of file vnl_sparse_lu.h.

◆ norm_

double vnl_sparse_lu::norm_
protected

Definition at line 90 of file vnl_sparse_lu.h.

◆ pivot_thresh_

double vnl_sparse_lu::pivot_thresh_
protected

Definition at line 93 of file vnl_sparse_lu.h.

◆ pmatrix_

void* vnl_sparse_lu::pmatrix_
private

The internal matrix representation.

We don't use the typedef spMatrix directly here to avoid exposing the implementation detail (sparse/spMatrix.h) to the user.

Definition at line 105 of file vnl_sparse_lu.h.

◆ rcond_

double vnl_sparse_lu::rcond_
protected

Definition at line 91 of file vnl_sparse_lu.h.


The documentation for this class was generated from the following files: