14 const idx n =
A.rows();
16 throw std::invalid_argument(
"power_iteration: matrix must be square");
43 result.eigenvalue = lambda;
51 const idx n =
A.rows();
53 throw std::invalid_argument(
"inverse_iteration: matrix must be square");
88 result.eigenvalue = lambda;
95 const idx n =
A.rows();
97 throw std::invalid_argument(
"rayleigh_iteration: matrix must be square");
99 throw std::invalid_argument(
"rayleigh_iteration: x0 size mismatch");
119 if (
f.singular)
break;
130 for (
idx i = 0;
i < n; ++
i) {
Dense row-major matrix with optional GPU storage.
real normalise(Vector &v)
Normalise v in-place; returns the old norm.
LUResult lu(const Matrix &A)
LU factorization of a square matrix A with partial pivoting.
Backend
Selects which backend handles a linalg operation.
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
void matvec(const Matrix &A, const Vector &x, Vector &y, Backend b=default_backend)
y = A * x
PowerResult inverse_iteration(const Matrix &A, real sigma, real tol=1e-10, idx max_iter=1000, Backend backend=default_backend)
Inverse iteration – finds the eigenvalue closest to a shift sigma.
real dot(const Vector &x, const Vector &y, Backend b=default_backend)
dot product
PowerResult power_iteration(const Matrix &A, real tol=1e-10, idx max_iter=1000, Backend backend=default_backend)
Power iteration – finds the eigenvalue largest in absolute value.
void lu_solve(const LUResult &f, const Vector &b, Vector &x)
Solve A*x = b using a precomputed LU factorization.
PowerResult rayleigh_iteration(const Matrix &A, const Vector &x0, real tol=1e-10, idx max_iter=50, Backend backend=default_backend)
Rayleigh quotient iteration – cubically convergent.
Power iteration, inverse iteration, Rayleigh quotient iteration.
Result of an LU factorization with partial pivoting (PA = LU)
Result of a single-eigenvalue iteration.