NumCpp  1.0
A C++ implementation of the Python Numpy library
StdComplexOperators.hpp
Go to the documentation of this file.
1 #pragma once
30 
32 
33 #include <complex>
34 
35 namespace nc
36 {
37  //============================================================================
38  // Method Description:
45  template<typename T>
46  bool operator<(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
47  {
48  if (lhs.real() != rhs.real())
49  {
50  return lhs.real() < rhs.real();
51  }
52  else
53  {
54  return lhs.imag() < rhs.imag();
55  }
56  }
57 
58  //============================================================================
59  // Method Description:
66  template<typename T>
67  bool operator<=(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
68  {
69  if (lhs.real() != rhs.real())
70  {
71  return lhs.real() <= rhs.real();
72  }
73  else
74  {
75  return lhs.imag() <= rhs.imag();
76  }
77  }
78 
79  //============================================================================
80  // Method Description:
87  template<typename T>
88  bool operator>(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
89  {
90  return !(lhs <= rhs);
91  }
92 
93  //============================================================================
94  // Method Description:
101  template<typename T>
102  bool operator>=(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
103  {
104  return !(lhs < rhs);
105  }
106 
107  //============================================================================
108  // Method Description:
114  template<typename Out, typename In>
115  std::complex<Out> complex_cast(const std::complex<In>& value) noexcept
116  {
118 
119  return std::complex<Out>(static_cast<Out>(value.real()),
120  static_cast<Out>(value.imag()));
121  }
122 }
StaticAsserts.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::operator<=
bool operator<=(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:67
nc::operator<
bool operator<(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:46
nc::operator>=
bool operator>=(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:102
nc
Definition: Coordinate.hpp:45
nc::operator>
bool operator>(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:88
nc::complex_cast
std::complex< Out > complex_cast(const std::complex< In > &value) noexcept
Definition: StdComplexOperators.hpp:115