NumCpp  2.4.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:
53  template<typename dtype>
54  double remainder(dtype inValue1, dtype inValue2) noexcept
55  {
57 
58  return std::remainder(static_cast<double>(inValue1), static_cast<double>(inValue2));
59  }
60 
61  //============================================================================
62  // Method Description:
73  template<typename dtype>
74  NdArray<double> remainder(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
75  {
76  if (inArray1.shape() != inArray2.shape())
77  {
78  THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
79  }
80 
81  NdArray<double> returnArray(inArray1.shape());
82  stl_algorithms::transform(inArray1.cbegin(), inArray1.cend(), inArray2.cbegin(), returnArray.begin(),
83  [](dtype inValue1, dtype inValue2) noexcept -> double
84  {
85  return remainder(inValue1, inValue2);
86  });
87 
88  return returnArray;
89  }
90 } // namespace nc
StaticAsserts.hpp
nc::remainder
NdArray< double > remainder(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition: remainder.hpp:74
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4356
Error.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::NdArray< double >
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
NdArray.hpp
nc::remainder
double remainder(dtype inValue1, dtype inValue2) noexcept
Definition: remainder.hpp:54
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1487
nc
Definition: Coordinate.hpp:44
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1143
StlAlgorithms.hpp
Types.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087