|
PSCF v1.5.0
|
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? | |
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.
| Pscf::LuSolver::LuSolver | ( | ) |
Constructor.
Definition at line 114 of file LuSolver.cpp.
Referenced by Pscf::FhMixture::computePhi().
| Pscf::LuSolver::~LuSolver | ( | ) |
Destructor.
Definition at line 134 of file LuSolver.cpp.
| void Pscf::LuSolver::allocate | ( | int | n | ) |
Allocate memory.
| n | dimension of n x n square array. |
Definition at line 146 of file LuSolver.cpp.
References UTIL_CHECK.
Referenced by Pscf::AmbdInteraction::update().
| 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.
| A | the 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 Ax = b for known b to compute x.
| b | the RHS vector |
| x | the solution vector |
Definition at line 206 of file LuSolver.cpp.
References Util::Array< Data >::capacity(), Util::Array< Data >::cArray(), and UTIL_CHECK.
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.
| b | the RHS vector |
| x | the 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.
| void Pscf::LuSolver::inverse | ( | Matrix< double > & | inv | ) |
Compute inverse of matrix A.
| inv | inverse 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().
| 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().