NumCpp  2.1.0
A C++ implementation of the Python Numpy library
fmod.hpp
Go to the documentation of this file.
1 #pragma once
30 
34 #include "NumCpp/NdArray.hpp"
35 
36 #include <string>
37 
38 namespace nc
39 {
40  //============================================================================
41  // Method Description:
52  template<typename dtype>
53  dtype fmod(dtype inValue1, dtype inValue2) noexcept
54  {
55  STATIC_ASSERT_INTEGER(dtype);
56 
57  return inValue1 % inValue2;
58  }
59 
60  //============================================================================
61  // Method Description:
72  template<typename dtype>
73  NdArray<dtype> fmod(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
74  {
75  if (inArray1.shape() != inArray2.shape())
76  {
77  THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
78  }
79 
80  NdArray<dtype> returnArray(inArray1.shape());
81 
82  stl_algorithms::transform(inArray1.cbegin(), inArray1.cend(), inArray2.cbegin(), returnArray.begin(),
83  [](dtype inValue1, dtype inValue2) noexcept -> dtype
84  {
85  return fmod(inValue1, inValue2);
86  });
87 
88  return returnArray;
89  }
90 } // namespace nc
STATIC_ASSERT_INTEGER
#define STATIC_ASSERT_INTEGER(dtype)
Definition: StaticAsserts.hpp:41
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4312
Error.hpp
nc::NdArray< dtype >
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:703
NdArray.hpp
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1491
nc
Definition: Coordinate.hpp:45
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1147
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091
nc::fmod
dtype fmod(dtype inValue1, dtype inValue2) noexcept
Definition: fmod.hpp:53