Template Class Shape#

Class Documentation#

template<typename T = size_t, size_t N = 32>
class Shape#

Public Types

using SizeType = 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, typename typetraits::EnableIf<typetraits::CanCast<V, T>::value> = 0>
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, typename typetraits::EnableIf<typetraits::CanCast<V, T>::value> = 0>
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(Shape &&other) noexcept = default#

Create a Shape from an RValue

Parameters

other – Temporary Shape object to copy

template<typename V, size_t Dim>
Shape(const Shape<V, Dim> &other)#

Create a Shape object from one with a different type and number of dimensions.

Template Parameters
  • V – Scalar type of the values

  • Dim – Number of dimensions

Parameters

otherShape object to copy

template<typename V, size_t Dim>
Shape(Shape<V, Dim> &&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, typename typetraits::EnableIf<typetraits::CanCast<V, T>::value> = 0>
Shape &operator=(const std::initializer_list<V> &vals)#

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, typename typetraits::EnableIf<typetraits::CanCast<V, T>::value> = 0>
Shape &operator=(const std::vector<V> &vals)#

Assign a Shape object to this object

Template Parameters

V – Scalar type of the Shape

Parameters

vals – Dimensions of the Shape

Returns

*this

Shape &operator=(Shape &&other) noexcept = default#

Assign an RValue Shape to this object

Parameters

other – RValue to move

Returns

Shape &operator=(const Shape &other) = default#

Assign a Shape to this object

Parameters

otherShape to copy

Returns

template<typename Index>
const T &operator[](Index index) const#

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>
T &operator[](Index index)#

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

bool operator==(const Shape &other) const#

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

bool operator!=(const Shape &other) const#

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

T ndim() const#

Return the number of dimensions in the Shape object

Returns

Number of dimensions

Shape subshape(size_t start, size_t end) const#

Return a subshape of the Shape object

Parameters
  • start – Starting index

  • end – Ending index

Returns

Subshape

T size() const#

Return the number of elements the Shape object represents

Returns

Number of elements

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

Convert a Shape object into a string representation

Returns

A string representation of the Shape object

template<typename V, typename typetraits::EnableIf<typetraits::CanCast<V, T>::value>>
Shape<T, N> &operator=(const std::initializer_list<V> &vals)#
template<typename V, typename typetraits::EnableIf<typetraits::CanCast<V, T>::value>>
Shape<T, N> &operator=(const std::vector<V> &vals)#

Public Static Functions

static Shape zeros(size_t dims)#

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

Parameters

dims – Number of dimensions

Returns

New Shape object

static Shape ones(size_t dims)#

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 = N#

Protected Attributes

T m_dims#
std::array<T, N> m_data#