-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SpecialFunctions extension (#82)
- Loading branch information
Showing
13 changed files
with
493 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...parseConnectivityTracerSpecialFunctionsExt/SparseConnectivityTracerSpecialFunctionsExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
module SparseConnectivityTracerSpecialFunctionsExt | ||
|
||
if isdefined(Base, :get_extension) | ||
import SparseConnectivityTracer as SCT | ||
using SpecialFunctions | ||
else | ||
import ..SparseConnectivityTracer as SCT | ||
using ..SpecialFunctions | ||
end | ||
|
||
#= | ||
Complex functions are ignored. | ||
Functions with more than 2 arguments are ignored. | ||
Functions with integer arguments are ignored. | ||
=# | ||
|
||
## 1-to-1 | ||
|
||
ops_1_to_1_s = ( | ||
# Gamma Function | ||
gamma, | ||
loggamma, | ||
digamma, | ||
invdigamma, | ||
trigamma, | ||
# Exponential and Trigonometric Integrals | ||
expinti, | ||
sinint, | ||
cosint, | ||
# Error functions, Dawson's and Fresnel Integrals | ||
erf, | ||
erfc, | ||
erfcinv, | ||
erfcx, | ||
logerfc, | ||
erfinv, | ||
# Airy and Related Functions | ||
airyai, | ||
airyaiprime, | ||
airybi, | ||
airybiprime, | ||
airyaix, | ||
airyaiprimex, | ||
airybix, | ||
airybiprimex, | ||
# Bessel Functions | ||
besselj0, | ||
besselj1, | ||
bessely0, | ||
bessely1, | ||
jinc, | ||
# Elliptic Integrals | ||
ellipk, | ||
ellipe, | ||
) | ||
|
||
for op in ops_1_to_1_s | ||
T = typeof(op) | ||
@eval SCT.is_influence_zero_global(::$T) = false | ||
@eval SCT.is_firstder_zero_global(::$T) = false | ||
@eval SCT.is_seconder_zero_global(::$T) = false | ||
end | ||
|
||
ops_1_to_1 = ops_1_to_1_s | ||
|
||
## 2-to-1 | ||
|
||
ops_2_to_1_ssc = ( | ||
# Gamma Function | ||
gamma, | ||
loggamma, | ||
beta, | ||
logbeta, | ||
# Exponential and Trigonometric Integrals | ||
expint, | ||
expintx, | ||
# Error functions, Dawson's and Fresnel Integrals | ||
erf, | ||
# Bessel Functions | ||
besselj, | ||
besseljx, | ||
sphericalbesselj, | ||
bessely, | ||
besselyx, | ||
sphericalbessely, | ||
besseli, | ||
besselix, | ||
besselk, | ||
besselkx, | ||
) | ||
|
||
for op in ops_2_to_1_ssc | ||
T = typeof(op) | ||
@eval SCT.is_influence_arg1_zero_global(::$T) = false | ||
@eval SCT.is_influence_arg2_zero_global(::$T) = false | ||
@eval SCT.is_firstder_arg1_zero_global(::$T) = false | ||
@eval SCT.is_seconder_arg1_zero_global(::$T) = false | ||
@eval SCT.is_firstder_arg2_zero_global(::$T) = false | ||
@eval SCT.is_seconder_arg2_zero_global(::$T) = false | ||
@eval SCT.is_crossder_zero_global(::$T) = false | ||
end | ||
|
||
ops_2_to_1 = ops_2_to_1_ssc | ||
|
||
## Lists | ||
|
||
SCT.list_operators_1_to_1(::Val{:SpecialFunctions}) = ops_1_to_1 | ||
SCT.list_operators_2_to_1(::Val{:SpecialFunctions}) = ops_2_to_1 | ||
SCT.list_operators_1_to_2(::Val{:SpecialFunctions}) = () | ||
|
||
## Overloads | ||
|
||
eval(SCT.overload_all(:SpecialFunctions)) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function overload_all(M) | ||
exprs_1_to_1 = [ | ||
quote | ||
$(overload_connectivity_1_to_1(M, op)) | ||
$(overload_gradient_1_to_1(M, op)) | ||
$(overload_hessian_1_to_1(M, op)) | ||
end for op in nameof.(list_operators_1_to_1(Val(M))) | ||
] | ||
exprs_2_to_1 = [ | ||
quote | ||
$(overload_connectivity_2_to_1(M, op)) | ||
$(overload_gradient_2_to_1(M, op)) | ||
$(overload_hessian_2_to_1(M, op)) | ||
end for op in nameof.(list_operators_2_to_1(Val(M))) | ||
] | ||
exprs_1_to_2 = [ | ||
quote | ||
$(overload_connectivity_1_to_2(M, op)) | ||
$(overload_gradient_1_to_2(M, op)) | ||
$(overload_hessian_1_to_2(M, op)) | ||
end for op in nameof.(list_operators_1_to_2(Val(M))) | ||
] | ||
return quote | ||
$(exprs_1_to_1...) | ||
$(exprs_2_to_1...) | ||
$(exprs_1_to_2...) | ||
end | ||
end | ||
|
||
eval(overload_all(:Base)) |
Oops, something went wrong.