Skip to content

Commit c508b77

Browse files
committed
Add cispi(x)
Added to Base in JuliaLang/julia#38449 I added tests that cover both methods in Base: ```julia julia> methods(cispi) [1] cispi(theta::Real) in Base at complex.jl:544 [2] cispi(z::Complex) in Base at complex.jl:563 ``` (both of the doc tests and then a couple more examples of real inputs).
1 parent aca5c27 commit c508b77

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Compat"
22
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
3-
version = "3.23.0"
3+
version = "3.24.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/Compat.jl

+10
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,16 @@ if VERSION < v"1.6.0-DEV.292" # 6cd329c371c1db3d9876bc337e82e274e50420e8
820820
sincospi(x) = (sinpi(x), cospi(x))
821821
end
822822

823+
# https://github.com/JuliaLang/julia/pull/38449
824+
if VERSION < v"1.6.0-DEV.1591" # 96d59f957e4c0413e2876592072c0f08a7482cf2
825+
export cispi
826+
cispi(theta::Real) = Complex(reverse(sincospi(theta))...)
827+
function cispi(z::Complex)
828+
sipi, copi = sincospi(z)
829+
return complex(real(copi) - imag(sipi), imag(copi) + real(sipi))
830+
end
831+
end
832+
823833
include("iterators.jl")
824834
include("deprecated.jl")
825835

test/runtests.jl

+8
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,14 @@ end
774774
@test sincospi(0.13im) == (sinpi(0.13im), cospi(0.13im))
775775
end
776776

777+
# https://github.com/JuliaLang/julia/pull/38449
778+
@testset "cispi(x)" begin
779+
@test cispi(true) == -1 + 0im
780+
@test cispi(1) == -1.0 + 0.0im
781+
@test cispi(2.0) == 1.0 + 0.0im
782+
@test cispi(0.25 + 1im) cis/4 + π*im)
783+
end
784+
777785
include("iterators.jl")
778786

779787
# Import renaming, https://github.com/JuliaLang/julia/pull/37396,

0 commit comments

Comments
 (0)