Skip to content
Snippets Groups Projects

WIP: Add csqrt, cpow to cuda_complex.hpp

Closed Stephan Seitz requested to merge seitz/pystencils:csqrt into master
1 file
+ 15
0
Compare changes
  • Side-by-side
  • Inline
@@ -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
}
Loading