NumCpp  2.1.0
A C++ implementation of the Python Numpy library
nanargmax.hpp
Go to the documentation of this file.
1 #pragma once
30 
34 #include "NumCpp/Core/Types.hpp"
36 #include "NumCpp/NdArray.hpp"
37 
38 #include <cmath>
39 
40 namespace nc
41 {
42  //============================================================================
43  // Method Description:
53  template<typename dtype>
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>::min(); };
63  });
64 
65  return argmax(arrayCopy, inAxis);
66  }
67 } // 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:75
nc::stl_algorithms::for_each
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:214
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
argmax.hpp
nc::nanargmax
NdArray< uint32 > nanargmax(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: nanargmax.hpp:54
StlAlgorithms.hpp
Types.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091
nc::argmax
NdArray< uint32 > argmax(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: argmax.hpp:48