Class Shape#

Class Documentation#

class Shape#

Public Types

using SizeType = uint32_t#

Public Functions

Shape() = default#

Default constructor.

template<typename Scalar, size_t... Dimensions>
explicit Shape(const FixedStorage<Scalar, Dimensions...> &fixed)#

Create a shape object from the dimensions of a FixedStorage object. This is used.

Template Parameters
Parameters

fixed – The FixedStorage object

template<typename V>
Shape(const std::initializer_list<V> &vals)#

Create a Shape object from a list of values

Template Parameters

V – Scalar type of the values

Parameters

vals – The dimensions for the object

template<typename V>
explicit Shape(const std::vector<V> &vals)#

Create a Shape object from a vector of values

Template Parameters

V – Scalar type of the values

Parameters

vals – The dimensions for the object

Shape(const Shape &other) = default#

Create a copy of a Shape object

Parameters

otherShape object to copy

Shape(const MatrixShape &other)#
Shape(const VectorShape &other)#
Shape(Shape &&other) noexcept = default#

Create a Shape from an RValue

Parameters

other – Temporary Shape object to copy

template<size_t Dim>
Shape(Shape &&other) noexcept#

Create a Shape object from one with a different type and number of dimensions, moving it instead of copying it.

Template Parameters
  • V – Scalar type of the values

  • Dim – Number of dimensions

Parameters

other – Temporary Shape object to move

template<typename V>
auto operator=(const std::initializer_list<V> &vals) -> Shape&#

Assign a Shape object to this object

Template Parameters

V – Scalar type of the Shape

Parameters

vals – Dimensions of the Shape

Returns

*this

template<typename V>
auto operator=(const std::vector<V> &vals) -> Shape&#

Assign a Shape object to this object

Template Parameters

V – Scalar type of the Shape

Parameters

vals – Dimensions of the Shape

Returns

*this

auto operator=(Shape &&other) noexcept -> Shape& = default#

Assign an RValue Shape to this object

Parameters

other – RValue to move

Returns

auto operator=(const Shape &other) -> Shape& = default#

Assign a Shape to this object

Parameters

otherShape to copy

Returns

template<typename Index>
auto operator[](Index index) const -> const SizeType&#

Access an element of the Shape object

Template Parameters

Index – Typename of the index

Parameters

index – Index to access

Returns

The value at the index

template<typename Index>
auto operator[](Index index) -> SizeType&#

Access an element of the Shape object

Template Parameters

Index – Typename of the index

Parameters

index – Index to access

Returns

A reference to the value at the index

auto operator==(const Shape &other) const -> bool#

Compare two Shape objects, returning true if and only if they are identical

Parameters

otherShape object to compare

Returns

true if the objects are identical

auto operator!=(const Shape &other) const -> bool#

Compare two Shape objects, returning true if and only if they are not identical

Parameters

otherShape object to compare

Returns

true if the objects are not identical

auto ndim() const -> int#

Return the number of dimensions in the Shape object

Returns

Number of dimensions

auto subshape(int start, int end) const -> Shape#

Return a subshape of the Shape object

Parameters
  • start – Starting index

  • end – Ending index

Returns

Subshape

auto size() const -> size_t#

Return the number of elements the Shape object represents

Returns

Number of elements

template<typename T_, typename Char, typename Ctx>
void str(const fmt::formatter<T_, Char> &format, Ctx &ctx) const#

Public Static Functions

static auto zeros(int dims) -> Shape#

Return a Shape object with dims dimensions, all initialized to zero.

Parameters

dims – Number of dimensions

Returns

New Shape object

static auto ones(int dims) -> Shape#

Return a Shape object with dims dimensions, all initialized to one.

Parameters

dims – Number of dimensions

Returns

New Shape object

Public Static Attributes

static constexpr size_t MaxDimensions = LIBRAPID_MAX_ARRAY_DIMS#

Protected Attributes

int m_dims#
std::array<SizeType, MaxDimensions> m_data#