12 #ifndef QMCPLUSPLUS_COMPLEX_HELP_HPP 13 #define QMCPLUSPLUS_COMPLEX_HELP_HPP 15 #include <type_traits> 28 using IsComplex = std::enable_if_t<IsComplex_t<T>::value,
bool>;
35 using IsReal = std::enable_if_t<std::is_floating_point<T>::value,
bool>;
37 template<
typename T,
typename =
bool>
62 template<
typename TREAL,
typename TREF,
typename =
bool>
66 template<
typename TREAL,
typename TREF>
72 template<
typename TREAL,
typename TREF>
82 template<typename TREAL, typename TREF, typename = std::enable_if_t<std::is_floating_point<TREAL>::value>>
86 inline float real(
const float& c) {
return c; }
87 inline double real(
const double& c) {
return c; }
88 inline float real(
const std::complex<float>& c) {
return c.real(); }
89 inline double real(
const std::complex<double>& c) {
return c.real(); }
91 inline float imag(
const float& c) {
return 0; }
92 inline double imag(
const double& c) {
return 0; }
93 inline float imag(
const std::complex<float>& c) {
return c.imag(); }
94 inline double imag(
const std::complex<double>& c) {
return c.imag(); }
96 inline float conj(
const float& c) {
return c; }
97 inline double conj(
const double& c) {
return c; }
98 inline std::complex<float>
conj(
const std::complex<float>& c) {
return std::conj(c); }
99 inline std::complex<double>
conj(
const std::complex<double>& c) {
return std::conj(c); }
helper functions for EinsplineSetBuilder
void copy_with_complex_cast(const std::complex< double > &source, std::complex< double > &dest)
float real(const float &c)
real part of a scalar. Cannot be replaced by std::real due to AFQMC specific needs.
std::enable_if_t< IsComplex_t< T >::value, bool > IsComplex
float imag(const float &c)
imaginary part of a scalar. Cannot be replaced by std::imag due to AFQMC specific needs...
std::enable_if_t< std::is_floating_point< T >::value, bool > IsReal
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
std::complex< TREAL > value_type
typename RealAlias_impl< T >::value_type RealAlias
If you have a function templated on a value that can be real or complex and you need to get the base ...
typename ValueAlias_impl< TREAL, TREF >::value_type ValueAlias
If you need to make a value type of a given precision based on a reference value type set the desired...
std::is_floating_point< T > IsReal_t
QMCTraits::FullPrecRealType value_type
typename T::value_type value_type
std::complex< double > conj(const std::complex< double > &c)