From 796c987c5680fb73c7c42ed2226aa883099e0b82 Mon Sep 17 00:00:00 2001 From: cossio Date: Fri, 10 Dec 2021 12:50:27 +0100 Subject: [PATCH 1/6] add rule for logerfcx --- src/rules.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rules.jl b/src/rules.jl index c6f8e48..06cc4af 100644 --- a/src/rules.jl +++ b/src/rules.jl @@ -121,6 +121,8 @@ _abs_deriv(x) = signbit(x) ? -one(x) : one(x) @define_diffrule SpecialFunctions.erfi(x) = :( (2 / sqrt(π)) * exp($x * $x) ) @define_diffrule SpecialFunctions.erfcx(x) = :( (2 * $x * SpecialFunctions.erfcx($x)) - (2 / sqrt(π)) ) +@define_diffrule SpecialFunctions.logerfcx(x) = + :( 2 * ($x - inv(SpecialFunctions.erfcx($x)) / sqrt(π)) ) @define_diffrule SpecialFunctions.dawson(x) = :( 1 - (2 * $x * SpecialFunctions.dawson($x)) ) @define_diffrule SpecialFunctions.digamma(x) = From 75ea22691ce566c2581e1ae7ae34af0a63bfccd0 Mon Sep 17 00:00:00 2001 From: cossio Date: Fri, 10 Dec 2021 13:02:44 +0100 Subject: [PATCH 2/6] version lower bound for logerfcx --- src/rules.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rules.jl b/src/rules.jl index 06cc4af..09edb28 100644 --- a/src/rules.jl +++ b/src/rules.jl @@ -121,8 +121,6 @@ _abs_deriv(x) = signbit(x) ? -one(x) : one(x) @define_diffrule SpecialFunctions.erfi(x) = :( (2 / sqrt(π)) * exp($x * $x) ) @define_diffrule SpecialFunctions.erfcx(x) = :( (2 * $x * SpecialFunctions.erfcx($x)) - (2 / sqrt(π)) ) -@define_diffrule SpecialFunctions.logerfcx(x) = - :( 2 * ($x - inv(SpecialFunctions.erfcx($x)) / sqrt(π)) ) @define_diffrule SpecialFunctions.dawson(x) = :( 1 - (2 * $x * SpecialFunctions.dawson($x)) ) @define_diffrule SpecialFunctions.digamma(x) = @@ -148,6 +146,12 @@ _abs_deriv(x) = signbit(x) ? -one(x) : one(x) @define_diffrule SpecialFunctions.bessely1(x) = :( (SpecialFunctions.bessely0($x) - SpecialFunctions.bessely(2, $x)) / 2 ) +# logerfcx added in SpeciaFunctions 0.10, which requires Julia 1.3 +if VERSION ≥ v"1.3" + @define_diffrule SpecialFunctions.logerfcx(x) = + :( 2 * ($x - inv(SpecialFunctions.erfcx($x)) / sqrt(π)) ) +end + # TODO: # # eta From 31e3a9137a9172a3975b15e8c15616cb29cb94cc Mon Sep 17 00:00:00 2001 From: cossio Date: Fri, 10 Dec 2021 15:16:34 +0100 Subject: [PATCH 3/6] David's suggestion --- src/rules.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules.jl b/src/rules.jl index 09edb28..5e4900a 100644 --- a/src/rules.jl +++ b/src/rules.jl @@ -149,7 +149,7 @@ _abs_deriv(x) = signbit(x) ? -one(x) : one(x) # logerfcx added in SpeciaFunctions 0.10, which requires Julia 1.3 if VERSION ≥ v"1.3" @define_diffrule SpecialFunctions.logerfcx(x) = - :( 2 * ($x - inv(SpecialFunctions.erfcx($x)) / sqrt(π)) ) + :( 2 * ($x - inv(SpecialFunctions.erfcx($x) * sqrt(π))) ) end # TODO: From a8bf818b4467c83fdb993c33c8ea2bee848f4054 Mon Sep 17 00:00:00 2001 From: cossio Date: Fri, 10 Dec 2021 15:50:29 +0100 Subject: [PATCH 4/6] David's suggestion 2 --- src/rules.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rules.jl b/src/rules.jl index 5e4900a..1f26ebf 100644 --- a/src/rules.jl +++ b/src/rules.jl @@ -146,8 +146,10 @@ _abs_deriv(x) = signbit(x) ? -one(x) : one(x) @define_diffrule SpecialFunctions.bessely1(x) = :( (SpecialFunctions.bessely0($x) - SpecialFunctions.bessely(2, $x)) / 2 ) -# logerfcx added in SpeciaFunctions 0.10, which requires Julia 1.3 -if VERSION ≥ v"1.3" +#= logerfcx added in SpeciaFunctions 0.10, which requires Julia 1.3, +so we need this check here to make things work in Julia 1.0, +and in general with older versions of SpecialFunctions =# +if isdefined(SpecialFunctions, :logerfcx) @define_diffrule SpecialFunctions.logerfcx(x) = :( 2 * ($x - inv(SpecialFunctions.erfcx($x) * sqrt(π))) ) end From 5da238cd1788c523ed6fc710810f32f1cf37c932 Mon Sep 17 00:00:00 2001 From: cossio Date: Fri, 10 Dec 2021 18:25:22 +0100 Subject: [PATCH 5/6] new compats logerfcx was introduced in SpecialFunctions 0.10, which in turn requires Julia 1.3. Therefore we don't do CI on Julia 1.0, but on 1.3. Also added the LTS, 1.6. --- Project.toml | 2 +- src/rules.jl | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 49d8e90..94cd858 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" [compat] LogExpFunctions = "0.3.2" NaNMath = "0.3" -SpecialFunctions = "0.8, 0.9, 0.10, 1.0, 2" +SpecialFunctions = "0.10, 1.0, 2" julia = "1.3" [extras] diff --git a/src/rules.jl b/src/rules.jl index 1f26ebf..9ed53ec 100644 --- a/src/rules.jl +++ b/src/rules.jl @@ -121,6 +121,8 @@ _abs_deriv(x) = signbit(x) ? -one(x) : one(x) @define_diffrule SpecialFunctions.erfi(x) = :( (2 / sqrt(π)) * exp($x * $x) ) @define_diffrule SpecialFunctions.erfcx(x) = :( (2 * $x * SpecialFunctions.erfcx($x)) - (2 / sqrt(π)) ) +@define_diffrule SpecialFunctions.logerfcx(x) = + :( 2 * ($x - inv(SpecialFunctions.erfcx($x) * sqrt(π))) ) @define_diffrule SpecialFunctions.dawson(x) = :( 1 - (2 * $x * SpecialFunctions.dawson($x)) ) @define_diffrule SpecialFunctions.digamma(x) = @@ -146,14 +148,6 @@ _abs_deriv(x) = signbit(x) ? -one(x) : one(x) @define_diffrule SpecialFunctions.bessely1(x) = :( (SpecialFunctions.bessely0($x) - SpecialFunctions.bessely(2, $x)) / 2 ) -#= logerfcx added in SpeciaFunctions 0.10, which requires Julia 1.3, -so we need this check here to make things work in Julia 1.0, -and in general with older versions of SpecialFunctions =# -if isdefined(SpecialFunctions, :logerfcx) - @define_diffrule SpecialFunctions.logerfcx(x) = - :( 2 * ($x - inv(SpecialFunctions.erfcx($x) * sqrt(π))) ) -end - # TODO: # # eta From f888ee5ef679b0cef32731adf2db5ca4707fadb4 Mon Sep 17 00:00:00 2001 From: cossio Date: Sat, 11 Dec 2021 20:28:22 +0100 Subject: [PATCH 6/6] bump minor version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 94cd858..fc3dfd5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DiffRules" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" -version = "1.7.0" +version = "1.8.0" [deps] LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"