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)
300 else if (
row.size() != shape_.
cols)
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)
379 else if (
row.size() != shape_.
cols)
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)
462 template<
typename UIntType1,
typename UIntType2,
463 std::enable_if_t<!std::is_same<UIntType1, bool>::value,
int> = 0,
464 std::enable_if_t<!std::is_same<UIntType2, bool>::value,
int> = 0>
470 if (inPtr !=
nullptr && size_ > 0)
486 template<
typename Bool,
487 std::enable_if_t<std::is_same<Bool, bool>::value,
int> = 0>
492 ownsPtr_(takeOwnership)
506 template<
typename Bool,
507 std::enable_if_t<std::is_same<Bool, bool>::value,
int> = 0>
512 ownsPtr_(takeOwnership)
523 shape_(inOtherArray.shape_),
524 size_(inOtherArray.size_),
525 endianess_(inOtherArray.endianess_)
542 shape_(inOtherArray.shape_),
543 size_(inOtherArray.size_),
544 endianess_(inOtherArray.endianess_),
545 array_(inOtherArray.array_),
546 ownsPtr_(inOtherArray.ownsPtr_)
548 inOtherArray.shape_.rows = inOtherArray.shape_.cols = 0;
549 inOtherArray.size_ = 0;
550 inOtherArray.ownsPtr_ =
false;
551 inOtherArray.array_ =
nullptr;
578 newArray(rhs.shape_);
579 endianess_ = rhs.endianess_;
600 if (array_ !=
nullptr)
624 endianess_ = rhs.endianess_;
626 ownsPtr_ = rhs.ownsPtr_;
628 rhs.shape_.rows = rhs.shape_.cols = rhs.size_ = 0;
629 rhs.array_ =
nullptr;
630 rhs.ownsPtr_ =
false;
652 return array_[inIndex];
671 return array_[inIndex];
687 inRowIndex += shape_.
rows;
692 inColIndex += shape_.
cols;
695 return array_[inRowIndex * shape_.
cols + inColIndex];
711 inRowIndex += shape_.
rows;
716 inColIndex += shape_.
cols;
719 return array_[inRowIndex * shape_.
cols + inColIndex];
734 Slice inSliceCopy(inSlice);
740 returnArray[counter++] =
at(i);
757 if (inMask.
shape() != shape_)
764 for (
size_type i = 0; i < indices.size(); ++i)
783 if (inIndices.
max().item() > size_ - 1)
790 for (
auto& index : inIndices)
810 Slice inRowSliceCopy(inRowSlice);
811 Slice inColSliceCopy(inColSlice);
819 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
821 returnArray(rowCounter, colCounter++) =
at(
row, col);
842 Slice inRowSliceCopy(inRowSlice);
849 returnArray(rowCounter++, 0) =
at(
row, inColIndex);
867 Slice inColSliceCopy(inColSlice);
872 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
874 returnArray(0, colCounter++) =
at(inRowIndex, col);
892 return Slice(inStartIdx, shape_.
cols, inStepSize);
907 return Slice(inStartIdx, shape_.
rows, inStepSize);
926 errStr +=
" is out of bounds for array of size " +
utils::num2str(size_) +
".";
949 errStr +=
" is out of bounds for array of size " +
utils::num2str(size_) +
".";
980 std::string errStr =
"Column index " +
utils::num2str(inColIndex);
1004 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
rows) +
".";
1012 std::string errStr =
"Column index " +
utils::num2str(inColIndex);
1013 errStr +=
" is out of bounds for array of size " +
utils::num2str(shape_.
cols) +
".";
1106 if (inRow >= shape_.
rows)
1111 return begin() += (inRow * shape_.
cols);
1162 if (inRow >= shape_.
rows)
1192 if (inCol >= shape_.
cols)
1248 if (inCol >= shape_.
cols)
1278 if (inRow >= shape_.
rows)
1334 if (inRow >= shape_.
rows)
1364 if (inCol >= shape_.
cols)
1420 if (inCol >= shape_.
cols)
1436 return begin() += size_;
1450 if (inRow >= shape_.
rows)
1492 return cbegin() += size_;
1506 if (inRow >= shape_.
rows)
1522 return rbegin() += size_;
1536 if (inRow >= shape_.
rows)
1566 return crend(inRow);
1592 if (inRow >= shape_.
rows)
1622 if (inCol >= shape_.
cols)
1678 if (inCol >= shape_.
cols)
1708 if (inCol >= shape_.
cols)
1764 if (inCol >= shape_.
cols)
1787 const auto function = [](dtype i) ->
bool
1789 return i != dtype{ 0 };
1843 const auto function = [](dtype i) ->
bool
1845 return i != dtype{ 0 };
1900 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
1960 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
2023 std::vector<uint32> idx(size_);
2024 std::iota(idx.begin(), idx.end(), 0);
2026 const auto function = [
this](
uint32 i1,
uint32 i2) noexcept ->
bool
2028 return (*
this)[i1] < (*this)[i2];
2039 std::vector<uint32> idx(shape_.
cols);
2040 std::iota(idx.begin(), idx.end(), 0);
2042 const auto function = [
this,
row](
uint32 i1,
uint32 i2) noexcept ->
bool
2049 for (
uint32 col = 0; col < shape_.
cols; ++col)
2051 returnArray(
row, col) = idx[col];
2062 std::vector<uint32> idx(arrayTransposed.shape_.
cols);
2063 std::iota(idx.begin(), idx.end(), 0);
2065 const auto function = [&arrayTransposed,
row](
uint32 i1,
uint32 i2) noexcept ->
bool
2067 return arrayTransposed(
row, i1) < arrayTransposed(
row, i2);
2072 for (
uint32 col = 0; col < arrayTransposed.shape_.
cols; ++col)
2074 returnArray(
row, col) = idx[col];
2097 template<
typename dtypeOut,
typename dtype_ = dtype,
2105 if (is_same_v<dtypeOut, dtype>)
2111 const auto function = [](dtype value) -> dtypeOut
2113 return static_cast<dtypeOut
>(value);
2132 template<
typename dtypeOut,
typename dtype_ = dtype,
2142 return std::complex<typename dtypeOut::value_type>(value);
2160 template<
typename dtypeOut,
typename dtype_ = dtype,
2168 if (std::is_same<dtypeOut, dtype>::value)
2176 return complex_cast<typename dtypeOut::value_type>(value);
2195 template<
typename dtypeOut,
typename dtype_ = dtype,
2205 return static_cast<dtypeOut
>(value.real());
2222 return *(
cend() - 1);
2234 return *(
end() - 1);
2275 [](dtype& value) noexcept ->
void
2320 [inMin, inMax](dtype value) noexcept -> dtype
2322 #ifdef __cpp_lib_clamp
2323 const auto comparitor = [](dtype lhs, dtype rhs) noexcept -> bool
2328 return std::clamp(value, inMin, inMax, comparitor);
2334 else if (value > inMax)
2356 return operator()(rSlice(), inColumn);
2382 for (
uint32 row = 0; row < shape_.rows; ++row)
2393 for (
uint32 row = 0; row < transArray.shape_.
rows; ++row)
2442 returnArray[0] = front();
2443 for (
uint32 i = 1; i < size_; ++i)
2445 returnArray[i] = returnArray[i - 1] * array_[i];
2453 for (
uint32 row = 0; row < shape_.rows; ++row)
2455 returnArray(row, 0) = operator()(row, 0);
2456 for (
uint32 col = 1; col < shape_.cols; ++col)
2458 returnArray(row, col) = returnArray(row, col - 1) * operator()(row, col);
2467 for (
uint32 col = 0; col < shape_.cols; ++col)
2469 returnArray(0, col) = operator()(0, col);
2470 for (
uint32 row = 1; row < shape_.rows; ++row)
2472 returnArray(row, col) = returnArray(row - 1, col) * operator()(row, col);
2506 returnArray[0] = front();
2507 for (
uint32 i = 1; i < size_; ++i)
2509 returnArray[i] = returnArray[i - 1] + array_[i];
2517 for (
uint32 row = 0; row < shape_.rows; ++row)
2519 returnArray(row, 0) = operator()(row, 0);
2520 for (
uint32 col = 1; col < shape_.cols; ++col)
2522 returnArray(row, col) = returnArray(row, col - 1) + operator()(row, col);
2531 for (
uint32 col = 0; col < shape_.cols; ++col)
2533 returnArray(0, col) = operator()(0, col);
2534 for (
uint32 row = 1; row < shape_.rows; ++row)
2536 returnArray(row, col) = returnArray(row - 1, col) + operator()(row, col);
2600 std::vector<dtype> diagnolValues;
2601 int32 col = inOffset;
2602 for (
uint32 row = 0; row < shape_.rows; ++row)
2609 if (col >=
static_cast<int32>(shape_.cols))
2614 diagnolValues.push_back(
operator()(row,
static_cast<uint32>(col)));
2622 std::vector<dtype> diagnolValues;
2624 for (
int32 row = inOffset; row < static_cast<int32>(shape_.rows); ++row)
2631 if (col >= shape_.cols)
2636 diagnolValues.push_back(
operator()(
static_cast<uint32>(row), col));
2668 if (shape_ == inOtherArray.shape_ && (shape_.rows == 1 || shape_.cols == 1))
2670 dtype dotProduct = std::inner_product(cbegin(), cend(), inOtherArray.
cbegin(), dtype{ 0 });
2674 if (shape_.cols == inOtherArray.shape_.
rows)
2678 auto otherArrayT = inOtherArray.
transpose();
2680 for (
uint32 i = 0; i < shape_.rows; ++i)
2682 for (
uint32 j = 0;
j < otherArrayT.shape_.rows; ++
j)
2684 returnArray(i,
j) = std::inner_product(otherArrayT.cbegin(
j), otherArrayT.cend(
j), cbegin(i), dtype{ 0 });
2693 errStr +=
" are not consistent.";
2708 void dump(
const std::string& inFilename)
const
2716 std::ofstream ofile(
f.fullName().c_str(), std::ios::binary);
2722 if (array_ !=
nullptr)
2724 ofile.write(
reinterpret_cast<const char*
>(array_), size_ *
sizeof(dtype));
2772 std::vector<uint32> indices;
2774 for (
auto value : *
this)
2776 if (value != dtype{ 0 })
2778 indices.push_back(idx);
2835 return *cbegin(row);
2861 return operator[](inIndices);
2877 return operator[](inMask);
2903 return shape_.rows == 1 || shape_.cols == 1;
2917 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
2932 for (
uint32 row = 0; row < transposedArray.shape_.rows; ++row)
2935 transposedArray.cend(row), comparitor);
2943 for (
uint32 row = 0; row < shape_.rows; ++row)
2966 return shape_.issquare();
3003 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3018 for (
uint32 row = 0; row < shape_.rows; ++row)
3029 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3032 transposedArray.
cend(row), comparitor);
3060 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3075 for (
uint32 row = 0; row < shape_.rows; ++row)
3086 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3089 transposedArray.
cend(row), comparitor);
3119 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3135 const uint32 middleIdx = size_ / 2;
3138 dtype medianValue = copyArray.array_[middleIdx];
3141 const uint32 lhsIndex = middleIdx - 1;
3143 medianValue = (medianValue + copyArray.array_[lhsIndex]) / dtype{2};
3146 return { medianValue };
3153 const bool isEven = shape_.cols % 2 == 0;
3154 for (
uint32 row = 0; row < shape_.rows; ++row)
3156 const uint32 middleIdx = shape_.cols / 2;
3158 copyArray.
end(row), comparitor);
3160 dtype medianValue = copyArray(row, middleIdx);
3163 const uint32 lhsIndex = middleIdx - 1;
3165 copyArray.
end(row), comparitor);
3166 medianValue = (medianValue + copyArray(row, lhsIndex)) / dtype{2};
3169 returnArray(0, row) = medianValue;
3179 const bool isEven = shape_.rows % 2 == 0;
3180 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3182 const uint32 middleIdx = transposedArray.shape_.
cols / 2;
3184 transposedArray.
end(row), comparitor);
3186 dtype medianValue = transposedArray(row, middleIdx);
3189 const uint32 lhsIndex = middleIdx - 1;
3191 transposedArray.
end(row), comparitor);
3192 medianValue = (medianValue + transposedArray(row, lhsIndex)) / dtype{2};
3195 returnArray(0, row) = medianValue;
3232 return static_cast<uint64>(
sizeof(dtype) * size_);
3257 switch (inEndianess)
3276 auto outArray =
NdArray(*
this);
3285 auto outArray =
NdArray(*
this);
3309 switch (inEndianess)
3324 auto outArray =
NdArray(*
this);
3352 switch (inEndianess)
3358 auto outArray =
NdArray(*
this);
3416 const auto function = [](dtype i) ->
bool
3418 return i != dtype{ 0 };
3431 for (
uint32 row = 0; row < shape_.rows; ++row)
3442 for (
uint32 row = 0; row < arrayTransposed.shape_.
rows; ++row)
3540 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3561 if (inKth >= shape_.cols)
3564 errStr +=
") out of bounds (" +
utils::num2str(shape_.cols) +
")";
3568 for (
uint32 row = 0; row < shape_.rows; ++row)
3576 if (inKth >= shape_.rows)
3579 errStr +=
") out of bounds (" +
utils::num2str(shape_.rows) +
")";
3584 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3587 transposedArray.
end(row), comparitor);
3628 dtype product = std::accumulate(cbegin(), cend(),
3629 dtype{ 1 }, std::multiplies<dtype>());
3636 for (
uint32 row = 0; row < shape_.rows; ++row)
3638 returnArray(0, row) = std::accumulate(cbegin(row), cend(row),
3639 dtype{ 1 }, std::multiplies<dtype>());
3648 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3650 returnArray(0, row) = std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row),
3651 dtype{ 1 }, std::multiplies<dtype>());
3679 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
3695 for (
uint32 row = 0; row < shape_.rows; ++row)
3698 returnArray(0, row) = *result.second - *result.first;
3707 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
3710 returnArray(0, row) = *result.second - *result.first;
3734 at(inIndex) = inValue;
3751 at(inRow, inCol) = inValue;
3767 for (
auto index : inIndices)
3769 put(index, inValue);
3786 if (inIndices.
size() != inValues.
size())
3792 for (
auto index : inIndices)
3794 put(index, inValues[counter++]);
3811 Slice inSliceCopy(inSlice);
3833 Slice inSliceCopy(inSlice);
3836 std::vector<uint32> indices;
3839 indices.push_back(i);
3857 Slice inRowSliceCopy(inRowSlice);
3858 Slice inColSliceCopy(inColSlice);
3863 std::vector<uint32> indices;
3864 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3866 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3868 put(row, col, inValue);
3887 Slice inRowSliceCopy(inRowSlice);
3890 std::vector<uint32> indices;
3891 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3893 put(row, inColIndex, inValue);
3911 Slice inColSliceCopy(inColSlice);
3914 std::vector<uint32> indices;
3915 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3917 put(inRowIndex, col, inValue);
3935 Slice inRowSliceCopy(inRowSlice);
3936 Slice inColSliceCopy(inColSlice);
3941 std::vector<uint32> indices;
3942 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3944 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3946 const uint32 index = row * shape_.cols + col;
3947 indices.push_back(index);
3966 Slice inRowSliceCopy(inRowSlice);
3969 std::vector<uint32> indices;
3970 for (
int32 row = inRowSliceCopy.
start; row < inRowSliceCopy.
stop; row += inRowSliceCopy.
step)
3972 const uint32 index = row * shape_.cols + inColIndex;
3973 indices.push_back(index);
3991 Slice inColSliceCopy(inColSlice);
3994 std::vector<uint32> indices;
3995 for (
int32 col = inColSliceCopy.
start; col < inColSliceCopy.
stop; col += inColSliceCopy.
step)
3997 const uint32 index = inRowIndex * shape_.cols + col;
3998 indices.push_back(index);
4013 if (inMask.
shape() != shape_)
4030 if (inMask.
shape() != shape_)
4065 NdArray<dtype> returnArray(shape_.rows * inNumRows, shape_.cols * inNumCols);
4067 for (
uint32 row = 0; row < inNumRows; ++row)
4069 for (
uint32 col = 0; col < inNumCols; ++col)
4071 std::vector<uint32> indices(shape_.size());
4073 const uint32 rowStart = row * shape_.rows;
4074 const uint32 colStart = col * shape_.cols;
4076 const uint32 rowEnd = (row + 1) * shape_.rows;
4077 const uint32 colEnd = (col + 1) * shape_.cols;
4080 for (
uint32 rowIdx = rowStart; rowIdx < rowEnd; ++rowIdx)
4082 for (
uint32 colIdx = colStart; colIdx < colEnd; ++colIdx)
4084 indices[counter++] = rowIdx * returnArray.shape_.
cols + colIdx;
4138 if (inSize != size_)
4140 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into shape ";
4146 shape_.cols = inSize;
4167 if (size_ % inNumCols == 0)
4169 return reshape(size_ / inNumCols, inNumCols);
4172 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into a shape ";
4180 if (size_ % inNumRows == 0)
4182 return reshape(inNumRows, size_ / inNumRows);
4185 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into a shape ";
4191 if (
static_cast<uint32>(inNumRows * inNumCols) != size_)
4193 std::string errStr =
"Cannot reshape array of size " +
utils::num2str(size_) +
" into shape ";
4198 shape_.rows =
static_cast<uint32>(inNumRows);
4199 shape_.cols =
static_cast<uint32>(inNumCols);
4233 newArray(
Shape(inNumRows, inNumCols));
4266 std::vector<dtype> oldData(size_);
4269 const Shape inShape(inNumRows, inNumCols);
4270 const Shape oldShape = shape_;
4274 for (
uint32 row = 0; row < inShape.
rows; ++row)
4276 for (
uint32 col = 0; col < inShape.
cols; ++col)
4278 if (row >= oldShape.
rows || col >= oldShape.
cols)
4280 operator()(row, col) = dtype{ 0 };
4284 operator()(row, col) = oldData[row * oldShape.
cols + col];
4326 const double multFactor =
utils::power(10.0, inNumDecimals);
4327 const auto function = [multFactor](dtype value) noexcept -> dtype
4329 return static_cast<dtype
>(std::nearbyint(
static_cast<double>(value) * multFactor) / multFactor);
4393 const auto comparitor = [](dtype lhs, dtype rhs) noexcept ->
bool
4407 for (
uint32 row = 0; row < shape_.rows; ++row)
4416 for (
uint32 row = 0; row < transposedArray.shape_.
rows; ++row)
4442 for (
uint32 row = 0; row < shape_.rows; ++row)
4445 for (
uint32 col = 0; col < shape_.cols; ++col)
4450 if (row == shape_.rows - 1)
4482 NdArray<dtype> returnArray = { std::accumulate(cbegin(), cend(), dtype{ 0 }) };
4488 for (
uint32 row = 0; row < shape_.rows; ++row)
4490 returnArray(0, row) = std::accumulate(cbegin(row), cend(row), dtype{ 0 });
4498 const Shape transShape = transposedArray.
shape();
4500 for (
uint32 row = 0; row < transShape.
rows; ++row)
4502 returnArray(0, row) = std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row), dtype{ 0 });
4542 void tofile(
const std::string& inFilename,
const std::string& inSep =
"")
const
4558 std::ofstream ofile(
f.fullName().c_str());
4565 for (
auto value : *
this)
4568 if (counter++ != size_ - 1)
4586 return std::vector<dtype>(cbegin(), cend());
4611 rowStart += inOffset;
4616 colStart += inOffset;
4627 if (rowStart >= shape_.rows || colStart >= shape_.cols)
4634 for (
uint32 row = rowStart; row < shape_.rows; ++row)
4636 if (col >= shape_.cols)
4640 sum += operator()(row, col++);
4658 for (
uint32 row = 0; row < shape_.rows; ++row)
4660 for (
uint32 col = 0; col < shape_.cols; ++col)
4662 transArray(col, row) = operator()(row, col);
4683 allocator_type allocator_{};
4684 Shape shape_{ 0, 0 };
4685 size_type size_{ 0 };
4687 pointer array_{
nullptr };
4688 bool ownsPtr_{
false };
4694 void deleteArray() noexcept
4696 if (ownsPtr_ && array_ !=
nullptr)
4698 allocator_.deallocate(array_, size_);
4702 shape_.rows = shape_.cols = 0;
4716 array_ = allocator_.allocate(size_);
4728 void newArray(
const Shape& inShape)
4733 size_ = inShape.size();
4740 template<
typename dtype,
class _Alloc>
4745 std::vector<uint32> rowIndices;
4746 std::vector<uint32> colIndices;
4748 for (
uint32 row = 0; row < shape_.rows; ++row)
4750 for (
uint32 col = 0; col < shape_.cols; ++col)
4752 if (
operator()(row, col) != dtype{ 0 })
4754 rowIndices.push_back(row);
4755 colIndices.push_back(col);
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:37
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:43
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:50
#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:834
Custom column const_iterator for NdArray.
Definition: NdArrayIterators.hpp:503
Custom const_iterator for NdArray.
Definition: NdArrayIterators.hpp:44
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
uint32 numCols() const noexcept
Definition: NdArrayCore.hpp:3478
NdArray(std::vector< std::array< dtype, Dim1Size >> &in2dArray, bool copy=true)
Definition: NdArrayCore.hpp:326
const_reverse_column_iterator rcolbegin() const noexcept
Definition: NdArrayCore.hpp:1378
NdArray< dtypeOut > astype() const
Definition: NdArrayCore.hpp:2101
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3732
size_type size() const noexcept
Definition: NdArrayCore.hpp:4373
reverse_iterator rbegin() noexcept
Definition: NdArrayCore.hpp:1262
NdArray< dtype > & resizeSlow(uint32 inNumRows, uint32 inNumCols)
Definition: NdArrayCore.hpp:4264
NdArray< dtype > & put(const Slice &inRowSlice, const Slice &inColSlice, value_type inValue)
Definition: NdArrayCore.hpp:3855
NdArray< bool > issorted(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2913
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1146
const_reference at(int32 inIndex) const
Definition: NdArrayCore.hpp:942
const_column_iterator ccolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1246
NdArrayConstColumnIterator< dtype, size_type, const_pointer, difference_type > const_column_iterator
Definition: NdArrayCore.hpp:96
NdArray< dtype > round(uint8 inNumDecimals=0) const
Definition: NdArrayCore.hpp:4321
NdArray< bool > any(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1839
const_pointer data() const noexcept
Definition: NdArrayCore.hpp:2565
NdArray< dtype > at(const Slice &inRowSlice, int32 inColIndex) const
Definition: NdArrayCore.hpp:1061
iterator end() noexcept
Definition: NdArrayCore.hpp:1434
NdArray< dtype > & put(const Slice &inRowSlice, const Slice &inColSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3933
NdArray(std::vector< dtype > &inVector, bool copy=true)
Definition: NdArrayCore.hpp:266
NdArray(const std::initializer_list< std::initializer_list< dtype > > &inList)
Definition: NdArrayCore.hpp:173
NdArray< dtype > prod(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3620
NdArray< dtype > copy() const
Definition: NdArrayCore.hpp:2417
NdArray< dtype > & resizeFast(const Shape &inShape)
Definition: NdArrayCore.hpp:4247
std::vector< dtype > toStlVector() const
Definition: NdArrayCore.hpp:4584
reference back(size_type row)
Definition: NdArrayCore.hpp:2256
NdArray< dtype > operator()(const Slice &inRowSlice, int32 inColIndex) const
Definition: NdArrayCore.hpp:840
iterator end(size_type inRow)
Definition: NdArrayCore.hpp:1448
NdArray< dtype > flatten() const
Definition: NdArrayCore.hpp:2795
const_column_iterator ccolbegin() const noexcept
Definition: NdArrayCore.hpp:1232
typename AllocTraits::pointer pointer
Definition: NdArrayCore.hpp:83
Slice cSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:890
reverse_iterator rbegin(size_type inRow)
Definition: NdArrayCore.hpp:1276
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4359
NdArray< dtype > & byteswap() noexcept
Definition: NdArrayCore.hpp:2270
const_reverse_column_iterator rcolend() const noexcept
Definition: NdArrayCore.hpp:1722
uint32 numRows() const noexcept
Definition: NdArrayCore.hpp:3491
const dtype & const_reference
Definition: NdArrayCore.hpp:86
NdArray< dtype > & put(const Slice &inRowSlice, int32 inColIndex, value_type inValue)
Definition: NdArrayCore.hpp:3885
NdArray< dtype > & partition(uint32 inKth, Axis inAxis=Axis::NONE)
Definition: NdArrayCore.hpp:3536
bool issquare() const noexcept
Definition: NdArrayCore.hpp:2964
NdArrayIterator< dtype, pointer, difference_type > iterator
Definition: NdArrayCore.hpp:90
bool isflat() const noexcept
Definition: NdArrayCore.hpp:2901
Endian endianess() const noexcept
Definition: NdArrayCore.hpp:2736
const_reverse_column_iterator crcolbegin() const noexcept
Definition: NdArrayCore.hpp:1404
const_reverse_column_iterator crcolend(size_type inCol) const
Definition: NdArrayCore.hpp:1762
column_iterator colbegin(size_type inCol)
Definition: NdArrayCore.hpp:1190
NdArrayColumnIterator< dtype, size_type, pointer, difference_type > column_iterator
Definition: NdArrayCore.hpp:95
NdArray< bool > none(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3412
NdArray< dtype > at(const Slice &inSlice) const
Definition: NdArrayCore.hpp:1029
reference at(int32 inIndex)
Definition: NdArrayCore.hpp:919
NdArray< dtype > & sort(Axis inAxis=Axis::NONE)
Definition: NdArrayCore.hpp:4389
pointer data() noexcept
Definition: NdArrayCore.hpp:2555
bool isempty() const noexcept
Definition: NdArrayCore.hpp:2888
column_iterator colbegin() noexcept
Definition: NdArrayCore.hpp:1176
const_reference front(size_type row) const
Definition: NdArrayCore.hpp:2833
reverse_column_iterator rcolend(size_type inCol)
Definition: NdArrayCore.hpp:1706
NdArray< dtype > sum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:4474
NdArray(Iterator inFirst, Iterator inLast)
Definition: NdArrayCore.hpp:423
NdArray< dtype > operator[](const Slice &inSlice) const
Definition: NdArrayCore.hpp:732
reverse_column_iterator rcolbegin() noexcept
Definition: NdArrayCore.hpp:1348
NdArrayConstIterator< dtype, const_pointer, difference_type > const_iterator
Definition: NdArrayCore.hpp:91
const_iterator cbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1160
const_column_iterator ccolend(size_type inCol) const
Definition: NdArrayCore.hpp:1676
NdArray< dtype > cumsum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2497
NdArray< dtype > median(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3115
NdArray< dtype > getByMask(const NdArray< bool > &inMask) const
Definition: NdArrayCore.hpp:2875
const_iterator cend(size_type inRow) const
Definition: NdArrayCore.hpp:1504
NdArray< dtype > column(uint32 inColumn)
Definition: NdArrayCore.hpp:2354
const_reverse_column_iterator rcolend(size_type inCol) const
Definition: NdArrayCore.hpp:1736
NdArray< dtype > & putMask(const NdArray< bool > &inMask, value_type inValue)
Definition: NdArrayCore.hpp:4011
const_iterator end(size_type inRow) const
Definition: NdArrayCore.hpp:1478
reference back() noexcept
Definition: NdArrayCore.hpp:2232
const_reverse_column_iterator crcolend() const noexcept
Definition: NdArrayCore.hpp:1748
const_reference back(size_type row) const
Definition: NdArrayCore.hpp:2244
reverse_column_iterator rcolbegin(size_type inCol)
Definition: NdArrayCore.hpp:1362
NdArray(const std::deque< std::deque< dtype >> &in2dDeque)
Definition: NdArrayCore.hpp:370
NdArray< dtype > & put(int32 inRow, int32 inCol, value_type inValue)
Definition: NdArrayCore.hpp:3749
iterator begin(size_type inRow)
Definition: NdArrayCore.hpp:1104
const_reverse_iterator rend() const noexcept
Definition: NdArrayCore.hpp:1550
NdArray< dtype > clip(value_type inMin, value_type inMax) const
Definition: NdArrayCore.hpp:2314
const_reverse_column_iterator rcolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1392
NdArray< dtype > & operator=(NdArray< dtype > &&rhs) noexcept
Definition: NdArrayCore.hpp:617
typename AllocTraits::difference_type difference_type
Definition: NdArrayCore.hpp:88
NdArray< uint32 > argmin(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1956
const_iterator end() const noexcept
Definition: NdArrayCore.hpp:1464
bool ownsInternalData() noexcept
Definition: NdArrayCore.hpp:3515
NdArray< dtype > & fill(value_type inFillValue) noexcept
Definition: NdArrayCore.hpp:2754
column_iterator colend() noexcept
Definition: NdArrayCore.hpp:1606
NdArray< dtype > & put(const NdArray< uint32 > &inIndices, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3784
const_reference back() const noexcept
Definition: NdArrayCore.hpp:2220
std::pair< NdArray< uint32 >, NdArray< uint32 > > nonzero() const
Definition: NdArrayCore.hpp:4741
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: NdArrayCore.hpp:93
NdArray(const_pointer inPtr, UIntType1 numRows, UIntType2 numCols)
Definition: NdArrayCore.hpp:465
NdArray< dtype > cumprod(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2433
uint64 nbytes() const noexcept
Definition: NdArrayCore.hpp:3230
const_reference at(int32 inRowIndex, int32 inColIndex) const
Definition: NdArrayCore.hpp:997
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4655
NdArray< dtype > swapaxes() const
Definition: NdArrayCore.hpp:4524
NdArray< dtype > & put(int32 inRowIndex, const Slice &inColSlice, value_type inValue)
Definition: NdArrayCore.hpp:3909
NdArray(const std::list< dtype > &inList)
Definition: NdArrayCore.hpp:403
NdArray< dtype > at(int32 inRowIndex, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:1077
const_reference front() const noexcept
Definition: NdArrayCore.hpp:2809
NdArray< dtype > repeat(const Shape &inRepeatShape) const
Definition: NdArrayCore.hpp:4106
~NdArray() noexcept
Definition: NdArrayCore.hpp:558
NdArray< dtype > min(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3056
NdArray(pointer inPtr, uint32 numRows, uint32 numCols, Bool takeOwnership) noexcept
Definition: NdArrayCore.hpp:508
NdArray< dtype > & reshape(const Shape &inShape)
Definition: NdArrayCore.hpp:4216
reference front() noexcept
Definition: NdArrayCore.hpp:2821
NdArray(size_type inNumRows, size_type inNumCols)
Definition: NdArrayCore.hpp:127
Allocator allocator_type
Definition: NdArrayCore.hpp:82
void print() const
Definition: NdArrayCore.hpp:3602
const_reverse_column_iterator crcolbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1418
reverse_iterator rend(size_type inRow)
Definition: NdArrayCore.hpp:1534
NdArray< uint32 > flatnonzero() const
Definition: NdArrayCore.hpp:2768
NdArray(size_type inSquareSize)
Definition: NdArrayCore.hpp:113
reverse_iterator rend() noexcept
Definition: NdArrayCore.hpp:1520
const_reverse_iterator rend(size_type inRow) const
Definition: NdArrayCore.hpp:1564
NdArray< dtype > getByIndices(const NdArray< uint32 > &inIndices) const
Definition: NdArrayCore.hpp:2859
typename AllocTraits::const_pointer const_pointer
Definition: NdArrayCore.hpp:84
NdArray< dtype > & resizeSlow(const Shape &inShape)
Definition: NdArrayCore.hpp:4304
const_reverse_iterator crbegin() const noexcept
Definition: NdArrayCore.hpp:1318
const_column_iterator colend(size_type inCol) const
Definition: NdArrayCore.hpp:1650
std::reverse_iterator< iterator > reverse_iterator
Definition: NdArrayCore.hpp:92
NdArray(const std::initializer_list< dtype > &inList)
Definition: NdArrayCore.hpp:155
NdArray(const std::vector< std::vector< dtype >> &in2dVector)
Definition: NdArrayCore.hpp:291
const_reverse_iterator rbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1306
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1490
std::string str() const
Definition: NdArrayCore.hpp:4436
std::reverse_iterator< const_column_iterator > const_reverse_column_iterator
Definition: NdArrayCore.hpp:98
reference operator[](int32 inIndex) noexcept
Definition: NdArrayCore.hpp:645
NdArray< dtype > & reshape(int32 inNumRows, int32 inNumCols)
Definition: NdArrayCore.hpp:4163
NdArray(NdArray< dtype > &&inOtherArray) noexcept
Definition: NdArrayCore.hpp:541
NdArray< dtype > & nans() noexcept
Definition: NdArrayCore.hpp:3213
NdArray< dtype > & put(const NdArray< uint32 > &inIndices, value_type inValue)
Definition: NdArrayCore.hpp:3765
NdArray< dtype > ptp(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:3675
const_reference operator()(int32 inRowIndex, int32 inColIndex) const noexcept
Definition: NdArrayCore.hpp:707
reference front(size_type row)
Definition: NdArrayCore.hpp:2845
NdArray< dtype > diagonal(int32 inOffset=0, Axis inAxis=Axis::ROW) const
Definition: NdArrayCore.hpp:2594
NdArray< dtype > & putMask(const NdArray< bool > &inMask, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:4028
NdArray< dtype > operator[](const NdArray< bool > &inMask) const
Definition: NdArrayCore.hpp:755
NdArray< dtype > row(uint32 inRow)
Definition: NdArrayCore.hpp:4345
const_iterator begin(size_type inRow) const
Definition: NdArrayCore.hpp:1134
iterator begin() noexcept
Definition: NdArrayCore.hpp:1090
NdArray< dtype > & put(const Slice &inSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3831
NdArray< dtype > operator()(const Slice &inRowSlice, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:808
const_column_iterator colbegin() const noexcept
Definition: NdArrayCore.hpp:1206
NdArray< dtype > max(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2999
std::reverse_iterator< column_iterator > reverse_column_iterator
Definition: NdArrayCore.hpp:97
NdArray< dtype > & operator=(const NdArray< dtype > &rhs)
Definition: NdArrayCore.hpp:572
value_type item() const
Definition: NdArrayCore.hpp:2978
reference operator()(int32 inRowIndex, int32 inColIndex) noexcept
Definition: NdArrayCore.hpp:683
const_column_iterator colend() const noexcept
Definition: NdArrayCore.hpp:1636
NdArray< dtype > & resizeFast(uint32 inNumRows, uint32 inNumCols)
Definition: NdArrayCore.hpp:4231
const_reverse_iterator crend() const noexcept
Definition: NdArrayCore.hpp:1576
NdArray< dtype > & ones() noexcept
Definition: NdArrayCore.hpp:3501
NdArray< dtype > & zeros() noexcept
Definition: NdArrayCore.hpp:4673
const_column_iterator colbegin(size_type inCol) const
Definition: NdArrayCore.hpp:1220
NdArray< dtype > dot(const NdArray< dtype > &inOtherArray) const
Definition: NdArrayCore.hpp:2664
NdArray< dtype > repeat(uint32 inNumRows, uint32 inNumCols) const
Definition: NdArrayCore.hpp:4063
NdArray< dtype > & reshape(size_type inSize)
Definition: NdArrayCore.hpp:4136
NdArray< bool > contains(value_type inValue, Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2368
const_column_iterator ccolend() const noexcept
Definition: NdArrayCore.hpp:1662
NdArray< uint32 > argmax(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1896
value_type trace(uint32 inOffset=0, Axis inAxis=Axis::ROW) const noexcept
Definition: NdArrayCore.hpp:4601
reverse_column_iterator rcolend() noexcept
Definition: NdArrayCore.hpp:1692
NdArray(std::array< dtype, ArraySize > &inArray, bool copy=true)
Definition: NdArrayCore.hpp:209
NdArray< dtype > & put(int32 inRowIndex, const Slice &inColSlice, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3989
const_reverse_iterator rbegin() const noexcept
Definition: NdArrayCore.hpp:1292
NdArray< dtype > operator()(int32 inRowIndex, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:865
NdArray(const_pointer inPtr, size_type size)
Definition: NdArrayCore.hpp:442
NdArray(const std::deque< dtype > &inDeque)
Definition: NdArrayCore.hpp:353
NdArray(std::array< std::array< dtype, Dim1Size >, Dim0Size > &in2dArray, bool copy=true)
Definition: NdArrayCore.hpp:237
void dump(const std::string &inFilename) const
Definition: NdArrayCore.hpp:2708
dtype & reference
Definition: NdArrayCore.hpp:85
pointer dataRelease() noexcept
Definition: NdArrayCore.hpp:2577
reference at(int32 inRowIndex, int32 inColIndex)
Definition: NdArrayCore.hpp:965
NdArray< dtype > at(const Slice &inRowSlice, const Slice &inColSlice) const
Definition: NdArrayCore.hpp:1045
NdArray(const NdArray< dtype > &inOtherArray)
Definition: NdArrayCore.hpp:522
NdArray< uint32 > argsort(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:2015
NdArray< dtype > operator[](const NdArray< size_type > &inIndices) const
Definition: NdArrayCore.hpp:781
uint32 size_type
Definition: NdArrayCore.hpp:87
const_iterator begin() const noexcept
Definition: NdArrayCore.hpp:1120
NdArray< dtype > & operator=(value_type inValue) noexcept
Definition: NdArrayCore.hpp:598
NdArray< dtype > newbyteorder(Endian inEndianess) const
Definition: NdArrayCore.hpp:3247
column_iterator colend(size_type inCol)
Definition: NdArrayCore.hpp:1620
NdArray< dtype > & put(const Slice &inSlice, value_type inValue)
Definition: NdArrayCore.hpp:3809
void tofile(const std::string &inFilename, const std::string &inSep="") const
Definition: NdArrayCore.hpp:4542
const_reference operator[](int32 inIndex) const noexcept
Definition: NdArrayCore.hpp:664
NdArray< dtype > & ravel() noexcept
Definition: NdArrayCore.hpp:4046
dtype value_type
Definition: NdArrayCore.hpp:81
NdArray(pointer inPtr, size_type size, Bool takeOwnership) noexcept
Definition: NdArrayCore.hpp:488
void replace(value_type oldValue, value_type newValue)
Definition: NdArrayCore.hpp:4118
NdArray< dtype > & put(const Slice &inRowSlice, int32 inColIndex, const NdArray< dtype > &inValues)
Definition: NdArrayCore.hpp:3964
Slice rSlice(int32 inStartIdx=0, uint32 inStepSize=1) const noexcept
Definition: NdArrayCore.hpp:905
const_reverse_iterator crend(size_type inRow) const
Definition: NdArrayCore.hpp:1590
const_reverse_iterator crbegin(size_type inRow) const
Definition: NdArrayCore.hpp:1332
NdArray(const Shape &inShape)
Definition: NdArrayCore.hpp:141
NdArray< bool > all(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:1783
Custom iterator for NdArray.
Definition: NdArrayIterators.hpp:324
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:102
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:137
uint32 numElements(uint32 inArraySize)
Definition: Slice.hpp:188
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(dtype inDofN, dtype inDofD)
Definition: f.hpp:56
bool any_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:76
void sort(RandomIt first, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:629
bool none_of(InputIt first, InputIt last, UnaryPredicate p) noexcept
Definition: StlAlgorithms.hpp:379
ForwardIt max_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:268
void stable_sort(RandomIt first, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:664
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
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:213
InputIt find(InputIt first, InputIt last, const T &value) noexcept
Definition: StlAlgorithms.hpp:195
std::pair< ForwardIt, ForwardIt > minmax_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:341
void replace(ForwardIt first, ForwardIt last, const T &oldValue, const T &newValue) noexcept
Definition: StlAlgorithms.hpp:435
bool is_sorted(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:231
OutputIt copy(InputIt first, InputIt last, OutputIt destination) noexcept
Definition: StlAlgorithms.hpp:95
void nth_element(RandomIt first, RandomIt nth, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:397
ForwardIt min_element(ForwardIt first, ForwardIt last) noexcept
Definition: StlAlgorithms.hpp:304
void fill(ForwardIt first, ForwardIt last, const T &value) noexcept
Definition: StlAlgorithms.hpp:174
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:50
std::pair< NdArray< uint32 >, NdArray< uint32 > > nonzero(const NdArray< dtype > &inArray)
Definition: nonzero.hpp:50
NdArray< dtype > & resizeFast(NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: resizeFast.hpp:51
Axis
Enum To describe an axis.
Definition: Types.hpp:46
NdArray< dtype > & reshape(NdArray< dtype > &inArray, uint32 inSize)
Definition: reshape.hpp:52
std::int64_t int64
Definition: Types.hpp:35
auto abs(dtype inValue) noexcept
Definition: abs.hpp:51
std::uint64_t uint64
Definition: Types.hpp:39
NdArray< dtype > & resizeSlow(NdArray< dtype > &inArray, uint32 inNumRows, uint32 inNumCols)
Definition: resizeSlow.hpp:53
Endian
Enum for endianess.
Definition: Types.hpp:50
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:47
NdArray< dtype > & put(NdArray< dtype > &inArray, const NdArray< uint32 > &inIndices, dtype inValue)
Definition: put.hpp:49
NdArray< dtype > transpose(const NdArray< dtype > &inArray)
Definition: transpose.hpp:47
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:47