NumCpp  1.0
A C++ implementation of the Python Numpy library
arctan2.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #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  auto arctan2(dtype inY, dtype inX) noexcept
54  {
56 
57  return std::atan2(inY, inX);
58  }
59 
60  //============================================================================
61  // Method Description:
71  template<typename dtype>
72  auto arctan2(const NdArray<dtype>& inY, const NdArray<dtype>& inX)
73  {
74  if (inX.shape() != inY.shape())
75  {
76  THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
77  }
78 
79  NdArray<decltype(arctan2(dtype{0}, dtype{0}))> returnArray(inY.shape());
80  stl_algorithms::transform(inY.cbegin(), inY.cend(), inX.cbegin(), returnArray.begin(),
81  [](dtype y, dtype x) noexcept -> auto
82  {
83  return arctan2(y, x);
84  });
85 
86  return returnArray;
87  }
88 }
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4296
Error.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::NdArray< dtype >
nc::arctan2
auto arctan2(dtype inY, dtype inX) noexcept
Definition: arctan2.hpp:53
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::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction) noexcept
Definition: StlAlgorithms.hpp:703
nc::NdArray::cbegin
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1147
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1091