-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdefaults.jl
More file actions
31 lines (25 loc) · 863 Bytes
/
defaults.jl
File metadata and controls
31 lines (25 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# TODO: make Defaults module? Replace `eltype` with `VectorInterface.scalartype`?
"""
defaulttol(x)
Default tolerance or precision for a given object, e.g. to decide when it can
be considerd to be zero or ignored in some other way, or how accurate some
quantity needs to be computed.
"""
defaulttol(x::Any) = eps(real(float(one(eltype(x)))))^(2 / 3)
"""
default_pullback_gaugetol(a)
Default tolerance for deciding to warn if incoming adjoints of a pullback rule
has components that are not gauge-invariant.
"""
function default_pullback_gaugetol(a)
n = norm(a, Inf)
return eps(eltype(n))^(3 / 4) * max(n, one(n))
end
"""
default_hermitian_tol(A)
Default tolerance for deciding to warn if the provided `A` is not hermitian.
"""
function default_hermitian_tol(A)
n = norm(A, Inf)
return eps(eltype(n))^(3 / 4) * max(n, one(n))
end