Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/ext/TrixiSparseConnectivityTracerExt.jl
2055 views
1
# Package extension for overloading of branching (if-clauses) base functions such as sqrt, log, etc.
2
module TrixiSparseConnectivityTracerExt
3
4
import Trixi
5
import SparseConnectivityTracer: AbstractTracer
6
7
# For the default package preference "sqrt_Trixi_NaN" we overload the `Base.sqrt` function
8
# to first check if the argument is < 0 and then return `NaN` instead of an error.
9
# To turn this behaviour off for the datatype `AbstractTracer` used in sparsity detection,
10
# we switch back to the Base implementation here which does not contain an if-clause.
11
Trixi.sqrt(x::AbstractTracer) = Base.sqrt(x)
12
13
end
14
15