Skip to content

num::mat

Defined in header <container/matrix.hpp>

template <std::floating_point T>
class mat;

Dense row-major owning matrix. mat<real> takes the CPU and GPU backends.

Members

member description
using value_type = T
mat() Construct an empty matrix.
mat(idx rows, idx cols) Construct a zero-initialized rows-by-cols matrix.
mat(idx rows, idx cols, T val) Construct a rows-by-cols matrix filled with val.
mat(const mat &o)
mat(mat &&o) noexcept
mat &operator=(const mat &o)
mat &operator=(mat &&o) noexcept
constexpr idx rows() const noexcept Return the matrix dimensions and total element count.
constexpr idx cols() const noexcept
constexpr idx size() const noexcept
T *data() noexcept Return contiguous row-major host storage, aligned to num::storage_alignment. The row stride is cols(), so only row 0 is guaranteed to start on that boundary; the alignment claim is about the base pointer.
const T *data() const noexcept
T &operator()(idx i, idx j)
T operator()(idx i, idx j) const
void to_gpu() Copy host data to a lazily allocated device mirror.
void to_cpu() Copy the device mirror back to host and release device storage.
T *gpu_data() Return device storage, or null when no mirror exists.
const T *gpu_data() const
bool on_gpu() const
template <class X = vec<real>, class Y = vec<real>> void apply(const X &x, Y &y) const Operator protocol application: y <- A * x