29 const real*
data()
const {
return data_.get(); }
37 bool on_gpu()
const {
return d_data_ !=
nullptr; }
41 std::unique_ptr<real[]> data_;
42 real* d_data_ =
nullptr;
Dense row-major matrix with optional GPU storage.
constexpr idx size() const noexcept
real operator()(idx i, idx j) const
real & operator()(idx i, idx j)
const real * data() const
constexpr idx rows() const noexcept
const real * gpu_data() const
constexpr idx cols() const noexcept
void matmul_simd(const Matrix &A, const Matrix &B, Matrix &C, idx block_size=64)
C = A * B (SIMD-accelerated)
Backend
Selects which backend handles a linalg operation.
void matvec_simd(const Matrix &A, const Vector &x, Vector &y)
y = A * x (SIMD-accelerated)
real beta(real a, real b)
B(a, b) – beta function.
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
void matmul_blocked(const Matrix &A, const Matrix &B, Matrix &C, idx block_size=64)
C = A * B (cache-blocked)
BasicVector< real > Vector
Real-valued dense vector with full backend dispatch (CPU + GPU)
void matmul(const Matrix &A, const Matrix &B, Matrix &C, Backend b=default_backend)
C = A * B.
constexpr Backend default_backend
void matadd(real alpha, const Matrix &A, real beta, const Matrix &B, Matrix &C, Backend b=default_backend)
C = alpha*A + beta*B.
void matmul_register_blocked(const Matrix &A, const Matrix &B, Matrix &C, idx block_size=64, idx reg_size=4)
C = A * B (register-blocked)
Backend enum for linear algebra operations.
Constexpr fixed-size stack-allocated matrix and Givens rotation.