Array Class Listing#

template<typename ShapeType_, typename StorageType_>
class ArrayContainer

Public Types

using StorageType = StorageType_
using ShapeType = ShapeType_
using StrideType = Stride<size_t, 32>
using SizeType = typename ShapeType::SizeType
using Scalar = typename StorageType::Scalar
using Packet = typename typetraits::TypeInfo<Scalar>::Packet
using Device = typename typetraits::TypeInfo<ArrayContainer>::Device

Public Functions

ArrayContainer()

Default constructor.

template<typename T>
ArrayContainer(const std::initializer_list<T> &data)
template<typename T>
explicit ArrayContainer(const std::vector<T> &data)
explicit ArrayContainer(const ShapeType &shape)

Constructs an array container from a shape

Parameters

shape – The shape of the array container

ArrayContainer(const ShapeType &shape, const Scalar &value)

Create an array container from a shape and a scalar value. The scalar value represents the value the memory is initialized with.

Parameters
  • shape – The shape of the array container

  • value – The value to initialize the memory with

explicit ArrayContainer(const Scalar &value)

Allows for a fixed-size array to be constructed with a fill value

Parameters

value – The value to fill the array with

explicit ArrayContainer(ShapeType &&shape)

Construct an array container from a shape, which is moved, not copied.

Parameters

shape – The shape of the array container

ArrayContainer(const ArrayContainer &other) = default

Construct an array container from another array container.

Parameters

other – The array container to copy.

ArrayContainer(ArrayContainer &&other) noexcept = default

Construct an array container from a temporary array container.

Parameters

other – The array container to move.

template<typename desc, typename Functor_, typename... Args>  ArrayContainer (const detail::Function< desc, Functor_, Args... > &function) LIBRAPID_RELEASE_NOEXCEPT

Construct an array container from a function object. This will assign the result of the function to the array container, evaluating it accordingly.

Template Parameters
  • desc – The assignment descriptor

  • Functor_ – The function type

  • Args – The argument types of the function

Parameters

function – The function to assign

ArrayContainer &operator=(const ArrayContainer &other) = default

Assign an array container to this array container.

Parameters

other – The array container to copy.

Returns

A reference to this array container.

ArrayContainer &operator=(const Scalar &value)
ArrayContainer &operator=(ArrayContainer &&other) noexcept = default

Assign a temporary array container to this array container.

Parameters

other – The array container to move.

Returns

A reference to this array container.

template<typename desc, typename Functor_, typename ...Args>
ArrayContainer &operator=(const detail::Function<desc, Functor_, Args...> &function)

Assign a function object to this array container. This will assign the result of the function to the array container, evaluating it accordingly.

Template Parameters
  • Functor_ – The function type

  • Args – The argument types of the function

Parameters

function – The function to assign

Returns

A reference to this array container.

template<typename TransposeType>
ArrayContainer &operator=(const Transpose<TransposeType> &transpose)
template<typename T>
detail::CommaInitializer<ArrayContainer> operator<<(const T &value)

Allow ArrayContainer objects to be initialized with a comma separated list of values. This makes use of the CommaInitializer class

Template Parameters

T – The type of the values

Parameters

value – The value to set in the Array object

Returns

The comma initializer object

template<typename ScalarTo = Scalar, typename DeviceTo = Device>
auto cast() const
auto copy() const
auto operator[](int64_t index) const

Access a sub-array of this ArrayContainer instance. The sub-array will reference the same memory as this ArrayContainer instance.

See also

ArrayView

Parameters

index – The index of the sub-array

Returns

A reference to the sub-array (ArrayView)

auto operator[](int64_t index)
Scalar get() const
ShapeType::SizeType ndim() const noexcept

Return the number of dimensions of the ArrayContainer object

Returns

Number of dimensions of the ArrayContainer

const ShapeType &shape() const noexcept

Return the shape of the array container. This is an immutable reference.

Returns

The shape of the array container.

const StorageType &storage() const noexcept

Return the StorageType object of the ArrayContainer

Returns

The StorageType object of the ArrayContainer

StorageType &storage() noexcept

Return the StorageType object of the ArrayContainer

Returns

The StorageType object of the ArrayContainer

Packet packet(size_t index) const

Return a Packet object from the array’s storage at a specific index.

Parameters

index – The index to get the packet from

Returns

A Packet object from the array’s storage at a specific index

Scalar scalar(size_t index) const

Return a Scalar from the array’s storage at a specific index.

Parameters

index – The index to get the scalar from

Returns

A Scalar from the array’s storage at a specific index

void writePacket(size_t index, const Packet &value)

Write a Packet object to the array’s storage at a specific index

Parameters
  • index – The index to write the packet to

  • value – The value to write to the array’s storage

void write(size_t index, const Scalar &value)

Write a Scalar to the array’s storage at a specific index

Parameters
  • index – The index to write the scalar to

  • value – The value to write to the array’s storage

std::string str(const std::string &format = "{}") const

Return a string representation of the array container \format The format to use for the string representation

Returns

A string representation of the array container

template<typename desc, typename Functor_, typename ...Args>
auto operator=(const detail::Function<desc, Functor_, Args...> &function) -> ArrayContainer&
template<typename TransposeType>
auto operator=(const Transpose<TransposeType> &transpose) -> ArrayContainer&
template<typename T>
auto operator<<(const T &value) -> detail::CommaInitializer<ArrayContainer>