Jive reference manual
List of all members | Public Types | Public Member Functions | Public Attributes | Protected Member Functions
jive::solver::SparseLU Class Reference

Implements a direct solver that is based on sparse LU factorization with pivoting. More...

Inheritance diagram for jive::solver::SparseLU:
Inheritance graph

Public Types

typedef algebra::SparseMatrixObject MatrixObject
 A type representing the coefficient matrix of a system of equations. More...
 
- Public Types inherited from jive::solver::Solver
typedef jem::util::Properties Properties
 A type representing a set of properties. More...
 
typedef util::Vector Vector
 A type that represents a vector. More...
 

Public Member Functions

 SparseLU (const jem::Ref< MatrixObject > &matrix)
 Constructs a new SparseLU solver given a matrix object. More...
 
void factor ()
 Computes the LU factorization of the coefficient matrix. More...
 
virtual void solve (const Vector &lhs, const Vector &rhs)
 Computes the solution of a linear system of equations. More...
 
bool enableAutoFactor (bool choice)
 Sets the auto-factorization mode. More...
 
virtual void setZeroPivotThreshold (double eps)
 Sets the threshold for detecting zero pivots. More...
 
virtual double getZeroPivotThreshold () const
 Returns the current zero pivot threshold. More...
 
virtual void setMaxZeroPivotCount (int n)
 Sets the maximum number of allowed zero pivots. More...
 
virtual int getMaxZeroPivotCount () const
 Returns the maximum number of allowed zero pivots. More...
 
- Public Member Functions inherited from jive::solver::DirectSolver
virtual void configure (const Properties &conf, const Properties &props)
 Configures this solver given a set of properties. More...
 
- Public Member Functions inherited from jive::solver::Solver
virtual jem::ClassgetClass () const
 Returns the Class instance representing the runtime class of this object. More...
 
- Public Member Functions inherited from jem::Object
virtual String toString () const
 Returns a short textual description of this object. More...
 
virtual long hashValue () const
 Returns a hash value for this object. More...
 
virtual bool equals (const Ref< Object > &obj) const
 Tests whether two objects are equal. More...
 
Ref< Objectclone () const
 Returns a copy of this object. More...
 

Public Attributes

jem::util::Event< int > zeroPivotEvent
 Signals the occurrence of a zero pivot. More...
 
- Public Attributes inherited from jive::solver::DirectSolver
jem::util::Event< double > progressEvent
 Signals that progress is being made. More...
 

Protected Member Functions

virtual ~SparseLU ()
 
- Protected Member Functions inherited from jive::solver::DirectSolver
virtual ~DirectSolver ()
 
- Protected Member Functions inherited from jive::solver::Solver
virtual ~Solver ()
 
- Protected Member Functions inherited from jem::Collectable
 Collectable ()
 Creates an empty Collectable. More...
 
 ~Collectable ()
 Frees resources. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from jive::solver::Solver
static jem::ClassgetType ()
 
- Static Public Member Functions inherited from jem::Object
static ClassgetType ()
 Returns the Class instance representing the Object class. More...
 
- Static Public Attributes inherited from jive::solver::DirectSolver
static const double DEFAULT_ZERO_PIVOT_THRESHOLD
 The default zero pivot threshold. More...
 

Detailed Description

#include<jive/solver/SparseLU.h>

The class SparseLU implements a direct solution algorithm that is based on LU factorization with partial (row-wise) pivoting. It can be used to solve any linear system of equations as long as the coefficient matrix is square and non-singular.

By default, a SparseLU instance will automatically update the LU factorization of the coefficient matrix whenever that is necessary. You can disable this behavior by calling the member function enableAutoFactor.

Although the SparseLU solver is often not the most efficient solver, it is one of the most robust solvers in Jive.

Member Typedef Documentation

The MatrixObject type represents the coefficient matrix of a linear system of equations. It is an alias for jive::algebra::SparseMatrixObject.

Constructor & Destructor Documentation

jive::solver::SparseLU::SparseLU ( const jem::Ref< MatrixObject > &  matrix)
explicit

