|
| | ndarray ()=default |
| | Default: empty array with zero extents.
|
| | ndarray (shape_type sh) |
| | Construct from shape, zero-initialized.
|
| | ndarray (std::initializer_list< size_type > extents) |
| | Construct from initializer list of extents.
|
| | ndarray (shape_type sh, const Value &val) |
| | Construct from shape + fill value.
|
| | ndarray (Value *ptr, shape_type sh, strides_type strides) |
| | Non-owning view: wraps external memory with given shape and strides.
|
| | ndarray (Value *ptr, shape_type sh) |
| | Non-owning view: wraps external memory with contiguous layout.
|
| | ndarray (const ndarray &other) |
| | ndarray (ndarray &&other) noexcept |
| | The source is left empty: no storage, a zero shape.
|
| ndarray & | operator= (const ndarray &other) |
| ndarray & | operator= (ndarray &&other) noexcept |
| constexpr const shape_type & | get_shape () const |
| constexpr const strides_type & | get_strides () const |
| constexpr size_type | extent (size_type dim) const |
| constexpr size_type | size () const |
| constexpr bool | empty () const |
| bool | is_view () const |
| | Check if this array owns its memory.
|
| bool | is_contiguous () const |
| | True when the elements occupy a dense block of size() values, in EITHER C or F order.
|
| bool | is_c_contiguous () const |
| | True when memory is contiguous in C (row-major) order.
|
| bool | is_f_contiguous () const |
| | True when memory is contiguous in F (column-major) order.
|
| bool | is_contiguous_in_own_order () const |
| | True when memory order matches THIS array's logical iteration order, i.e.
|
template<typename... Indices>
requires (sizeof...(Indices) == N) |
| reference | operator() (Indices... indices) |
| | Multi-index access: a(i, j, k, ...).
|
template<typename... Indices>
requires (sizeof...(Indices) == N) |
| const_reference | operator() (Indices... indices) const |
| reference | operator[] (const std::array< size_type, N > &idx) |
| | Array-index access: a[{i, j, k}].
|
| const_reference | operator[] (const std::array< size_type, N > &idx) const |
| reference | flat (size_type i) |
| | Flat (linear) index access - only valid for contiguous arrays.
|
| const_reference | flat (size_type i) const |
| pointer | data () |
| const_pointer | data () const |
| pointer | begin () |
| const_pointer | begin () const |
| pointer | end () |
| const_pointer | end () const |
| void | fill (const Value &val) |
| ndarray | view () |
| | Create a view (non-owning) of this array with the same shape and strides.
|
| template<std::size_t M> |
| ndarray< Value, M, Order > | reshape (::mtl::array::shape< M > new_shape) |
| | Reshape: a view over the same elements, read in this array's Order.
|
| template<std::size_t M> |
| ndarray< const Value, M, Order > | reshape (::mtl::array::shape< M > new_shape) const |
| | Reshape of a const array: a read-only view (#856: it used to return a mutable view through a const_cast).
|
| ndarray< Value, N, Order > | transpose () |
| | Transpose: a view with reversed shape and strides.
|
| ndarray< const Value, N, Order > | transpose () const |
| | Transpose of a const array: a read-only view (#856).
|
| ndarray & | operator+= (const Value &s) |
| ndarray & | operator-= (const Value &s) |
| ndarray & | operator*= (const Value &s) |
| ndarray & | operator/= (const Value &s) |
| template<typename F> |
| void | iterate_indices (F &&f) const |
| | Iterate over all valid multi-indices, calling f(idx) for each, in this array's Order (the last index fastest for c_order, the first for f_order).
|
| template<typename F> |
| void | for_each_element (F &&f) |
| | Apply f to every element, in this array's Order.
|
| template<typename F> |
| void | for_each_element (F &&f) const |
template<typename Value, std::size_t N, typename Order = c_order>
class mtl::array::ndarray< Value, N, Order >
N-dimensional array with static rank and runtime shape.
Its logical order – the order of iterate_indices, for_each_element, reduce and flatten – is its own Order: c_order arrays walk the last index fastest, f_order arrays the first, whatever the strides of a view say. reshape reads in the same order (#359), so flatten(a) and a.reshape({a.size()}) agree.
- Template Parameters
-
| Value | element type (must be default-constructible) |
| N | number of dimensions (compile-time rank) |
| Order | memory layout: c_order (default) or f_order |
template<typename Value, std::size_t N, typename Order = c_order>
True when the elements occupy a dense block of size() values, in EITHER C or F order.
This is the right question for anything order-INdependent – BLAS dispatch, fill, a commutative reduction – and the WRONG one for anything that walks memory as though it were logical order. A transpose of a C-order array is F-contiguous, so this returns true while memory order and logical order disagree (#359). Use is_c_contiguous() / is_f_contiguous() when the distinction matters.