Skip to content

Commit

Permalink
add complex sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Apr 1, 2024
1 parent edfb21f commit 7cfb9f6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ include("compiler/utils.jl")
const cmplx_known_ops =

Check warning on line 70 in src/compiler.jl

View workflow job for this annotation

GitHub Actions / format

[JuliaFormatter] reported by reviewdog 🐶 Raw Output: src/compiler.jl:70:-const cmplx_known_ops = src/compiler.jl:71:-Dict{DataType, Tuple{Symbol, Int, Union{Nothing, Tuple{Symbol, DataType}}}}( src/compiler.jl:72:- typeof(Base.inv) => (:cmplx_inv, 1, nothing), src/compiler.jl:73:- typeof(Base.sqrt) => (:cmplx_sqrt, 1, nothing), src/compiler.jl:74:- ) src/compiler.jl:75:-const known_ops = src/compiler.jl:76:-Dict{DataType, Tuple{Symbol, Int, Union{Nothing, Tuple{Symbol, DataType}}}}( src/compiler.jl:77:- typeof(Base.cbrt) => (:cbrt, 1, nothing), src/compiler.jl:78:- typeof(Base.rem2pi) => (:jl_rem2pi, 2, nothing), src/compiler.jl:79:- typeof(Base.sqrt) => (:sqrt, 1, nothing), src/compiler.jl:80:- typeof(Base.sin) => (:sin, 1, nothing), src/compiler.jl:81:- typeof(Base.sinc) => (:sincn, 1, nothing), src/compiler.jl:82:- typeof(Base.sincos) => (:__fd_sincos_1, 1, nothing), src/compiler.jl:83:- typeof(Base.sincospi) => (:sincospi, 1, nothing), src/compiler.jl:84:- typeof(Base.sinpi) => (:sinpi, 1, nothing), src/compiler.jl:85:- typeof(Base.cospi) => (:cospi, 1, nothing), src/compiler.jl:86:- typeof(Base.:^) => (:pow, 2, nothing), src/compiler.jl:87:- typeof(Base.rem) => (:fmod, 2, nothing), src/compiler.jl:88:- typeof(Base.cos) => (:cos, 1, nothing), src/compiler.jl:89:- typeof(Base.tan) => (:tan, 1, nothing), src/compiler.jl:90:- typeof(Base.exp) => (:exp, 1, nothing), src/compiler.jl:91:- typeof(Base.exp2) => (:exp2, 1, nothing), src/compiler.jl:92:- typeof(Base.expm1) => (:expm1, 1, nothing), src/compiler.jl:93:- typeof(Base.exp10) => (:exp10, 1, nothing), src/compiler.jl:94:- typeof(Base.FastMath.exp_fast) => (:exp, 1, nothing), src/compiler.jl:95:- typeof(Base.log) => (:log, 1, nothing), src/compiler.jl:96:- typeof(Base.FastMath.log) => (:log, 1, nothing), src/compiler.jl:97:- typeof(Base.log1p) => (:log1p, 1, nothing), src/compiler.jl:98:- typeof(Base.log2) => (:log2, 1, nothing), src/compiler.jl:99:- typeof(Base.log10) => (:log10, 1, nothing), src/compiler.jl:100:- typeof(Base.asin) => (:asin, 1, nothing), src/compiler.jl:101:- typeof(Base.acos) => (:acos, 1, nothing), src/compiler.jl:102:- typeof(Base.atan) => (:atan, 1, nothing), src/compiler.jl:103:- typeof(Base.atan) => (:atan2, 2, nothing), src/compiler.jl:104:- typeof(Base.sinh) => (:sinh, 1, nothing), src/compiler.jl:105:- typeof(Base.FastMath.sinh_fast) => (:sinh, 1, nothing), src/compiler.jl:106:- typeof(Base.cosh) => (:cosh, 1, nothing), src/compiler.jl:107:- typeof(Base.FastMath.cosh_fast) => (:cosh, 1, nothing), src/compiler.jl:108:- typeof(Base.tanh) => (:tanh, 1, nothing), src/compiler.jl:109:- typeof(Base.ldexp) => (:ldexp, 2, nothing), src/compiler.jl:110:- typeof(Base.FastMath.tanh_fast) => (:tanh, 1, nothing) src/compiler.jl:111:-) src/compiler.jl:75:+const cmplx_known_ops = Dict{DataType, src/compiler.jl:76:+ Tuple{Symbol,Int,Union{Nothing,Tuple{Symbol,DataType}}}}(typeof(Base.inv) => (:cmplx_inv, src/compiler.jl:77:+ 1, src/compiler.jl:78:+ nothing), src/compiler.jl:79:+ typeof(Base.sqrt) => (:cmplx_sqrt, src/compiler.jl:80:+ 1, src/compiler.jl:81:+ nothing)) src/compiler.jl:82:+const known_ops = Dict{DataType,Tuple{Symbol,Int,Union{Nothing,Tuple{Symbol,DataType}}}}(typeof(Base.cbrt) => (:cbrt, src/compiler.jl:83:+ 1, src/compiler.jl:84:+
Dict{DataType, Tuple{Symbol, Int, Union{Nothing, Tuple{Symbol, DataType}}}}(
typeof(Base.inv) => (:cmplx_inv, 1, nothing),
typeof(Base.sqrt) => (:cmplx_sqrt, 1, nothing),
)
const known_ops =
Dict{DataType, Tuple{Symbol, Int, Union{Nothing, Tuple{Symbol, DataType}}}}(
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/interpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function is_primitive_func(@nospecialize(TT))
end
end

if ft == typeof(Base.inv)
if ft == typeof(Base.inv) || ft == typeof(Base.sqrt)
if TT <: Tuple{ft, Complex{Float32}} || TT <: Tuple{ft, Complex{Float64}}
return true
end
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ make3() = (1.0, 2.0, 3.0)
test_scalar(x->rem(x, 1), 0.7)
test_scalar(x->rem2pi(x,RoundDown), 0.7)
test_scalar(x->fma(x,x+1,x/3), 2.3)
test_scalar(sqrt, 1.7+2.1im)

@test autodiff(Forward, sincos, Duplicated(1.0, 1.0))[1][1] cos(1.0)

Expand Down

0 comments on commit 7cfb9f6

Please sign in to comment.