Skip to content
Snippets Groups Projects
Commit 3c53a568 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Add csqrt, cpow to cuda_complex.hpp

parent e512cf88
No related branches found
No related tags found
1 merge request!101WIP: Add csqrt, cpow to cuda_complex.hpp
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment