 |
NumCpp
2.3.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
|
Go to the documentation of this file.
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);
543 inRow += elementShape_.
rows;
548 inCol += elementShape_.
cols;
551 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
556 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
576 inRow += elementShape_.
rows;
581 inCol += elementShape_.
cols;
584 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
588 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
594 if (numElements >
sizeZ())
599 return sliceZ(inRow, inCol, inSliceZ);
612 if (numRows > elementShape_.
rows)
619 inCol += elementShape_.
cols;
622 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
641 if (numRows > elementShape_.
rows)
648 inCol += elementShape_.
cols;
651 if (
static_cast<uint32>(inCol) >= elementShape_.
cols)
657 if (numElements >
sizeZ())
662 return sliceZ(inRow, inCol, inSliceZ);
675 if (numCols > elementShape_.
cols)
682 inRow += elementShape_.
rows;
685 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
704 if (numCols > elementShape_.
cols)
711 inRow += elementShape_.
rows;
714 if (
static_cast<uint32>(inRow) >= elementShape_.
rows)
720 if (numElements >
sizeZ())
725 return sliceZ(inRow, inCol, inSliceZ);
771 if (numElements >
sizeZ())
776 return sliceZ(inRow, inCol, inSliceZ);
788 return cube_[inIndex];
800 return cube_[inIndex];
805 std::vector<NdArray<dtype> > cube_{};
806 Shape elementShape_{ 0, 0 };
int32 stop
Definition: Slice.hpp:48
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4311
std::int32_t int32
Definition: Types.hpp:36
DataCube(uint32 inSize)
Definition: DataCube.hpp:63
DataCube< dtype > sliceZAllat(Slice inRow, Slice inCol) const
Definition: DataCube.hpp:735
NdArray< dtype > sliceZat(int32 inIndex, Slice inSliceZ) const
Definition: DataCube.hpp:510
iterator end() noexcept
Definition: DataCube.hpp:164
NdArray< dtype > sliceZ(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:428
std::uint32_t uint32
Definition: Types.hpp:40
Slice rSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:905
uint32 sizeZ() const noexcept
Definition: DataCube.hpp:204
NdArray< dtype > & back() noexcept
Definition: DataCube.hpp:97
bool isempty() noexcept
Definition: DataCube.hpp:154
void dump(const std::string &inFilename) const
Definition: DataCube.hpp:127
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:40
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3684
int32 start
Definition: Slice.hpp:47
NdArray< dtype > & front() noexcept
Definition: DataCube.hpp:184
NdArray< dtype > sliceZ(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:380
typename std::deque< NdArray< dtype > >::const_iterator const_iterator
Definition: DataCube.hpp:51
const NdArray< dtype > & operator[](uint32 inIndex) const noexcept
Definition: DataCube.hpp:798
Convenience container for holding a uniform array of NdArrays.
Definition: DataCube.hpp:46
uint32 cols
Definition: Core/Shape.hpp:45
const NdArray< dtype > & at(uint32 inIndex) const
Definition: DataCube.hpp:87
NdArray< dtype > sliceZAllat(int32 inRow, int32 inCol) const
Definition: DataCube.hpp:539
uint32 numElements(uint32 inArraySize)
Definition: Slice.hpp:164
NdArray< dtype > sliceZAllat(int32 inRow, Slice inCol) const
Definition: DataCube.hpp:672
const_iterator cend() const noexcept
Definition: DataCube.hpp:174
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:37
int32 step
Definition: Slice.hpp:49
const Shape & shape() const noexcept
Definition: DataCube.hpp:194
Definition: Coordinate.hpp:44
NdArray< dtype > sliceZat(Slice inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:638
void push_back(const NdArray< dtype > &inArray)
Definition: DataCube.hpp:222
NdArray< dtype > sliceZAll(int32 inIndex) const
Definition: DataCube.hpp:247
DataCube< dtype > sliceZat(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:758
NdArray< dtype > sliceZAllat(Slice inRow, int32 inCol) const
Definition: DataCube.hpp:609
uint32 rows
Definition: Core/Shape.hpp:44
DataCube< dtype > sliceZ(Slice inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:471
NdArray< dtype > & operator[](uint32 inIndex) noexcept
Definition: DataCube.hpp:786
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
constexpr uint32 size() const noexcept
Definition: Core/Shape.hpp:102
NdArray< dtype > sliceZat(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:572
NdArray< dtype > sliceZAll(Slice inRow, int32 inCol) const
Definition: DataCube.hpp:356
NdArray< dtype > sliceZAllat(int32 inIndex) const
Definition: DataCube.hpp:488
NdArray< dtype > sliceZ(int32 inRow, int32 inCol, Slice inSliceZ) const
Definition: DataCube.hpp:326
NdArray< dtype > sliceZat(int32 inRow, Slice inCol, Slice inSliceZ) const
Definition: DataCube.hpp:701
typename std::deque< NdArray< dtype > >::iterator iterator
Definition: DataCube.hpp:50
dtype f(dtype inDofN, dtype inDofD)
Definition: f.hpp:57
A Class for slicing into NdArrays.
Definition: Slice.hpp:43
DataCube< dtype > sliceZAll(Slice inRow, Slice inCol) const
Definition: DataCube.hpp:452
const_iterator cbegin() const noexcept
Definition: DataCube.hpp:117
NdArray< dtype > & at(uint32 inIndex)
Definition: DataCube.hpp:75
NdArray< dtype > sliceZAll(int32 inRow, int32 inCol) const
Definition: DataCube.hpp:296
Provides simple filesystem functions.
Definition: Filesystem.hpp:39
NdArray< dtype > sliceZ(int32 inIndex, Slice inSliceZ) const
Definition: DataCube.hpp:271
iterator begin() noexcept
Definition: DataCube.hpp:107
void pop_back() noexcept
Definition: DataCube.hpp:212
NdArray< dtype > sliceZAll(int32 inRow, Slice inCol) const
Definition: DataCube.hpp:404