46 for (
size_t k = 0; k <
LU.
cols(); ++k) {
59 double max_elem = std::abs(
LU(k, k));
61 for (
size_t i = k + 1; i <
LU.
rows(); ++i) {
62 double abs_elem = std::abs(
LU(i, k));
63 if (abs_elem > max_elem) {
120 double pivot =
LU(k, k);
123 for (
size_t i = k + 1; i <
LU.
rows(); ++i)
127 for (
size_t c = k + 1; c <
LU.
cols(); ++c)
129 for (
size_t i = k + 1; i <
LU.
rows(); ++i)
131 LU(i, c) -=
LU(i, k) *
LU(k, c);
165 for (
size_t i = 0; i < B.
cols(); ++i) {
166 for (
size_t r =
LU.
rows(); r-- > 0;) {
168 for (
size_t c = r + 1; c <
LU.
cols(); ++c)
169 X(r, i) -=
LU(r, c) * X(c, i);
199 for (
size_t i = 0; i < B.
cols(); ++i) {
200 for (
size_t r = 0; r <
LU.
rows(); ++r) {
202 for (
size_t c = 0; c < r; ++c)
203 X(r, i) -=
LU(r, c) * X(c, i);
void swap_rows(size_t a, size_t b)
Swap two rows of the matrix.
size_t rows() const
Get the number of rows of the matrix.
size_t cols() const
Get the number of columns of the matrix.
size_t size() const
Get the size of the permutation matrix.
void permute_rows(Matrix &A) const
Apply the permutation to the rows of matrix A.
SquareMatrix LU
Result of a LU factorization: stores the upper-triangular matrix U and the strict lower-triangular pa...
void back_subs(const Matrix &B, Matrix &X) const
Back substitution algorithm for solving upper-triangular systems UX = B.
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 forward_subs(const Matrix &B, Matrix &X) const
Forward substitution algorithm for solving lower-triangular systems LX = B.
void compute_factorization()
The actual LU factorization algorithm.
PermutationMatrix P
The permutation of A that maximizes pivot size.
enum RowPivotLU::State state