PSCF v1.5.0
Pscf::LuSolver Class Reference

Solve Ax=b by LU decomposition of A. More...

#include <LuSolver.h>

Public Member Functions

 LuSolver ()
 Constructor.
 ~LuSolver ()
 Destructor.
void allocate (int n)
 Allocate memory.
void computeLU (const Matrix< double > &A)
 Compute the LU decomposition for later use.
void solve (Array< double > &b, Array< double > &x)
 Solve Ax = b for known b to compute x.
void solveBasic (Array< double > const &b, Array< double > &x) const
 Solve Ax = b by a basic solution, also for a singular matrix A.
void inverse (Matrix< double > &inv)
 Compute inverse of matrix A.
bool isSingular () const
 Does the last LU decomposition have a zero pivot?

Detailed Description

Solve Ax=b by LU decomposition of A.

This class is a simple wrapper for the functions provided by the Gnu Scientific Library (GSL).

Definition at line 30 of file LuSolver.h.

Constructor & Destructor Documentation

◆ LuSolver()

Pscf::LuSolver::LuSolver ( )

Constructor.

Definition at line 114 of file LuSolver.cpp.

Referenced by Pscf::FhMixture::computePhi().

◆ ~LuSolver()

Pscf::LuSolver::~LuSolver ( )

Destructor.

Definition at line 134 of file LuSolver.cpp.

Member Function Documentation

◆ allocate()

void Pscf::LuSolver::allocate ( int n)

Allocate memory.

Parameters
ndimension of n x n square array.

Definition at line 146 of file LuSolver.cpp.

References UTIL_CHECK.

Referenced by Pscf::AmbdInteraction::update().

◆ computeLU()

void Pscf::LuSolver::computeLU ( const Matrix< double > & A)

Compute the LU decomposition for later use.

The decomposition is completed also for a singular matrix A, with a zero pivot, which isSingular() then reports.

Parameters
Athe square matrix A in problem Ax=b.

Definition at line 163 of file LuSolver.cpp.

References Util::Matrix< Data >::capacity1(), Util::Matrix< Data >::capacity2(), and UTIL_CHECK.

Referenced by Pscf::AmbdInteraction::update().

◆ solve()

void Pscf::LuSolver::solve ( Array< double > & b,
Array< double > & x )

Solve Ax = b for known b to compute x.

Parameters
bthe RHS vector
xthe solution vector

Definition at line 206 of file LuSolver.cpp.

References Util::Array< Data >::capacity(), Util::Array< Data >::cArray(), and UTIL_CHECK.

◆ solveBasic()

void Pscf::LuSolver::solveBasic ( Array< double > const & b,
Array< double > & x ) const

Solve Ax = b by a basic solution, also for a singular matrix A.

The component of x of each zero pivot of the LU decomposition is set to zero, and the equation of that pivot is not used. The result solves Ax = b if b lies in the range of A and the number of zero pivots equals the rank deficiency of A, i.e., if each zero pivot belongs to a column that depends on the preceding columns (as for a matrix with a single null direction). Otherwise it need not solve the system, so callers must check the residual. Use solve() for a matrix that is not singular.

Parameters
bthe RHS vector
xthe solution vector (must not be b)

Definition at line 239 of file LuSolver.cpp.

References Util::Array< Data >::capacity(), Util::Array< Data >::cArray(), and UTIL_CHECK.

◆ inverse()

void Pscf::LuSolver::inverse ( Matrix< double > & inv)

Compute inverse of matrix A.

Parameters
invinverse of matrix A (output)

Definition at line 282 of file LuSolver.cpp.

References Util::Matrix< Data >::cArray(), and UTIL_CHECK.

Referenced by Pscf::AmbdInteraction::update().

◆ isSingular()

bool Pscf::LuSolver::isSingular ( ) const

Does the last LU decomposition have a zero pivot?

If so, solve() and inverse() abort through the GSL error handler.

Definition at line 227 of file LuSolver.cpp.

References UTIL_CHECK.

Referenced by Pscf::AmbdInteraction::update().


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