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