62 template<
typename dtype>
70 if (inPercentile < 0. || inPercentile > 100.)
104 static_cast<uint32>(std::floor(
static_cast<double>(inArray.
size() - 1) * inPercentile / 100.));
107 switch (inInterpMethod)
111 const double percentI =
112 static_cast<double>(indexLower) /
static_cast<double>(inArray.
size() - 1);
113 const double fraction =
114 (inPercentile / 100. - percentI) /
115 (
static_cast<double>(indexLower + 1) /
static_cast<double>(inArray.
size() - 1) - percentI);
118 arrayCopy[indexLower] + (arrayCopy[indexLower + 1] - arrayCopy[indexLower]) * fraction
134 const double percent = inPercentile / 100.;
135 const double percent1 =
136 static_cast<double>(indexLower) /
static_cast<double>(inArray.
size() - 1);
137 const double percent2 =
138 static_cast<double>(indexLower + 1) /
static_cast<double>(inArray.
size() - 1);
139 const double diff1 = percent - percent1;
140 const double diff2 = percent2 - percent;
160 NdArray<double> returnArray = { (arrayCopy[indexLower] + arrayCopy[indexLower + 1]) / 2. };
175 for (
uint32 row = 0; row < inShape.
rows; ++row)
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
iterator end() noexcept
Definition NdArrayCore.hpp:1619
typename AllocTraits::pointer pointer
Definition NdArrayCore.hpp:148
self_type transpose() const
Definition NdArrayCore.hpp:4959
bool isempty() const noexcept
Definition NdArrayCore.hpp:3008
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
const_reference back() const noexcept
Definition NdArrayCore.hpp:2359
const_reference front() const noexcept
Definition NdArrayCore.hpp:2936
iterator begin() noexcept
Definition NdArrayCore.hpp:1311
bool isscalar() const noexcept
Definition NdArrayCore.hpp:3032
value_type item() const
Definition NdArrayCore.hpp:3098
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
uint32 rows
Definition Core/shape.hpp:44
uint32 cols
Definition Core/shape.hpp:45
void sort(RandomIt first, RandomIt last) noexcept
Definition StlAlgorithms.hpp:697
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition essentiallyEqual.hpp:47
Definition Cartesian.hpp:39
InterpolationMethod
Definition Enums.hpp:139
@ HIGHER
Definition Enums.hpp:142
@ LOWER
Definition Enums.hpp:141
@ LINEAR
Definition Enums.hpp:140
@ NEAREST
Definition Enums.hpp:143
@ MIDPOINT
Definition Enums.hpp:144
dtype clip(dtype inValue, dtype inMinValue, dtype inMaxValue)
Definition clip.hpp:49
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
NdArray< double > percentile(const NdArray< dtype > &inArray, double inPercentile, Axis inAxis=Axis::NONE, InterpolationMethod inInterpMethod=InterpolationMethod::LINEAR)
Definition percentile.hpp:63
NdArray< uint32 > argmin(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition argmin.hpp:46
@ SHELL
Definition Enums.hpp:58
NdArray< dtypeOut > astype(const NdArray< dtype > inArray)
Definition astype.hpp:43
std::uint32_t uint32
Definition Types.hpp:40