8#ifdef NUMERICS_HAS_BLAS
36 for (
idx i = 0; i < k; ++i) {
37 h[i] =
dot(v, basis[i]);
38 axpy(-h[i], basis[i], v);
49 const idx stride = basis.
cols();
51 for (
idx l = 0; l < k; ++l) {
52#ifdef NUMERICS_HAS_BLAS
53 const real proj = cblas_ddot(
static_cast<int>(n),
55 static_cast<int>(stride),
57 cblas_daxpy(
static_cast<int>(n), -proj,
58 basis.
data() + l,
static_cast<int>(stride),
62 for (
idx i = 0; i < n; ++i) { proj += basis(i, l) * v[i]; }
63 for (
idx i = 0; i < n; ++i) { v[i] -= proj * basis(i, l); }
74 std::vector<Vector>& basis,
80 A.
apply(basis[k], scratch);
87 if (
beta > breakdown_tol) {
89 basis.push_back(scratch);
constexpr idx size() const noexcept
Dense row-major matrix with optional GPU storage.
constexpr idx rows() const noexcept
constexpr idx cols() const noexcept
real arnoldi_step(const LinearOp &A, std::vector< Vector > &basis, std::vector< real > &h, idx k, Vector &scratch, real breakdown_tol=real(1e-14))
One Arnoldi step: expand the orthonormal basis by one vector.
real mgs_orthogonalize(const std::vector< Vector > &basis, Vector &v, std::vector< real > &h, idx k)
Modified Gram-Schmidt: orthogonalize v against basis[0..k-1].
real beta(real a, real b)
B(a, b) – beta function.
void matvec(const Matrix &A, const Vector &x, Vector &y, Backend b=default_backend)
y = A * x
void scale(Vector &v, real alpha, Backend b=default_backend)
v *= alpha
void sparse_matvec(const SparseMatrix &A, const Vector &x, Vector &y)
y = A * x
real dot(const Vector &x, const Vector &y, Backend b=default_backend)
dot product
BasicVector< real > Vector
Real-valued dense vector with full backend dispatch (CPU + GPU)
real norm(const Vector &x, Backend b=default_backend)
Euclidean norm.
void axpy(real alpha, const Vector &x, Vector &y, Backend b=default_backend)
y += alpha * x
Compressed Sparse Row (CSR) matrix and operations.
void apply(const Vector &x, Vector &y) const override
y = A*x (y must be pre-allocated to the correct size)
Abstract matrix-free linear operator: y = A*x.
virtual void apply(const Vector &x, Vector &y) const =0
y = A*x (y must be pre-allocated to the correct size)
void apply(const Vector &x, Vector &y) const override
y = A*x (y must be pre-allocated to the correct size)
Subspace construction and orthogonalization kernels. (namespace num::kernel::subspace)