NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
imag.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 #include "NumCpp/NdArray.hpp"
32 
33 #include <complex>
34 
35 namespace nc
36 {
37  //============================================================================
38  // Method Description:
48  template<typename dtype>
49  auto imag(const std::complex<dtype>& inValue)
50  {
52 
53  return std::imag(inValue);
54  }
55 
56  //============================================================================
57  // Method Description:
67  template<typename dtype>
68  auto imag(const NdArray<std::complex<dtype>>& inArray)
69  {
70  NdArray<decltype(nc::imag(std::complex<dtype>{0}))> returnArray(inArray.shape());
71  stl_algorithms::transform(inArray.cbegin(), inArray.cend(), returnArray.begin(),
72  [](auto& inValue) -> auto
73  {
74  return nc::imag(inValue);
75  });
76 
77  return returnArray;
78  }
79 } // namespace nc
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::imag
auto imag(const NdArray< std::complex< dtype >> &inArray)
Definition: imag.hpp:68
nc::NdArray
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:71
nc::stl_algorithms::transform
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
NdArray.hpp
nc::imag
auto imag(const std::complex< dtype > &inValue)
Definition: imag.hpp:49
nc
Definition: Coordinate.hpp:44
StlAlgorithms.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087