NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
fmin.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 fmin(dtype inValue1, dtype inValue2) noexcept
56  {
58 
59  return std::min(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> fmin(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
79  {
80  if (inArray1.shape() != inArray2.shape())
81  {
82  THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
83  }
84 
85  NdArray<dtype> returnArray(inArray1.shape());
86 
88  inArray1.cend(),
89  inArray2.cbegin(),
90  returnArray.begin(),
91  [](dtype inValue1, dtype inValue2) noexcept -> dtype
92  { return fmin(inValue1, inValue2); });
93 
94  return returnArray;
95  }
96 } // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:49
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1221
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4092
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1529
iterator begin() noexcept
Definition: NdArrayCore.hpp:1171
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:784
Definition: Coordinate.hpp:45
dtype fmin(dtype inValue1, dtype inValue2) noexcept
Definition: fmin.hpp:55
NdArray< dtype > min(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: min.hpp:44