Skip to content

num::vec

Defined in header <container/vector.hpp>

template <typename T>
class vec;

Dense vector \(x \in \mathbb{K}^n\).

Members

member description
using value_type = T
vec() Construct an empty vector.
explicit vec(idx n) Construct a vector of n zeros.
vec(idx n, T val) Construct a vector of n entries equal to val.
vec(std::initializer_list<T> init) Construct a vector from an initializer list.
explicit vec(view<const T> values) Construct a vector by copying a view.
explicit vec(const std::vector<T> &values)
vec(const vec &o)
vec(vec &&o) noexcept
vec &operator=(const vec &o)
vec &operator=(vec &&o) noexcept
constexpr idx size() const noexcept Return the length \(n\).
vec &as_vec() Return the vector itself, for code written for fields.
const vec &as_vec() const
T *data() noexcept Return the storage; it is aligned to storage_alignment.
const T *data() const noexcept
view<T> span() noexcept Return a view of the whole vector.
view<const T> span() const noexcept
T &operator[](idx i)
T operator[](idx i) const
T &front() Return the first or last entry; the vector must not be empty.
const T &front() const
T &back()
const T &back() const
T *begin()
T *end()
const T *begin() const
const T *end() const
void to_gpu() Copy the vector to the device, allocating a copy there on first use.
void to_cpu() Copy the vector back from the device and free the device copy.
real *gpu_data() Return the device copy, or null when there is none.
const real *gpu_data() const
bool on_gpu() const