MatrixSolver.h

Classes

MatrixSolver -- MatrixSolver.h: the base class for solvers of linear equations AX=B (full description)

class MatrixSolver

Interface

Public Members
MatrixSolver()
MatrixSolver(const MatrixSolver & other)
MatrixSolver(const Matrix<FType> & A, const Vector<FType> & B)
virtual ~MatrixSolver()
MatrixSolver & operator=(const MatrixSolver & other)
void setAB(const Matrix<FType> & A, const Vector<FType> & B)
void setX(const Vector<FType> & X)
virtual Bool solve()
Bool accurateSolution()
const Vector<FType> & getResidual()
const Vector<FType> & getSolution()
void setTolerance(FType tol)
FType Tolerance()
void setMaxIters(uInt maxiters)
uInt MaxIters()
void setGain(FType g)
FType Gain()
void setSolved(Bool s)
Bool Solved()
FType getNorm()
Protected Members
virtual LogSink& logSink()

Description

Review Status

Date Reviewed:
",

Prerequisite

Etymology

The MatrixSolver class name reflects its use as the base class for solving Linear Equations of the form AX=B. This class is purely virtual and provides the essential implementation for derived solvers classes.

Synopsis

The MatrixSolver class is a purely virtual base class. The programmer needs to define the following functions in a class derived from MatrixSolver:
  1. the derived destructor.
  2. void setImageAndPsf(const Array<FType> & image, const Array<FType> & psf); Set the image and the Point Spread Function (beam). Setting this should reset the internal state, e.g. CurrentIter()==0.
  3. Bool solve(); Perform solution of AX=B. Returns True if algorithm has converged or stop criterium reached.

To Do

Member Description

MatrixSolver()

Default Constructor

MatrixSolver(const MatrixSolver & other)

Copy Constructor

MatrixSolver(const Matrix<FType> & A, const Vector<FType> & B)

Create a MatrixSolver from a matrix A and a Vector B

Warning A and B are accessed by reference, so do not modify them during the lifetime of the MatrixSolver

virtual ~MatrixSolver()

Virtual destructor: calls all derived class destructors

MatrixSolver & operator=(const MatrixSolver & other)

Assignment operator: uses reference semantics, i.e., it references the internal arrays of other

void setAB(const Matrix<FType> & A, const Vector<FType> & B)

Set A matrix and B vector

void setX(const Vector<FType> & X)

Set initial value of X

virtual Bool solve()

Solve for the X vector.

Bool accurateSolution()

Is the current solution good enough?

const Vector<FType> & getResidual()

Return residual vector B-AX

const Vector<FType> & getSolution()

Return solution vector

void setTolerance(FType tol)

Set the tolerance for solution

FType Tolerance()

Return the tolerance for solution

void setMaxIters(uInt maxiters)

Set the maximum number of iterations.

uInt MaxIters()

Return the maximum number of iterations.

void setGain(FType g)

Set the gain for solution

FType Gain()

Return the gain for solution

void setSolved(Bool s)

Set status of solution

Bool Solved()

Return status of solution

FType getNorm()

Return norm of solution i.e. ||B-AX||

virtual LogSink& logSink()