5#include "backends/lapack/impl.hpp"
6#include "backends/seq/impl.hpp"
25 for (
idx k = 0; k < n; ++k)
27 std::swap(y[k], y[f.
piv[k]]);
29 for (
idx i = 1; i < n; ++i)
30 for (
idx j = 0; j < i; ++j)
31 y[i] -= M(i, j) * y[j];
33 for (
idx i = n; i-- > 0;) {
34 for (
idx j = i + 1; j < n; ++j)
35 y[i] -= M(i, j) * y[j];
46 for (
idx j = 0; j < nrhs; ++j) {
47 for (
idx i = 0; i < n; ++i)
50 for (
idx i = 0; i < n; ++i)
60 for (
idx i = 0; i < n; ++i)
63 for (
idx k = 0; k < n; ++k)
66 return (swaps % 2 == 0) ? det : -det;
75 for (
idx j = 0; j < n; ++j) {
78 for (
idx i = 0; i < n; ++i)
constexpr idx rows() const noexcept
constexpr idx cols() const noexcept
LU factorization with partial pivoting.
LUResult lu(const Matrix &A)
LUResult lu(const Matrix &A)
real lu_det(const LUResult &f)
Compute .
Matrix lu_inv(const LUResult &f)
Compute by solving .
void lu_solve(const LUResult &f, const Vector &b, Vector &x)
Solve from a precomputed factorization.
LUResult lu(const Matrix &A, Backend backend=lapack_backend)