vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
array_descriptor.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/array/numerical_type.hpp>
6#include <vitrio/export.hpp>
7#include <vitrio/span.hpp>
8
9#include <cstddef>
10#include <vector>
11
12namespace vitrio
13{
14
31{
32public:
40 VITRIO_API
41 array_descriptor() noexcept;
42
55 VITRIO_API
57 std::vector<std::size_t> extents,
58 std::vector<std::ptrdiff_t> strides,
59 std::ptrdiff_t offset,
60 numerical_type data_type
61 );
62
63 VITRIO_API
65 VITRIO_API
66 array_descriptor(array_descriptor &&other) noexcept;
67 VITRIO_API
69
70 VITRIO_API
71 array_descriptor& operator=(const array_descriptor &other);
72 VITRIO_API
73 array_descriptor& operator=(array_descriptor &&other) noexcept;
74
81 VITRIO_API
82 span<const std::size_t> get_extents() const noexcept;
83
90 VITRIO_API
91 span<const std::ptrdiff_t> get_strides() const noexcept;
92
99 VITRIO_API
100 std::ptrdiff_t get_offset() const noexcept;
101
108 VITRIO_API
109 numerical_type get_data_type() const noexcept;
110
111 friend bool operator==(
112 const array_descriptor &lhs,
113 const array_descriptor &rhs
114 ) noexcept
115 {
116 return
117 lhs.m_offset == rhs.m_offset &&
118 lhs.m_data_type == rhs.m_data_type &&
119 lhs.m_extents == rhs.m_extents &&
120 lhs.m_strides == rhs.m_strides;
121 }
122
123 friend bool operator!=(
124 const array_descriptor &lhs,
125 const array_descriptor &rhs
126 ) noexcept
127 {
128 return !(lhs == rhs);
129 }
130
131private:
132 std::vector<std::size_t> m_extents;
133 std::vector<std::ptrdiff_t> m_strides;
134 std::ptrdiff_t m_offset;
135 numerical_type m_data_type;
136};
137
151VITRIO_API
152array_descriptor make_contiguous_array_descriptor(
153 span<const std::size_t> extents,
154 numerical_type data_type
155);
156
164VITRIO_API
165bool is_initialized(const array_descriptor &descriptor) noexcept;
166
167} // namespace vitrio
How a block of memory is read as a multidimensional array.
Definition array_descriptor.hpp:31
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.
numerical_type get_data_type() const noexcept
Get the type of the elements.
array_descriptor() noexcept
Construct a descriptor that describes nothing.
std::ptrdiff_t get_offset() const noexcept
Get the position of the element at the origin.
A view of a contiguous sequence of elements.
Definition span.hpp:29