Constructs a new SparseLU solver that encapsulates a reference to the coefficient matrix matrix. The solver connects itself to the changeEvent of the matrix so that it receives an event whenever the matrix has been modified. In this way, the solver automatically knows when it is necessary to (re-)compute the LU factorization of the coefficient matrix.

Parameters
matrix- the coefficient matrix of the linear system of equations to be solved.
Precondition
matrix != NIL
virtual jive::solver::SparseLU::~SparseLU ( )
protectedvirtual

Member Function Documentation

void jive::solver::SparseLU::factor ( )

Computes the LU factorization of the coefficient matrix that has been passed to the constructor of this SparseLU object. This function does nothing if the current LU factorization is up to date; that is, if the coefficient matrix has not been modified since the last time that this function was called.

If a zero pivot is encountered during the factorization procedure, and the maximum number of zero pivots has not yet been exceeded, the zero pivot is replaced by an infinitely large number. That is, the inverse of the pivot is set to zero. A pivot is marked as zero if its value divided by a scale factor is less than the zero pivot threshold. The scale factors are equal to the maximum row elements – in absolute value – of the coefficient matrix.

Exceptions
SolverException- if the maximum number of allowed zero pivots is exceeded.
jem::IllegalArgumentException- if the coefficient matrix is non-square.
virtual void jive::solver::SparseLU::solve ( const Vector lhs,
const Vector rhs 
)
virtual

Computes the solution of

L * U * lhs = rhs

with L and U the lower and upper factors of the coefficient matrix that has been passed to the constructor of this SparseLU object. This function calls the factor() function to (re-)compute the lower and upper factors, unless the auto-factorization mode has been disabled by the enableAutoFactor() function.

When this function is called, the vector rhs should contain the right-hand side vector. On exit, the vector lhs will be set to the solution of the system of equations. The sizes of the two vectors must match the size of the coefficient matrix.

Parameters
lhs- the solution vector.
rhs- the right-hand side vector.
Precondition
The sizes of the vectors lhs and rhs are equal to the size of the coefficient matrix.
Exceptions
SolverException- if the maximum number of allowed zero pivots is exceeded.
jem::IllegalArgumentException- if the coefficient matrix is non-square.

Implements jive::solver::Solver.

bool jive::solver::SparseLU::enableAutoFactor ( bool  choice)

Enables (when choice is true) or disables (when choice is false) the auto-factorization mode. If this mode is enabled, the function factor() is automatically called by the solve() function. Otherwise, you are responsible for calling the factor() function.

Parameters
choice- a boolean value that indicates whether the auto-factorization mode should be enabled or not.
Returns
true if the auto-factorization mode was enabled before this function was called, and false otherwise.
virtual void jive::solver::SparseLU::setZeroPivotThreshold ( double  eps)
virtual

Sets the zero pivot threshold to eps.

Parameters
eps- the relative zero pivot threshold.
Precondition
eps > 0.0
Postcondition
this->getZeroPivotThreshold() == eps

Implements jive::solver::DirectSolver.

virtual double jive::solver::SparseLU::getZeroPivotThreshold ( ) const
virtual

Returns the current zero pivot threshold.

Returns
The relative zero pivot threshold.

Implements jive::solver::DirectSolver.

virtual void jive::solver::SparseLU::setMaxZeroPivotCount ( int  n)
virtual

Sets the maximum number of allowed zero pivots to n.

Parameters
n- the maximum number of allowed zero pivots.
Precondition
n >= 0
Postcondition
this->getMaxZeroPivotCount() == n

Implements jive::solver::DirectSolver.

virtual int jive::solver::SparseLU::getMaxZeroPivotCount ( ) const
virtual

Returns the maximum number of allowed zero pivots.

Returns
The maximum number of allowed zero pivots.

Implements jive::solver::DirectSolver.

Member Data Documentation

jem::util::Event<int> jive::solver::SparseLU::zeroPivotEvent

The event zeroPivotEvent is emitted whenever a zero pivot is encountered. The event argument is the index of the matrix column containing the zero pivot.