NumCpp  1.0
A C++ implementation of the Python Numpy library
unwrap.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
34 
35 #include <cmath>
36 
37 namespace nc
38 {
39  //============================================================================
40  // Method Description:
52  template<typename dtype>
53  dtype unwrap(dtype inValue) noexcept
54  {
56 
57  return static_cast<dtype>(std::atan2(std::sin(inValue), std::cos(inValue)));
58  }
59 
60  //============================================================================
61  // Method Description:
73  template<typename dtype>
75  {
76  NdArray<dtype> returnArray(inArray.shape());
77  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
78  [](dtype inValue) noexcept -> dtype
79  {
80  return unwrap(inValue);
81  });
82 
83  return returnArray;
84  }
85 }
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4296
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::NdArray< dtype >
nc::cos
auto cos(dtype inValue) noexcept
Definition: cos.hpp:52
NdArray.hpp
nc::unwrap
dtype unwrap(dtype inValue) noexcept
Definition: unwrap.hpp:53
nc::NdArray::cend
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1491
nc::sin
auto sin(dtype inValue) noexcept
Definition: sin.hpp:52
nc
Definition: Coordinate.hpp:45
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