NumCpp  2.5.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
StdComplexOperators.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 
32 #include <complex>
33 
34 namespace nc
35 {
36  //============================================================================
37  // Method Description:
44  template<typename T>
45  bool operator<(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
46  {
47  if (lhs.real() != rhs.real())
48  {
49  return lhs.real() < rhs.real();
50  }
51 
52  return lhs.imag() < rhs.imag();
53  }
54 
55  //============================================================================
56  // Method Description:
63  template<typename T>
64  bool operator<=(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
65  {
66  if (lhs.real() != rhs.real())
67  {
68  return lhs.real() <= rhs.real();
69  }
70 
71  return lhs.imag() <= rhs.imag();
72  }
73 
74  //============================================================================
75  // Method Description:
82  template<typename T>
83  bool operator>(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
84  {
85  return !(lhs <= rhs);
86  }
87 
88  //============================================================================
89  // Method Description:
96  template<typename T>
97  bool operator>=(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
98  {
99  return !(lhs < rhs);
100  }
101 
102  //============================================================================
103  // Method Description:
109  template<typename Out, typename In>
110  std::complex<Out> complex_cast(const std::complex<In>& value) noexcept
111  {
113 
114  return std::complex<Out>(static_cast<Out>(value.real()),
115  static_cast<Out>(value.imag()));
116  }
117 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Definition: Coordinate.hpp:45
bool operator>=(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:97
bool operator>(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:83
bool operator<(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:45
bool operator<=(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:64
std::complex< Out > complex_cast(const std::complex< In > &value) noexcept
Definition: StdComplexOperators.hpp:110