NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
arctan2.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31
35#include "NumCpp/NdArray.hpp"
36
37namespace nc
38{
39 //============================================================================
40 // Method Description:
49 template<typename dtype>
50 auto arctan2(dtype inY, dtype inX) noexcept
51 {
53
54 return std::atan2(inY, inX);
55 }
56
57 //============================================================================
58 // Method Description:
67 template<typename dtype>
68 auto arctan2(const NdArray<dtype>& inY, const NdArray<dtype>& inX)
69 {
70 if (inX.shape() != inY.shape())
71 {
72 THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
73 }
74
75 NdArray<decltype(arctan2(dtype{ 0 }, dtype{ 0 }))> returnArray(inY.shape());
77 inY.cend(),
78 inX.cbegin(),
79 returnArray.begin(),
80 [](dtype y, dtype x) noexcept -> auto { return arctan2(y, x); });
81
82 return returnArray;
83 }
84} // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition StlAlgorithms.hpp:776
Definition Cartesian.hpp:39
auto arctan2(dtype inY, dtype inX) noexcept
Definition arctan2.hpp:50