Skip to content

Commit

Permalink
Replace Float32 consts with oftype expressions (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff authored and ararslan committed Jun 9, 2019
1 parent 9ad23b0 commit 0e551fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions src/rules/base.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
@scalar_rule(abs2(x), Wirtinger(x', x))
@scalar_rule(log(x), inv(x))
@scalar_rule(log10(x), inv(x) / log(10f0))
@scalar_rule(log2(x), inv(x) / log(2f0))
@scalar_rule(log10(x), inv(x) / log(oftype(x, 10)))
@scalar_rule(log2(x), inv(x) / log(oftype(x, 2)))
@scalar_rule(log1p(x), inv(x + 1))
@scalar_rule(expm1(x), exp(x))
@scalar_rule(sin(x), cos(x))
@scalar_rule(cos(x), -sin(x))
@scalar_rule(sinpi(x), π * cospi(x))
@scalar_rule(cospi(x), -π * sinpi(x))
@scalar_rule(sind(x), (π / 180f0) * cosd(x))
@scalar_rule(cosd(x), -/ 180f0) * sind(x))
@scalar_rule(sind(x), (π / oftype(x, 180)) * cosd(x))
@scalar_rule(cosd(x), -/ oftype(x, 180)) * sind(x))
@scalar_rule(asin(x), inv(sqrt(1 - x^2)))
@scalar_rule(acos(x), -inv(sqrt(1 - x^2)))
@scalar_rule(atan(x), inv(1 + x^2))
@scalar_rule(asec(x), inv(abs(x) * sqrt(x^2 - 1)))
@scalar_rule(acsc(x), -inv(abs(x) * sqrt(x^2 - 1)))
@scalar_rule(acot(x), -inv(1 + x^2))
@scalar_rule(asind(x), 180f0 / π / sqrt(1 - x^2))
@scalar_rule(acosd(x), -180f0 / π / sqrt(1 - x^2))
@scalar_rule(atand(x), 180f0 / π / (1 + x^2))
@scalar_rule(asecd(x), 180f0 / π / abs(x) / sqrt(x^2 - 1))
@scalar_rule(acscd(x), -180f0 / π / abs(x) / sqrt(x^2 - 1))
@scalar_rule(acotd(x), -180f0 / π / (1 + x^2))
@scalar_rule(asind(x), oftype(x, 180) / π / sqrt(1 - x^2))
@scalar_rule(acosd(x), -oftype(x, 180) / π / sqrt(1 - x^2))
@scalar_rule(atand(x), oftype(x, 180) / π / (1 + x^2))
@scalar_rule(asecd(x), oftype(x, 180) / π / abs(x) / sqrt(x^2 - 1))
@scalar_rule(acscd(x), -oftype(x, 180) / π / abs(x) / sqrt(x^2 - 1))
@scalar_rule(acotd(x), -oftype(x, 180) / π / (1 + x^2))
@scalar_rule(sinh(x), cosh(x))
@scalar_rule(cosh(x), sinh(x))
@scalar_rule(tanh(x), sech(x)^2)
Expand All @@ -32,8 +32,8 @@
@scalar_rule(asech(x), -inv(x * sqrt(1 - x^2)))
@scalar_rule(acsch(x), -inv(abs(x) * sqrt(1 + x^2)))
@scalar_rule(acoth(x), inv(1 - x^2))
@scalar_rule(deg2rad(x), π / 180f0)
@scalar_rule(rad2deg(x), 180f0 / π)
@scalar_rule(deg2rad(x), π / oftype(x, 180))
@scalar_rule(rad2deg(x), oftype(x, 180) / π)
@scalar_rule(conj(x), Wirtinger(Zero(), One()))
@scalar_rule(adjoint(x), Wirtinger(Zero(), One()))
@scalar_rule(transpose(x), One())
Expand All @@ -50,16 +50,16 @@
@scalar_rule(sqrt(x), inv(2 * Ω))
@scalar_rule(cbrt(x), inv(3 * Ω^2))
@scalar_rule(exp(x), Ω)
@scalar_rule(exp2(x), Ω * log(2f0))
@scalar_rule(exp10(x), Ω * log(10f0))
@scalar_rule(exp2(x), Ω * log(oftype(x, 2)))
@scalar_rule(exp10(x), Ω * log(oftype(x, 10)))
@scalar_rule(tan(x), 1 + Ω^2)
@scalar_rule(sec(x), Ω * tan(x))
@scalar_rule(csc(x), -Ω * cot(x))
@scalar_rule(cot(x), -(1 + Ω^2))
@scalar_rule(tand(x), (π / 180f0) * (1 + Ω^2))
@scalar_rule(secd(x), (π / 180f0) * Ω * tand(x))
@scalar_rule(cscd(x), -/ 180f0) * Ω * cotd(x))
@scalar_rule(cotd(x), -/ 180f0) * (1 + Ω^2))
@scalar_rule(tand(x), (π / oftype(x, 180)) * (1 + Ω^2))
@scalar_rule(secd(x), (π / oftype(x, 180)) * Ω * tand(x))
@scalar_rule(cscd(x), -/ oftype(x, 180)) * Ω * cotd(x))
@scalar_rule(cotd(x), -/ oftype(x, 180)) * (1 + Ω^2))
@scalar_rule(sech(x), -tanh(x) * Ω)
@scalar_rule(csch(x), -coth(x) * Ω)
@scalar_rule(hypot(x, y), (y / Ω, x / Ω))
Expand Down
4 changes: 2 additions & 2 deletions src/rules/nanmath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
@scalar_rule(NaNMath.acosh(x), inv(NaNMath.sqrt(NaNMath.pow(x, 2) - 1)))
@scalar_rule(NaNMath.atanh(x), inv(1 - NaNMath.pow(x, 2)))
@scalar_rule(NaNMath.log(x), inv(x))
@scalar_rule(NaNMath.log2(x), inv(x) / NaNMath.log(2f0))
@scalar_rule(NaNMath.log10(x), inv(x) / NaNMath.log(10f0))
@scalar_rule(NaNMath.log2(x), inv(x) / NaNMath.log(oftype(x, 2)))
@scalar_rule(NaNMath.log10(x), inv(x) / NaNMath.log(oftype(x, 10)))
@scalar_rule(NaNMath.log1p(x), inv(x + 1))
@scalar_rule(NaNMath.lgamma(x), SpecialFunctions.digamma(x))
@scalar_rule(NaNMath.sqrt(x), inv(2 * Ω))
Expand Down

0 comments on commit 0e551fb

Please sign in to comment.