template<typename Value, int Rank>
atlas::array::LocalView class

Multi-dimensional access existing POD array pointer.

A LocalView is a wrapper around data that enables multidimensional access, and has the exact same API as ArrayView.

The data may be strided.

Example 1:

int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9};
int[2] strides = { 3, 1 };
int[2] shape = { 3, 3 };
LocalView<int,2> matrix( array, shape, strides );
for( idx_t i=0; i<matrix.shape(0); ++i ) {
    for( idx_t j=0; j<matrix.shape(1); ++j ) {
        matrix(i,j) *= 10;
    }
}

Strides can also be omitted as for most common cases it can be inferred from the shape.

Example 2:

    int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int[2] shape = { 3, 3 };
    LocalView<int,2> matrix( array, shape );
which is identical for this matrix to previous Example 1

Public types

using value_type = Value
using return_type = value_type

Public static variables

static int RANK constexpr

Public static functions

static auto rank() -> idx_t constexpr

Constructors, destructors, conversion operators

template<typename ValueTp, typename = std::enable_if_t<std::is_convertible_v<ValueTp*, Value*>>>
LocalView(const LocalView<ValueTp, Rank>& other)
template<typename ValueTp, typename Int1, typename Int2, typename = std::enable_if_t<std::is_convertible_v<ValueTp*, Value*>&& std::is_integral_v<Int1>&& std::is_integral_v<Int2>>>
LocalView(ValueTp* data, const Int1 shape[], const Int2 strides[])
template<typename ValueTp, typename Int, typename = std::enable_if_t<std::is_convertible_v<ValueTp*, Value*>&& std::is_integral_v<Int>>>
LocalView(ValueTp* data, const Int shape[])
template<typename ValueTp, typename ArrayShape, typename = std::enable_if_t<std::is_convertible_v<ValueTp*, Value*>>>
LocalView(ValueTp* data, const ArrayShape& shape)
ENABLE_IF_CONST_WITH_NON_CONST(value_type) operator const LocalView< value_type
return(const LocalView<value_type, Rank>&)

Public functions

template<typename... Idx, int Rank_ = Rank, typename = std::enable_if_t<sizeof...(Idx) == Rank_>>
auto operator()(Idx... idx) -> value_type&
template<typename... Idx, int Rank_ = Rank, typename = std::enable_if_t<sizeof...(Idx) == Rank_>>
auto operator()(Idx... idx) const -> const value_type&
template<typename Idx, int Rank_ = Rank, typename = std::enable_if_t<Rank_ == 1>>
auto operator[](Idx idx) const -> const value_type&
template<typename Idx, int Rank_ = Rank, typename = std::enable_if_t<Rank_ == 1>>
auto operator[](Idx idx) -> value_type&
auto size() const -> idx_t
template<typename Int>
auto shape(Int idx) const -> idx_t
template<typename Int>
auto stride(Int idx) const -> idx_t
auto shape() const -> const idx_t*
auto strides() const -> const idx_t*
auto data() const -> value_type const*
auto data() -> value_type*
auto contiguous() const -> bool
auto assign(const value_type& value) -> ENABLE_IF_NON_CONST void
void dump(std::ostream& os) const
template<typename... Args>
auto slice(Args... args) -> slice_t<Args...>::type
template<typename... Args>
auto slice(Args... args) const -> const_slice_t<Args...>::type

Public variables

Rank& const

Friends

auto operator<<(std::ostream& out, const LocalView& x) -> std::ostream&
This website is beyond its original expiry date and the content may be out of date. The site owner has been notified and may choose to extend the expiry date and remove this banner. If you have any questions about this, please visit our support portal.