NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StdComplexOperators.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <complex>
31
34
35namespace 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 (!utils::essentiallyEqual(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 (!utils::essentiallyEqual(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()), static_cast<Out>(value.imag()));
116 }
117} // namespace nc
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition essentiallyEqual.hpp:49
Definition Cartesian.hpp:40
bool operator>=(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition StdComplexOperators.hpp:98
bool operator>(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition StdComplexOperators.hpp:84
bool operator<(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition StdComplexOperators.hpp:46
std::complex< Out > complex_cast(const std::complex< In > &value) noexcept
Definition StdComplexOperators.hpp:111
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
bool operator<=(const std::complex< T > &lhs, const std::complex< T > &rhs) noexcept
Definition StdComplexOperators.hpp:65