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