46 template<
typename dtype>
66 cube_.reserve(inSize);
78 return cube_.at(inIndex);
90 return cube_.at(inIndex);
110 return cube_.begin();
120 return cube_.cbegin();
130 return cube_.cbegin();
138 void dump(
const std::string& inFilename)
const
140 std::filesystem::path f(inFilename);
141 if (!f.has_extension())
143 f.replace_extension(
"bin");
146 std::ofstream ofile(f.c_str(), std::ios::binary);
152 for (
auto& ndarray : cube_)
154 ofile.write(
reinterpret_cast<const char*
>(ndarray.data()), ndarray.size() *
sizeof(dtype));
167 return cube_.empty();
207 return cube_.front();
217 return elementShape_;
227 return static_cast<uint32>(cube_.size());
247 if (elementShape_.rows == 0 && elementShape_.cols == 0)
250 elementShape_.rows = inputShape.
rows;
251 elementShape_.cols = inputShape.
cols;
254 if (inputShape != elementShape_)
259 cube_.push_back(inArray);
272 inIndex += elementShape_.size();
279 returnArray[i] = cube_[i][inIndex];
296 inIndex += elementShape_.size();
304 returnArray[idx++] = cube_[i][inIndex];
321 inRow += elementShape_.rows;
326 inCol += elementShape_.cols;
333 returnArray[i] = cube_[i](inRow, inCol);
351 inRow += elementShape_.rows;
356 inCol += elementShape_.cols;
364 returnArray[idx++] = cube_[i](inRow, inCol);
381 inCol += elementShape_.cols;
387 returnArray.
put(returnArray.
rSlice(), i, cube_[i](inRow, inCol));
405 inCol += elementShape_.cols;
412 returnArray.
put(returnArray.
rSlice(), idx++, cube_[i](inRow, inCol));
429 inRow += elementShape_.rows;
435 returnArray.
put(returnArray.
rSlice(), i, cube_[i](inRow, inCol));
453 inRow += elementShape_.rows;
460 returnArray.
put(returnArray.
rSlice(), idx++, cube_[i](inRow, inCol));
478 returnCube.
push_back(cube_[i](inRow, inCol));
497 returnCube.
push_back(cube_[i](inRow, inCol));
513 inIndex += elementShape_.size();
516 if (
static_cast<uint32>(inIndex) >= elementShape_.size())
535 inIndex += elementShape_.size();
538 if (
static_cast<uint32>(inIndex) >= elementShape_.size())
544 if (numElements >
sizeZ())
549 return sliceZ(inIndex, inSliceZ);
563 inRow += elementShape_.rows;
568 inCol += elementShape_.cols;
571 if (
static_cast<uint32>(inRow) >= elementShape_.rows)
576 if (
static_cast<uint32>(inCol) >= elementShape_.cols)
596 inRow += elementShape_.rows;
601 inCol += elementShape_.cols;
604 if (
static_cast<uint32>(inRow) >= elementShape_.rows)
608 if (
static_cast<uint32>(inCol) >= elementShape_.cols)
614 if (numElements >
sizeZ())
619 return sliceZ(inRow, inCol, inSliceZ);
631 auto numRows = inRow.
numElements(elementShape_.rows);
632 if (numRows > elementShape_.rows)
639 inCol += elementShape_.cols;
642 if (
static_cast<uint32>(inCol) >= elementShape_.cols)
660 auto numRows = inRow.
numElements(elementShape_.rows);
661 if (numRows > elementShape_.rows)
668 inCol += elementShape_.cols;
671 if (
static_cast<uint32>(inCol) >= elementShape_.cols)
677 if (numElements >
sizeZ())
682 return sliceZ(inRow, inCol, inSliceZ);
694 auto numCols = inCol.
numElements(elementShape_.cols);
695 if (numCols > elementShape_.cols)
702 inRow += elementShape_.rows;
705 if (
static_cast<uint32>(inRow) >= elementShape_.rows)
723 auto numCols = inCol.
numElements(elementShape_.cols);
724 if (numCols > elementShape_.cols)
731 inRow += elementShape_.rows;
734 if (
static_cast<uint32>(inRow) >= elementShape_.rows)
740 if (numElements >
sizeZ())
745 return sliceZ(inRow, inCol, inSliceZ);
757 if (inRow.
numElements(elementShape_.rows) > elementShape_.rows)
762 if (inCol.
numElements(elementShape_.cols) > elementShape_.cols)
780 if (inRow.
numElements(elementShape_.rows) > elementShape_.rows)
785 if (inCol.
numElements(elementShape_.cols) > elementShape_.cols)
791 if (numElements >
sizeZ())
796 return sliceZ(inRow, inCol, inSliceZ);
808 return cube_[inIndex];
820 return cube_[inIndex];
825 std::vector<NdArray<dtype>> cube_{};
826 Shape elementShape_{ 0, 0 };
#define THROW_RUNTIME_ERROR(msg)
Definition Error.hpp:40
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
void push_back(const NdArray< dtype > &inArray)
Definition DataCube.hpp:243
NdArray< dtype > sliceZAll(int32 inIndex) const
Definition DataCube.hpp:268
iterator begin() noexcept
Definition DataCube.hpp:108
const NdArray< dtype > & at(uint32 inIndex) const
Definition DataCube.hpp:88
NdArray< dtype > & at(uint32 inIndex)
Definition DataCube.hpp:76
NdArray< dtype > & operator[](uint32 inIndex) noexcept
Definition DataCube.hpp:806
NdArray< dtype > sliceZ(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition DataCube.hpp:347
DataCube< dtype > sliceZat(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition DataCube.hpp:778
NdArray< dtype > sliceZAllat(Slice inRow, int32 inCol) const
Definition DataCube.hpp:629
uint32 sizeZ() const noexcept
Definition DataCube.hpp:225
NdArray< dtype > sliceZAll(Slice inRow, int32 inCol) const
Definition DataCube.hpp:377
DataCube< dtype > sliceZ(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition DataCube.hpp:492
NdArray< dtype > sliceZat(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition DataCube.hpp:658
DataCube(uint32 inSize)
Definition DataCube.hpp:64
DataCube< dtype > sliceZAll(Slice inRow, Slice inCol) const
Definition DataCube.hpp:473
void pop_back() noexcept
Definition DataCube.hpp:233
NdArray< dtype > sliceZAllat(int32 inRow, Slice inCol) const
Definition DataCube.hpp:692
NdArray< dtype > sliceZat(int32 inIndex, Slice inSliceZ) const
Definition DataCube.hpp:531
const Shape & shape() const noexcept
Definition DataCube.hpp:215
NdArray< dtype > sliceZAll(int32 inRow, int32 inCol) const
Definition DataCube.hpp:317
iterator end() noexcept
Definition DataCube.hpp:175
NdArray< dtype > & front() noexcept
Definition DataCube.hpp:205
NdArray< dtype > sliceZAllat(int32 inIndex) const
Definition DataCube.hpp:509
typename std::deque< NdArray< dtype > >::iterator iterator
Definition DataCube.hpp:51
NdArray< dtype > & back() noexcept
Definition DataCube.hpp:98
const NdArray< dtype > & operator[](uint32 inIndex) const noexcept
Definition DataCube.hpp:818
void dump(const std::string &inFilename) const
Definition DataCube.hpp:138
typename std::deque< NdArray< dtype > >::const_iterator const_iterator
Definition DataCube.hpp:52
bool isempty() noexcept
Definition DataCube.hpp:165
const_iterator cend() const noexcept
Definition DataCube.hpp:195
const_iterator end() const noexcept
Definition DataCube.hpp:185
NdArray< dtype > sliceZAllat(int32 inRow, int32 inCol) const
Definition DataCube.hpp:559
const_iterator begin() const noexcept
Definition DataCube.hpp:118
const_iterator cbegin() const noexcept
Definition DataCube.hpp:128
NdArray< dtype > sliceZAll(int32 inRow, Slice inCol) const
Definition DataCube.hpp:425
NdArray< dtype > sliceZ(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition DataCube.hpp:401
NdArray< dtype > sliceZ(int32 inIndex, Slice inSliceZ) const
Definition DataCube.hpp:292
NdArray< dtype > sliceZ(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition DataCube.hpp:449
NdArray< dtype > sliceZat(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition DataCube.hpp:721
DataCube< dtype > sliceZAllat(Slice inRow, Slice inCol) const
Definition DataCube.hpp:755
NdArray< dtype > sliceZat(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition DataCube.hpp:592
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
Slice rSlice(index_type inStartIdx=0, size_type inStepSize=1) const
Definition NdArrayCore.hpp:1018
self_type & put(index_type inIndex, const value_type &inValue)
Definition NdArrayCore.hpp:3769
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
uint32 rows
Definition Core/shape.hpp:44
uint32 cols
Definition Core/shape.hpp:45
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
Definition Cartesian.hpp:39
std::int32_t int32
Definition Types.hpp:36
std::uint32_t uint32
Definition Types.hpp:40