Template Class Storage#

Class Documentation#

template<typename Scalar_>
class Storage#

Public Types

using Scalar = Scalar_#
using Packet = typename typetraits::TypeInfo<Scalar>::Packet#
using Pointer = Scalar*#
using ConstPointer = const Scalar*#
using Reference = Scalar&#
using ConstReference = const Scalar&#
using SizeType = size_t#
using DifferenceType = ptrdiff_t#
using Iterator = Pointer#
using ConstIterator = ConstPointer#
using ReverseIterator = std::reverse_iterator<Iterator>#
using ConstReverseIterator = std::reverse_iterator<ConstIterator>#

Public Functions

Storage() = default#

Default constructor.

explicit Storage(SizeType size)#

Create a Storage object with size elements

Parameters

size – Number of elements to allocate

explicit Storage(Scalar *begin, Scalar *end, bool ownsData)#
Storage(SizeType size, ConstReference value)#

Create a Storage object with size elements, each initialized to value.

Parameters
  • size – Number of elements to allocate

  • value – Value to initialize each element to

Storage(const Storage &other)#

Create a Storage object from another Storage object. Additionally a custom allocator can be used. The data is NOT copied &#8212; it is referenced by the new Storage object. For a deep copy, use the copy() method.

Parameters

otherStorage object to copy

Storage(Storage &&other) noexcept#

Move a Storage object into this object.

Parameters

otherStorage object to move

template<typename V>
Storage(const std::initializer_list<V> &list)#

Create a Storage object from an std::initializer_list

Template Parameters

V – Type of the elements in the initializer list

Parameters
  • list – Initializer list to copy

  • alloc – Allocator to use

template<typename V>
explicit Storage(const std::vector<V> &vec)#

Create a Storage object from a std::vector

Template Parameters

V – Type of the elements in the vector

Parameters

vecVector to copy

Storage &operator=(const Storage &other)#

Assignment operator for a Storage object

Parameters

otherStorage object to copy

Returns

*this

Storage &operator=(Storage &&other) noexcept#

Move assignment operator for a Storage object

Parameters

otherStorage object to move

Returns

*this

~Storage()#

Free a Storage object.

Storage toHostStorage() const#

Return a Storage object on the host with the same data as this Storage object (mainly for use with CUDA or OpenCL)

Returns

Storage toHostStorageUnsafe() const#

Same as toHostStorage() but does not necessarily copy the data.

Returns

Storage object on the host

Storage copy() const#

Create a deep copy of this Storage object.

Returns

Deep copy of this Storage object

void resize(SizeType newSize)#

Resize a Storage object to size elements. Existing elements are preserved.

Parameters

size – New size of the Storage object

void resize(SizeType newSize, int)#

Resize a Storage object to size elements. Existing elements are not preserved

Parameters

size – New size of the Storage object

SizeType size() const noexcept#

Return the number of elements in the Storage object

Returns

ConstReference operator[](SizeType index) const#

Const access to the element at index index

Parameters

index – Index of the element to access

Returns

Const reference to the element at index index

Reference operator[](SizeType index)#

Access to the element at index index

Parameters

index – Index of the element to access

Returns

Reference to the element at index index

Pointer data() const noexcept#
Pointer begin() noexcept#
Pointer end() noexcept#
ConstPointer begin() const noexcept#
ConstPointer end() const noexcept#
ConstIterator cbegin() const noexcept#
ConstIterator cend() const noexcept#
ReverseIterator rbegin() noexcept#
ReverseIterator rend() noexcept#
ConstReverseIterator rbegin() const noexcept#
ConstReverseIterator rend() const noexcept#
ConstReverseIterator crbegin() const noexcept#
ConstReverseIterator crend() const noexcept#
template<typename V>
auto fromData(const std::initializer_list<V> &list) -> Storage#
template<typename V>
auto fromData(const std::vector<V> &vec) -> Storage#
template<typename ShapeType>
auto defaultShape() -> ShapeType#

Public Static Functions

template<typename V>
static Storage fromData(const std::initializer_list<V> &vec)
template<typename V>
static Storage fromData(const std::vector<V> &vec)
template<typename ShapeType>
static ShapeType defaultShape()

Public Static Attributes

static constexpr uint64_t packetWidth = typetraits::TypeInfo<Scalar>::packetWidth#