NumCpp  2.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 
53  return lhs.imag() < rhs.imag();
54  }
55 
56  //============================================================================
57  // Method Description:
64  template<typename T>
65  bool operator<=(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
66  {
67  if (lhs.real() != rhs.real())
68  {
69  return lhs.real() <= rhs.real();
70  }
71 
72  return lhs.imag() <= rhs.imag();
73  }
74 
75  //============================================================================
76  // Method Description:
83  template<typename T>
84  bool operator>(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
85  {
86  return !(lhs <= rhs);
87  }
88 
89  //============================================================================
90  // Method Description:
97  template<typename T>
98  bool operator>=(const std::complex<T>& lhs, const std::complex<T>& rhs) noexcept
99  {
100  return !(lhs < rhs);
101  }
102 
103  //============================================================================
104  // Method Description:
110  template<typename Out, typename In>
111  std::complex<Out> complex_cast(const std::complex<In>& value) noexcept
112  {
114 
115  return std::complex<Out>(static_cast<Out>(value.real()),
116  static_cast<Out>(value.imag()));
117  }
118 } // namespace nc
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:65
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:98
nc
Definition: Coordinate.hpp:45
nc::operator>
bool operator>(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition: StdComplexOperators.hpp:84
nc::complex_cast
std::complex< Out > complex_cast(const std::complex< In > &value) noexcept
Definition: StdComplexOperators.hpp:111