Skip to content

Commit 13a362c

Browse files
authored
Use logten and logtwo from IrrationalConstants (#555)
* Use `logten` and `logtwo` from IrrationalConstants * Update Project.toml * Update Project.toml
1 parent 3590f94 commit 13a362c

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name = "ChainRules"
22
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
3-
version = "1.22"
3+
version = "1.23"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
77
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
8+
IrrationalConstants = "92d709cd-6900-40b7-9082-c6be49f344b6"
89
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
910
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1011
RealDot = "c1ae055f-0cd5-4b69-90a6-9a35b1a98df9"
@@ -15,6 +16,7 @@ ChainRulesCore = "1.11.5"
1516
ChainRulesTestUtils = "1"
1617
Compat = "3.35"
1718
FiniteDifferences = "0.12.20"
19+
IrrationalConstants = "0.1.1"
1820
JuliaInterpreter = "0.8" # latest is "0.9.1"
1921
RealDot = "0.1"
2022
StaticArrays = "1.2"

src/ChainRules.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module ChainRules
33
using Base.Broadcast: materialize, materialize!, broadcasted, Broadcasted, broadcastable
44
using ChainRulesCore
55
using Compat
6+
using IrrationalConstants: logtwo, logten
67
using LinearAlgebra
78
using LinearAlgebra.BLAS
89
using Random

src/rulesets/Base/fastmath_able.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ let
5454
@scalar_rule inv(x) -^ 2)
5555
@scalar_rule sqrt(x) inv(2Ω) # gradient +Inf at x==0
5656
@scalar_rule exp(x) Ω
57-
@scalar_rule exp10(x) Ω * log(oftype(x, 10))
58-
@scalar_rule exp2(x) Ω * log(oftype(x, 2))
57+
@scalar_rule exp10(x) logten * Ω
58+
@scalar_rule exp2(x) logtwo * Ω
5959
@scalar_rule expm1(x) exp(x)
6060
@scalar_rule log(x) inv(x)
61-
@scalar_rule log10(x) inv(x) / log(oftype(x, 10))
61+
@scalar_rule log10(x) inv(logten * x)
6262
@scalar_rule log1p(x) inv(x + 1)
63-
@scalar_rule log2(x) inv(x) / log(oftype(x, 2))
63+
@scalar_rule log2(x) inv(logtwo * x)
6464

6565
# Unary complex functions
6666
## abs

0 commit comments

Comments
 (0)