NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
fmod.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <cmath>
31 #include <string>
32 
36 #include "NumCpp/NdArray.hpp"
37 
38 namespace nc
39 {
40  //============================================================================
41  // Method Description:
51  template<typename dtype, enable_if_t<is_integral_v<dtype>, int> = 0>
52  dtype fmod(dtype inValue1, dtype inValue2) noexcept
53  {
54  return inValue1 % inValue2;
55  }
56 
57  //============================================================================
58  // Method Description:
68  template<typename dtype, enable_if_t<is_floating_point_v<dtype>, int> = 0>
69  dtype fmod(dtype inValue1, dtype inValue2) noexcept
70  {
71  return std::fmod(inValue1, inValue2);
72  }
73 
74  //============================================================================
75  // Method Description:
85  template<typename dtype>
86  NdArray<dtype> fmod(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
87  {
88  if (inArray1.shape() != inArray2.shape())
89  {
90  THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
91  }
92 
93  NdArray<dtype> returnArray(inArray1.shape());
94 
96  inArray1.cend(),
97  inArray2.cbegin(),
98  returnArray.begin(),
99  [](dtype inValue1, dtype inValue2) noexcept -> dtype
100  { return fmod(inValue1, inValue2); });
101 
102  return returnArray;
103  }
104 } // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
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 fmod(dtype inValue1, dtype inValue2) noexcept
Definition: fmod.hpp:52
NdArray< dtype > fmod(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition: fmod.hpp:86