vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
vitrio::array_descriptor Class Reference

How a block of memory is read as a multidimensional array. More...

#include <vitrio/array/array_descriptor.hpp>

Public Member Functions

 array_descriptor () noexcept
 Construct a descriptor that describes nothing.
 
 array_descriptor (std::vector< std::size_t > extents, std::vector< std::ptrdiff_t > strides, std::ptrdiff_t offset, numerical_type data_type)
 Construct a descriptor from its components.
 
 array_descriptor (const array_descriptor &other)
 
 array_descriptor (array_descriptor &&other) noexcept
 
array_descriptor & operator= (const array_descriptor &other)
 
array_descriptor & operator= (array_descriptor &&other) noexcept
 
span< const std::size_t > get_extents () const noexcept
 Get the number of elements along each axis.
 
span< const std::ptrdiff_t > get_strides () const noexcept
 Get the distance between consecutive elements along each axis.
 
std::ptrdiff_t get_offset () const noexcept
 Get the position of the element at the origin.
 
numerical_type get_data_type () const noexcept
 Get the type of the elements.
 

Friends

bool operator== (const array_descriptor &lhs, const array_descriptor &rhs) noexcept
 
bool operator!= (const array_descriptor &lhs, const array_descriptor &rhs) noexcept
 

Detailed Description

How a block of memory is read as a multidimensional array.

A descriptor states the extents of the array, where each of its elements is within the memory, and the type of the elements. It does not refer to any memory itself.

The element at index (i0,i1,...) is offset+i0*strides[0]+i1*strides[1]+... elements after the first byte of the memory. Strides and the offset are counted in elements, not in bytes. A stride may be negative, as long as the offset keeps every element at or after the first byte.

See also
make_contiguous_array_descriptor

Constructor & Destructor Documentation

◆ array_descriptor() [1/2]

vitrio::array_descriptor::array_descriptor ( )
noexcept

Construct a descriptor that describes nothing.

It has no extents and its data type is unknown.

See also
is_initialized

◆ array_descriptor() [2/2]

vitrio::array_descriptor::array_descriptor ( std::vector< std::size_t >  extents,
std::vector< std::ptrdiff_t >  strides,
std::ptrdiff_t  offset,
numerical_type  data_type 
)

Construct a descriptor from its components.

Parameters
extentsNumber of elements along each axis, slowest axis first.
stridesDistance between consecutive elements along each axis, in elements. There must be one per extent.
offsetPosition of the element at the origin, in elements from the first byte of the memory.
data_typeType of the elements.
Exceptions
std::invalid_argumentIf strides does not have one stride per extent, or if data_type is unknown.

Member Function Documentation

◆ get_data_type()

numerical_type vitrio::array_descriptor::get_data_type ( ) const
noexcept

Get the type of the elements.

Returns
numerical_type The data type. Unknown only for a descriptor that describes nothing.

◆ get_extents()

span< const std::size_t > vitrio::array_descriptor::get_extents ( ) const
noexcept

Get the number of elements along each axis.

Returns
span<const std::size_t> The extents, slowest axis first. It refers to storage owned by this descriptor.

◆ get_offset()

std::ptrdiff_t vitrio::array_descriptor::get_offset ( ) const
noexcept

Get the position of the element at the origin.

Returns
std::ptrdiff_t The offset, in elements from the first byte of the memory.

◆ get_strides()

span< const std::ptrdiff_t > vitrio::array_descriptor::get_strides ( ) const
noexcept

Get the distance between consecutive elements along each axis.

Returns
span<const std::ptrdiff_t> The strides, in elements and one per extent. It refers to storage owned by this descriptor.

The documentation for this class was generated from the following file: