8 LU = std::move(matrix);
25 for (
size_t c = 0; c <
LU.
cols(); ++c) {
27 for (
size_t r = 0; r < c; ++r)
40 for (
size_t c = 0; c < L.
cols(); ++c) {
42 for (
size_t r = 0; r < c; ++r)
47 for (
size_t r = c + 1; r < L.
rows(); ++r)
62 for (
size_t c = 0; c <
LU.
cols(); ++c) {
65 for (
size_t r = c + 1; r <
LU.
rows(); ++r)
75 for (
size_t c = 0; c < U.
cols(); ++c) {
77 for (
size_t r = 0; r <= c; ++r)
80 for (
size_t r = c + 1; r < U.
rows(); ++r)
100 return std::move(
LU);
127 os <<
"Not factored." << std::endl;
132 int w = os.precision() + 9;
135 os <<
"L = " << std::endl;
136 for (
size_t r = 0; r < LU.cols(); ++r) {
137 for (
size_t c = 0; c < r; ++c)
138 os << std::setw(w) << 0;
139 for (
size_t c = r; c < LU.cols(); ++c)
140 os << std::setw(w) << LU(r, c);
144 os <<
"U = " << std::endl;
145 for (
size_t r = 0; r < LU.cols(); ++r) {
146 for (
size_t c = 0; c < r; ++c)
147 os << std::setw(w) << LU(r, c);
148 os << std::setw(w) << 1;
149 for (
size_t c = r; c < LU.cols(); ++c)
150 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.
Class that represents matrices that permute the rows or columns of other matrices.
void resize(size_t size)
Resize the permutation matrix.
void fill_identity()
Fill the matrix as an identity permutation.
LU factorization with row 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.
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.
PermutationMatrix && steal_P()
Get the permutation matrix P, reusing the internal storage.
SquareMatrix && steal_U()
Get the upper-triangular matrix U, reusing the internal storage.
PermutationMatrix P
The permutation of A that maximizes pivot size.
enum RowPivotLU::State state
A column vector (nĂ—1 matrix).