Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit 323aa8f

Browse files
committed
add complex angle and logarithm functions
1 parent 3ecd33e commit 323aa8f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/device/cuda/math.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@
3232
@inline atan(x::Float64) = @wrap __nv_atan(x::double)::double
3333
@inline atan(x::Float32) = @wrap __nv_atanf(x::float)::float
3434

35+
# ! CUDAnative.atan2 is equivalent to Base.atan
3536
@inline atan2(x::Float64, y::Float64) = @wrap __nv_atan2(x::double, y::double)::double
3637
@inline atan2(x::Float32, y::Float32) = @wrap __nv_atan2f(x::float, y::float)::float
3738

39+
@inline angle(x::ComplexF64) = atan2(x.re, y.im)
40+
@inline angle(x::ComplexF32) = atan2(x.re, y.im)
41+
@inline angle(x::Float64) = 0.0
42+
@inline angle(x::Float32) = 0.0
3843

3944
## hyperbolic
4045

@@ -66,6 +71,10 @@
6671
@inline log(x::Float32) = @wrap __nv_logf(x::float)::float
6772
@inline log_fast(x::Float32) = @wrap __nv_fast_logf(x::float)::float
6873

74+
@inline log(x::ComplexF64) = log(abs(x)) + im * angle(x)
75+
@inline log(x::ComplexF32) = log(abs(x)) + im * angle(x)
76+
@inline log_fast(x::ComplexF32) = log_fast(abs(x)) + im * angle(x)
77+
6978
@inline log10(x::Float64) = @wrap __nv_log10(x::double)::double
7079
@inline log10(x::Float32) = @wrap __nv_log10f(x::float)::float
7180
@inline log10_fast(x::Float32) = @wrap __nv_fast_log10f(x::float)::float

0 commit comments

Comments
 (0)