10 LU = std::move(matrix);
22 for (
size_t c = 0; c <
LU.
cols(); ++c) {
24 for (
size_t r = 0; r < c; ++r)
37 for (
size_t c = 0; c < L.
cols(); ++c) {
39 for (
size_t r = 0; r < c; ++r)
44 for (
size_t r = c + 1; r < L.
rows(); ++r)
58 for (
size_t c = 0; c <
LU.
cols(); ++c) {
61 for (
size_t r = c + 1; r <
LU.
rows(); ++r)
71 for (
size_t c = 0; c < U.
cols(); ++c) {
73 for (
size_t r = 0; r <= c; ++r)
76 for (
size_t r = c + 1; r < U.
rows(); ++r)
112 #ifndef NO_IOSTREAM_SUPPORT
121 os <<
"Not factored." << std::endl;
126 int w = os.precision() + 9;
129 os <<
"L = " << std::endl;
130 for (
size_t r = 0; r < LU.cols(); ++r) {
131 for (
size_t c = 0; c < r; ++c)
132 os << std::setw(w) << 0;
133 for (
size_t c = r; c < LU.cols(); ++c)
134 os << std::setw(w) << LU(r, c);
138 os <<
"U = " << std::endl;
139 for (
size_t r = 0; r < LU.cols(); ++r) {
140 for (
size_t c = 0; c < r; ++c)
141 os << std::setw(w) << LU(r, c);
142 os << std::setw(w) << 1;
143 for (
size_t c = r; c < LU.cols(); ++c)
144 os << std::setw(w) << 0;
std::ostream & operator<<(std::ostream &os, const HouseholderQR &qr)
Print the Q and R matrices of a HouseholderQR object.
size_t rows() const
Get the number of rows of the matrix.
size_t cols() const
Get the number of columns of the matrix.
LU factorization without pivoting.
SquareMatrix LU
Result of a LU factorization: stores the upper-triangular matrix U and the strict lower-triangular pa...
void get_U_inplace(Matrix &U) const
Copy the upper-triangular matrix U to the given matrix.
SquareMatrix && steal_LU()
Get the internal storage of the upper-triangular matrix U and the strict lower-triangular part of mat...
const SquareMatrix & get_LU() const &
Get a copy of the internal storage of the upper-triangular matrix U and the strict lower-triangular p...
bool has_LU() const
Check if this object contains valid L and U factors.
Matrix solve(const Matrix &B) const
Solve the system AX = B or LUX = B.
void get_L_inplace(Matrix &L) const
Copy the lower-triangular matrix L to the given matrix.
void compute(SquareMatrix &&matrix)
Perform the LU factorization of the given matrix.
SquareMatrix && steal_L()
Get the lower-triangular matrix L, reusing the internal storage.
void solve_inplace(Matrix &B) const
Solve the system AX = B or LUX = B.
bool is_factored() const
Check if this object contains a factorization.
void compute_factorization()
The actual LU factorization algorithm.
enum NoPivotLU::State state
SquareMatrix get_L() const &
Get a copy of the lower-triangular matrix L.
SquareMatrix get_U() const &
Get a copy of the upper-triangular matrix U.
SquareMatrix && steal_U()
Get the upper-triangular matrix U, reusing the internal storage.
A column vector (nĂ—1 matrix).