NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
remainder.hpp
Go to the documentation of this file.
1 #pragma once
29 
33 #include "NumCpp/Core/Types.hpp"
34 #include "NumCpp/NdArray.hpp"
35 
36 #include <cmath>
37 #include <string>
38 
39 namespace nc
40 {
41  //============================================================================
42  // Method Description:
52  template<typename dtype>
53  double remainder(dtype inValue1, dtype inValue2) noexcept
54  {
56 
57  return static_cast<double>(std::remainder(inValue1, inValue2));
58  }
59 
60  //============================================================================
61  // Method Description:
71  template<typename dtype>
72  NdArray<double> remainder(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
73  {
74  if (inArray1.shape() != inArray2.shape())
75  {
76  THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
77  }
78 
79  NdArray<double> returnArray(inArray1.shape());
80  stl_algorithms::transform(inArray1.cbegin(), inArray1.cend(), inArray2.cbegin(), returnArray.begin(),
81  [](dtype inValue1, dtype inValue2) noexcept -> double
82  {
83  return remainder(inValue1, inValue2);
84  });
85 
86  return returnArray;
87  }
88 } // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1216
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4283
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1524
iterator begin() noexcept
Definition: NdArrayCore.hpp:1166
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
Definition: Coordinate.hpp:45
double remainder(dtype inValue1, dtype inValue2) noexcept
Definition: remainder.hpp:53
NdArray< double > remainder(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition: remainder.hpp:72