3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 11:43:47 +01:00
dft_tools/triqs/utility/complex_ops.hpp
Olivier Parcollet aa2c52cb01 utility : tuple, complex_ops
- add _j notation on C++11 compliant compilers
- correct tuple fold (was working in reverse)
- add construction of mini_vector from tuple
2013-07-19 13:27:03 +02:00

26 lines
1.2 KiB
C++

#ifndef TRIQS_UTILITY_COMPLEX_OPS_H
#define TRIQS_UTILITY_COMPLEX_OPS_H
#include <complex>
#ifdef TRIQS_COMPILER_IS_C11_COMPLIANT
inline std::complex<double> operator"" _j ( long double x ) { return std::complex<double>(0,x); }
inline std::complex<double> operator"" _j ( unsigned long long x ) { return std::complex<double>(0,x); }
#endif
namespace std { // has to be in the right namespace for ADL !
template<typename T> std::complex<T> operator+(std::complex<T> const & a, long b) { return a+T(b);}
template<typename T> std::complex<T> operator+(long a, std::complex<T> const & b) { return T(a)+b;}
template<typename T> std::complex<T> operator-(std::complex<T> const & a, long b) { return a-T(b);}
template<typename T> std::complex<T> operator-(long a, std::complex<T> const & b) { return T(a)-b;}
template<typename T> std::complex<T> operator*(std::complex<T> const & a, long b) { return a*T(b);}
template<typename T> std::complex<T> operator*(long a, std::complex<T> const & b) { return T(a)*b;}
template<typename T> std::complex<T> operator/(std::complex<T> const & a, long b) { return a/T(b);}
template<typename T> std::complex<T> operator/(long a, std::complex<T> const & b) { return T(a)/b;}
}
#endif