NumCpp  2.10.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
fmax.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <cmath>
31 #include <complex>
32 #include <string>
33 
37 #include "NumCpp/NdArray.hpp"
38 
39 namespace nc
40 {
41  //============================================================================
42  // Method Description:
54  template<typename dtype>
55  dtype fmax(dtype inValue1, dtype inValue2) noexcept
56  {
58 
59  return std::max(inValue1,
60  inValue2,
61  [](const dtype value1, const dtype value2) noexcept -> bool { return value1 < value2; });
62  }
63 
64  //============================================================================
65  // Method Description:
77  template<typename dtype>
78  NdArray<dtype> fmax(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
79  {
80  return broadcast::broadcaster<dtype>(inArray1,
81  inArray2,
82  [](dtype inValue1, dtype inValue2) noexcept -> dtype
83  { return fmax(inValue1, inValue2); });
84  }
85 
86  //============================================================================
87  // Method Description:
100  template<typename dtype>
101  NdArray<dtype> fmax(const NdArray<dtype>& inArray, const dtype& inScalar)
102  {
103  const NdArray<dtype> inArray2 = { inScalar };
104  return fmax(inArray, inArray2);
105  }
106 
107  //============================================================================
108  // Method Description:
121  template<typename dtype>
122  NdArray<dtype> fmax(const dtype& inScalar, const NdArray<dtype>& inArray)
123  {
124  return fmax(inArray, inScalar);
125  }
126 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:56
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:138
Definition: Coordinate.hpp:45
NdArray< dtype > max(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: max.hpp:44
dtype fmax(dtype inValue1, dtype inValue2) noexcept
Definition: fmax.hpp:55