36 typedef vector<Array::dimension>::const_iterator
DimItC;
46 Array& from =
const_cast<Array&
>(copyDimsFrom);
47 Array::Dim_iter endIt = from.dim_end();
49 for (it = from.dim_begin(); it != endIt; ++it)
51 const Array::dimension& dim = (*it);
84 if (rhs._dims.size() != _dims.size())
90 for (
unsigned int i=0; i<_dims.size(); ++i)
106 for (
unsigned int i=0; i<_dims.size(); ++i)
108 const Array::dimension& dim = _dims[i];
109 ret |= (dim.c_size != dim.size);
121 for (
unsigned int i=0; i<_dims.size(); ++i)
123 Array::dimension& dim = _dims[i];
124 dim.c_size = dim.size;
126 dim.stop = dim.size-1;
146 equal &= (lhs.size == rhs.size);
147 equal &= (lhs.name == rhs.name);
148 equal &= (lhs.start == rhs.start);
149 equal &= (lhs.stride == rhs.stride);
150 equal &= (lhs.c_size == rhs.c_size);
163 unsigned int index = indices[0];
164 for (
unsigned int i=1; i<indices.size(); ++i)
166 index = indices[i] + (_dims[i].size * index);
186 std::stringstream sos;
194 strm <<
"Shape = { ";
195 for (
unsigned int i=0; i<_dims.size(); ++i)
197 const Array::dimension& dim = _dims[i];
206 strm <<
"\tDim = { \n";
207 strm <<
"\t\tname=" << dim.name <<
"\n";
208 strm <<
"\t\tsize=" << dim.size <<
"\n";
209 strm <<
"\t\tc_size=" << dim.c_size <<
"\n";
210 strm <<
"\t\tstart=" << dim.start <<
"\n";
211 strm <<
"\t\tstop=" << dim.stop <<
"\n";
212 strm <<
"\t\tstride=" << dim.stride <<
"\n";
218 if (indices.size() != _dims.size())
223 for (
unsigned int i=0; i<_dims.size(); ++i)
226 if (indices[i] >= static_cast<unsigned int>(_dims[i].size))
255 : _shape(proto._shape)
256 , _current(proto._current)
277 _current = rhs._current;
287 if (_shape != rhs._shape)
293 if (_end != rhs._end)
299 return (_current == rhs._current);
321 Shape::IndexIterator::advanceCurrent()
330 unsigned int dimInd = _shape->getNumDimensions();
331 while (carry && dimInd-- > 0)
333 const Array::dimension& dim = _shape->_dims[dimInd];
335 unsigned int& currentDimIndex = _current[dimInd];
336 currentDimIndex += dim.stride;
339 if (currentDimIndex > static_cast<unsigned int>(dim.stop))
341 currentDimIndex = dim.start;
355 Shape::IndexIterator::setCurrentToStart()
358 for (
unsigned int i=0; i<_shape->getNumDimensions(); ++i)
360 _current[i] = _shape->_dims[i].start;
IndexIterator()
isEnd is only set by Shape for creating an end() iterator...
Shape::IndexIterator endSpaceEnumeration() const
The end of the enumeration for testing end conditions.
bool validateIndices(const IndexTuple &indices) const
A custom iterator that enumerates all the points in the space defined by a Shape in row major order...
#define NCML_ASSERT(cond)
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
std::vector< unsigned int > IndexTuple
IndexIterator & operator=(const IndexIterator &rhs)
void print(std::ostream &strm) const
Print the contents of this to the stream.
Shape & operator=(const Shape &rhs)
void setToUnconstrained()
Go through and set all the values to be the unconstrained values.
A wrapper class for a vector of Array::dimension structs.
Shape()
The empty shape, with no dimensions.
bool isConstrained() const
Are there constraints on the dimension?
bool operator==(const IndexIterator &rhs) const
Shape::IndexIterator beginSpaceEnumeration() const
Create a forward iterator that returns IndexTuple's in a row major order (leftmost dimension slowest ...
static bool areDimensionsEqual(const Array::dimension &lhs, const Array::dimension &rhs)
Helper:
#define THROW_NCML_INTERNAL_ERROR(msg)
bool operator==(const Shape &rhs) const
Return if this contains the same shape as rhs.
std::string toString() const
Make a string that prints the contents of this.
vector< Array::dimension >::const_iterator DimItC
unsigned int getNumDimensions() const
unsigned int getRowMajorIndex(const IndexTuple &indices, bool validate=true) const
Return the row major linear index into a slowest varying dimension first flattening of the given UNCO...
friend class IndexIterator
static void printDimension(std::ostream &strm, const Array::dimension &dim)
Helper to print the dimension to a stream.