| IOLink 1.11.0

Loading...
Searching...
No Matches
Indexer.h
1#pragma once
2
3#include <iolink/DataType.h>
4#include <iolink/MemoryLayout.h>
5#include <iolink/VectorX.h>
6
7 namespace iolink
8{
9
35 class IOLINK_API Indexer final
36{
37 public:
38 Indexer();
39
55 Indexer(const VectorXu64& shape, const VectorXu64& stride, const VectorXu64& layout);
56
73 Indexer(const VectorXu64& shape, const VectorXu64& stride, MemoryLayout standardLayout);
74
85 Indexer(const VectorXu64& shape, const VectorXu64& layout);
86
98 Indexer(const VectorXu64& shape, MemoryLayout standardLayout);
99
111 explicit Indexer(const VectorXu64& shape);
112
122 Indexer(const VectorXu64& shape, DataType dtype);
123
133 Indexer(const VectorXu64& shape, DataType dtype, MemoryLayout standardLayout);
134
144 Indexer(const VectorXu64& shape, DataType dtype, const VectorXu64& byteStride);
145
154 Indexer(const VectorXu64& shape, DataType dtype, const VectorXu64& byteStride, const VectorXu64& layout);
155
156 Indexer(const Indexer& other);
157 Indexer& operator=(const Indexer& other);
158
159 Indexer(Indexer&& other) noexcept;
160 Indexer& operator=(Indexer&& other) noexcept;
161
162 ~Indexer();
163
164 bool operator==(const Indexer& other) const;
165 bool operator!=(const Indexer& other) const;
166
170 size_t dimensionCount() const;
171
175 const VectorXu64& shape() const;
176
180 DataType dtype() const;
181
188 const VectorXu64& stride() const;
189
193 const VectorXu64& byteStride() const;
194
198 const VectorXu64& layout() const;
199
205 size_t shape(size_t index) const;
206
215 size_t stride(size_t index) const;
216
220 size_t byteStride(size_t index) const;
221
227 size_t layout(size_t index) const;
228
232 size_t elementCount() const;
233
240 size_t byteCount() const;
241
250 size_t offset(const VectorXu64& index) const;
251
261 size_t byteOffset(const VectorXu64& index) const;
262
270 bool isContinuous() const;
271
272 private:
273 class Private;
274 Private* m_private;
275};
276
277} // end namespace iolink
iolink::DataType
Stores information about a data type.
Definition DataType.h:162
iolink::Indexer
This class is used to index a classic array into a multi dimensional array.
Definition Indexer.h:36
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, DataType dtype)
Constructor with shape and datatype, using default layout and stride.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, MemoryLayout standardLayout)
Auto compute the Indexer's strides from shape and standard layout.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, DataType dtype, const VectorXu64 &byteStride)
Constructor with shape, datatype and byte stride, using default layout.
iolink::Indexer::byteStride
const VectorXu64 & byteStride() const
iolink::Indexer::stride
size_t stride(size_t index) const
Return the current stride for given dimension.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, DataType dtype, const VectorXu64 &byteStride, const VectorXu64 &layout)
Constructor with shape, datatype, byte stride and layout.
iolink::Indexer::layout
const VectorXu64 & layout() const
Return the layout dimension order.
iolink::Indexer::offset
size_t offset(const VectorXu64 &index) const
Return the computed 1D offset corresponding to indexed sample in multi dimensional array.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, const VectorXu64 &stride, MemoryLayout standardLayout)
Create an indexer by giving all its informations.
iolink::Indexer::dtype
DataType dtype() const
iolink::Indexer::elementCount
size_t elementCount() const
Returns the number of elements managed by this Indexer.
iolink::Indexer::byteOffset
size_t byteOffset(const VectorXu64 &index) const
Computes the offset in bytes to the given index.
iolink::Indexer::shape
const VectorXu64 & shape() const
Return the shape.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, DataType dtype, MemoryLayout standardLayout)
Constructor with shape, datatype and standard layout, using default stride.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, const VectorXu64 &layout)
Initialize the indexer using a custom memory layout.
iolink::Indexer::byteStride
size_t byteStride(size_t index) const
iolink::Indexer::stride
const VectorXu64 & stride() const
Return the stride.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape, const VectorXu64 &stride, const VectorXu64 &layout)
Create an indexer by giving all its informations.
iolink::Indexer::byteCount
size_t byteCount() const
Get the total number of bytes needed to adress this indexer, taking the padding into account.
iolink::Indexer::layout
size_t layout(size_t index) const
Return the dimension index of the nth one in order.
iolink::Indexer::shape
size_t shape(size_t index) const
Return the current size for given dimension.
iolink::Indexer::dimensionCount
size_t dimensionCount() const
The number of dimensions managed by this indexer.
iolink::Indexer::Indexer
Indexer(const VectorXu64 &shape)
Simpliest way to initialize an indexer from a shape.
iolink::Indexer::isContinuous
bool isContinuous() const
Checks if the indexed elements are contiguous.
iolink::VectorX
A dynamically sized arithmetic vector.
Definition VectorX.h:18
iolink
All IOLink symbols are enclosed in this namespace.
Definition ArrayX.h:8
iolink::MemoryLayout
MemoryLayout
This enum indicates how a multidimensionnal array is stored in continuous memory.
Definition MemoryLayout.h:11