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();
129 return cube_.cbegin();
137 void dump(
const std::string& inFilename)
const
139 std::filesystem::path
f(inFilename);
140 if (!
f.has_extension())
142 f.replace_extension(
"bin");
145 std::ofstream ofile(
f.c_str(), std::ios::binary);
151 for (
auto& ndarray : cube_)
153 ofile.write(
reinterpret_cast<const char*
>(ndarray.data()), ndarray.size() *
sizeof(dtype));
166 return cube_.empty();
206 return cube_.front();
216 return elementShape_;
226 return static_cast<uint32>(cube_.size());
246 if (elementShape_.
rows == 0 && elementShape_.
cols == 0)
249 elementShape_.
rows = inputShape.
rows;
250 elementShape_.
cols = inputShape.
cols;
253 if (inputShape != elementShape_)
258 cube_.push_back(inArray);
271 inIndex += elementShape_.
size();
278 returnArray[i] = cube_[i][inIndex];
295 inIndex += elementShape_.
size();
303 returnArray[idx++] = cube_[i][inIndex];
320 inRow += elementShape_.
rows;
325 inCol += elementShape_.
cols;
332 returnArray[i] = cube_[i](inRow, inCol);
350 inRow += elementShape_.
rows;
355 inCol += elementShape_.
cols;
363 returnArray[idx++] = cube_[i](inRow, inCol);
380 inCol += elementShape_.
cols;
386 returnArray.
put(returnArray.
rSlice(), i, cube_[i](inRow, inCol));
404 inCol += elementShape_.
cols;
411 returnArray.
put(returnArray.
rSlice(), idx++, cube_[i](inRow, inCol));
428 inRow += elementShape_.
rows;
434 returnArray.
put(returnArray.
rSlice(), i, cube_[i](inRow, inCol));
452 inRow += elementShape_.
rows;
459 returnArray.
put(returnArray.
rSlice(), idx++, cube_[i](inRow, inCol));
477 returnCube.
push_back(cube_[i](inRow, inCol));
496 returnCube.
push_back(cube_[i](inRow, inCol));
512 inIndex += elementShape_.
size();
515 if (
static_cast<uint32>(inIndex) >= elementShape_.
size())
534 inIndex += elementShape_.
size();
537 if (
static_cast<uint32>(inIndex) >= elementShape_.
size())
543 if (numElements >
sizeZ())
548 return sliceZ(inIndex, inSliceZ);
562 inRow += elementShape_.
rows;
567 inCol += elementShape_.
cols;
570 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
575 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
595 inRow += elementShape_.
rows;
600 inCol += elementShape_.
cols;
603 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
607 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
613 if (numElements >
sizeZ())
618 return sliceZ(inRow, inCol, inSliceZ);
631 if (numRows > elementShape_.
rows)
638 inCol += elementShape_.
cols;
641 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
660 if (numRows > elementShape_.
rows)
667 inCol += elementShape_.
cols;
670 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
676 if (numElements >
sizeZ())
681 return sliceZ(inRow, inCol, inSliceZ);
694 if (numCols > elementShape_.
cols)
701 inRow += elementShape_.
rows;
704 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
723 if (numCols > elementShape_.
cols)
730 inRow += elementShape_.
rows;
733 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
739 if (numElements >
sizeZ())
744 return sliceZ(inRow, inCol, inSliceZ);
790 if (numElements >
sizeZ())
795 return sliceZ(inRow, inCol, inSliceZ);
807 return cube_[inIndex];
819 return cube_[inIndex];
824 std::vector<NdArray<dtype>> cube_{};
825 Shape elementShape_{ 0, 0 };
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:40
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
Convenience container for holding a uniform array of NdArrays.
Definition: DataCube.hpp:47
void push_back(const NdArray< dtype > &inArray)
Definition: DataCube.hpp:242
typename std::deque< NdArray< dtype > >::const_iterator const_iterator
Definition: DataCube.hpp:51
NdArray< dtype > sliceZAll(int32 inIndex) const
Definition: DataCube.hpp:267
iterator begin() noexcept
Definition: DataCube.hpp:107
const NdArray< dtype > & at(uint32 inIndex) const
Definition: DataCube.hpp:87
NdArray< dtype > & at(uint32 inIndex)
Definition: DataCube.hpp:75
NdArray< dtype > & operator[](uint32 inIndex) noexcept
Definition: DataCube.hpp:805
NdArray< dtype > sliceZ(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:346
DataCube< dtype > sliceZat(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:777
typename std::deque< NdArray< dtype > >::iterator iterator
Definition: DataCube.hpp:50
NdArray< dtype > sliceZAllat(Slice inRow, int32 inCol) const
Definition: DataCube.hpp:628
uint32 sizeZ() const noexcept
Definition: DataCube.hpp:224
NdArray< dtype > sliceZAll(Slice inRow, int32 inCol) const
Definition: DataCube.hpp:376
DataCube< dtype > sliceZ(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:491
NdArray< dtype > sliceZat(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:657
DataCube(uint32 inSize)
Definition: DataCube.hpp:63
DataCube< dtype > sliceZAll(Slice inRow, Slice inCol) const
Definition: DataCube.hpp:472
void pop_back() noexcept
Definition: DataCube.hpp:232
NdArray< dtype > sliceZAllat(int32 inRow, Slice inCol) const
Definition: DataCube.hpp:691
NdArray< dtype > sliceZat(int32 inIndex, Slice inSliceZ) const
Definition: DataCube.hpp:530
const Shape & shape() const noexcept
Definition: DataCube.hpp:214
NdArray< dtype > sliceZAll(int32 inRow, int32 inCol) const
Definition: DataCube.hpp:316
iterator end() noexcept
Definition: DataCube.hpp:174
NdArray< dtype > & front() noexcept
Definition: DataCube.hpp:204
NdArray< dtype > sliceZAllat(int32 inIndex) const
Definition: DataCube.hpp:508
NdArray< dtype > & back() noexcept
Definition: DataCube.hpp:97
const NdArray< dtype > & operator[](uint32 inIndex) const noexcept
Definition: DataCube.hpp:817
void dump(const std::string &inFilename) const
Definition: DataCube.hpp:137
bool isempty() noexcept
Definition: DataCube.hpp:164
const_iterator cend() const noexcept
Definition: DataCube.hpp:194
const_iterator end() const noexcept
Definition: DataCube.hpp:184
NdArray< dtype > sliceZAllat(int32 inRow, int32 inCol) const
Definition: DataCube.hpp:558
const_iterator begin() const noexcept
Definition: DataCube.hpp:117
const_iterator cbegin() const noexcept
Definition: DataCube.hpp:127
NdArray< dtype > sliceZAll(int32 inRow, Slice inCol) const
Definition: DataCube.hpp:424
NdArray< dtype > sliceZ(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:400
NdArray< dtype > sliceZ(int32 inIndex, Slice inSliceZ) const
Definition: DataCube.hpp:291
NdArray< dtype > sliceZ(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:448
NdArray< dtype > sliceZat(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:720
DataCube< dtype > sliceZAllat(Slice inRow, Slice inCol) const
Definition: DataCube.hpp:754
NdArray< dtype > sliceZat(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:591
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
Slice rSlice(index_type inStartIdx=0, size_type inStepSize=1) const
Definition: NdArrayCore.hpp:1022
self_type & put(index_type inIndex, const value_type &inValue)
Definition: NdArrayCore.hpp:3693
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:104
A Class for slicing into NdArrays.
Definition: Slice.hpp:45
int32 step
Definition: Slice.hpp:50
int32 start
Definition: Slice.hpp:48
uint32 numElements(uint32 inArraySize)
Definition: Slice.hpp:195
int32 stop
Definition: Slice.hpp:49
dtype f(GeneratorType &generator, dtype inDofN, dtype inDofD)
Definition: f.hpp:56
Definition: Cartesian.hpp:40
std::int32_t int32
Definition: Types.hpp:36
std::uint32_t uint32
Definition: Types.hpp:40