45 template<
typename dtype>
65 cube_.reserve(inSize);
77 return cube_.at(inIndex);
89 return cube_.at(inIndex);
109 return cube_.begin();
119 return cube_.cbegin();
127 void dump(
const std::string& inFilename)
const
135 std::ofstream ofile(
f.fullName().c_str(), std::ios::binary);
141 for (
auto& ndarray : cube_)
143 ofile.write(
reinterpret_cast<const char*
>(ndarray.data()), ndarray.size() *
sizeof(dtype));
156 return cube_.empty();
186 return cube_.front();
196 return elementShape_;
206 return static_cast<uint32>(cube_.size());
226 if (elementShape_.
rows == 0 && elementShape_.
cols == 0)
229 elementShape_.
rows = inputShape.
rows;
230 elementShape_.
cols = inputShape.
cols;
233 if (inputShape != elementShape_)
238 cube_.push_back(inArray);
251 inIndex += elementShape_.
size();
258 returnArray[i] = cube_[i][inIndex];
275 inIndex += elementShape_.
size();
283 returnArray[idx++] = cube_[i][inIndex];
300 inRow += elementShape_.
rows;
305 inCol += elementShape_.
cols;
312 returnArray[i] = cube_[i](inRow, inCol);
330 inRow += elementShape_.
rows;
335 inCol += elementShape_.
cols;
343 returnArray[idx++] = cube_[i](inRow, inCol);
360 inCol += elementShape_.
cols;
366 returnArray.
put(returnArray.
rSlice(), i, cube_[i](inRow, inCol));
384 inCol += elementShape_.
cols;
391 returnArray.
put(returnArray.
rSlice(), idx++, cube_[i](inRow, inCol));
408 inRow += elementShape_.
rows;
414 returnArray.
put(returnArray.
rSlice(), i, cube_[i](inRow, inCol));
432 inRow += elementShape_.
rows;
439 returnArray.
put(returnArray.
rSlice(), idx++, cube_[i](inRow, inCol));
457 returnCube.
push_back(cube_[i](inRow, inCol));
476 returnCube.
push_back(cube_[i](inRow, inCol));
492 inIndex += elementShape_.
size();
495 if (
static_cast<uint32>(inIndex) >= elementShape_.
size())
514 inIndex += elementShape_.
size();
517 if (
static_cast<uint32>(inIndex) >= elementShape_.
size())
523 if (numElements >
sizeZ())
528 return sliceZ(inIndex, inSliceZ);
542 inRow += elementShape_.
rows;
547 inCol += elementShape_.
cols;
550 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
555 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
575 inRow += elementShape_.
rows;
580 inCol += elementShape_.
cols;
583 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
587 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
593 if (numElements >
sizeZ())
598 return sliceZ(inRow, inCol, inSliceZ);
611 if (numRows > elementShape_.
rows)
618 inCol += elementShape_.
cols;
621 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
640 if (numRows > elementShape_.
rows)
647 inCol += elementShape_.
cols;
650 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
656 if (numElements >
sizeZ())
661 return sliceZ(inRow, inCol, inSliceZ);
674 if (numCols > elementShape_.
cols)
681 inRow += elementShape_.
rows;
684 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
703 if (numCols > elementShape_.
cols)
710 inRow += elementShape_.
rows;
713 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
719 if (numElements >
sizeZ())
724 return sliceZ(inRow, inCol, inSliceZ);
770 if (numElements >
sizeZ())
775 return sliceZ(inRow, inCol, inSliceZ);
787 return cube_[inIndex];
799 return cube_[inIndex];
804 std::vector<NdArray<dtype> > cube_{};
805 Shape elementShape_{ 0, 0 };
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:37
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
Convenience container for holding a uniform array of NdArrays.
Definition: DataCube.hpp:47
void push_back(const NdArray< dtype > &inArray)
Definition: DataCube.hpp:222
NdArray< dtype > sliceZAll(int32 inRow, int32 inCol) const
Definition: DataCube.hpp:296
NdArray< dtype > sliceZAll(int32 inRow, Slice inCol) const
Definition: DataCube.hpp:404
NdArray< dtype > & operator[](uint32 inIndex) noexcept
Definition: DataCube.hpp:785
const Shape & shape() const noexcept
Definition: DataCube.hpp:194
typename std::deque< NdArray< dtype > >::const_iterator const_iterator
Definition: DataCube.hpp:51
DataCube< dtype > sliceZat(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:757
NdArray< dtype > & front() noexcept
Definition: DataCube.hpp:184
DataCube< dtype > sliceZ(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:471
const NdArray< dtype > & operator[](uint32 inIndex) const noexcept
Definition: DataCube.hpp:797
iterator begin() noexcept
Definition: DataCube.hpp:107
NdArray< dtype > sliceZat(int32 inIndex, Slice inSliceZ) const
Definition: DataCube.hpp:510
DataCube< dtype > sliceZAllat(Slice inRow, Slice inCol) const
Definition: DataCube.hpp:734
NdArray< dtype > sliceZat(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:571
typename std::deque< NdArray< dtype > >::iterator iterator
Definition: DataCube.hpp:50
DataCube< dtype > sliceZAll(Slice inRow, Slice inCol) const
Definition: DataCube.hpp:452
uint32 sizeZ() const noexcept
Definition: DataCube.hpp:204
NdArray< dtype > sliceZ(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:326
NdArray< dtype > sliceZat(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:637
NdArray< dtype > sliceZat(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:700
NdArray< dtype > sliceZ(int32 inIndex, Slice inSliceZ) const
Definition: DataCube.hpp:271
NdArray< dtype > sliceZAll(int32 inIndex) const
Definition: DataCube.hpp:247
DataCube(uint32 inSize)
Definition: DataCube.hpp:63
NdArray< dtype > sliceZAllat(int32 inIndex) const
Definition: DataCube.hpp:488
NdArray< dtype > sliceZ(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:428
NdArray< dtype > & at(uint32 inIndex)
Definition: DataCube.hpp:75
void pop_back() noexcept
Definition: DataCube.hpp:212
iterator end() noexcept
Definition: DataCube.hpp:164
NdArray< dtype > sliceZ(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:380
NdArray< dtype > sliceZAllat(int32 inRow, int32 inCol) const
Definition: DataCube.hpp:538
const NdArray< dtype > & at(uint32 inIndex) const
Definition: DataCube.hpp:87
void dump(const std::string &inFilename) const
Definition: DataCube.hpp:127
NdArray< dtype > & back() noexcept
Definition: DataCube.hpp:97
bool isempty() noexcept
Definition: DataCube.hpp:154
const_iterator cend() const noexcept
Definition: DataCube.hpp:174
NdArray< dtype > sliceZAllat(Slice inRow, int32 inCol) const
Definition: DataCube.hpp:608
const_iterator cbegin() const noexcept
Definition: DataCube.hpp:117
NdArray< dtype > sliceZAllat(int32 inRow, Slice inCol) const
Definition: DataCube.hpp:671
NdArray< dtype > sliceZAll(Slice inRow, int32 inCol) const
Definition: DataCube.hpp:356
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3666
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4283
Slice rSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:978
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
uint32 rows
Definition: Core/Shape.hpp:44
uint32 cols
Definition: Core/Shape.hpp:45
uint32 size() const noexcept
Definition: Core/Shape.hpp:102
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
int32 step
Definition: Slice.hpp:49
int32 start
Definition: Slice.hpp:47
uint32 numElements(uint32 inArraySize)
Definition: Slice.hpp:188
int32 stop
Definition: Slice.hpp:48
Provides simple filesystem functions.
Definition: Filesystem.hpp:40
dtype f(dtype inDofN, dtype inDofD)
Definition: f.hpp:55
Definition: Coordinate.hpp:45
std::int32_t int32
Definition: Types.hpp:36
std::uint32_t uint32
Definition: Types.hpp:40