Skip to content

Commit 84a1763

Browse files
authored
Merge pull request JuliaDiff#74 from YingboMa/myb/hypot
Fix hypot frule
2 parents e24c190 + 79bac43 commit 84a1763

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/rulesets/Base/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
@scalar_rule(cotd(x), -/ oftype(x, 180)) * (1 + Ω^2))
6363
@scalar_rule(sech(x), -tanh(x) * Ω)
6464
@scalar_rule(csch(x), -coth(x) * Ω)
65-
@scalar_rule(hypot(x, y), (y / Ω, x / Ω))
65+
@scalar_rule(hypot(x, y), (x / Ω, y / Ω))
6666
@scalar_rule(sincos(x), @setup((sinx, cosx) = Ω), cosx, -sinx)
6767
@scalar_rule(atan(y, x), @setup(u = hypot(x, y)), (x / u, y / u))
6868
@scalar_rule(max(x, y), @setup(gt = x > y), (gt, !gt))

test/rulesets/Base/base.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ end
8383
x, y = rand(2)
8484
h, dxy = frule(hypot, x, y)
8585

86-
@test extern(dxy(One(), Zero())) === y / h
87-
@test extern(dxy(Zero(), One())) === x / h
86+
@test extern(dxy(One(), Zero())) === x / h
87+
@test extern(dxy(Zero(), One())) === y / h
8888

8989
cx, cy = cast((One(), Zero())), cast((Zero(), One()))
9090
dx, dy = extern(dxy(cx, cy))
91-
@test dx === y / h
92-
@test dy === x / h
91+
@test dx === x / h
92+
@test dy === y / h
9393

9494
cx, cy = cast((rand(), Zero())), cast((Zero(), rand()))
9595
dx, dy = extern(dxy(cx, cy))
96-
@test dx === y / h * cx.value[1]
97-
@test dy === x / h * cy.value[2]
96+
@test dx === x / h * cx.value[1]
97+
@test dy === y / h * cy.value[2]
9898
end
9999
end
100100
@testset "identity" begin

0 commit comments

Comments
 (0)