|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
#include <triqs/utility/real_or_complex.hpp>
Type that can represent either a real or a complex number.
Internally stores a std::complex<double> and a bool flag indicating whether the imaginary part is known to be zero.
Arithmetic operations (+, -, *, /) and compound assignment operations (+=, -=, *=, /=) are provided for all combinations of real_or_complex, std::complex<double> and double operands. The result is real if and only if both operands are real.
Once the value is considered complex, conversion back to real throws.
Definition at line 56 of file real_or_complex.hpp.
Public Member Functions | |
| real_or_complex () | |
| Default construct a real value initialized to zero. | |
| real_or_complex (double x) | |
| Construct a real value. | |
| real_or_complex (std::complex< double > x) | |
| Construct a complex value. | |
| bool | is_real () const |
| Whether the stored value is real. | |
| operator double () const | |
| Explicit conversion to double. | |
| operator std::complex< double > () const | |
| Explicit conversion to std::complex<double>. | |
| bool | operator!= (real_or_complex const &x) const |
| Not-equal-to operator compares the underlying complex values exactly. | |
| bool | operator== (real_or_complex const &x) const |
| Equal-to operator compares the underlying complex values exactly. | |
Friends | |
| double | abs (real_or_complex const &x) |
| Absolute value of a utility::real_or_complex value. | |
| real_or_complex | conj (real_or_complex x) |
| Complex conjugate of a utility::real_or_complex value. | |
| double | imag (real_or_complex const &x) |
| Imaginary part of a utility::real_or_complex value. | |
| bool | is_zero (real_or_complex const &x, double tolerance=100 *std::numeric_limits< double >::epsilon()) |
| Zero check for a utility::real_or_complex value. | |
| real_or_complex | operator- (real_or_complex a) |
| Unary minus operator for a utility::real_or_complex value. | |
| std::ostream & | operator<< (std::ostream &out, real_or_complex const &x) |
| Write a utility::real_or_complex value to an output stream. | |
| double | real (real_or_complex const &x) |
| Real part of a utility::real_or_complex value. | |
|
inline |
Construct a real value.
| x | Real value to store. |
Definition at line 68 of file real_or_complex.hpp.
|
inline |
Construct a complex value.
| x | Complex value to store. |
Definition at line 74 of file real_or_complex.hpp.
|
inline |
Whether the stored value is real.
Definition at line 80 of file real_or_complex.hpp.
|
inlineexplicit |
Explicit conversion to double.
It throws a triqs::runtime_error if the stored value is complex.
Definition at line 93 of file real_or_complex.hpp.
|
inlineexplicit |
Explicit conversion to std::complex<double>.
Definition at line 86 of file real_or_complex.hpp.
|
inline |
Not-equal-to operator compares the underlying complex values exactly.
| x | Value to compare against. |
Definition at line 190 of file real_or_complex.hpp.
|
inline |
Equal-to operator compares the underlying complex values exactly.
| x | Value to compare against. |
Definition at line 182 of file real_or_complex.hpp.
|
friend |
Absolute value of a utility::real_or_complex value.
| x | Value to inspect. |
Definition at line 131 of file real_or_complex.hpp.
|
friend |
Complex conjugate of a utility::real_or_complex value.
| x | Value to conjugate. |
Definition at line 139 of file real_or_complex.hpp.
|
friend |
Imaginary part of a utility::real_or_complex value.
| x | Value to inspect. |
Definition at line 123 of file real_or_complex.hpp.
|
friend |
Zero check for a utility::real_or_complex value.
| x | Value to test. |
| tolerance | Absolute tolerance \( \epsilon \). |
Definition at line 152 of file real_or_complex.hpp.
|
friend |
Unary minus operator for a utility::real_or_complex value.
| a | Value to negate. |
Definition at line 104 of file real_or_complex.hpp.
|
friend |
Write a utility::real_or_complex value to an output stream.
| out | Output stream to write to. |
| x | Value to write. |
Definition at line 165 of file real_or_complex.hpp.
|
friend |
Real part of a utility::real_or_complex value.
| x | Value to inspect. |
Definition at line 115 of file real_or_complex.hpp.