5 #include <libutl/Vector.h> 37 virtual size_t getSize()
const;
40 void setNumDims(
size_t numDims);
84 void set(
size_t dim0);
86 const T& operator()(
size_t idx0)
const 91 T& operator()(
size_t idx0)
96 const T&
get(
size_t idx0)
const;
135 void set(
size_t dim0,
size_t dim1);
137 const T& operator()(
size_t idx0,
size_t idx1)
const 139 return get(idx0, idx1);
142 T& operator()(
size_t idx0,
size_t idx1)
144 return get(idx0, idx1);
147 const T&
get(
size_t idx0,
size_t idx1)
const;
149 T&
get(
size_t idx0,
size_t idx1);
180 Vector3d(
size_t dim0,
size_t dim1,
size_t dim2)
183 set(dim0, dim1, dim2);
186 void set(
size_t dim0,
size_t dim1,
size_t dim2);
188 const T& operator()(
size_t idx0,
size_t idx1,
size_t idx2)
const 190 return get(idx0, idx1, idx2);
193 T& operator()(
size_t idx0,
size_t idx1,
size_t idx2)
195 return get(idx0, idx1, idx2);
198 const T&
get(
size_t idx0,
size_t idx1,
size_t idx2)
const;
200 T&
get(
size_t idx0,
size_t idx1,
size_t idx2);
231 for (i = 0; i < _numDims; i++)
248 auto& vect = utl::cast<VectorMD<T>>(rhs);
249 res =
utl::compare(_dims, _numDims, vect._dims, vect._numDims);
264 auto& vect = utl::cast<VectorMD<T>>(rhs);
265 ASSERTD(_numDims == vect._numDims);
266 if (memcmp(_dims, vect._dims, _numDims *
sizeof(
size_t)) != 0)
270 _array =
new T[getSize()];
272 utl::copy(_array, vect._array, getSize());
286 _dims =
new size_t[_numDims];
296 _array =
new T[getSize()];
304 bool arrayExists = (_array !=
nullptr);
307 if (_array !=
nullptr)
320 size_t res = _dims[0];
322 for (i = 1; i < _numDims; i++)
337 _dims =
new size_t[_numDims];
347 this->_dims[0] = dim0;
348 this->_array =
new T[this->getSize()];
357 ASSERTD(idx0 < this->_dims[0]);
358 return this->_array[idx0];
367 ASSERTD(idx0 < this->_dims[0]);
368 return this->_array[idx0];
378 this->_dims[0] = dim0;
379 this->_dims[1] = dim1;
380 this->_array =
new T[this->getSize()];
389 ASSERTD(idx0 < this->_dims[0]);
390 ASSERTD(idx1 < this->_dims[1]);
391 return this->_array[(idx0 * this->_dims[1]) + idx1];
400 ASSERTD(idx0 < this->_dims[0]);
401 ASSERTD(idx1 < this->_dims[1]);
402 return this->_array[(idx0 * this->_dims[1]) + idx1];
412 this->_dims[0] = dim0;
413 this->_dims[1] = dim1;
414 this->_dims[2] = dim2;
415 this->_array =
new T[this->getSize()];
424 ASSERTD(idx0 < this->_dims[0]);
425 ASSERTD(idx1 < this->_dims[1]);
426 ASSERTD(idx2 < this->_dims[2]);
427 return this->_array[(((idx0 * this->_dims[1]) + idx1) * this->_dims[2]) + idx2];
436 ASSERTD(idx0 < this->_dims[0]);
437 ASSERTD(idx1 < this->_dims[1]);
438 ASSERTD(idx2 < this->_dims[2]);
439 return this->_array[(((idx0 * this->_dims[1]) + idx1) * this->_dims[2]) + idx2];
#define UTL_CLASS_IMPL_TPL(className, T)
Implementation of standard UTL++ functionality for a template class.
void serialize(bool &b, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a boolean.
void deInit()
De-initialize UTL++.
default representation (via getSerializeMode())
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
Three-dimensional vector.
unsigned int uint_t
Unsigned integer.
#define UTL_CLASS_DECL_TPL(DC, T, BC)
Declaration of standard UTL++ functionality for a template class with one parameter.
Abstract base for n-dimensional vectors.
Root of UTL++ class hierarchy.
int compare(bool lhs, bool rhs)
Compare two boolean values.
void init()
Initialize UTL++.
#define ASSERTD
Do an assertion in DEBUG mode only.