Skip to content

Commit

Permalink
Add some projectors
Browse files Browse the repository at this point in the history
  • Loading branch information
sethaxen committed Feb 12, 2022
1 parent 55d64f1 commit 0cb446f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/rulesets/Base/fastmath_able.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let
## sin
function rrule(::typeof(sin), x::CommutativeMulNumber)
sinx, cosx = sincos(x)
sin_pullback(Δy) = (NoTangent(), cosx' * Δy)
project_x = ProjectTo(x)
sin_pullback(Δy) = (NoTangent(), project_x(cosx' * Δy))
return (sinx, sin_pullback)
end

Expand All @@ -23,7 +24,8 @@ let
## cos
function rrule(::typeof(cos), x::CommutativeMulNumber)
sinx, cosx = sincos(x)
cos_pullback(Δy) = (NoTangent(), -sinx' * Δy)
project_x = ProjectTo(x)
cos_pullback(Δy) = (NoTangent(), -project_x(sinx' * Δy))
return (cosx, cos_pullback)
end

Expand Down Expand Up @@ -61,7 +63,7 @@ let
project_x = ProjectTo(x)
function inv_pullback(ΔΩ)
Ω′ = conj(Ω)
return NoTangent(), project_x(Ω′ * -ΔΩ * Ω′)
return NoTangent(), -project_x(Ω′ * ΔΩ * Ω′)
end
return Ω, inv_pullback
end
Expand Down

0 comments on commit 0cb446f

Please sign in to comment.