17template <
class,
class I,
class Str
ide>
19 using type = std::integral_constant<I, 0>;
21template <
class T,
class I,
class Str
ide>
23 { Stride::value } -> std::convertible_to<I>;
26 using type = std::integral_constant<I,
alignof(T) * Stride::value>;
28template <
class T,
class I,
class Str
ide>
50template <
class T,
class I = index_t,
class S = std::
integral_constant<I, 1>,
class D = I,
51 StorageOrder O = StorageOrder::ColMajor,
class A = detail::default_alignment_t<T, I, S>>
53 static_assert(!std::is_const_v<T>);
69 if constexpr (std::is_integral_v<alignment_type>)
70 return alignof(T) *
static_cast<size_t>(
layout.batch_size);
71 if constexpr (alignment_type::value == 0)
72 return alignof(T) *
static_cast<size_t>(
layout.batch_size);
86 if (
auto d = std::exchange(
view_.data_ptr,
nullptr))
88 view_.layout.rows = 0;
102 view_.layout = new_layout;
131 swap(o.view_.data_ptr, this->view_.data_ptr);
132 swap(o.view_.layout, this->view_.layout);
147 return view()(l, r, c);
154 return view()(l, r, c);
232template <
class T,
class I,
class S,
class D,
class A, StorageOrder O>
236template <
class T,
class I,
class S,
class D,
class A, StorageOrder O>
238template <
class T,
class I,
class S,
class D,
class A, StorageOrder O>
242template <
class T,
class I,
class S,
class D,
class A, StorageOrder O>
246template <
class T,
class I,
class S,
class D,
class A, StorageOrder O>
250template <
class T,
class I,
class S,
class D,
class A, StorageOrder O>
254template <
class T,
class I,
class S,
class D,
class A, StorageOrder O>
auto make_aligned_unique_ptr(size_t size, A align)
Returns a smart pointer to an array of T that satisfies the given alignment requirements.
std::integral_constant< I, 0 > type
typename default_alignment< T, I, Stride >::type default_alignment_t
std::integral_constant< I, alignof(T) *Stride::value > type
constexpr auto cols(const Matrix< T, I, S, D, O, A > &v)
constexpr auto data(Matrix< T, I, S, D, O, A > &v)
constexpr auto outer_stride(const Matrix< T, I, S, D, O, A > &v)
constexpr auto rows(const Matrix< T, I, S, D, O, A > &v)
constexpr auto depth(const Matrix< T, I, S, D, O, A > &v)
Aligned allocation for matrix storage.
Class for a batch of matrices that owns its storage.
auto top_right(index_type nr, index_type nc) const
auto bottom_rows(index_type n) const
auto bottom_left(index_type nr, index_type nc) const
auto batch_dyn(index_type b)
View< S, index_t, simd_stride_t, index_t, DefaultStride, O > view_type
Matrix(plain_layout_type p)
Matrix(plain_layout_type p, uninitialized_t init)
typename layout_type::PlainLayout plain_layout_type
Matrix & operator=(Matrix &&o) noexcept
typename layout_type::batch_size_type batch_size_type
auto reshaped(index_type rows, index_type cols) const
typename layout_type::standard_stride_type standard_stride_type
static auto allocate(layout_type layout)
index_type padded_size() const
void resize(layout_type new_layout)
batch_size_type batch_size() const
Matrix & operator=(const Matrix &o)
auto block(index_type r, index_type c, index_type nr, index_type nc)
auto top_rows(index_type n) const
Matrix(layout_type layout)
auto reshaped(index_type rows, index_type cols)
void set_constant(value_type t)
auto top_left(index_type nr, index_type nc) const
auto bottom_rows(index_type n)
auto left_cols(index_type n)
auto left_cols(index_type n) const
auto middle_cols(index_type c, index_type n)
auto top_rows(index_type n)
auto middle_cols(index_type c, index_type n) const
auto right_cols(index_type n)
auto bottom_right(index_type nr, index_type nc) const
auto top_right(index_type nr, index_type nc)
auto bottom_left(index_type nr, index_type nc)
auto right_cols(index_type n) const
Matrix(layout_type layout, uninitialized_t init)
typename view_type::layout_type layout_type
guanaqo::MatrixView< const T, I, standard_stride_type, O > operator()(index_type l) const
static constexpr auto default_alignment(layout_type layout)
auto top_left(index_type nr, index_type nc)
auto batch_dyn(index_type b) const
simd_align_t alignment_type
value_type & operator()(index_type l, index_type r, index_type c)
index_type outer_stride() const
Matrix(Matrix &&o) noexcept
const_view_type view() const
typename view_type::const_view_type const_view_type
auto batch(index_type b) const
layout_type layout() const
auto block(index_type r, index_type c, index_type nr, index_type nc) const
static auto allocate(layout_type layout, uninitialized_t init)
typename layout_type::depth_type depth_type
const value_type & operator()(index_type l, index_type r, index_type c) const
index_type ceil_depth() const
auto middle_rows(index_type r, index_type n) const
typename layout_type::index_type index_type
auto bottom_right(index_type nr, index_type nc)
guanaqo::MatrixView< T, I, standard_stride_type, O > operator()(index_type l)
auto middle_rows(index_type r, index_type n)
const value_type * data() const
index_type num_batches() const
Non-owning view of a batch of matrices.
Layout< I, S, D, L, O > layout_type
general_slice_view_type bottom_right(index_type nr, index_type nc) const
Get a view of the bottom-right nr by nc block of the matrices.
general_slice_view_type block(index_type r, index_type c, index_type nr, index_type nc) const
Get a view of the nr by nc block of the matrices starting at row r and column c.
void set_constant(value_type t)
auto transposed() const
Get a transposed view of the matrices.
constexpr index_type num_batches() const
Number of batches in the view, i.e. ceil_depth() / batch_size().
col_slice_view_type middle_cols(index_type c, index_type n) const
Get a view of n columns starting at column c.
constexpr index_type padded_size() const
Total number of elements in the view (including all padding).
linear_iterator begin() const
Iterate linearly (in storage order) over all elements of the view.
row_slice_view_type bottom_rows(index_type n) const
Get a view of the last n rows.
general_slice_view_type reshaped(index_type rows, index_type cols) const
Reshape the view to the given dimensions. The total size should not change.
general_slice_view_type bottom_left(index_type nr, index_type nc) const
Get a view of the bottom-left nr by nc block of the matrices.
View< const T, I, S, D, L, O > const_view_type
row_slice_view_type middle_rows(index_type r, index_type n) const
Get a view of n rows starting at row r.
constexpr batch_size_type batch_size() const
The batch size, i.e. the number of layers in each batch. Equals the inner stride.
constexpr index_type cols() const
Number of columns of the matrices.
std::default_sentinel_t end() const
Sentinel for begin().
col_slice_view_type right_cols(index_type n) const
Get a view of the last n columns.
View< T, I, S, I, L, O > batch_dyn(index_type b) const
Same as batch(), but returns a view with a dynamic batch size.
col_slice_view_type left_cols(index_type n) const
Get a view of the first n columns.
row_slice_view_type top_rows(index_type n) const
Get a view of the first n rows.
constexpr index_type rows() const
Number of rows of the matrices.
constexpr index_type ceil_depth() const
The depth rounded up to a multiple of the batch size.
constexpr index_type size() const
Total number of elements in the view (excluding padding).
T * data() const
Get a pointer to the first element of the first layer.
general_slice_view_type top_left(index_type nr, index_type nc) const
Get a view of the top-left nr by nc block of the matrices.
general_slice_view_type top_right(index_type nr, index_type nc) const
Get a view of the top-right nr by nc block of the matrices.
constexpr depth_type depth() const
Number of layers in the view (i.e. depth).
void copy_values(const Other &other) const
constexpr index_type outer_stride() const
Outer stride of the matrices (leading dimension in BLAS parlance).
batch_view_type batch(index_type b) const
Access a batch of batch_size() layers, starting at batch index b (i.e.
Deleter for aligned memory allocated with operator new(size, align_val).
Non-owning view of a batch of matrices.