Linear Algebra
arduino
Accessible implementations of linear algebra algorithms
|
#include <include/linalg/NoPivotLU.hpp>
LU factorization without pivoting.
Factorizes a square matrix into a lower triangular and an upper-triangular factor.
This version does not use row pivoting, and is not rank-revealing.
Definition at line 20 of file NoPivotLU.hpp.
Constructors | |
NoPivotLU ()=default | |
Default constructor. More... | |
NoPivotLU (const SquareMatrix &matrix) | |
Factorize the given matrix. More... | |
NoPivotLU (SquareMatrix &&matrix) | |
Factorize the given matrix. More... | |
Factorization | |
void | compute (SquareMatrix &&matrix) |
Perform the LU factorization of the given matrix. More... | |
void | compute (const SquareMatrix &matrix) |
Perform the LU factorization of the given matrix. More... | |
Retrieving the L factor | |
SquareMatrix && | steal_L () |
Get the lower-triangular matrix L, reusing the internal storage. More... | |
void | get_L_inplace (Matrix &L) const |
Copy the lower-triangular matrix L to the given matrix. More... | |
SquareMatrix | get_L () const & |
Get a copy of the lower-triangular matrix L. More... | |
SquareMatrix && | get_L () && |
Get the lower-triangular matrix L. More... | |
Retrieving the U factor | |
SquareMatrix && | steal_U () |
Get the upper-triangular matrix U, reusing the internal storage. More... | |
void | get_U_inplace (Matrix &U) const |
Copy the upper-triangular matrix U to the given matrix. More... | |
SquareMatrix | get_U () const & |
Get a copy of the upper-triangular matrix U. More... | |
SquareMatrix && | get_U () && |
Get the upper-triangular matrix U. More... | |
Solving systems of equations problems | |
void | solve_inplace (Matrix &B) const |
Solve the system AX = B or LUX = B. More... | |
Matrix | solve (const Matrix &B) const |
Solve the system AX = B or LUX = B. More... | |
Matrix && | solve (Matrix &&B) const |
Solve the system AX = B or LUX = B. More... | |
Vector | solve (const Vector &B) const |
Solve the system Ax = b or LUx = b. More... | |
Vector && | solve (Vector &&B) const |
Solve the system Ax = b or LUx = b. More... | |
Access to internal representation | |
bool | is_factored () const |
Check if this object contains a factorization. More... | |
bool | has_LU () const |
Check if this object contains valid L and U factors. More... | |
SquareMatrix && | steal_LU () |
Get the internal storage of the upper-triangular matrix U and the strict lower-triangular part of matrix L. More... | |
const SquareMatrix & | get_LU () const & |
Get a copy of the internal storage of the upper-triangular matrix U and the strict lower-triangular part of matrix L. More... | |
SquareMatrix && | get_LU () && |
Get the internal storage of the upper-triangular matrix U and the strict lower-triangular part of matrix L. More... | |
Private Types | |
enum | State { NotFactored = 0 , Factored = 1 } |
Private Member Functions | |
void | compute_factorization () |
The actual LU factorization algorithm. More... | |
void | back_subs (const Matrix &B, Matrix &X) const |
Back substitution algorithm for solving upper-triangular systems UX = B. More... | |
void | forward_subs (const Matrix &B, Matrix &X) const |
Forward substitution algorithm for solving lower-triangular systems LX = B. More... | |
Private Attributes | |
SquareMatrix | LU |
Result of a LU factorization: stores the upper-triangular matrix U and the strict lower-triangular part of matrix L. More... | |
enum NoPivotLU::State | state = NotFactored |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, const NoPivotLU &lu) |
Print the L and U matrices of an NoPivotLU object. More... | |
|
private |
Enumerator | |
---|---|
NotFactored | |
Factored |
Definition at line 139 of file NoPivotLU.hpp.
|
default |
Default constructor.
|
inline |
Factorize the given matrix.
Definition at line 28 of file NoPivotLU.hpp.
|
inline |
Factorize the given matrix.
Definition at line 30 of file NoPivotLU.hpp.
void compute | ( | SquareMatrix && | matrix | ) |
Perform the LU factorization of the given matrix.
Definition at line 9 of file NoPivotLU.ipp.
void compute | ( | const SquareMatrix & | matrix | ) |
Perform the LU factorization of the given matrix.
Definition at line 14 of file NoPivotLU.ipp.
SquareMatrix && steal_L | ( | ) |
Get the lower-triangular matrix L, reusing the internal storage.
Definition at line 19 of file NoPivotLU.ipp.
void get_L_inplace | ( | Matrix & | L | ) | const |
Copy the lower-triangular matrix L to the given matrix.
Definition at line 33 of file NoPivotLU.ipp.
SquareMatrix get_L | ( | ) | const & |
Get a copy of the lower-triangular matrix L.
Definition at line 49 of file NoPivotLU.ipp.
|
inline |
Get the lower-triangular matrix L.
Definition at line 59 of file NoPivotLU.hpp.
SquareMatrix && steal_U | ( | ) |
Get the upper-triangular matrix U, reusing the internal storage.
Definition at line 55 of file NoPivotLU.ipp.
void get_U_inplace | ( | Matrix & | U | ) | const |
Copy the upper-triangular matrix U to the given matrix.
Definition at line 67 of file NoPivotLU.ipp.
SquareMatrix get_U | ( | ) | const & |
Get a copy of the upper-triangular matrix U.
Definition at line 81 of file NoPivotLU.ipp.
|
inline |
Get the upper-triangular matrix U.
Definition at line 77 of file NoPivotLU.hpp.
void solve_inplace | ( | Matrix & | B | ) | const |
Solve the system AX = B or LUX = B.
Matrix B is overwritten with the result X.
Definition at line 238 of file NoPivotLU.cpp.
Solve the system AX = B or LUX = B.
Definition at line 92 of file NoPivotLU.ipp.
Solve the system AX = B or LUX = B.
Definition at line 98 of file NoPivotLU.ipp.
Solve the system Ax = b or LUx = b.
Definition at line 103 of file NoPivotLU.ipp.
Solve the system Ax = b or LUx = b.
Definition at line 107 of file NoPivotLU.ipp.
|
inline |
Check if this object contains a factorization.
Definition at line 104 of file NoPivotLU.hpp.
|
inline |
Check if this object contains valid L and U factors.
Definition at line 107 of file NoPivotLU.hpp.
SquareMatrix && steal_LU | ( | ) |
Get the internal storage of the upper-triangular matrix U and the strict lower-triangular part of matrix L.
Definition at line 87 of file NoPivotLU.ipp.
|
inline |
Get a copy of the internal storage of the upper-triangular matrix U and the strict lower-triangular part of matrix L.
Definition at line 117 of file NoPivotLU.hpp.
|
inline |
Get the internal storage of the upper-triangular matrix U and the strict lower-triangular part of matrix L.
Definition at line 120 of file NoPivotLU.hpp.
|
private |
The actual LU factorization algorithm.
LU
contains the matrix A to be factorized LU.rows() == LU.cols()
LU
contains the full upper-triangular matrix U and the strict lower-triangular part of matrix L. The diagonal elements of L are implicitly 1. get_L() * get_U() == A
(up to rounding errors)Definition at line 21 of file NoPivotLU.cpp.
Back substitution algorithm for solving upper-triangular systems UX = B.
Definition at line 173 of file NoPivotLU.cpp.
Forward substitution algorithm for solving lower-triangular systems LX = B.
Definition at line 205 of file NoPivotLU.cpp.
|
related |
Print the L and U matrices of an NoPivotLU object.
Definition at line 119 of file NoPivotLU.ipp.
|
private |
Result of a LU factorization: stores the upper-triangular matrix U and the strict lower-triangular part of matrix L.
The diagonal elements of L are implicitly 1.
Definition at line 137 of file NoPivotLU.hpp.
|
private |