Commit 3c53a568 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Add csqrt, cpow to cuda_complex.hpp

parent e512cf88
Pipeline #20783 failed with stage
in 5 minutes and 43 seconds
......@@ -866,6 +866,14 @@ CUDA_CALLABLE_MEMBER complex<_Tp> sqrt(const complex<_Tp> &__x) {
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
}
template <class T> CUDA_CALLABLE_MEMBER complex<T> csqrt(complex<T> z) {
return sqrt<T>(z);
};
template<class T>
CUDA_CALLABLE_MEMBER complex<T> csqrt(T z) {
return csqrt<T>({z, 0});
};
// exp
template <class _Tp>
......@@ -1224,5 +1232,12 @@ CUDA_CALLABLE_MEMBER auto operator/(const V scalar,
using ComplexDouble = complex<double>;
using ComplexFloat = complex<float>;
CUDA_CALLABLE_MEMBER
template <class T, class U> complex<T> cpow(const complex<T> &z, const U &n) {
return {(pow(abs(z), n) * cos(n * arg(z))),
(pow(abs(z), n) * sin(n * arg(z)))};
}
#endif // CUDA_COMPLEX_HPP
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment