Template Class GeneralArrayView#
Defined in File generalArrayView.hpp
Class Documentation#
-
template<typename ArrayViewType, typename ArrayViewShapeType = typename std::decay_t<ArrayViewType>::ShapeType>
class GeneralArrayView# An intermediate type to represent a slice or view of an array.
- Template Parameters
T – The type of the array.
Public Types
-
using BaseType = typename std::decay_t<ArrayViewType>#
-
using Scalar = typename typetraits::TypeInfo<BaseType>::Scalar#
-
using Backend = typename typetraits::TypeInfo<BaseType>::Backend#
-
using ShapeType = ArrayViewShapeType#
-
using StorageType = typename typetraits::TypeInfo<BaseType>::StorageType#
-
using ArrayType = array::ArrayContainer<ShapeType, StorageType>#
-
using Iterator = detail::ArrayIterator<GeneralArrayView>#
Public Functions
-
GeneralArrayView() = delete#
Default constructor should never be used.
-
GeneralArrayView(ArrayViewType &&array)#
Copy an ArrayView object
- Parameters
array – The array to copy Copy an ArrayView object (not const)
array – The array to copy
-
GeneralArrayView(const GeneralArrayView &other) = default#
Copy an ArrayView object (const)
- Parameters
other – The array to copy
-
GeneralArrayView(GeneralArrayView &&other) = default#
Constructs an ArrayView from a temporary instance
- Parameters
other – The ArrayView to move
-
GeneralArrayView &operator=(const GeneralArrayView &other) = default#
Assigns another ArrayView object to this ArrayView.
- Parameters
other – The ArrayView to assign.
- Returns
A reference to this
-
GeneralArrayView &operator=(GeneralArrayView &&other) noexcept = default#
Assigns a temporary ArrayView to this ArrayView.
- Parameters
other – The ArrayView to move.
- Returns
A reference to this ArrayView.
-
GeneralArrayView &operator=(const Scalar &scalar)#
Assign a scalar value to this ArrayView. This function should only be used to assign to a zero-dimensional “scalar” ArrayView, and will throw an error if used incorrectly.
- Parameters
scalar – The scalar value to assign
- Returns
A reference to this
-
template<typename ShapeType_, typename StorageType_>
GeneralArrayView &operator=(const ArrayContainer<ShapeType_, StorageType_> &other)#
-
const auto operator[](int64_t index) const#
Access a sub-array of this ArrayView.
- Parameters
index – The index of the sub-array.
- Returns
An ArrayView from this
-
auto operator[](int64_t index)#
-
template<typename CAST = Scalar>
CAST get() const# Since even scalars are represented as an ArrayView object, it can be difficult to operate on them directly. This allows you to extract the scalar value stored by a zero-dimensional ArrayView object
- Template Parameters
CAST – Type to cast to
- Returns
The scalar represented by the ArrayView object
-
template<typename CAST>
explicit operator CAST() const# Same functionality as “get”, except slightly less robust for user-defined types.
- Template Parameters
CAST – Type to cast to
- Returns
The scalar represented by the ArrayView object
-
StrideType stride() const#
Access the stride of this ArrayView
- Returns
Stride object
-
int64_t offset() const#
Access the offset of this ArrayView. This is the offset, in elements, from the referenced Array’s first element.
- Returns
Offset
-
void setShape(const ShapeType &shape)#
Set the Shape of this ArrayView to something else. Intended for internal use only.
- Parameters
shape – The new shape of this ArrayView
-
void setStride(const StrideType &stride)#
Set the Stride of this ArrayView to something else. Intended for internal use only.
- Parameters
stride – The new stride of this ArrayView
-
void setOffset(const int64_t &offset)#
Set the offset of this ArrayView object. Intended for internal use only.
- Parameters
offset – The new offset of this ArrayView
-
int64_t ndim() const#
Returns the number of dimensions of this ArrayView
- Returns
Number of dimensions
-
auto scalar(int64_t index) const#
Return the Scalar at a given index in this ArrayView. This is intended for use internally, but can be used externally too.
- Parameters
index – The index of the Scalar to return
- Returns
Scalar at the given index
-
ArrayType eval() const#
Evaluate the contents of this ArrayView object and return an Array instance from it. Depending on your use case, this may result in more performant code, but the new Array will not reference the original data in the ArrayView.
- Returns
A new Array instance
-
template<typename T, typename Char, typename Ctx>
void str(const fmt::formatter<T, Char> &format, char bracket, char separator, Ctx &ctx) const#
-
template<typename ShapeType_, typename StorageType_>
GeneralArrayView<ArrayViewType, ArrayViewShapeType> &operator=(const ArrayContainer<ShapeType_, StorageType_> &other)#