Block-Structured AMR Software Framework
amrex::GpuComplex< T > Struct Template Reference

A host / device complex number type, because std::complex doesn't work in device code with Cuda yet. More...

#include <AMReX_GpuComplex.H>

Public Types

using value_type = T
 

Public Member Functions

AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE GpuComplex (const T &a_r=T(), const T &a_i=T()) noexcept
 Construct a complex number given the real and imaginary part. More...
 
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINEreal () const noexcept
 Return the real part. More...
 
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINEimag () const noexcept
 Return the imaginary part. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator+= (const T &a_t) noexcept
 Add a real number to this complex number. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator-= (const T &a_t) noexcept
 Subtract a real number from this complex number. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator*= (const T &a_t) noexcept
 Multiply this complex number by a real. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator/= (const T &a_t) noexcept
 Divide this complex number by a real. More...
 
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator+= (const GpuComplex< U > &a_z) noexcept
 Add another complex number to this one. More...
 
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator-= (const GpuComplex< U > &a_z) noexcept
 Subtract another complex number from this one. More...
 
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator*= (const GpuComplex< U > &a_z) noexcept
 Multiply this complex number by another one. More...
 
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > & operator/= (const GpuComplex< U > &a_z) noexcept
 Divide this complex number by another one. More...
 

Public Attributes

m_real
 
m_imag
 

Friends

template<typename U >
std::ostream & operator<< (std::ostream &out, const GpuComplex< U > &c)
 Print this complex number to an ostream. More...
 

Detailed Description

template<typename T>
struct amrex::GpuComplex< T >

A host / device complex number type, because std::complex doesn't work in device code with Cuda yet.

Should be bit-wise compatible with std::complex.

GpuComplex is aligned to its size (stricter than std::complex) to allow for coalesced memory accesses with nvidia GPUs.

Member Typedef Documentation

◆ value_type

template<typename T >
using amrex::GpuComplex< T >::value_type = T

Constructor & Destructor Documentation

◆ GpuComplex()

template<typename T >
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE amrex::GpuComplex< T >::GpuComplex ( const T &  a_r = T(),
const T &  a_i = T() 
)
inlineconstexprnoexcept

Construct a complex number given the real and imaginary part.

Member Function Documentation

◆ imag()

template<typename T >
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T amrex::GpuComplex< T >::imag ( ) const
inlineconstexprnoexcept

Return the imaginary part.

◆ operator*=() [1/2]

template<typename T >
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator*= ( const GpuComplex< U > &  a_z)
inlinenoexcept

Multiply this complex number by another one.

◆ operator*=() [2/2]

template<typename T >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator*= ( const T &  a_t)
inlinenoexcept

Multiply this complex number by a real.

◆ operator+=() [1/2]

template<typename T >
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator+= ( const GpuComplex< U > &  a_z)
inlinenoexcept

Add another complex number to this one.

◆ operator+=() [2/2]

template<typename T >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator+= ( const T &  a_t)
inlinenoexcept

Add a real number to this complex number.

◆ operator-=() [1/2]

template<typename T >
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator-= ( const GpuComplex< U > &  a_z)
inlinenoexcept

Subtract another complex number from this one.

◆ operator-=() [2/2]

template<typename T >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator-= ( const T &  a_t)
inlinenoexcept

Subtract a real number from this complex number.

◆ operator/=() [1/2]

template<typename T >
template<typename U >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator/= ( const GpuComplex< U > &  a_z)
inlinenoexcept

Divide this complex number by another one.

◆ operator/=() [2/2]

template<typename T >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex<T>& amrex::GpuComplex< T >::operator/= ( const T &  a_t)
inlinenoexcept

Divide this complex number by a real.

◆ real()

template<typename T >
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T amrex::GpuComplex< T >::real ( ) const
inlineconstexprnoexcept

Return the real part.

Friends And Related Function Documentation

◆ operator<<

template<typename T >
template<typename U >
std::ostream& operator<< ( std::ostream &  out,
const GpuComplex< U > &  c 
)
friend

Print this complex number to an ostream.

Member Data Documentation

◆ m_imag

template<typename T >
T amrex::GpuComplex< T >::m_imag

◆ m_real

template<typename T >
T amrex::GpuComplex< T >::m_real

The documentation for this struct was generated from the following file: