![]() |
alpaka
Abstraction Library for Parallel Kernel Acceleration
|
Implementation of a complex number useable on host and device. More...
#include <Complex.hpp>
Public Types | |
using | value_type = T |
Type of the real and imaginary parts. | |
Public Member Functions | |
constexpr | Complex (Complex const &other)=default |
Copy constructor. | |
template<typename U > | |
constexpr ALPAKA_FN_HOST_ACC | Complex (Complex< U > const &other) |
Constructor from Complex of another type. | |
constexpr ALPAKA_FN_HOST_ACC | Complex (std::complex< T > const &other) |
Constructor from std::complex. | |
constexpr ALPAKA_FN_HOST_ACC | Complex (T const &real=T{}, T const &imag=T{}) |
Constructor from the given real and imaginary parts. | |
constexpr ALPAKA_FN_HOST_ACC T | imag () const |
Get the imaginary part. | |
constexpr ALPAKA_FN_HOST_ACC void | imag (T value) |
Set the imaginary part. | |
constexpr ALPAKA_FN_HOST_ACC | operator std::complex< T > () const |
Conversion to std::complex. | |
template<typename U > | |
ALPAKA_FN_HOST_ACC Complex & | operator*= (Complex< U > const &other) |
Multiplication assignment with a complex number. | |
ALPAKA_FN_HOST_ACC Complex & | operator*= (T const &other) |
Multiplication assignment with a real number. | |
template<typename U > | |
ALPAKA_FN_HOST_ACC Complex & | operator+= (Complex< U > const &other) |
Addition assignment with a complex number. | |
ALPAKA_FN_HOST_ACC Complex & | operator+= (T const &other) |
Addition assignment with a real number. | |
template<typename U > | |
ALPAKA_FN_HOST_ACC Complex & | operator-= (Complex< U > const &other) |
Subtraction assignment with a complex number. | |
ALPAKA_FN_HOST_ACC Complex & | operator-= (T const &other) |
Subtraction assignment with a real number. | |
template<typename U > | |
ALPAKA_FN_HOST_ACC Complex & | operator/= (Complex< U > const &other) |
Division assignment with a complex number. | |
ALPAKA_FN_HOST_ACC Complex & | operator/= (T const &other) |
Division assignment with a real number. | |
Complex & | operator= (Complex const &)=default |
Assignment. | |
constexpr ALPAKA_FN_HOST_ACC T | real () const |
Get the real part. | |
constexpr ALPAKA_FN_HOST_ACC void | real (T value) |
Set the real part. | |
Implementation of a complex number useable on host and device.
It follows the layout of std::complex and so array-oriented access. The class template implements all methods and operators as std::complex<T>. Additionally, it provides an implicit conversion to and from std::complex<T>. All methods besides operators << and >> are host-device. It does not provide non-member functions of std::complex besides the operators. Those are provided the same way as alpaka math functions for real numbers.
Note that unlike most of alpaka, this is a concrete type template, and not merely a concept.
Naming and order of the methods match https://en.cppreference.com/w/cpp/numeric/complex in C++17. Implementation chose to not extend it e.g. by adding constexpr to some places that would get it in C++20. The motivation is that with internal conversion to std::complex<T> for CPU backends, it would define the common interface for generic code anyways. So it is more clear to have alpaka's interface exactly matching when possible, and not "improving".
T | type of the real and imaginary part: float, double, or long double. |
Definition at line 40 of file Complex.hpp.
using alpaka::internal::Complex< T >::value_type = T |
Type of the real and imaginary parts.
Definition at line 47 of file Complex.hpp.
|
inlineconstexpr |
Constructor from the given real and imaginary parts.
Definition at line 50 of file Complex.hpp.
|
constexprdefault |
Copy constructor.
|
inlineconstexpr |
Constructor from Complex of another type.
Definition at line 59 of file Complex.hpp.
|
inlineconstexpr |
Constructor from std::complex.
Definition at line 66 of file Complex.hpp.
|
inlineconstexpr |
Get the imaginary part.
Definition at line 94 of file Complex.hpp.
|
inlineconstexpr |
Set the imaginary part.
Definition at line 100 of file Complex.hpp.
|
inlineconstexpr |
Conversion to std::complex.
Definition at line 73 of file Complex.hpp.
|
inline |
Multiplication assignment with a complex number.
Definition at line 147 of file Complex.hpp.
|
inline |
Multiplication assignment with a real number.
Definition at line 138 of file Complex.hpp.
|
inline |
Addition assignment with a complex number.
Definition at line 114 of file Complex.hpp.
|
inline |
Addition assignment with a real number.
Definition at line 106 of file Complex.hpp.
|
inline |
Subtraction assignment with a complex number.
Definition at line 130 of file Complex.hpp.
|
inline |
Subtraction assignment with a real number.
Definition at line 122 of file Complex.hpp.
|
inline |
Division assignment with a complex number.
Definition at line 166 of file Complex.hpp.
|
inline |
Division assignment with a real number.
Definition at line 157 of file Complex.hpp.
|
default |
Assignment.
|
inlineconstexpr |
Get the real part.
Definition at line 82 of file Complex.hpp.
|
inlineconstexpr |
Set the real part.
Definition at line 88 of file Complex.hpp.