PARTONS/NumA++  
Numerical Analysis C++ routines
Public Member Functions | Private Member Functions | Private Attributes | List of all members
NumA::LSMRSolver Class Reference

LSMR solves Ax = b or min ||Ax - b|| with or without damping, using the iterative algorithm of David Fong and Michael Saunders: http://www.stanford.edu/group/SOL/software/lsmr.html. More...

Public Member Functions

 LSMRSolver (double damp=0., double atol=1.e-6, double btol=1.e-6, double conlim=1.e8, size_t maxiter=0, ElemUtils::Formatter *output=0)
 Constructor. More...
 
virtual ~LSMRSolver ()
 Default destructor. More...
 
VectorD solve (const MatrixD &A, const VectorD &B)
 Solves the linear system \( A X = B \) and returns \( X \) in the least-squares sense. More...
 
double getToleranceA () const
 Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol. More...
 
void setToleranceA (double atol)
 Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol. More...
 
double getToleranceB () const
 Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol. More...
 
void setToleranceB (double btol)
 Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol. More...
 
double getConditionNumberLimit () const
 LSMR terminates if an estimate of cond(A) exceeds conlim. More...
 
void setConditionNumberLimit (double conlim)
 LSMR terminates if an estimate of cond(A) exceeds conlim. More...
 
double getDamping () const
 Damping factor for regularized least-squares. More...
 
void setDamping (double damp)
 Damping factor for regularized least-squares. More...
 
size_t getMaximumIerations () const
 LSMR terminates if the number of iterations reaches maxiter. More...
 
void setMaximumIerations (size_t maxiter)
 LSMR terminates if the number of iterations reaches maxiter. More...
 
ElemUtils::Formatter & getOutput () const
 
void setOutput (ElemUtils::Formatter &output)
 
double getConditionNumber () const
 
unsigned int getStoppingCase () const
 Reason for stopping the iterations. More...
 
size_t getNumberIterations () const
 Number of iterations. More...
 
double getNormA () const
 
double getNormAr () const
 
double getNormr () const
 
double getNormX () const
 
const std::string & getStoppingMessage () const
 Reason for stopping the iterations. More...
 

Private Member Functions

void _sym_ortho (double a, double b, double &c, double &s, double &r) const
 Routine of rotation from scipy. More...
 

Private Attributes

double m_damp
 Damping factor for regularized least-squares. More...
 
double m_atol
 Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol. More...
 
double m_btol
 Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol. More...
 
double m_conlim
 LSMR terminates if an estimate of cond(A) exceeds conlim. More...
 
size_t m_maxiter
 LSMR terminates if the number of iterations reaches maxiter. More...
 
ElemUtils::Formatter * m_output
 Pointer to the stream where to write the output. More...
 
unsigned int m_istop
 Reason for stopping the iterations. More...
 
size_t m_itn
 Number of iterations. More...
 
double m_normr
 
double m_normar
 
double m_normA
 
double m_condA
 
double m_normx
 
std::string m_stopMessage
 Reason for stopping the iterations. More...
 
std::vector< std::string > m_msg
 
std::string m_hdg1
 
std::string m_hdg2
 
unsigned int m_pfreq
 

Detailed Description

LSMR solves Ax = b or min ||Ax - b|| with or without damping, using the iterative algorithm of David Fong and Michael Saunders: http://www.stanford.edu/group/SOL/software/lsmr.html.

Adapted for C++ from the scipy implementation: https://github.com/scipy/scipy/blob/v0.18.1/scipy/sparse/linalg/isolve/lsmr.py

Constructor & Destructor Documentation

◆ LSMRSolver()

NumA::LSMRSolver::LSMRSolver ( double  damp = 0.,
double  atol = 1.e-6,
double  btol = 1.e-6,
double  conlim = 1.e8,
size_t  maxiter = 0,
ElemUtils::Formatter *  output = 0 
)

Constructor.

Parameters
dampDamping factor for regularized least-squares.
atolStopping tolerance.
btolStopping tolerance.
conlimLSMR terminates if an estimate of cond(A) exceeds conlim.
maxiterLSMR terminates if the number of iterations reaches maxiter.
outputPointer to the stream where to write the output.

◆ ~LSMRSolver()

NumA::LSMRSolver::~LSMRSolver ( )
virtual

Default destructor.

Member Function Documentation

◆ _sym_ortho()

void NumA::LSMRSolver::_sym_ortho ( double  a,
double  b,
double &  c,
double &  s,
double &  r 
) const
private

Routine of rotation from scipy.

Parameters
a
b
c
s
r

◆ getConditionNumber()

double NumA::LSMRSolver::getConditionNumber ( ) const

◆ getConditionNumberLimit()

double NumA::LSMRSolver::getConditionNumberLimit ( ) const

LSMR terminates if an estimate of cond(A) exceeds conlim.

◆ getDamping()

double NumA::LSMRSolver::getDamping ( ) const

Damping factor for regularized least-squares.

◆ getMaximumIerations()

size_t NumA::LSMRSolver::getMaximumIerations ( ) const

LSMR terminates if the number of iterations reaches maxiter.

◆ getNormA()

double NumA::LSMRSolver::getNormA ( ) const

◆ getNormAr()

double NumA::LSMRSolver::getNormAr ( ) const

◆ getNormr()

double NumA::LSMRSolver::getNormr ( ) const

◆ getNormX()

double NumA::LSMRSolver::getNormX ( ) const

◆ getNumberIterations()

size_t NumA::LSMRSolver::getNumberIterations ( ) const

Number of iterations.

◆ getOutput()

ElemUtils::Formatter & NumA::LSMRSolver::getOutput ( ) const
Returns
Reference to the stream where the output is written.

◆ getStoppingCase()

unsigned int NumA::LSMRSolver::getStoppingCase ( ) const

Reason for stopping the iterations.

◆ getStoppingMessage()

const std::string & NumA::LSMRSolver::getStoppingMessage ( ) const

Reason for stopping the iterations.

◆ getToleranceA()

double NumA::LSMRSolver::getToleranceA ( ) const

Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol.

◆ getToleranceB()

double NumA::LSMRSolver::getToleranceB ( ) const

Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol.

◆ setConditionNumberLimit()

void NumA::LSMRSolver::setConditionNumberLimit ( double  conlim)

LSMR terminates if an estimate of cond(A) exceeds conlim.

◆ setDamping()

void NumA::LSMRSolver::setDamping ( double  damp)

Damping factor for regularized least-squares.

◆ setMaximumIerations()

void NumA::LSMRSolver::setMaximumIerations ( size_t  maxiter)

LSMR terminates if the number of iterations reaches maxiter.

◆ setOutput()

void NumA::LSMRSolver::setOutput ( ElemUtils::Formatter &  output)
Parameters
outputReference to the stream where the output is written.

◆ setToleranceA()

void NumA::LSMRSolver::setToleranceA ( double  atol)

Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol.

◆ setToleranceB()

void NumA::LSMRSolver::setToleranceB ( double  btol)

Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol.

◆ solve()

VectorD NumA::LSMRSolver::solve ( const MatrixD A,
const VectorD B 
)

Solves the linear system \( A X = B \) and returns \( X \) in the least-squares sense.

Iterative method for large sparse matrices.

Parameters
AMatrixD.
BVectorD.
Returns
VectorD Solution X.

Member Data Documentation

◆ m_atol

double NumA::LSMRSolver::m_atol
private

Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol.

◆ m_btol

double NumA::LSMRSolver::m_btol
private

Stopping tolerance. LSMR continues iterations until a certain backward error estimate is smaller than some quantity depending on atol and btol.

◆ m_condA

double NumA::LSMRSolver::m_condA
private

◆ m_conlim

double NumA::LSMRSolver::m_conlim
private

LSMR terminates if an estimate of cond(A) exceeds conlim.

◆ m_damp

double NumA::LSMRSolver::m_damp
private

Damping factor for regularized least-squares.

◆ m_hdg1

std::string NumA::LSMRSolver::m_hdg1
private

◆ m_hdg2

std::string NumA::LSMRSolver::m_hdg2
private

◆ m_istop

unsigned int NumA::LSMRSolver::m_istop
private

Reason for stopping the iterations.

◆ m_itn

size_t NumA::LSMRSolver::m_itn
private

Number of iterations.

◆ m_maxiter

size_t NumA::LSMRSolver::m_maxiter
private

LSMR terminates if the number of iterations reaches maxiter.

◆ m_msg

std::vector<std::string> NumA::LSMRSolver::m_msg
private

◆ m_normA

double NumA::LSMRSolver::m_normA
private

◆ m_normar

double NumA::LSMRSolver::m_normar
private

◆ m_normr

double NumA::LSMRSolver::m_normr
private

◆ m_normx

double NumA::LSMRSolver::m_normx
private

◆ m_output

ElemUtils::Formatter* NumA::LSMRSolver::m_output
private

Pointer to the stream where to write the output.

◆ m_pfreq

unsigned int NumA::LSMRSolver::m_pfreq
private

◆ m_stopMessage

std::string NumA::LSMRSolver::m_stopMessage
private

Reason for stopping the iterations.


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