C++QEDCore  v2 Milestone 10
a framework for simulating open quantum dynamics – core
ComplexExtensions.h
Go to the documentation of this file.
1 // Copyright András Vukics 2006–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
2 // -*- C++ -*-
4 #ifndef CPPQEDCORE_UTILS_COMPLEXEXTENSIONS_H_INCLUDED
5 #define CPPQEDCORE_UTILS_COMPLEXEXTENSIONS_H_INCLUDED
6 
7 #include "core_config.h"
8 
9 #include <complex>
10 
11 #ifndef DO_NOT_USE_BOOST_SERIALIZATION
12 #include <boost/serialization/complex.hpp>
13 #endif // DO_NOT_USE_BOOST_SERIALIZATION
14 
15 
17 
18 typedef std::complex<double> dcomp;
19 
21 const dcomp DCOMP_I(0,1);
22 
23 inline bool isNonZero(const dcomp& c) {return bool(real(c)) || bool(imag(c));}
24 
25 inline bool hasRealPart(const dcomp& c) {return bool(real(c));}
26 inline bool hasImagPart(const dcomp& c) {return bool(imag(c));}
27 
28 inline bool absCompare(const dcomp& c1, const dcomp& c2) {return abs(c1)< abs(c2);}
29 inline bool realCompare(const dcomp& c1, const dcomp& c2) {return real(c1)<real(c2);}
30 
31 #endif // CPPQEDCORE_UTILS_COMPLEXEXTENSIONS_H_INCLUDED
const dcomp DCOMP_I(0, 1)
Imaginary unit.
std::complex< double > dcomp
Double-precision complex number.