 |
NumCpp
2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
|
Go to the documentation of this file.
51 #include <forward_list>
53 #include <initializer_list>
61 #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>,
"value_type and Allocator::value_type must match");
77 using AllocType =
typename std::allocator_traits<Allocator>::template rebind_alloc<dtype>;
78 using AllocTraits = std::allocator_traits<AllocType>;
83 using pointer =
typename AllocTraits::pointer;
114 shape_(inSquareSize, inSquareSize),
115 size_(inSquareSize * inSquareSize)
128 shape_(inNumRows, inNumCols),
129 size_(inNumRows * inNumCols)
155 NdArray(
const std::initializer_list<dtype>& inList) :
156 shape_(1, static_cast<
uint32>(inList.
size())),
173 NdArray(
const std::initializer_list<std::initializer_list<dtype> >& inList) :
176 for (
const auto& list : inList)
178 if (shape_.
cols == 0)
180 shape_.
cols =
static_cast<uint32>(list.size());
182 else if (list.size() != shape_.
cols)
188 size_ = shape_.
size();
191 for (
const auto& list : inList)
207 template<
size_t ArraySize,
208 std::enable_if_t<is_valid_dtype_v<dtype>,
int> = 0>
209 NdArray(std::array<dtype, ArraySize>& inArray,
bool copy =
true) :
210 shape_(1, static_cast<
uint32>(ArraySize)),
223 array_ = inArray.data();
236 template<
size_t Dim0Size,
size_t Dim1Size>
237 NdArray(std::array<std::array<dtype, Dim1Size>, Dim0Size>& in2dArray,
bool copy =
true) :
238 shape_(static_cast<
uint32>(Dim0Size), static_cast<
uint32>(Dim1Size)),
246 const auto start = in2dArray.front().begin();
252 array_ = in2dArray.front().data();
265 template<std::enable_if_t<is_val
id_dtype_v<dtype>,
int> = 0>
267 shape_(1, static_cast<
uint32>(inVector.
size())),
280 array_ = inVector.data();
291 explicit NdArray(
const std::vector<std::vector<dtype>>& in2dVector) :
292 shape_(static_cast<
uint32>(in2dVector.
size()), 0)
294 for (
const auto&
row : in2dVector)
296 if (shape_.
cols == 0)
306 size_ = shape_.
size();
309 auto currentPosition =
begin();
310 for (
const auto&
row : in2dVector)
313 currentPosition += shape_.
cols;
325 template<
size_t Dim1Size>
326 NdArray(std::vector<std::array<dtype, Dim1Size>>& in2dArray,
bool copy =
true) :
327 shape_(static_cast<
uint32>(in2dArray.
size()), static_cast<
uint32>(Dim1Size)),
335 const auto start = in2dArray.front().begin();
341 array_ = in2dArray.front().data();
352 template<std::enable_if_t<is_val
id_dtype_v<dtype>,
int> = 0>
353 explicit NdArray(
const std::deque<dtype>& inDeque) :
354 shape_(1, static_cast<
uint32>(inDeque.
size())),
370 explicit NdArray(
const std::deque<std::deque<dtype>>& in2dDeque) :
371 shape_(static_cast<
uint32>(in2dDeque.
size()), 0)
373 for (
const auto&
row : in2dDeque)
375 if (shape_.
cols == 0)
385 size_ = shape_.
size();
388 auto currentPosition =
begin();
389 for (
const auto&
row : in2dDeque)
392 currentPosition += shape_.
cols;
403 explicit NdArray(
const std::list<dtype>& inList) :
404 shape_(1, static_cast<
uint32>(inList.
size())),
421 template<
typename Iterator,
422 std::enable_if_t<std::is_same<typename std::iterator_traits<Iterator>::value_type, dtype>::value,
int> = 0>
424 shape_(1, static_cast<
uint32>(std::distance(inFirst, inLast))),
447 if (inPtr !=
nullptr && size_ > 0)
467 if (inPtr !=
nullptr && size_ > 0)
483 template<
typename Bool,
484 std::enable_if_t<std::is_same<Bool, bool>::value,
int> = 0>
489 ownsPtr_(takeOwnership)
503 template<
typename Bool,
504 std::enable_if_t<std::is_same<Bool, bool>::value,
int> = 0>
509 ownsPtr_(takeOwnership)
520 shape_(inOtherArray.shape_),
521 size_(inOtherArray.size_),
522 endianess_(inOtherArray.endianess_)
539 shape_(inOtherArray.shape_),
540 size_(inOtherArray.size_),
541 endianess_(inOtherArray.endianess_),
542 array_(inOtherArray.array_),
543 ownsPtr_(inOtherArray.ownsPtr_)
545 inOtherArray.shape_.rows = inOtherArray.shape_.cols = 0;
546 inOtherArray.size_ = 0;
547 inOtherArray.ownsPtr_ =
false;
548 inOtherArray.array_ =
nullptr;
575 newArray(rhs.shape_);
576 endianess_ = rhs.endianess_;
597 if (array_ !=
nullptr)
621 endianess_ = rhs.endianess_;
623 ownsPtr_ = rhs.ownsPtr_;
625 rhs.shape_.rows = rhs.shape_.cols = rhs.size_ = 0;
626 rhs.array_ =
nullptr;
627 rhs.ownsPtr_ =
false;
649 return array_[inIndex];
668 return array_[inIndex];
684 inRowIndex += shape_.
rows;
689 inColIndex += shape_.
cols;
692 return array_[inRowIndex * shape_.
cols + inColIndex];
708 inRowIndex += shape_.
rows;
713 inColIndex += shape_.
cols;
716 return array_[inRowIndex * shape_.
cols + inColIndex];
731 Slice inSliceCopy(inSlice);
737 returnArray[counter++] =
at(i);
754 if (inMask.
shape() != shape_)
761 for (
size_type i = 0; i < indices.size(); ++i)
780 if (inIndices.
max().item() > size_ - 1)
787 for (
auto& index : inIndices)
807 Slice inRowSliceCopy(inRowSlice);
808 Slice inColSliceCopy(inColSlice);
816 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
818 returnArray(rowCounter, colCounter++) =
at(
row, col);
839 Slice inRowSliceCopy(inRowSlice);
846 returnArray(rowCounter++, 0) =
at(
row, inColIndex);
864 Slice inColSliceCopy(inColSlice);
869 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
871 returnArray(0, colCounter++) =
at(inRowIndex, col);
889 return Slice(inStartIdx, shape_.
cols, inStepSize);
904 return Slice(inStartIdx, shape_.
rows, inStepSize);
923 errStr +=
" is out of bounds for array of size " +
utils::num2str(size_) +
".";
946 errStr +=
" is out of bounds for array of size " +
utils::num2str(size_) +
".";
977 std::string errStr =
"Column index " +
utils::num2str(inColIndex);
1001 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
rows) +
".";
1009 std::string errStr =
"Column index " +
utils::num2str(inColIndex);
1010 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
cols) +
".";
1103 if (inRow >= shape_.
rows)
1108 return begin() += (inRow * shape_.
cols);
1159 if (inRow >= shape_.
rows)
1189 if (inCol >= shape_.
cols)
1245 if (inCol >= shape_.
cols)
1275 if (inRow >= shape_.
rows)
1331 if (inRow >= shape_.
rows)
1361 if (inCol >= shape_.
cols)
1417 if (inCol >= shape_.
cols)
1433 return begin() += size_;
1447 if (inRow >= shape_.
rows)
1489 return cbegin() += size_;
1503 if (inRow >= shape_.
rows)
1519 return rbegin() += size_;
1533 if (inRow >= shape_.
rows)
1563 return crend(inRow);
1589 if (inRow >= shape_.
rows)
1619 if (inCol >= shape_.
cols)
1675 if (inCol >= shape_.
cols)
1705 if (inCol >= shape_.
cols)
1761 if (inCol >= shape_.
cols)
1784 const auto function = [](dtype i) ->
bool
1786 return i != dtype{ 0 };
1840 const auto function = [](dtype i) ->
bool
1842 return i != dtype{ 0 };
1897 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
1957 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
2020 std::vector<uint32> idx(size_);
2021 std::iota(idx.begin(), idx.end(), 0);
2023 const auto function = [
this](
uint32 i1,
uint32 i2) noexcept ->
bool
2025 return (*
this)[i1] < (*this)[i2];
2036 std::vector<uint32> idx(shape_.
cols);
2037 std::iota(idx.begin(), idx.end(), 0);
2039 const auto function = [
this,
row](
uint32 i1,
uint32 i2) noexcept ->
bool
2046 for (
uint32 col = 0; col < shape_.
cols; ++col)
2048 returnArray(
row, col) = idx[col];
2059 std::vector<uint32> idx(arrayTransposed.shape_.
cols);
2060 std::iota(idx.begin(), idx.end(), 0);
2062 const auto function = [&arrayTransposed,
row](
uint32 i1,
uint32 i2) noexcept ->
bool
2064 return arrayTransposed(
row, i1) < arrayTransposed(
row, i2);
2069 for (
uint32 col = 0; col < arrayTransposed.shape_.
cols; ++col)
2071 returnArray(
row, col) = idx[col];
2094 template<
typename dtypeOut,
typename dtype_ = dtype,
2102 if (is_same_v<dtypeOut, dtype>)
2108 const auto function = [](dtype value) -> dtypeOut
2110 return static_cast<dtypeOut
>(value);
2129 template<
typename dtypeOut,
typename dtype_ = dtype,
2139 return std::complex<typename dtypeOut::value_type>(value);
2157 template<
typename dtypeOut,
typename dtype_ = dtype,
2165 if (std::is_same<dtypeOut, dtype>::value)
2173 return complex_cast<typename dtypeOut::value_type>(value);
2192 template<
typename dtypeOut,
typename dtype_ = dtype,
2202 return static_cast<dtypeOut
>(value.real());
2219 return *(
cend() - 1);
2231 return *(
end() - 1);
2272 [](dtype& value) noexcept ->
void
2317 [inMin, inMax](dtype value) noexcept -> dtype
2319 #ifdef __cpp_lib_clamp
2320 const auto comparitor = [](dtype lhs, dtype rhs) noexcept -> bool
2325 return std::clamp(value, inMin, inMax, comparitor);
2331 else if (value > inMax)
2353 return operator()(rSlice(), inColumn);
2379 for (
uint32 row = 0; row < shape_.rows; ++row)
2390 for (
uint32 row = 0; row < transArray.shape_.
rows; ++row)
2439 returnArray[0] = front();
2440 for (
uint32 i = 1; i < size_; ++i)
2442 returnArray[i] = returnArray[i - 1] * array_[i];
2450 for (
uint32 row = 0; row < shape_.rows; ++row)
2452 returnArray(row, 0) = operator()(row, 0);
2453 for (
uint32 col = 1; col < shape_.cols; ++col)
2455 returnArray(row, col) = returnArray(row, col - 1) * operator()(row, col);
2464 for (
uint32 col = 0; col < shape_.cols; ++col)
2466 returnArray(0, col) = operator()(0, col);
2467 for (
uint32 row = 1; row < shape_.rows; ++row)
2469 returnArray(row, col) = returnArray(row - 1, col) * operator()(row, col);
2503 returnArray[0] = front();
2504 for (
uint32 i = 1; i < size_; ++i)
2506 returnArray[i] = returnArray[i - 1] + array_[i];
2514 for (
uint32 row = 0; row < shape_.rows; ++row)
2516 returnArray(row, 0) = operator()(row, 0);
2517 for (
uint32 col = 1; col < shape_.cols; ++col)
2519 returnArray(row, col) = returnArray(row, col - 1) + operator()(row, col);
2528 for (
uint32 col = 0; col < shape_.cols; ++col)
2530 returnArray(0, col) = operator()(0, col);
2531 for (
uint32 row = 1; row < shape_.rows; ++row)
2533 returnArray(row, col) = returnArray(row - 1, col) + operator()(row, col);
2597 std::vector<dtype> diagnolValues;
2598 int32 col = inOffset;
2599 for (
uint32 row = 0; row < shape_.rows; ++row)
2606 if (col >=
static_cast<int32>(shape_.cols))
2611 diagnolValues.push_back(
operator()(row,
static_cast<uint32>(col)));
2619 std::vector<dtype> diagnolValues;
2621 for (
int32 row = inOffset; row < static_cast<int32>(shape_.rows); ++row)
2628 if (col >= shape_.cols)
2633 diagnolValues.push_back(
operator()(
static_cast<uint32>(row), col));
2665 if (shape_ == inOtherArray.shape_ && (shape_.rows == 1 || shape_.cols == 1))
2667 dtype dotProduct = std::inner_product(cbegin(), cend(), inOtherArray.
cbegin(), dtype{ 0 });
2671 if (shape_.cols == inOtherArray.shape_.
rows)
2675 auto otherArrayT = inOtherArray.
transpose();
2677 for (
uint32 i = 0; i < shape_.rows; ++i)
2679 for (
uint32 j = 0;
j < otherArrayT.shape_.rows; ++
j)
2681 returnArray(i,
j) = std::inner_product(otherArrayT.cbegin(
j), otherArrayT.cend(
j), cbegin(i), dtype{ 0 });
2690 errStr +=
" are not consistent.";
2705 void dump(
const std::string& inFilename)
const
2713 std::ofstream ofile(
f.fullName().c_str(), std::ios::binary);
2719 if (array_ !=
nullptr)
2721 ofile.write(
reinterpret_cast<const char*
>(array_), size_ *
sizeof(dtype));
2769 std::vector<uint32> indices;
2771 for (
auto value : *
this)
2773 if (value != dtype{ 0 })
2775 indices.push_back(idx);
2832 return *cbegin(row);
2858 return operator[](inIndices);
2874 return operator[](inMask);
2900 return shape_.rows == 1 || shape_.cols == 1;
2914 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
2929 for (
uint32 row = 0; row < transposedArray.shape_.rows; ++row)
2932 transposedArray.cend(row), comparitor);
2940 for (
uint32 row = 0; row < shape_.rows; ++row)
2963 return shape_.issquare();
3000 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3015 for (
uint32 row = 0; row < shape_.rows; ++row)
3026 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3029 transposedArray.
cend(row), comparitor);
3057 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3072 for (
uint32 row = 0; row < shape_.rows; ++row)
3083 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3086 transposedArray.
cend(row), comparitor);
3116 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3132 const uint32 middleIdx = size_ / 2;
3135 dtype medianValue = copyArray.array_[middleIdx];
3138 const uint32 lhsIndex = middleIdx - 1;
3140 medianValue = (medianValue + copyArray.array_[lhsIndex]) / dtype{2};
3143 return { medianValue };
3150 const bool isEven = shape_.cols % 2 == 0;
3151 for (
uint32 row = 0; row < shape_.rows; ++row)
3153 const uint32 middleIdx = shape_.cols / 2;
3155 copyArray.
end(row), comparitor);
3157 dtype medianValue = copyArray(row, middleIdx);
3160 const uint32 lhsIndex = middleIdx - 1;
3162 copyArray.
end(row), comparitor);
3163 medianValue = (medianValue + copyArray(row, lhsIndex)) / dtype{2};
3166 returnArray(0, row) = medianValue;
3176 const bool isEven = shape_.rows % 2 == 0;
3177 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3179 const uint32 middleIdx = transposedArray.shape_.
cols / 2;
3181 transposedArray.
end(row), comparitor);
3183 dtype medianValue = transposedArray(row, middleIdx);
3186 const uint32 lhsIndex = middleIdx - 1;
3188 transposedArray.
end(row), comparitor);
3189 medianValue = (medianValue + transposedArray(row, lhsIndex)) / dtype{2};
3192 returnArray(0, row) = medianValue;
3229 return static_cast<uint64>(
sizeof(dtype) * size_);
3254 switch (inEndianess)
3273 auto outArray =
NdArray(*
this);
3282 auto outArray =
NdArray(*
this);
3306 switch (inEndianess)
3321 auto outArray =
NdArray(*
this);
3349 switch (inEndianess)
3355 auto outArray =
NdArray(*
this);
3413 const auto function = [](dtype i) ->
bool
3415 return i != dtype{ 0 };
3428 for (
uint32 row = 0; row < shape_.rows; ++row)
3439 for (
uint32 row = 0; row < arrayTransposed.shape_.
rows; ++row)
3537 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3558 if (inKth >= shape_.cols)
3561 errStr +=
") out of bounds (" +
utils::num2str(shape_.cols) +
")";
3565 for (
uint32 row = 0; row < shape_.rows; ++row)
3573 if (inKth >= shape_.rows)
3576 errStr +=
") out of bounds (" +
utils::num2str(shape_.rows) +
")";
3581 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3584 transposedArray.
end(row), comparitor);
3625 dtype product = std::accumulate(cbegin(), cend(),
3626 dtype{ 1 }, std::multiplies<dtype>());
3633 for (
uint32 row = 0; row < shape_.rows; ++row)
3635 returnArray(0, row) = std::accumulate(cbegin(row), cend(row),
3636 dtype{ 1 }, std::multiplies<dtype>());
3645 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3647 returnArray(0, row) = std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row),
3648 dtype{ 1 }, std::multiplies<dtype>());
3676 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3692 for (
uint32 row = 0; row < shape_.rows; ++row)
3695 returnArray(0, row) = *result.second - *result.first;
3704 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3707 returnArray(0, row) = *result.second - *result.first;
3731 at(inIndex) = inValue;
3748 at(inRow, inCol) = inValue;
3764 for (
auto index : inIndices)
3766 put(index, inValue);
3783 if (inIndices.
size() != inValues.
size())
3789 for (
auto index : inIndices)
3791 put(index, inValues[counter++]);
3808 Slice inSliceCopy(inSlice);
3830 Slice inSliceCopy(inSlice);
3833 std::vector<uint32> indices;
3836 indices.push_back(i);
3854 Slice inRowSliceCopy(inRowSlice);
3855 Slice inColSliceCopy(inColSlice);
3860 std::vector<uint32> indices;
3861 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3863 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3865 put(row, col, inValue);
3884 Slice inRowSliceCopy(inRowSlice);
3887 std::vector<uint32> indices;
3888 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3890 put(row, inColIndex, inValue);
3908 Slice inColSliceCopy(inColSlice);
3911 std::vector<uint32> indices;
3912 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3914 put(inRowIndex, col, inValue);
3932 Slice inRowSliceCopy(inRowSlice);
3933 Slice inColSliceCopy(inColSlice);
3938 std::vector<uint32> indices;
3939 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3941 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3943 const uint32 index = row * shape_.cols + col;
3944 indices.push_back(index);
3963 Slice inRowSliceCopy(inRowSlice);
3966 std::vector<uint32> indices;
3967 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3969 const uint32 index = row * shape_.cols + inColIndex;
3970 indices.push_back(index);
3988 Slice inColSliceCopy(inColSlice);
3991 std::vector<uint32> indices;
3992 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3994 const uint32 index = inRowIndex * shape_.cols + col;
3995 indices.push_back(index);
4010 if (inMask.
shape() != shape_)
4027 if (inMask.
shape() != shape_)
4062 NdArray<dtype> returnArray(shape_.rows * inNumRows, shape_.cols * inNumCols);
4064 for (
uint32 row = 0; row < inNumRows; ++row)
4066 for (
uint32 col = 0; col < inNumCols; ++col)
4068 std::vector<uint32> indices(shape_.size());
4070 const uint32 rowStart = row * shape_.rows;
4071 const uint32 colStart = col * shape_.cols;
4073 const uint32 rowEnd = (row + 1) * shape_.rows;
4074 const uint32 colEnd = (col + 1) * shape_.cols;
4077 for (
uint32 rowIdx = rowStart; rowIdx < rowEnd; ++rowIdx)
4079 for (
uint32 colIdx = colStart; colIdx < colEnd; ++colIdx)
4081 indices[counter++] = rowIdx * returnArray.shape_.
cols + colIdx;
4135 if (inSize != size_)
4137 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into shape ";
4143 shape_.cols = inSize;
4164 if (size_ % inNumCols == 0)
4166 return reshape(size_ / inNumCols, inNumCols);
4169 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into a shape ";
4177 if (size_ % inNumRows == 0)
4179 return reshape(inNumRows, size_ / inNumRows);
4182 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into a shape ";
4188 if (
static_cast<uint32>(inNumRows * inNumCols) != size_)
4190 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into shape ";
4195 shape_.rows =
static_cast<uint32>(inNumRows);
4196 shape_.cols =
static_cast<uint32>(inNumCols);
4230 newArray(
Shape(inNumRows, inNumCols));
4263 std::vector<dtype> oldData(size_);
4266 const Shape inShape(inNumRows, inNumCols);
4267 const Shape oldShape = shape_;
4271 for (
uint32 row = 0; row < inShape.
rows; ++row)
4273 for (
uint32 col = 0; col < inShape.
cols; ++col)
4275 if (row >= oldShape.
rows || col >= oldShape.
cols)
4277 operator()(row, col) = dtype{ 0 };
4281 operator()(row, col) = oldData[row * oldShape.
cols + col];
4323 const double multFactor =
utils::power(10.0, inNumDecimals);
4324 const auto function = [multFactor](dtype value) noexcept -> dtype
4326 return static_cast<dtype
>(std::nearbyint(
static_cast<double>(value) * multFactor) / multFactor);
4390 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
4404 for (
uint32 row = 0; row < shape_.rows; ++row)
4413 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
4439 for (
uint32 row = 0; row < shape_.rows; ++row)
4442 for (
uint32 col = 0; col < shape_.cols; ++col)
4447 if (row == shape_.rows - 1)
4479 NdArray<dtype> returnArray = { std::accumulate(cbegin(), cend(), dtype{ 0 }) };
4485 for (
uint32 row = 0; row < shape_.rows; ++row)
4487 returnArray(0, row) = std::accumulate(cbegin(row), cend(row), dtype{ 0 });
4495 const Shape transShape = transposedArray.
shape();
4497 for (
uint32 row = 0; row < transShape.
rows; ++row)
4499 returnArray(0, row) = std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row), dtype{ 0 });
4539 void tofile(
const std::string& inFilename,
const std::string& inSep =
"")
const
4555 std::ofstream ofile(
f.fullName().c_str());
4562 for (
auto value : *
this)
4565 if (counter++ != size_ - 1)
4583 return std::vector<dtype>(cbegin(), cend());
4608 rowStart += inOffset;
4613 colStart += inOffset;
4624 if (rowStart >= shape_.rows || colStart >= shape_.cols)
4631 for (
uint32 row = rowStart; row < shape_.rows; ++row)
4633 if (col >= shape_.cols)
4637 sum += operator()(row, col++);
4655 for (
uint32 row = 0; row < shape_.rows; ++row)
4657 for (
uint32 col = 0; col < shape_.cols; ++col)
4659 transArray(col, row) = operator()(row, col);
4680 allocator_type allocator_{};
4681 Shape shape_{ 0, 0 };
4682 size_type size_{ 0 };
4684 pointer array_{
nullptr };
4685 bool ownsPtr_{
false };
4691 void deleteArray() noexcept
4693 if (ownsPtr_ && array_ !=
nullptr)
4695 allocator_.deallocate(array_, size_);
4699 shape_.rows = shape_.cols = 0;
4713 array_ = allocator_.allocate(size_);
4725 void newArray(
const Shape& inShape)
4730 size_ = inShape.size();
4737 template<
typename dtype,
class _Alloc>
4742 std::vector<uint32> rowIndices;
4743 std::vector<uint32> colIndices;
4745 for (
uint32 row = 0; row < shape_.rows; ++row)
4747 for (
uint32 col = 0; col < shape_.cols; ++col)
4749 if (
operator()(row, col) != dtype{ 0 })
4751 rowIndices.push_back(row);
4752 colIndices.push_back(col);
const_reverse_column_iterator rcolend() const noexcept
Definition: NdArrayCore.hpp:1719
#define STATIC_ASSERT_INTEGER(dtype)
Definition: StaticAsserts.hpp:40
std::reverse_iterator< const_column_iterator > const_reverse_column_iterator
Definition: NdArrayCore.hpp:98
const_reverse_iterator crbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1329
typename std::enable_if< B, T >::type enable_if_t
Definition: TypeTraits.hpp:40
value_type item() const
Definition: NdArrayCore.hpp:2975
column_iterator colbegin(size_type inCol)
Definition: NdArrayCore.hpp:1187
NdArray< bool > contains(value_type inValue, Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2365
int32 stop
Definition: Slice.hpp:48
NdArray< dtype > & put(int32 inRowIndex, const Slice &inColSlice, value_type inValue)
Definition: NdArrayCore.hpp:3906
const_iterator cend(size_type inRow) const
Definition: NdArrayCore.hpp:1501
NdArray< bool > any(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1836
std::vector< dtype > toStlVector() const
Definition: NdArrayCore.hpp:4581
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4356
std::int32_t int32
Definition: Types.hpp:36
NdArray< dtype > & operator=(NdArray< dtype > &&rhs) noexcept
Definition: NdArrayCore.hpp:614
Custom column iterator for NdArray.
Definition: NdArrayIterators.hpp:827
const_iterator cbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1157
std::reverse_iterator< column_iterator > reverse_column_iterator
Definition: NdArrayCore.hpp:97
NdArray(const NdArray< dtype > &inOtherArray)
Definition: NdArrayCore.hpp:519
void makePositiveAndValidate(uint32 inArraySize)
Definition: Slice.hpp:137
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
NdArray< dtype > dot(const NdArray< dtype > &inOtherArray) const
Definition: NdArrayCore.hpp:2661
NdArray< dtype > & sort(Axis inAxis=Axis::NONE)
Definition: NdArrayCore.hpp:4386
reference operator[](int32 inIndex) noexcept
Definition: NdArrayCore.hpp:642
NdArray< dtype > & put(const Slice &inRowSlice, const Slice &inColSlice, value_type inValue)
Definition: NdArrayCore.hpp:3852
NdArray< dtype > round(uint8 inNumDecimals=0) const
Definition: NdArrayCore.hpp:4318
NdArray< dtype > copy() const
Definition: NdArrayCore.hpp:2414
NdArray< dtype > at(int32 inRowIndex, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:1074
reference back(size_type row)
Definition: NdArrayCore.hpp:2253
NdArray< dtype > & nans() noexcept
Definition: NdArrayCore.hpp:3210
const_iterator begin() const noexcept
Definition: NdArrayCore.hpp:1117
reference at(int32 inIndex)
Definition: NdArrayCore.hpp:916
NdArray< dtype > operator()(const Slice &inRowSlice, int32 inColIndex) const
Definition: NdArrayCore.hpp:837
value_type trace(uint32 inOffset=0, Axis inAxis=Axis::ROW) const noexcept
Definition: NdArrayCore.hpp:4598
NdArray< dtype > at(const Slice &inRowSlice, int32 inColIndex) const
Definition: NdArrayCore.hpp:1058
NdArray(std::vector< std::array< dtype, Dim1Size >> &in2dArray, bool copy=true)
Definition: NdArrayCore.hpp:326
NdArray(std::array< dtype, ArraySize > &inArray, bool copy=true)
Definition: NdArrayCore.hpp:209
NdArray< dtype > operator[](const NdArray< bool > &inMask) const
Definition: NdArrayCore.hpp:752
NdArray< dtype > & reshape(const Shape &inShape)
Definition: NdArrayCore.hpp:4213
NdArray< dtype > & resizeSlow(NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: resizeSlow.hpp:53
const_reverse_column_iterator crcolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1415
NdArray< dtype > & resizeSlow(const Shape &inShape)
Definition: NdArrayCore.hpp:4301
NdArray(const std::initializer_list< dtype > &inList)
Definition: NdArrayCore.hpp:155
const dtype & const_reference
Definition: NdArrayCore.hpp:86
std::uint8_t uint8
Definition: Types.hpp:42
NdArray< dtype > & reshape(size_type inSize)
Definition: NdArrayCore.hpp:4133
std::uint64_t uint64
Definition: Types.hpp:39
NdArray< dtype > & put(int32 inRowIndex, const Slice &inColSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3986
void tofile(const std::string &inFilename, const std::string &inSep="") const
Definition: NdArrayCore.hpp:4539
std::string num2str(dtype inNumber)
Definition: num2str.hpp:46
bool issquare() const noexcept
Definition: NdArrayCore.hpp:2961
NdArray< dtype > prod(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3617
NdArray< dtype > diagonal(int32 inOffset=0, Axis inAxis=Axis::ROW) const
Definition: NdArrayCore.hpp:2591
NdArray< dtype > & operator=(const NdArray< dtype > &rhs)
Definition: NdArrayCore.hpp:569
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:50
NdArray< dtype > & putMask(const NdArray< bool > &inMask, value_type inValue)
Definition: NdArrayCore.hpp:4008
const_reverse_iterator rend() const noexcept
Definition: NdArrayCore.hpp:1547
NdArrayConstColumnIterator< dtype, size_type, const_pointer, difference_type > const_column_iterator
Definition: NdArrayCore.hpp:96
const_reference at(int32 inRowIndex, int32 inColIndex) const
Definition: NdArrayCore.hpp:994
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4652
uint64 nbytes() const noexcept
Definition: NdArrayCore.hpp:3227
NdArray< dtype > getByMask(const NdArray< bool > &inMask) const
Definition: NdArrayCore.hpp:2872
uint32 size_type
Definition: NdArrayCore.hpp:87
const_column_iterator ccolend() const noexcept
Definition: NdArrayCore.hpp:1659
const_reverse_iterator crend(size_type inRow) const
Definition: NdArrayCore.hpp:1587
void dump(const NdArray< dtype > &inArray, const std::string &inFilename)
Definition: dump.hpp:47
const_reference at(int32 inIndex) const
Definition: NdArrayCore.hpp:939
NdArray< dtype > max(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2996
NdArray(const std::initializer_list< std::initializer_list< dtype > > &inList)
Definition: NdArrayCore.hpp:173
typename AllocTraits::const_pointer const_pointer
Definition: NdArrayCore.hpp:84
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:71
NdArray< dtype > & put(const NdArray< uint32 > &inIndices, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3781
iterator end(size_type inRow)
Definition: NdArrayCore.hpp:1445
value_type front() const noexcept
Definition: NdArrayCore.hpp:2806
value_type back(size_type row) const
Definition: NdArrayCore.hpp:2241
reverse_column_iterator rcolend(size_type inCol)
Definition: NdArrayCore.hpp:1703
NdArray< dtype > & put(const Slice &inRowSlice, const Slice &inColSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3930
value_type back() const noexcept
Definition: NdArrayCore.hpp:2217
bool ownsInternalData() noexcept
Definition: NdArrayCore.hpp:3512
reference front() noexcept
Definition: NdArrayCore.hpp:2818
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: NdArrayCore.hpp:93
NdArray< dtype > at(const Slice &inSlice) const
Definition: NdArrayCore.hpp:1026
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:213
NdArray< dtype > clip(value_type inMin, value_type inMax) const
Definition: NdArrayCore.hpp:2311
constexpr auto j
Definition: Constants.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40
Slice rSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:902
NdArray(std::vector< dtype > &inVector, bool copy=true)
Definition: NdArrayCore.hpp:266
bool is_sorted(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:231
std::allocator< dtype > allocator_type
Definition: NdArrayCore.hpp:82
const_reverse_iterator crend() const noexcept
Definition: NdArrayCore.hpp:1573
const_column_iterator colend(size_type inCol) const
Definition: NdArrayCore.hpp:1647
Slice cSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:887
uint32 numCols() const noexcept
Definition: NdArrayCore.hpp:3475
NdArrayIterator< dtype, pointer, difference_type > iterator
Definition: NdArrayCore.hpp:90
Custom column const_iterator for NdArray.
Definition: NdArrayIterators.hpp:496
std::string str() const
Definition: NdArrayCore.hpp:4433
column_iterator colend() noexcept
Definition: NdArrayCore.hpp:1603
NdArray< dtype > newbyteorder(Endian inEndianess) const
Definition: NdArrayCore.hpp:3244
bool isLittleEndian() noexcept
Definition: Endian.hpp:44
pointer dataRelease() noexcept
Definition: NdArrayCore.hpp:2574
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:40
ForwardIt max_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:268
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3729
NdArray< dtype > & reshape(int32 inNumRows, int32 inNumCols)
Definition: NdArrayCore.hpp:4160
bool all_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:57
const_column_iterator ccolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1243
int32 start
Definition: Slice.hpp:47
void fill(ForwardIt first, ForwardIt last, const T &value) noexcept
Definition: StlAlgorithms.hpp:174
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:43
NdArray< dtype > column(uint32 inColumn)
Definition: NdArrayCore.hpp:2351
OutputIt copy(InputIt first, InputIt last, OutputIt destination) noexcept
Definition: StlAlgorithms.hpp:95
bool isflat() const noexcept
Definition: NdArrayCore.hpp:2898
const_iterator end() const noexcept
Definition: NdArrayCore.hpp:1461
const_reverse_iterator rend(size_type inRow) const
Definition: NdArrayCore.hpp:1561
NdArray(const Shape &inShape)
Definition: NdArrayCore.hpp:141
column_iterator colbegin() noexcept
Definition: NdArrayCore.hpp:1173
column_iterator colend(size_type inCol)
Definition: NdArrayCore.hpp:1617
iterator end() noexcept
Definition: NdArrayCore.hpp:1431
NdArray< dtype > & put(NdArray< dtype > &inArray, const NdArray< uint32 > &inIndices, dtype inValue)
Definition: put.hpp:49
Endian
Enum for endianess.
Definition: Types.hpp:50
const_reverse_iterator rbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1303
NdArray(const_pointer inPtr, uint32 numRows, uint32 numCols)
Definition: NdArrayCore.hpp:462
size_type size() const noexcept
Definition: NdArrayCore.hpp:4370
uint32 cols
Definition: Core/Shape.hpp:45
reverse_column_iterator rcolend() noexcept
Definition: NdArrayCore.hpp:1689
NdArray< dtype > repeat(const Shape &inRepeatShape) const
Definition: NdArrayCore.hpp:4103
NdArray< dtype > & reshape(NdArray< dtype > &inArray, uint32 inSize)
Definition: reshape.hpp:52
void dump(const std::string &inFilename) const
Definition: NdArrayCore.hpp:2705
NdArray< dtype > sum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:4471
NdArray< dtype > swapaxes() const
Definition: NdArrayCore.hpp:4521
uint32 size() const noexcept
Definition: Core/Shape.hpp:102
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:47
const_reverse_iterator rbegin() const noexcept
Definition: NdArrayCore.hpp:1289
dtype & reference
Definition: NdArrayCore.hpp:85
NdArray< dtype > & operator=(value_type inValue) noexcept
Definition: NdArrayCore.hpp:595
NdArray< dtype > & put(const Slice &inRowSlice, int32 inColIndex, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3961
reverse_column_iterator rcolbegin() noexcept
Definition: NdArrayCore.hpp:1345
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1487
NdArray(NdArray< dtype > &&inOtherArray) noexcept
Definition: NdArrayCore.hpp:538
const_reverse_column_iterator rcolend(size_type inCol) const
Definition: NdArrayCore.hpp:1733
uint32 numElements(uint32 inArraySize)
Definition: Slice.hpp:188
Axis
Enum To describe an axis.
Definition: Types.hpp:46
InputIt find(InputIt first, InputIt last, const T &value) noexcept
Definition: StlAlgorithms.hpp:195
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:37
NdArray< dtype > & put(const Slice &inRowSlice, int32 inColIndex, value_type inValue)
Definition: NdArrayCore.hpp:3882
void nth_element(RandomIt first, RandomIt nth, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:397
std::reverse_iterator< iterator > reverse_iterator
Definition: NdArrayCore.hpp:92
const double nan
NaN.
Definition: Constants.hpp:44
reverse_iterator rend(size_type inRow)
Definition: NdArrayCore.hpp:1531
int32 step
Definition: Slice.hpp:49
NdArray< dtype > & put(const Slice &inSlice, value_type inValue)
Definition: NdArrayCore.hpp:3806
NdArray< dtype > & zeros() noexcept
Definition: NdArrayCore.hpp:4670
NdArray< dtype > flatten() const
Definition: NdArrayCore.hpp:2792
NdArray< dtype > & put(const Slice &inSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3828
NdArray< dtype > cumsum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2494
NdArray< dtype > & ones() noexcept
Definition: NdArrayCore.hpp:3498
NdArray(const std::deque< dtype > &inDeque)
Definition: NdArrayCore.hpp:353
dtype value_type
Definition: NdArrayCore.hpp:81
Endian endianess() const noexcept
Definition: NdArrayCore.hpp:2733
NdArray(size_type inSquareSize)
Definition: NdArrayCore.hpp:113
Definition: Coordinate.hpp:44
const_column_iterator ccolbegin() const noexcept
Definition: NdArrayCore.hpp:1229
bool any_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:76
pointer data() noexcept
Definition: NdArrayCore.hpp:2552
const_column_iterator ccolend(size_type inCol) const
Definition: NdArrayCore.hpp:1673
const_reverse_column_iterator crcolbegin() const noexcept
Definition: NdArrayCore.hpp:1401
reverse_iterator rend() noexcept
Definition: NdArrayCore.hpp:1517
dtype byteSwap(dtype value) noexcept
Definition: Endian.hpp:63
reference at(int32 inRowIndex, int32 inColIndex)
Definition: NdArrayCore.hpp:962
uint32 rows
Definition: Core/Shape.hpp:44
NdArray< dtype > operator()(int32 inRowIndex, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:862
NdArray< uint32 > argmin(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1953
std::int64_t int64
Definition: Types.hpp:35
void replace(ForwardIt first, ForwardIt last, const T &oldValue, const T &newValue) noexcept
Definition: StlAlgorithms.hpp:435
Custom const_iterator for NdArray.
Definition: NdArrayIterators.hpp:42
NdArray< dtype > operator[](const Slice &inSlice) const
Definition: NdArrayCore.hpp:729
NdArray< dtype > row(uint32 inRow)
Definition: NdArrayCore.hpp:4342
NdArrayColumnIterator< dtype, size_type, pointer, difference_type > column_iterator
Definition: NdArrayCore.hpp:95
NdArray(pointer inPtr, uint32 numRows, uint32 numCols, Bool takeOwnership) noexcept
Definition: NdArrayCore.hpp:505
NdArray< uint32 > argsort(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2012
NdArray< dtype > getByIndices(const NdArray< uint32 > &inIndices) const
Definition: NdArrayCore.hpp:2856
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
Custom iterator for NdArray.
Definition: NdArrayIterators.hpp:317
reverse_iterator rbegin() noexcept
Definition: NdArrayCore.hpp:1259
NdArray< dtype > & put(int32 inRow, int32 inCol, value_type inValue)
Definition: NdArrayCore.hpp:3746
dtype power(dtype inValue, uint8 inPower) noexcept
Definition: Utils/power.hpp:48
NdArray< dtype > repeat(const NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: repeat.hpp:50
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1143
NdArray< dtype > cumprod(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2430
void sort(RandomIt first, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:629
NdArray(const std::deque< std::deque< dtype >> &in2dDeque)
Definition: NdArrayCore.hpp:370
NdArray< dtype > & resizeFast(NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: resizeFast.hpp:51
const_iterator end(size_type inRow) const
Definition: NdArrayCore.hpp:1475
reference back() noexcept
Definition: NdArrayCore.hpp:2229
NdArray< dtypeOut > astype() const
Definition: NdArrayCore.hpp:2098
NdArrayConstIterator< dtype, const_pointer, difference_type > const_iterator
Definition: NdArrayCore.hpp:91
const_column_iterator colbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1217
NdArray(const std::vector< std::vector< dtype >> &in2dVector)
Definition: NdArrayCore.hpp:291
ForwardIt min_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:304
NdArray< dtype > & resizeFast(uint32 inNumRows, uint32 inNumCols)
Definition: NdArrayCore.hpp:4228
const_column_iterator colbegin() const noexcept
Definition: NdArrayCore.hpp:1203
const_reference operator()(int32 inRowIndex, int32 inColIndex) const noexcept
Definition: NdArrayCore.hpp:704
const_reverse_column_iterator crcolend(size_type inCol) const
Definition: NdArrayCore.hpp:1759
NdArray< uint32 > argmax(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1893
NdArray< uint32 > flatnonzero() const
Definition: NdArrayCore.hpp:2765
void replace(value_type oldValue, value_type newValue)
Definition: NdArrayCore.hpp:4115
reference operator()(int32 inRowIndex, int32 inColIndex) noexcept
Definition: NdArrayCore.hpp:680
void stable_sort(RandomIt first, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:664
NdArray< dtype > & putMask(const NdArray< bool > &inMask, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:4025
const_reverse_column_iterator rcolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1389
NdArray< bool > none(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3409
std::pair< ForwardIt, ForwardIt > minmax_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:341
bool isempty() const noexcept
Definition: NdArrayCore.hpp:2885
value_type front(size_type row) const
Definition: NdArrayCore.hpp:2830
const_reverse_iterator crbegin() const noexcept
Definition: NdArrayCore.hpp:1315
const_reverse_column_iterator rcolbegin() const noexcept
Definition: NdArrayCore.hpp:1375
NdArray(pointer inPtr, size_type size, Bool takeOwnership) noexcept
Definition: NdArrayCore.hpp:485
uint32 numRows() const noexcept
Definition: NdArrayCore.hpp:3488
reference front(size_type row)
Definition: NdArrayCore.hpp:2842
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087
std::pair< NdArray< uint32 >, NdArray< uint32 > > nonzero(const NdArray< dtype > &inArray)
Definition: nonzero.hpp:50
NdArray< dtype > at(const Slice &inRowSlice, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:1042
dtype f(dtype inDofN, dtype inDofD)
Definition: f.hpp:56
std::string value2str(dtype inValue)
Definition: value2str.hpp:48
reverse_iterator rbegin(size_type inRow)
Definition: NdArrayCore.hpp:1273
reverse_column_iterator rcolbegin(size_type inCol)
Definition: NdArrayCore.hpp:1359
A Class for slicing into NdArrays.
Definition: Slice.hpp:43
NdArray< dtype > & resizeFast(const Shape &inShape)
Definition: NdArrayCore.hpp:4244
NdArray< dtype > ptp(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3672
NdArray(const std::list< dtype > &inList)
Definition: NdArrayCore.hpp:403
const_reference operator[](int32 inIndex) const noexcept
Definition: NdArrayCore.hpp:661
const_pointer data() const noexcept
Definition: NdArrayCore.hpp:2562
NdArray< dtype > operator[](const NdArray< size_type > &inIndices) const
Definition: NdArrayCore.hpp:778
NdArray(std::array< std::array< dtype, Dim1Size >, Dim0Size > &in2dArray, bool copy=true)
Definition: NdArrayCore.hpp:237
NdArray(const_pointer inPtr, size_type size)
Definition: NdArrayCore.hpp:442
bool none_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:379
typename AllocTraits::pointer pointer
Definition: NdArrayCore.hpp:83
const_column_iterator colend() const noexcept
Definition: NdArrayCore.hpp:1633
NdArray< dtype > & partition(uint32 inKth, Axis inAxis=Axis::NONE)
Definition: NdArrayCore.hpp:3533
NdArray< bool > issorted(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2910
const_reverse_column_iterator crcolend() const noexcept
Definition: NdArrayCore.hpp:1745
NdArray< dtype > & fill(value_type inFillValue) noexcept
Definition: NdArrayCore.hpp:2751
NdArray(Iterator inFirst, Iterator inLast)
Definition: NdArrayCore.hpp:423
NdArray< bool > all(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1780
~NdArray() noexcept
Definition: NdArrayCore.hpp:555
const_iterator begin(size_type inRow) const
Definition: NdArrayCore.hpp:1131
NdArray< dtype > median(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3112
NdArray< dtype > & ravel() noexcept
Definition: NdArrayCore.hpp:4043
NdArray< dtype > repeat(uint32 inNumRows, uint32 inNumCols) const
Definition: NdArrayCore.hpp:4060
typename AllocTraits::difference_type difference_type
Definition: NdArrayCore.hpp:88
NdArray(size_type inNumRows, size_type inNumCols)
Definition: NdArrayCore.hpp:127
NdArray< dtype > & byteswap() noexcept
Definition: NdArrayCore.hpp:2267
NdArray< dtype > transpose(const NdArray< dtype > &inArray)
Definition: transpose.hpp:47
void print() const
Definition: NdArrayCore.hpp:3599
Provides simple filesystem functions.
Definition: Filesystem.hpp:39
NdArray< dtype > & put(const NdArray< uint32 > &inIndices, value_type inValue)
Definition: NdArrayCore.hpp:3762
iterator begin(size_type inRow)
Definition: NdArrayCore.hpp:1101
auto abs(dtype inValue) noexcept
Definition: abs.hpp:51
NdArray< dtype > & resizeSlow(uint32 inNumRows, uint32 inNumCols)
Definition: NdArrayCore.hpp:4261
NdArray< dtype > operator()(const Slice &inRowSlice, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:805
NdArray< dtype > min(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3053