NumCpp  1.0
A C++ implementation of the Python Numpy library
nanmin.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
33 #include "NumCpp/Core/Types.hpp"
36 #include "NumCpp/Functions/min.hpp"
37 
38 #include <cmath>
39 
40 namespace nc
41 {
42  //============================================================================
43  // Method Description:
54  template<typename dtype>
55  NdArray<dtype> nanmin(const NdArray<dtype>& inArray, Axis inAxis = Axis::NONE)
56  {
57  STATIC_ASSERT_FLOAT(dtype);
58 
59  NdArray<dtype> arrayCopy(inArray);
60  stl_algorithms::for_each(arrayCopy.begin(), arrayCopy.end(),
61  [](dtype& value) noexcept -> void
62  {
63  if (std::isnan(value)) { value = DtypeInfo<dtype>::max(); };
64  });
65 
66  return min(arrayCopy, inAxis);
67  }
68 }
StaticAsserts.hpp
nc::Axis::NONE
@ NONE
nc::stl_algorithms::for_each
void for_each(InputIt first, InputIt last, UnaryFunction f) noexcept
Definition: StlAlgorithms.hpp:214
nc::NdArray< dtype >
min.hpp
NdArray.hpp
STATIC_ASSERT_FLOAT
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:44
nc::NdArray::end
iterator end() noexcept
Definition: NdArrayCore.hpp:1435
nc::Axis
Axis
Enum To describe an axis.
Definition: Types.hpp:47
nc
Definition: Coordinate.hpp:45
DtypeInfo.hpp
nc::nanmin
NdArray< dtype > nanmin(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: nanmin.hpp:55
StlAlgorithms.hpp
Types.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091
nc::min
NdArray< dtype > min(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: min.hpp:46