bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
dmrpp::DmrppChunkOdometer Class Reference

#include <DmrppChunkOdometer.h>

Collaboration diagram for dmrpp::DmrppChunkOdometer:
Collaboration graph

Public Member Functions

 DmrppChunkOdometer (shape chunk_shape, shape array_shape)
 
const shape & indices () const noexcept
 
bool next ()
 
void reset () noexcept
 

Detailed Description

Map the indices of a N-dimensional array to the offset into memory (i.e., a vector) that matches those indices. This code can be used to step through each element of an N-dim array without using multiplication to compute the offset into the vector that holds the array's data.

Note
The code does use multiplication, but only performs N-1 multiplies for a N dimensional array in set_indices() (called once) and not in next() which will likely be called many times.

reset(): zero internal state

bool next(): move to the next element, incrementing the shape information and returning an offset into a linear vector for that element. Calling next() when the object is at the last element returns false. Calling next() after that is probably a bad idea.

vector<int> indices(): for the given state of the odometer, return the indices that match the offset.

Definition at line 56 of file DmrppChunkOdometer.h.

Constructor & Destructor Documentation

◆ DmrppChunkOdometer()

dmrpp::DmrppChunkOdometer::DmrppChunkOdometer ( shape chunk_shape,
shape array_shape )
inline

Build an instance of Odometer using the given 'shape'. Each element of the shape vector is the size of the corresponding dimension. E.G., a 10 by 20 by 30 array would be described by a vector of 10,20,30.

Initially, the Odometer object is set to index 0, 0, ..., 0 that matches the offset 0

Definition at line 78 of file DmrppChunkOdometer.h.

Member Function Documentation

◆ indices()

const shape & dmrpp::DmrppChunkOdometer::indices ( ) const
inlinenoexcept

Return the current set of indices. These match the current offset. Both the offset and indices are incremented by the next() method.

To access the ith index, use [i] or .at(i)

Definition at line 129 of file DmrppChunkOdometer.h.

◆ next()

bool dmrpp::DmrppChunkOdometer::next ( )
inline

Increment the Odometer to the next element and return the offset value. This increments the internal state and returns the offset to that element in a vector of values. Calling indices() after calling this method will return a vector<unsigned int> of the current index value.

Returns
The offset into memory for the next element. Returns a value that matches the one returned by end() when next has been called when the object index is at the last element.

Definition at line 104 of file DmrppChunkOdometer.h.

◆ reset()

void dmrpp::DmrppChunkOdometer::reset ( )
inlinenoexcept

Reset the internal state. The offset is reset to the 0th element and the indices are reset to 0, 0, ..., 0.

Definition at line 88 of file DmrppChunkOdometer.h.


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