Loading [MathJax]/extensions/TeX/newcommand.js
 deal.II version GIT relicensing-3110-g10dd77059b 2025-04-22 10:30:00+00:00
\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}} \newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=} \newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]} \newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
Functions
complex_overloads.h File Reference
#include <deal.II/base/config.h>
#include <complex>
#include <type_traits>

Go to the source code of this file.

Functions

template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, std::complex< U > >::type > operator* (const std::complex< T > &left, const std::complex< U > &right)
 
template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, std::complex< U > >::type > operator/ (const std::complex< T > &left, const std::complex< U > &right)
 
template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, U >::type > operator* (const std::complex< T > &left, const U &right)
 
template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, U >::type > operator/ (const std::complex< T > &left, const U &right)
 
template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< T, std::complex< U > >::type > operator* (const T &left, const std::complex< U > &right)
 
template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< T, std::complex< U > >::type > operator/ (const T &left, const std::complex< U > &right)
 

Function Documentation

◆ operator*() [1/3]

template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, std::complex< U > >::type > operator* ( const std::complex< T > &  left,
const std::complex< U > &  right 
)
inline

Provide an operator* that operates on mixed complex floating point types. Annoyingly, the standard library does not provide such an operator.

Note
Because the C++ standard does not provide for mixed-precision complex operators, code such as the following does not compile:
double factor = 3.141;
std::complex<float> x(1,2); // =1+2i
auto z = factor*x; // error
Because this does not compile, writing mixed-precision complex linear algebra libraries is not easily possible without much additional work that requires explicit casts. For example, one would have to write the code above as follows:
double factor = 1.0;
std::complex<float> x(1,2); // =1+2i
auto z = static_cast<P>(factor) * static_cast<P>(x);
This makes much code unreadable. As a consequence, we define the necessary overloaded multiplication and division operators for mixed complex arithmetic (in namespace dealii) to make the code above compile without the extra casts.

Definition at line 70 of file complex_overloads.h.

◆ operator/() [1/3]

template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, std::complex< U > >::type > operator/ ( const std::complex< T > &  left,
const std::complex< U > &  right 
)
inline

Provide an operator/ that operates on mixed complex floating point types. Annoyingly, the standard library does not provide such an operator.

Note
Because the C++ standard does not provide for mixed-precision complex operators, code such as the following does not compile:
double factor = 3.141;
std::complex<float> x(1,2); // =1+2i
auto z = factor*x; // error
Because this does not compile, writing mixed-precision complex linear algebra libraries is not easily possible without much additional work that requires explicit casts. For example, one would have to write the code above as follows:
double factor = 1.0;
std::complex<float> x(1,2); // =1+2i
auto z = static_cast<P>(factor) * static_cast<P>(x);
This makes much code unreadable. As a consequence, we define the necessary overloaded multiplication and division operators for mixed complex arithmetic (in namespace dealii) to make the code above compile without the extra casts.

Definition at line 111 of file complex_overloads.h.

◆ operator*() [2/3]

template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, U >::type > operator* ( const std::complex< T > &  left,
const U &  right 
)
inline

Provide an operator* for a scalar multiplication of a complex floating point type with a different real floating point type. Annoyingly, the standard library does not provide such an operator.

Note
Because the C++ standard does not provide for mixed-precision complex operators, code such as the following does not compile:
double factor = 3.141;
std::complex<float> x(1,2); // =1+2i
auto z = factor*x; // error
Because this does not compile, writing mixed-precision complex linear algebra libraries is not easily possible without much additional work that requires explicit casts. For example, one would have to write the code above as follows:
double factor = 1.0;
std::complex<float> x(1,2); // =1+2i
auto z = static_cast<P>(factor) * static_cast<P>(x);
This makes much code unreadable. As a consequence, we define the necessary overloaded multiplication and division operators for mixed complex arithmetic (in namespace dealii) to make the code above compile without the extra casts.

Definition at line 151 of file complex_overloads.h.

◆ operator/() [2/3]

template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, U >::type > operator/ ( const std::complex< T > &  left,
const U &  right 
)
inline

Provide an operator/ for a scalar division of a complex floating point type with a different real floating point type. Annoyingly, the standard library does not provide such an operator.

Note
Because the C++ standard does not provide for mixed-precision complex operators, code such as the following does not compile:
double factor = 3.141;
std::complex<float> x(1,2); // =1+2i
auto z = factor*x; // error
Because this does not compile, writing mixed-precision complex linear algebra libraries is not easily possible without much additional work that requires explicit casts. For example, one would have to write the code above as follows:
double factor = 1.0;
std::complex<float> x(1,2); // =1+2i
auto z = static_cast<P>(factor) * static_cast<P>(x);
This makes much code unreadable. As a consequence, we define the necessary overloaded multiplication and division operators for mixed complex arithmetic (in namespace dealii) to make the code above compile without the extra casts.

Definition at line 190 of file complex_overloads.h.

◆ operator*() [3/3]

template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< T, std::complex< U > >::type > operator* ( const T &  left,
const std::complex< U > &  right 
)
inline

Provide an operator* for a scalar multiplication of a real floating point type with a different complex floating point type. Annoyingly, the standard library does not provide such an operator.

Note
Because the C++ standard does not provide for mixed-precision complex operators, code such as the following does not compile:
double factor = 3.141;
std::complex<float> x(1,2); // =1+2i
auto z = factor*x; // error
Because this does not compile, writing mixed-precision complex linear algebra libraries is not easily possible without much additional work that requires explicit casts. For example, one would have to write the code above as follows:
double factor = 1.0;
std::complex<float> x(1,2); // =1+2i
auto z = static_cast<P>(factor) * static_cast<P>(x);
This makes much code unreadable. As a consequence, we define the necessary overloaded multiplication and division operators for mixed complex arithmetic (in namespace dealii) to make the code above compile without the extra casts.

Definition at line 229 of file complex_overloads.h.

◆ operator/() [3/3]

template<typename T , typename U >
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< T, std::complex< U > >::type > operator/ ( const T &  left,
const std::complex< U > &  right 
)
inline

Provide an operator/ for a scalar division of a real floating point type with a different complex floating point type. Annoyingly, the standard library does not provide such an operator.

Note
Because the C++ standard does not provide for mixed-precision complex operators, code such as the following does not compile:
double factor = 3.141;
std::complex<float> x(1,2); // =1+2i
auto z = factor*x; // error
Because this does not compile, writing mixed-precision complex linear algebra libraries is not easily possible without much additional work that requires explicit casts. For example, one would have to write the code above as follows:
double factor = 1.0;
std::complex<float> x(1,2); // =1+2i
auto z = static_cast<P>(factor) * static_cast<P>(x);
This makes much code unreadable. As a consequence, we define the necessary overloaded multiplication and division operators for mixed complex arithmetic (in namespace dealii) to make the code above compile without the extra casts.

Definition at line 268 of file complex_overloads.h.