33 #include <forward_list>
35 #include <initializer_list>
43 #include <type_traits>
70 template<
typename dtype,
class Allocator = std::allocator<dtype>>
74 STATIC_ASSERT_VALID_DTYPE(dtype);
75 static_assert(is_same_v<dtype, typename Allocator::value_type>,
76 "value_type and Allocator::value_type must match");
78 using AllocType =
typename std::allocator_traits<Allocator>::template rebind_alloc<dtype>;
79 using AllocTraits = std::allocator_traits<AllocType>;
84 using pointer =
typename AllocTraits::pointer;
114 shape_(inSquareSize, inSquareSize),
115 size_(inSquareSize * inSquareSize)
128 shape_(inNumRows, inNumCols),
129 size_(inNumRows * inNumCols)
153 NdArray(std::initializer_list<dtype> inList) :
154 shape_(1, static_cast<
uint32>(inList.
size())),
170 NdArray(
const std::initializer_list<std::initializer_list<dtype>>& inList) :
173 for (
const auto& list : inList)
175 if (shape_.
cols == 0)
177 shape_.
cols =
static_cast<uint32>(list.size());
179 else if (list.size() != shape_.
cols)
182 "All rows of the initializer list needs to have the same number of elements");
186 size_ = shape_.
size();
189 for (
const auto& list : inList)
205 template<
size_t ArraySize, std::enable_if_t<is_val
id_dtype_v<dtype>,
int> = 0>
206 NdArray(std::array<dtype, ArraySize>& inArray,
bool copy =
true) :
207 shape_(1, static_cast<
uint32>(ArraySize)),
220 array_ = inArray.data();
233 template<
size_t Dim0Size,
size_t Dim1Size>
234 NdArray(std::array<std::array<dtype, Dim1Size>, Dim0Size>& in2dArray,
bool copy =
true) :
235 shape_(static_cast<
uint32>(Dim0Size), static_cast<
uint32>(Dim1Size)),
243 const auto start = in2dArray.front().begin();
249 array_ = in2dArray.front().data();
262 template<std::enable_if_t<is_val
id_dtype_v<dtype>,
int> = 0>
264 shape_(1, static_cast<
uint32>(inVector.
size())),
277 array_ = inVector.data();
288 explicit NdArray(
const std::vector<std::vector<dtype>>& in2dVector) :
289 shape_(static_cast<
uint32>(in2dVector.
size()), 0)
291 for (
const auto&
row : in2dVector)
293 if (shape_.
cols == 0)
297 else if (
row.size() != shape_.
cols)
303 size_ = shape_.
size();
306 auto currentPosition =
begin();
307 for (
const auto&
row : in2dVector)
310 currentPosition += shape_.
cols;
322 template<
size_t Dim1Size>
323 NdArray(std::vector<std::array<dtype, Dim1Size>>& in2dArray,
bool copy =
true) :
324 shape_(static_cast<
uint32>(in2dArray.
size()), static_cast<
uint32>(Dim1Size)),
332 const auto start = in2dArray.front().begin();
338 array_ = in2dArray.front().data();
349 template<std::enable_if_t<is_val
id_dtype_v<dtype>,
int> = 0>
350 explicit NdArray(
const std::deque<dtype>& inDeque) :
351 shape_(1, static_cast<
uint32>(inDeque.
size())),
367 explicit NdArray(
const std::deque<std::deque<dtype>>& in2dDeque) :
368 shape_(static_cast<
uint32>(in2dDeque.
size()), 0)
370 for (
const auto&
row : in2dDeque)
372 if (shape_.
cols == 0)
376 else if (
row.size() != shape_.
cols)
382 size_ = shape_.
size();
385 auto currentPosition =
begin();
386 for (
const auto&
row : in2dDeque)
389 currentPosition += shape_.
cols;
399 explicit NdArray(
const std::list<dtype>& inList) :
400 shape_(1, static_cast<
uint32>(inList.
size())),
417 template<
typename Iterator,
418 std::enable_if_t<is_same_v<typename std::iterator_traits<Iterator>::value_type, dtype>,
int> = 0>
420 shape_(1, static_cast<
uint32>(std::distance(inFirst, inLast))),
443 if (inPtr !=
nullptr && size_ > 0)
458 template<
typename UIntType1,
460 std::enable_if_t<!is_same_v<UIntType1, bool>,
int> = 0,
461 std::enable_if_t<!is_same_v<UIntType2, bool>,
int> = 0>
467 if (inPtr !=
nullptr && size_ > 0)
483 template<
typename BoolType, std::enable_if_t<is_same_v<BoolType,
bool>,
int> = 0>
488 ownsPtr_(takeOwnership)
503 template<
typename BoolType, std::enable_if_t<is_same_v<BoolType,
bool>,
int> = 0>
508 ownsPtr_(takeOwnership)
519 shape_(inOtherArray.shape_),
520 size_(inOtherArray.size_),
521 endianess_(inOtherArray.endianess_)
537 shape_(inOtherArray.shape_),
538 size_(inOtherArray.size_),
539 endianess_(inOtherArray.endianess_),
540 array_(inOtherArray.array_),
541 ownsPtr_(inOtherArray.ownsPtr_)
543 inOtherArray.shape_.rows = inOtherArray.shape_.cols = 0;
544 inOtherArray.size_ = 0;
545 inOtherArray.ownsPtr_ =
false;
546 inOtherArray.array_ =
nullptr;
571 newArray(rhs.shape_);
572 endianess_ = rhs.endianess_;
591 if (array_ !=
nullptr)
613 endianess_ = rhs.endianess_;
615 ownsPtr_ = rhs.ownsPtr_;
617 rhs.shape_.rows = rhs.shape_.cols = rhs.size_ = 0;
618 rhs.array_ =
nullptr;
619 rhs.ownsPtr_ =
false;
639 return array_[inIndex];
656 return array_[inIndex];
671 inRowIndex += shape_.
rows;
676 inColIndex += shape_.
cols;
679 return array_[inRowIndex * shape_.
cols + inColIndex];
694 inRowIndex += shape_.
rows;
699 inColIndex += shape_.
cols;
702 return array_[inRowIndex * shape_.
cols + inColIndex];
715 Slice inSliceCopy(inSlice);
721 returnArray[counter++] =
at(i);
736 if (inMask.
shape() != shape_)
739 "input inMask must have the same shape as the NdArray it will be masking.");
744 for (
size_type i = 0; i < indices.size(); ++i)
760 template<
typename Indices, enable_if_t<is_same_v<Indices, NdArray<
size_type>>,
int> = 0>
763 if (inIndices.max().item() > size_ - 1)
770 for (
auto& index : inIndices)
797 returnArray(rowCounter, colCounter++) =
at(
row, col);
822 returnArray(rowCounter++, 0) =
at(
row, inColIndex);
844 returnArray(0, colCounter++) =
at(inRowIndex, col);
859 template<
typename Indices,
876 template<
typename Indices,
892 template<
typename Indices,
909 template<
typename Indices,
925 template<
typename RowIndices,
934 std::vector<int32> rowIndicesUnique(rowIndices.size());
935 std::vector<int32> colIndicesUnique(colIndices.size());
943 static_cast<uint32>(lastCol - colIndicesUnique.begin()));
946 for (
auto rowIter = rowIndicesUnique.begin(); rowIter != lastRow; ++rowIter)
949 for (
auto colIter = colIndicesUnique.begin(); colIter != lastCol; ++colIter)
951 returnArray(rowCounter, colCounter++) =
at(*rowIter, *colIter);
971 return Slice(inStartIdx, shape_.
cols, inStepSize);
985 return Slice(inStartIdx, shape_.
rows, inStepSize);
1002 errStr +=
" is out of bounds for array of size " +
utils::num2str(size_) +
".";
1023 errStr +=
" is out of bounds for array of size " +
utils::num2str(size_) +
".";
1045 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
rows) +
".";
1053 std::string errStr =
"Column index " +
utils::num2str(inColIndex);
1054 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
cols) +
".";
1076 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
rows) +
".";
1084 std::string errStr =
"Column index " +
utils::num2str(inColIndex);
1085 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
cols) +
".";
1185 if (inRow >= shape_.
rows)
1190 return begin() += (inRow * shape_.
cols);
1235 if (inRow >= shape_.
rows)
1262 if (inCol >= shape_.
cols)
1312 if (inCol >= shape_.
cols)
1339 if (inRow >= shape_.
rows)
1389 if (inRow >= shape_.
rows)
1416 if (inCol >= shape_.
cols)
1466 if (inCol >= shape_.
cols)
1481 return begin() += size_;
1493 if (inRow >= shape_.
rows)
1531 return cbegin() += size_;
1543 if (inRow >= shape_.
rows)
1558 return rbegin() += size_;
1570 if (inRow >= shape_.
rows)
1597 return crend(inRow);
1620 if (inRow >= shape_.
rows)
1647 if (inCol >= shape_.
cols)
1697 if (inCol >= shape_.
cols)
1724 if (inCol >= shape_.
cols)
1774 if (inCol >= shape_.
cols)
1795 const auto function = [](dtype i) ->
bool {
return i != dtype{ 0 }; };
1839 const auto function = [](dtype i) ->
bool {
return i != dtype{ 0 }; };
1884 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
1899 returnArray(0,
row) =
static_cast<uint32>(
1931 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
1946 returnArray(0,
row) =
static_cast<uint32>(
1981 std::vector<uint32> idx(size_);
1982 std::iota(idx.begin(), idx.end(), 0);
1984 const auto function = [
this](
uint32 i1,
uint32 i2) noexcept ->
bool
1985 {
return (*
this)[i1] < (*this)[i2]; };
1993 std::vector<uint32> idx(shape_.
cols);
1997 std::iota(idx.begin(), idx.end(), 0);
1999 const auto function = [
this,
row](
uint32 i1,
uint32 i2) noexcept ->
bool
2004 for (
uint32 col = 0; col < shape_.
cols; ++col)
2006 returnArray(
row, col) = idx[col];
2032 template<
typename dtypeOut,
2033 typename dtype_ = dtype,
2043 [](dtype value) -> dtypeOut { return static_cast<dtypeOut>(value); });
2057 template<
typename dtypeOut,
2058 typename dtype_ = dtype,
2067 {
return std::complex<typename dtypeOut::value_type>(value); };
2083 template<
typename dtypeOut,
2084 typename dtype_ = dtype,
2092 if (is_same_v<dtypeOut, dtype>)
2099 {
return complex_cast<typename dtypeOut::value_type>(value); };
2116 template<
typename dtypeOut,
2117 typename dtype_ = dtype,
2125 const auto function = [](
const_reference value) -> dtypeOut {
return static_cast<dtypeOut
>(value.real()); };
2140 return *(
cend() - 1);
2151 return *(
end() - 1);
2232 [inMin, inMax](dtype value) noexcept -> dtype
2234 #ifdef __cpp_lib_clamp
2235 const auto comparitor = [](dtype lhs, dtype rhs) noexcept -> bool
2236 { return lhs < rhs; };
2238 return std::clamp(value, inMin, inMax, comparitor);
2244 else if (value > inMax)
2265 return operator()(rSlice(), inColumn);
2290 for (
uint32 row = 0; row < shape_.rows; ++row)
2340 returnArray[0] = front();
2341 for (
uint32 i = 1; i < size_; ++i)
2343 returnArray[i] = returnArray[i - 1] * array_[i];
2351 for (
uint32 row = 0; row < shape_.rows; ++row)
2353 returnArray(row, 0) = operator()(row, 0);
2354 for (
uint32 col = 1; col < shape_.cols; ++col)
2356 returnArray(row, col) = returnArray(row, col - 1) * operator()(row, col);
2392 returnArray[0] = front();
2393 for (
uint32 i = 1; i < size_; ++i)
2395 returnArray[i] = returnArray[i - 1] + array_[i];
2403 for (
uint32 row = 0; row < shape_.rows; ++row)
2405 returnArray(row, 0) = operator()(row, 0);
2406 for (
uint32 col = 1; col < shape_.cols; ++col)
2408 returnArray(row, col) = returnArray(row, col - 1) + operator()(row, col);
2476 std::vector<dtype> diagnolValues;
2478 for (
int32 row = inOffset; row < static_cast<int32>(shape_.rows); ++row)
2485 if (col >= shape_.cols)
2490 diagnolValues.push_back(
operator()(
static_cast<uint32>(row), col));
2524 if (shape_ == inOtherArray.shape_ && (shape_.rows == 1 || shape_.cols == 1))
2526 dtype dotProduct = std::inner_product(cbegin(), cend(), inOtherArray.
cbegin(), dtype{ 0 });
2530 if (shape_.cols == inOtherArray.shape_.
rows)
2534 auto otherArrayT = inOtherArray.
transpose();
2536 for (
uint32 i = 0; i < shape_.rows; ++i)
2538 for (
uint32 j = 0;
j < otherArrayT.shape_.rows; ++
j)
2541 std::inner_product(otherArrayT.cbegin(
j), otherArrayT.cend(
j), cbegin(i), dtype{ 0 });
2551 errStr +=
" are not consistent.";
2566 void dump(
const std::string& inFilename)
const
2574 std::ofstream ofile(
f.fullName().c_str(), std::ios::binary);
2580 if (array_ !=
nullptr)
2582 ofile.write(
reinterpret_cast<const char*
>(array_), size_ *
sizeof(dtype));
2626 std::vector<uint32> indices;
2628 for (
auto value : *
this)
2630 if (value != dtype{ 0 })
2632 indices.push_back(idx);
2685 return *cbegin(row);
2708 return operator[](inIndices);
2722 return operator[](inMask);
2746 return shape_.rows == 1 || shape_.cols == 1;
2760 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
2771 for (
uint32 row = 0; row < shape_.rows; ++row)
2798 return shape_.issquare();
2832 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
2844 for (
uint32 row = 0; row < shape_.rows; ++row)
2876 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
2888 for (
uint32 row = 0; row < shape_.rows; ++row)
2922 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
2935 const uint32 middleIdx = size_ / 2;
2937 copyArray.
begin() + middleIdx,
2941 dtype medianValue = copyArray.array_[middleIdx];
2944 const uint32 lhsIndex = middleIdx - 1;
2946 copyArray.
begin() + lhsIndex,
2950 (medianValue + copyArray.array_[lhsIndex]) / dtype{ 2 };
2953 return { medianValue };
2960 const bool isEven = shape_.cols % 2 == 0;
2961 for (
uint32 row = 0; row < shape_.rows; ++row)
2963 const uint32 middleIdx = shape_.cols / 2;
2965 copyArray.
begin(row) + middleIdx,
2969 dtype medianValue = copyArray(row, middleIdx);
2972 const uint32 lhsIndex = middleIdx - 1;
2974 copyArray.
begin(row) + lhsIndex,
2977 medianValue = (medianValue + copyArray(row, lhsIndex)) /
2981 returnArray(0, row) = medianValue;
3022 return static_cast<uint64>(
sizeof(dtype) * size_);
3045 switch (inEndianess)
3064 auto outArray =
NdArray(*
this);
3073 auto outArray =
NdArray(*
this);
3097 switch (inEndianess)
3112 auto outArray =
NdArray(*
this);
3140 switch (inEndianess)
3146 auto outArray =
NdArray(*
this);
3202 const auto function = [](dtype i) ->
bool {
return i != dtype{ 0 }; };
3214 for (
uint32 row = 0; row < shape_.rows; ++row)
3312 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
3330 if (inKth >= shape_.cols)
3333 errStr +=
") out of bounds (" +
utils::num2str(shape_.cols) +
")";
3337 for (
uint32 row = 0; row < shape_.rows; ++row)
3345 if (inKth >= shape_.rows)
3348 errStr +=
") out of bounds (" +
utils::num2str(shape_.rows) +
")";
3353 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3356 transposedArray.
begin(row) + inKth,
3357 transposedArray.
end(row),
3397 dtype product = std::accumulate(cbegin(), cend(), dtype{ 1 }, std::multiplies<dtype>());
3404 for (
uint32 row = 0; row < shape_.rows; ++row)
3406 returnArray(0, row) =
3407 std::accumulate(cbegin(row), cend(row), dtype{ 1 }, std::multiplies<dtype>());
3437 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
3450 for (
uint32 row = 0; row < shape_.rows; ++row)
3453 returnArray(0, row) = *result.second - *result.first;
3481 at(inIndex) = inValue;
3498 at(inRow, inCol) = inValue;
3514 for (
auto index : inIndices)
3516 put(index, inValue);
3533 if (inIndices.
size() != inValues.
size())
3539 for (
auto index : inIndices)
3541 put(index, inValues[counter++]);
3558 Slice inSliceCopy(inSlice);
3580 Slice inSliceCopy(inSlice);
3583 std::vector<uint32> indices;
3586 indices.push_back(i);
3604 Slice inRowSliceCopy(inRowSlice);
3605 Slice inColSliceCopy(inColSlice);
3610 std::vector<uint32> indices;
3611 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3613 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3615 put(row, col, inValue);
3634 Slice inRowSliceCopy(inRowSlice);
3637 std::vector<uint32> indices;
3638 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3640 put(row, inColIndex, inValue);
3658 Slice inColSliceCopy(inColSlice);
3661 std::vector<uint32> indices;
3662 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3664 put(inRowIndex, col, inValue);
3682 Slice inRowSliceCopy(inRowSlice);
3683 Slice inColSliceCopy(inColSlice);
3688 std::vector<uint32> indices;
3689 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3691 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3693 const uint32 index = row * shape_.cols + col;
3694 indices.push_back(index);
3713 Slice inRowSliceCopy(inRowSlice);
3716 std::vector<uint32> indices;
3717 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3719 const uint32 index = row * shape_.cols + inColIndex;
3720 indices.push_back(index);
3738 Slice inColSliceCopy(inColSlice);
3741 std::vector<uint32> indices;
3742 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3744 const uint32 index = inRowIndex * shape_.cols + col;
3745 indices.push_back(index);
3760 if (inMask.
shape() != shape_)
3777 if (inMask.
shape() != shape_)
3811 NdArray<dtype> returnArray(shape_.rows * inNumRows, shape_.cols * inNumCols);
3813 for (
uint32 row = 0; row < inNumRows; ++row)
3815 for (
uint32 col = 0; col < inNumCols; ++col)
3817 std::vector<uint32> indices(shape_.size());
3819 const uint32 rowStart = row * shape_.rows;
3820 const uint32 colStart = col * shape_.cols;
3822 const uint32 rowEnd = (row + 1) * shape_.rows;
3823 const uint32 colEnd = (col + 1) * shape_.cols;
3826 for (
uint32 rowIdx = rowStart; rowIdx < rowEnd; ++rowIdx)
3828 for (
uint32 colIdx = colStart; colIdx < colEnd; ++colIdx)
3830 indices[counter++] = rowIdx * returnArray.shape_.
cols + colIdx;
3882 if (inSize != size_)
3884 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into shape ";
3890 shape_.cols = inSize;
3911 if (size_ % inNumCols == 0)
3913 return reshape(size_ / inNumCols, inNumCols);
3916 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into a shape ";
3923 if (size_ % inNumRows == 0)
3925 return reshape(inNumRows, size_ / inNumRows);
3928 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into a shape ";
3933 if (
static_cast<uint32>(inNumRows * inNumCols) != size_)
3935 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into shape ";
3940 shape_.rows =
static_cast<uint32>(inNumRows);
3941 shape_.cols =
static_cast<uint32>(inNumCols);
3974 newArray(
Shape(inNumRows, inNumCols));
4006 std::vector<dtype> oldData(size_);
4009 const Shape inShape(inNumRows, inNumCols);
4010 const Shape oldShape = shape_;
4014 for (
uint32 row = 0; row < inShape.
rows; ++row)
4016 for (
uint32 col = 0; col < inShape.
cols; ++col)
4018 if (row >= oldShape.
rows || col >= oldShape.
cols)
4020 operator()(row, col) = dtype{ 0 };
4024 operator()(row, col) = oldData[row * oldShape.
cols + col];
4063 const double multFactor =
utils::power(10., inNumDecimals);
4064 const auto function = [multFactor](dtype value) noexcept -> dtype
4065 {
return static_cast<dtype
>(std::nearbyint(
static_cast<double>(value) * multFactor) / multFactor); };
4123 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool {
return lhs < rhs; };
4134 for (
uint32 row = 0; row < shape_.rows; ++row)
4143 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
4168 for (
uint32 row = 0; row < shape_.rows; ++row)
4171 for (
uint32 col = 0; col < shape_.cols; ++col)
4176 if (row == shape_.rows - 1)
4206 NdArray<dtype> returnArray = { std::accumulate(cbegin(), cend(), dtype{ 0 }) };
4212 for (
uint32 row = 0; row < shape_.rows; ++row)
4214 returnArray(0, row) = std::accumulate(cbegin(row), cend(row), dtype{ 0 });
4253 for (
int32 row = 0; row < static_cast<int32>(shape_.rows); ++row)
4255 std::swap(
operator()(row, colIdx1),
operator()(row, colIdx2));
4268 for (
int32 col = 0; col < static_cast<int32>(shape_.cols); ++col)
4270 std::swap(
operator()(rowIdx1, col),
operator()(rowIdx2, col));
4285 void tofile(
const std::string& inFilename)
const
4302 void tofile(
const std::string& inFilename,
const char inSep)
const
4312 std::ofstream ofile(
f.fullName().c_str());
4319 for (
auto value : *
this)
4322 if (counter++ != size_ - 1)
4366 if (numElements == 0)
4372 indices[0] = inSlice.
start;
4375 indices[i] =
static_cast<uint32>(indices[i - 1] + inSlice.
step);
4389 return std::vector<dtype>(cbegin(), cend());
4414 rowStart += inOffset;
4419 colStart += inOffset;
4430 if (rowStart >= shape_.rows || colStart >= shape_.cols)
4437 for (
uint32 row = rowStart; row < shape_.rows; ++row)
4439 if (col >= shape_.cols)
4443 sum += operator()(row, col++);
4460 for (
uint32 row = 0; row < shape_.rows; ++row)
4462 for (
uint32 col = 0; col < shape_.cols; ++col)
4464 transArray(col, row) = operator()(row, col);
4485 allocator_type allocator_{};
4486 Shape shape_{ 0, 0 };
4487 size_type size_{ 0 };
4489 pointer array_{
nullptr };
4490 bool ownsPtr_{
false };
4496 void deleteArray() noexcept
4498 if (ownsPtr_ && array_ !=
nullptr)
4500 allocator_.deallocate(array_, size_);
4504 shape_.rows = shape_.cols = 0;
4518 array_ = allocator_.allocate(size_);
4529 void newArray(
const Shape& inShape)
4534 size_ = inShape.size();
4541 template<
typename dtype,
class _Alloc>
4546 std::vector<uint32> rowIndices;
4547 std::vector<uint32> colIndices;
4549 for (
uint32 row = 0; row < shape_.rows; ++row)
4551 for (
uint32 col = 0; col < shape_.cols; ++col)
4553 if (
operator()(row, col) != dtype{ 0 })
4555 rowIndices.push_back(row);
4556 colIndices.push_back(col);
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:38
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:45
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:49
#define STATIC_ASSERT_INTEGER(dtype)
Definition: StaticAsserts.hpp:40
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Custom column iterator for NdArray.
Definition: NdArrayIterators.hpp:818
Custom column const_iterator for NdArray.
Definition: NdArrayIterators.hpp:492
Custom const_iterator for NdArray.
Definition: NdArrayIterators.hpp:42
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
uint32 numCols() const noexcept
Definition: NdArrayCore.hpp:3252
NdArray(std::vector< std::array< dtype, Dim1Size >> &in2dArray, bool copy=true)
Definition: NdArrayCore.hpp:323
const_reverse_column_iterator rcolbegin() const noexcept
Definition: NdArrayCore.hpp:1429
NdArray< dtype > at(const NdArray< int32 > &rowIndices, const NdArray< int32 > &colIndices) const
Definition: NdArrayCore.hpp:1159
NdArray< dtypeOut > astype() const
Definition: NdArrayCore.hpp:2037
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3479
size_type size() const noexcept
Definition: NdArrayCore.hpp:4105
reverse_iterator rbegin() noexcept
Definition: NdArrayCore.hpp:1325
NdArray< dtype > & resizeSlow(uint32 inNumRows, uint32 inNumCols)
Definition: NdArrayCore.hpp:4004
NdArray< dtype > & put(const Slice &inRowSlice, const Slice &inColSlice, value_type inValue)
Definition: NdArrayCore.hpp:3602
NdArray< bool > issorted(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2756
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1221
NdArray< dtype > operator[](const Indices &inIndices) const
Definition: NdArrayCore.hpp:761
const_reference at(int32 inIndex) const
Definition: NdArrayCore.hpp:1016
const_column_iterator ccolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1310
NdArrayConstColumnIterator< dtype, size_type, const_pointer, difference_type > const_column_iterator
Definition: NdArrayCore.hpp:97
NdArray< dtype > round(uint8 inNumDecimals=0) const
Definition: NdArrayCore.hpp:4058
NdArray< bool > any(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1835
const_pointer data() const noexcept
Definition: NdArrayCore.hpp:2441
NdArray< uint32 > toIndices(Slice inSlice, Axis inAxis=Axis::ROW) const
Definition: NdArrayCore.hpp:4339
NdArray< dtype > at(const Slice &inRowSlice, int32 inColIndex) const
Definition: NdArrayCore.hpp:1129
iterator end() noexcept
Definition: NdArrayCore.hpp:1479
NdArray< dtype > operator()(Slice inRowSlice, int32 inColIndex) const
Definition: NdArrayCore.hpp:815
NdArray< dtype > & put(const Slice &inRowSlice, const Slice &inColSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3680
NdArray(std::vector< dtype > &inVector, bool copy=true)
Definition: NdArrayCore.hpp:263
NdArray< dtype > prod(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3389
NdArray< dtype > copy() const
Definition: NdArrayCore.hpp:2317
NdArray< dtype > & resizeFast(const Shape &inShape)
Definition: NdArrayCore.hpp:3987
std::vector< dtype > toStlVector() const
Definition: NdArrayCore.hpp:4387
reference back(size_type row)
Definition: NdArrayCore.hpp:2171
iterator end(size_type inRow)
Definition: NdArrayCore.hpp:1491
NdArray< dtype > flatten() const
Definition: NdArrayCore.hpp:2648
NdArray(const std::initializer_list< std::initializer_list< dtype >> &inList)
Definition: NdArrayCore.hpp:170
void tofile(const std::string &inFilename, const char inSep) const
Definition: NdArrayCore.hpp:4302
const_column_iterator ccolbegin() const noexcept
Definition: NdArrayCore.hpp:1298
typename AllocTraits::pointer pointer
Definition: NdArrayCore.hpp:84
Slice cSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:969
reverse_iterator rbegin(size_type inRow)
Definition: NdArrayCore.hpp:1337
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4092
NdArray< dtype > & byteswap() noexcept
Definition: NdArrayCore.hpp:2184
const_reverse_column_iterator rcolend() const noexcept
Definition: NdArrayCore.hpp:1737
uint32 numRows() const noexcept
Definition: NdArrayCore.hpp:3264
const dtype & const_reference
Definition: NdArrayCore.hpp:87
NdArray< dtype > & put(const Slice &inRowSlice, int32 inColIndex, value_type inValue)
Definition: NdArrayCore.hpp:3632
NdArray< dtype > & partition(uint32 inKth, Axis inAxis=Axis::NONE)
Definition: NdArrayCore.hpp:3308
bool issquare() const noexcept
Definition: NdArrayCore.hpp:2796
NdArrayIterator< dtype, pointer, difference_type > iterator
Definition: NdArrayCore.hpp:91
bool isflat() const noexcept
Definition: NdArrayCore.hpp:2744
Endian endianess() const noexcept
Definition: NdArrayCore.hpp:2593
void tofile(const std::string &inFilename) const
Definition: NdArrayCore.hpp:4285
const_reverse_column_iterator crcolbegin() const noexcept
Definition: NdArrayCore.hpp:1452
const_reverse_column_iterator crcolend(size_type inCol) const
Definition: NdArrayCore.hpp:1772
column_iterator colbegin(size_type inCol)
Definition: NdArrayCore.hpp:1260
NdArrayColumnIterator< dtype, size_type, pointer, difference_type > column_iterator
Definition: NdArrayCore.hpp:96
NdArray< bool > none(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3198
NdArray< dtype > at(const Slice &inSlice) const
Definition: NdArrayCore.hpp:1099
reference at(int32 inIndex)
Definition: NdArrayCore.hpp:995
NdArray< dtype > & sort(Axis inAxis=Axis::NONE)
Definition: NdArrayCore.hpp:4119
pointer data() noexcept
Definition: NdArrayCore.hpp:2431
bool isempty() const noexcept
Definition: NdArrayCore.hpp:2732
column_iterator colbegin() noexcept
Definition: NdArrayCore.hpp:1248
const_reference front(size_type row) const
Definition: NdArrayCore.hpp:2683
reverse_column_iterator rcolend(size_type inCol)
Definition: NdArrayCore.hpp:1722
NdArray< dtype > sum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:4198
NdArray(Iterator inFirst, Iterator inLast)
Definition: NdArrayCore.hpp:419
NdArray< dtype > operator[](const Slice &inSlice) const
Definition: NdArrayCore.hpp:713
reverse_column_iterator rcolbegin() noexcept
Definition: NdArrayCore.hpp:1402
NdArrayConstIterator< dtype, const_pointer, difference_type > const_iterator
Definition: NdArrayCore.hpp:92
const_iterator cbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1233
const_column_iterator ccolend(size_type inCol) const
Definition: NdArrayCore.hpp:1695
NdArray< dtype > cumsum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2383
NdArray< dtype > median(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2918
NdArray< dtype > getByMask(const NdArray< bool > &inMask) const
Definition: NdArrayCore.hpp:2720
const_iterator cend(size_type inRow) const
Definition: NdArrayCore.hpp:1541
NdArray< dtype > column(uint32 inColumn)
Definition: NdArrayCore.hpp:2263
const_reverse_column_iterator rcolend(size_type inCol) const
Definition: NdArrayCore.hpp:1749
NdArray< dtype > & putMask(const NdArray< bool > &inMask, value_type inValue)
Definition: NdArrayCore.hpp:3758
const_iterator end(size_type inRow) const
Definition: NdArrayCore.hpp:1518
reference back() noexcept
Definition: NdArrayCore.hpp:2149
const_reverse_column_iterator crcolend() const noexcept
Definition: NdArrayCore.hpp:1760
const_reference back(size_type row) const
Definition: NdArrayCore.hpp:2160
reverse_column_iterator rcolbegin(size_type inCol)
Definition: NdArrayCore.hpp:1414
NdArray(const std::deque< std::deque< dtype >> &in2dDeque)
Definition: NdArrayCore.hpp:367
NdArray< dtype > & put(int32 inRow, int32 inCol, value_type inValue)
Definition: NdArrayCore.hpp:3496
iterator begin(size_type inRow)
Definition: NdArrayCore.hpp:1183
const_reverse_iterator rend() const noexcept
Definition: NdArrayCore.hpp:1583
NdArray< dtype > clip(value_type inMin, value_type inMax) const
Definition: NdArrayCore.hpp:2224
const_reverse_column_iterator rcolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1441
NdArray< dtype > & operator=(NdArray< dtype > &&rhs) noexcept
Definition: NdArrayCore.hpp:606
typename AllocTraits::difference_type difference_type
Definition: NdArrayCore.hpp:89
NdArray< uint32 > argmin(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1927
const_iterator end() const noexcept
Definition: NdArrayCore.hpp:1506
bool ownsInternalData() noexcept
Definition: NdArrayCore.hpp:3288
NdArray< dtype > & fill(value_type inFillValue) noexcept
Definition: NdArrayCore.hpp:2609
column_iterator colend() noexcept
Definition: NdArrayCore.hpp:1633
NdArray(std::initializer_list< dtype > inList)
Definition: NdArrayCore.hpp:153
NdArray< dtype > operator()(Slice inRowSlice, Slice inColSlice) const
Definition: NdArrayCore.hpp:787
NdArray< dtype > & put(const NdArray< uint32 > &inIndices, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3531
const_reference back() const noexcept
Definition: NdArrayCore.hpp:2138
NdArray< dtype > operator()(int32 inRowIndex, Slice inColSlice) const
Definition: NdArrayCore.hpp:837
std::pair< NdArray< uint32 >, NdArray< uint32 > > nonzero() const
Definition: NdArrayCore.hpp:4542
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: NdArrayCore.hpp:94
NdArray(const_pointer inPtr, UIntType1 numRows, UIntType2 numCols)
Definition: NdArrayCore.hpp:462
NdArray< dtype > cumprod(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2331
uint64 nbytes() const noexcept
Definition: NdArrayCore.hpp:3020
const_reference at(int32 inRowIndex, int32 inColIndex) const
Definition: NdArrayCore.hpp:1069
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4457
NdArray< dtype > swapaxes() const
Definition: NdArrayCore.hpp:4239
NdArray< dtype > & put(int32 inRowIndex, const Slice &inColSlice, value_type inValue)
Definition: NdArrayCore.hpp:3656
NdArray(const std::list< dtype > &inList)
Definition: NdArrayCore.hpp:399
NdArray< dtype > at(int32 inRowIndex, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:1144
const_reference front() const noexcept
Definition: NdArrayCore.hpp:2661
NdArray< dtype > repeat(const Shape &inRepeatShape) const
Definition: NdArrayCore.hpp:3850
~NdArray() noexcept
Definition: NdArrayCore.hpp:553
NdArray< dtype > min(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2872
NdArray< dtype > & reshape(const Shape &inShape)
Definition: NdArrayCore.hpp:3957
reference front() noexcept
Definition: NdArrayCore.hpp:2672
NdArray(size_type inNumRows, size_type inNumCols)
Definition: NdArrayCore.hpp:127
Allocator allocator_type
Definition: NdArrayCore.hpp:83
void print() const
Definition: NdArrayCore.hpp:3373
void swapCols(int32 colIdx1, int32 colIdx2) noexcept
Definition: NdArrayCore.hpp:4251
const_reverse_column_iterator crcolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1464
reverse_iterator rend(size_type inRow)
Definition: NdArrayCore.hpp:1568
NdArray< uint32 > flatnonzero() const
Definition: NdArrayCore.hpp:2622
NdArray(size_type inSquareSize)
Definition: NdArrayCore.hpp:113
NdArray< dtype > operator()(int32 rowIndex, const Indices &colIndices) const
Definition: NdArrayCore.hpp:894
reverse_iterator rend() noexcept
Definition: NdArrayCore.hpp:1556
const_reverse_iterator rend(size_type inRow) const
Definition: NdArrayCore.hpp:1595
NdArray< dtype > getByIndices(const NdArray< uint32 > &inIndices) const
Definition: NdArrayCore.hpp:2706
typename AllocTraits::const_pointer const_pointer
Definition: NdArrayCore.hpp:85
NdArray< dtype > & resizeSlow(const Shape &inShape)
Definition: NdArrayCore.hpp:4043
const_reverse_iterator crbegin() const noexcept
Definition: NdArrayCore.hpp:1375
const_column_iterator colend(size_type inCol) const
Definition: NdArrayCore.hpp:1672
std::reverse_iterator< iterator > reverse_iterator
Definition: NdArrayCore.hpp:93
NdArray< dtype > operator()(const Indices &rowIndices, Slice colSlice) const
Definition: NdArrayCore.hpp:878
NdArray(const std::vector< std::vector< dtype >> &in2dVector)
Definition: NdArrayCore.hpp:288
const_reverse_iterator rbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1364
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1529
std::string str() const
Definition: NdArrayCore.hpp:4162
std::reverse_iterator< const_column_iterator > const_reverse_column_iterator
Definition: NdArrayCore.hpp:99
reference operator[](int32 inIndex) noexcept
Definition: NdArrayCore.hpp:632
NdArray< dtype > & reshape(int32 inNumRows, int32 inNumCols)
Definition: NdArrayCore.hpp:3907
NdArray(NdArray< dtype > &&inOtherArray) noexcept
Definition: NdArrayCore.hpp:536
NdArray< dtype > & nans() noexcept
Definition: NdArrayCore.hpp:3003
NdArray< dtype > & put(const NdArray< uint32 > &inIndices, value_type inValue)
Definition: NdArrayCore.hpp:3512
NdArray< dtype > ptp(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3433
const_reference operator()(int32 inRowIndex, int32 inColIndex) const noexcept
Definition: NdArrayCore.hpp:690
reference front(size_type row)
Definition: NdArrayCore.hpp:2694
NdArray< dtype > diagonal(int32 inOffset=0, Axis inAxis=Axis::ROW) const
Definition: NdArrayCore.hpp:2470
NdArray(pointer inPtr, uint32 numRows, uint32 numCols, BoolType takeOwnership) noexcept
Definition: NdArrayCore.hpp:504
NdArray< dtype > & putMask(const NdArray< bool > &inMask, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3775
NdArray< dtype > operator[](const NdArray< bool > &inMask) const
Definition: NdArrayCore.hpp:734
NdArray< dtype > row(uint32 inRow)
Definition: NdArrayCore.hpp:4079
NdArray< dtype > operator()(const Indices &rowIndices, int32 colIndex) const
Definition: NdArrayCore.hpp:861
const_iterator begin(size_type inRow) const
Definition: NdArrayCore.hpp:1210
iterator begin() noexcept
Definition: NdArrayCore.hpp:1171
NdArray< dtype > & put(const Slice &inSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3578
const_column_iterator colbegin() const noexcept
Definition: NdArrayCore.hpp:1275
NdArray< dtype > max(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2828
std::reverse_iterator< column_iterator > reverse_column_iterator
Definition: NdArrayCore.hpp:98
void swapRows(int32 rowIdx1, int32 rowIdx2) noexcept
Definition: NdArrayCore.hpp:4266
NdArray< dtype > & operator=(const NdArray< dtype > &rhs)
Definition: NdArrayCore.hpp:565
value_type item() const
Definition: NdArrayCore.hpp:2809
reference operator()(int32 inRowIndex, int32 inColIndex) noexcept
Definition: NdArrayCore.hpp:667
const_column_iterator colend() const noexcept
Definition: NdArrayCore.hpp:1660
NdArray< dtype > & resizeFast(uint32 inNumRows, uint32 inNumCols)
Definition: NdArrayCore.hpp:3972
const_reverse_iterator crend() const noexcept
Definition: NdArrayCore.hpp:1606
NdArray< dtype > & ones() noexcept
Definition: NdArrayCore.hpp:3274
NdArray< dtype > operator()(RowIndices rowIndices, ColIndices colIndices) const
Definition: NdArrayCore.hpp:929
NdArray< dtype > & zeros() noexcept
Definition: NdArrayCore.hpp:4475
const_column_iterator colbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1287
NdArray< dtype > dot(const NdArray< dtype > &inOtherArray) const
Definition: NdArrayCore.hpp:2520
NdArray< dtype > repeat(uint32 inNumRows, uint32 inNumCols) const
Definition: NdArrayCore.hpp:3809
NdArray< dtype > & reshape(size_type inSize)
Definition: NdArrayCore.hpp:3880
NdArray< bool > contains(value_type inValue, Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2276
const_column_iterator ccolend() const noexcept
Definition: NdArrayCore.hpp:1683
NdArray< uint32 > argmax(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1880
value_type trace(uint32 inOffset=0, Axis inAxis=Axis::ROW) const noexcept
Definition: NdArrayCore.hpp:4404
reverse_column_iterator rcolend() noexcept
Definition: NdArrayCore.hpp:1710
NdArray(std::array< dtype, ArraySize > &inArray, bool copy=true)
Definition: NdArrayCore.hpp:206
NdArray< dtype > & put(int32 inRowIndex, const Slice &inColSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3736
const_reverse_iterator rbegin() const noexcept
Definition: NdArrayCore.hpp:1352
NdArray(const_pointer inPtr, size_type size)
Definition: NdArrayCore.hpp:438
NdArray(const std::deque< dtype > &inDeque)
Definition: NdArrayCore.hpp:350
NdArray(std::array< std::array< dtype, Dim1Size >, Dim0Size > &in2dArray, bool copy=true)
Definition: NdArrayCore.hpp:234
void dump(const std::string &inFilename) const
Definition: NdArrayCore.hpp:2566
dtype & reference
Definition: NdArrayCore.hpp:86
pointer dataRelease() noexcept
Definition: NdArrayCore.hpp:2453
reference at(int32 inRowIndex, int32 inColIndex)
Definition: NdArrayCore.hpp:1038
NdArray< dtype > at(const Slice &inRowSlice, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:1114
NdArray< dtype > operator()(Slice rowSlice, const Indices &colIndices) const
Definition: NdArrayCore.hpp:911
NdArray(const NdArray< dtype > &inOtherArray)
Definition: NdArrayCore.hpp:518
NdArray< uint32 > argsort(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1973
uint32 size_type
Definition: NdArrayCore.hpp:88
const_iterator begin() const noexcept
Definition: NdArrayCore.hpp:1198
NdArray< dtype > & operator=(value_type inValue) noexcept
Definition: NdArrayCore.hpp:589
NdArray< dtype > newbyteorder(Endian inEndianess) const
Definition: NdArrayCore.hpp:3035
column_iterator colend(size_type inCol)
Definition: NdArrayCore.hpp:1645
NdArray< dtype > & put(const Slice &inSlice, value_type inValue)
Definition: NdArrayCore.hpp:3556
const_reference operator[](int32 inIndex) const noexcept
Definition: NdArrayCore.hpp:649
NdArray< dtype > & ravel() noexcept
Definition: NdArrayCore.hpp:3793
dtype value_type
Definition: NdArrayCore.hpp:82
void replace(value_type oldValue, value_type newValue)
Definition: NdArrayCore.hpp:3862
NdArray< dtype > & put(const Slice &inRowSlice, int32 inColIndex, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3711
Slice rSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:983
const_reverse_iterator crend(size_type inRow) const
Definition: NdArrayCore.hpp:1618
const_reverse_iterator crbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1387
NdArray(pointer inPtr, size_type size, BoolType takeOwnership) noexcept
Definition: NdArrayCore.hpp:484
NdArray(const Shape &inShape)
Definition: NdArrayCore.hpp:140
NdArray< bool > all(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1791
Custom iterator for NdArray.
Definition: NdArrayIterators.hpp:318
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:44
int32 step
Definition: Slice.hpp:49
int32 start
Definition: Slice.hpp:47
void makePositiveAndValidate(uint32 inArraySize)
Definition: Slice.hpp:141
uint32 numElements(uint32 inArraySize)
Definition: Slice.hpp:196
int32 stop
Definition: Slice.hpp:48
Provides simple filesystem functions.
Definition: Filesystem.hpp:40
constexpr auto j
Definition: Constants.hpp:45
const double nan
NaN.
Definition: Constants.hpp:44
bool isLittleEndian() noexcept
Definition: Endian.hpp:44
dtype byteSwap(dtype value) noexcept
Definition: Endian.hpp:63
dtype f(GeneratorType &generator, dtype inDofN, dtype inDofD)
Definition: f.hpp:58
bool any_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:78
void sort(RandomIt first, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:705
bool none_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:408
ForwardIt max_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:287
void stable_sort(RandomIt first, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:743
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:784
bool all_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:57
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:227
InputIt find(InputIt first, InputIt last, const T &value) noexcept
Definition: StlAlgorithms.hpp:207
constexpr OutputIt unique_copy(InputIt first, InputIt last, OutputIt destination) noexcept
Definition: StlAlgorithms.hpp:835
std::pair< ForwardIt, ForwardIt > minmax_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:366
void replace(ForwardIt first, ForwardIt last, const T &oldValue, const T &newValue) noexcept
Definition: StlAlgorithms.hpp:471
bool is_sorted(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:247
OutputIt copy(InputIt first, InputIt last, OutputIt destination) noexcept
Definition: StlAlgorithms.hpp:99
void nth_element(RandomIt first, RandomIt nth, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:428
ForwardIt min_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:326
void fill(ForwardIt first, ForwardIt last, const T &value) noexcept
Definition: StlAlgorithms.hpp:185
std::string num2str(dtype inNumber)
Definition: num2str.hpp:46
dtype power(dtype inValue, uint8 inPower) noexcept
Definition: Utils/power.hpp:48
std::string value2str(dtype inValue)
Definition: value2str.hpp:48
Definition: Coordinate.hpp:45
NdArray< dtype > repeat(const NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: repeat.hpp:49
void swap(NdArray< dtype > &inArray1, NdArray< dtype > &inArray2) noexcept
Definition: swap.hpp:42
std::pair< NdArray< uint32 >, NdArray< uint32 > > nonzero(const NdArray< dtype > &inArray)
Definition: nonzero.hpp:48
NdArray< dtype > & resizeFast(NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: resizeFast.hpp:50
Axis
Enum To describe an axis.
Definition: Types.hpp:47
NdArray< dtype > & reshape(NdArray< dtype > &inArray, uint32 inSize)
Definition: reshape.hpp:51
std::int64_t int64
Definition: Types.hpp:35
auto abs(dtype inValue) noexcept
Definition: abs.hpp:49
std::uint64_t uint64
Definition: Types.hpp:39
NdArray< dtype > & resizeSlow(NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: resizeSlow.hpp:52
Endian
Enum for endianess.
Definition: Types.hpp:56
std::int32_t int32
Definition: Types.hpp:36
std::uint8_t uint8
Definition: Types.hpp:42
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:46
NdArray< dtype > & put(NdArray< dtype > &inArray, const NdArray< uint32 > &inIndices, dtype inValue)
Definition: put.hpp:48
NdArray< dtype > transpose(const NdArray< dtype > &inArray)
Definition: transpose.hpp:45
typename std::enable_if< B, T >::type enable_if_t
Definition: TypeTraits.hpp:40
std::uint32_t uint32
Definition: Types.hpp:40
void dump(const NdArray< dtype > &inArray, const std::string &inFilename)
Definition: dump.hpp:46