NumCpp  2.5.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
nanmin.hpp
Go to the documentation of this file.
1 #pragma once
29 
33 #include "NumCpp/Core/Types.hpp"
34 #include "NumCpp/Functions/min.hpp"
35 #include "NumCpp/NdArray.hpp"
36 
37 #include <cmath>
38 
39 namespace nc
40 {
41  //============================================================================
42  // Method Description:
53  template<typename dtype>
54  NdArray<dtype> nanmin(const NdArray<dtype>& inArray, Axis inAxis = Axis::NONE)
55  {
56  STATIC_ASSERT_FLOAT(dtype);
57 
58  NdArray<dtype> arrayCopy(inArray);
59  stl_algorithms::for_each(arrayCopy.begin(), arrayCopy.end(),
60  [](dtype& value) noexcept -> void
61  {
62  if (std::isnan(value)) { value = DtypeInfo<dtype>::max(); };
63  });
64 
65  return min(arrayCopy, inAxis);
66  }
67 } // namespace nc
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:43
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
iterator end() noexcept
Definition: NdArrayCore.hpp:1558
iterator begin() noexcept
Definition: NdArrayCore.hpp:1214
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:213
Definition: Coordinate.hpp:45
NdArray< dtype > nanmin(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: nanmin.hpp:54
Axis
Enum To describe an axis.
Definition: Types.hpp:46
NdArray< dtype > min(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: min.hpp:45