NumCpp  2.1.0
A C++ implementation of the Python Numpy library
remainder.hpp
Go to the documentation of this file.
1 #pragma once
30 
34 #include "NumCpp/Core/Types.hpp"
35 #include "NumCpp/NdArray.hpp"
36 
37 #include <cmath>
38 #include <string>
39 
40 namespace nc
41 {
42  //============================================================================
43  // Method Description:
54  template<typename dtype>
55  double remainder(dtype inValue1, dtype inValue2) noexcept
56  {
58 
59  return std::remainder(static_cast<double>(inValue1), static_cast<double>(inValue2));
60  }
61 
62  //============================================================================
63  // Method Description:
74  template<typename dtype>
75  NdArray<double> remainder(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
76  {
77  if (inArray1.shape() != inArray2.shape())
78  {
79  THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
80  }
81 
82  NdArray<double> returnArray(inArray1.shape());
83  stl_algorithms::transform(inArray1.cbegin(), inArray1.cend(), inArray2.cbegin(), returnArray.begin(),
84  [](dtype inValue1, dtype inValue2) noexcept -> double
85  {
86  return remainder(inValue1, inValue2);
87  });
88 
89  return returnArray;
90  }
91 } // namespace nc
StaticAsserts.hpp
nc::remainder
NdArray< double > remainder(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition: remainder.hpp:75
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4312
Error.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::NdArray< double >
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:703
NdArray.hpp
nc::remainder
double remainder(dtype inValue1, dtype inValue2) noexcept
Definition: remainder.hpp:55
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
Types.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091