-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdefaults.jl
More file actions
60 lines (45 loc) · 1.76 KB
/
defaults.jl
File metadata and controls
60 lines (45 loc) · 1.76 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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_gauge_atol(ΔA...)
Default tolerance for deciding to warn if incoming adjoints of a pullback rule
has components that are not gauge-invariant.
"""
default_pullback_gauge_atol(A) = iszerotangent(A) ? 0 : eps(norm(A, Inf))^(3 / 4)
function default_pullback_gauge_atol(A, As...)
As′ = filter(!iszerotangent, (A, As...))
return isempty(As′) ? 0 : eps(norm(As′, Inf))^(3 / 4)
end
"""
default_pullback_degeneracy_atol(A)
Default tolerance for deciding when values should be considered as degenerate.
"""
default_pullback_degeneracy_atol(A) = eps(norm(A, Inf))^(3 / 4)
"""
default_pullback_rank_atol(A)
Default tolerance for deciding what values should be considered equal to 0.
"""
default_pullback_rank_atol(A) = eps(norm(A, Inf))^(3 / 4)
"""
default_hermitian_tol(A)
Default tolerance for deciding to warn if the provided `A` is not hermitian.
"""
default_hermitian_tol(A) = eps(norm(A, Inf))^(3 / 4)
const DEFAULT_FIXGAUGE = Ref(true)
@doc """
default_fixgauge() -> current_value
default_fixgauge(new_value::Bool) -> previous_value
Global toggle for enabling or disabling the default behavior of gauge fixing the output of the eigen- and singular value decompositions.
""" default_fixgauge
default_fixgauge() = DEFAULT_FIXGAUGE[]
function default_fixgauge(new_value::Bool)
previous_value = DEFAULT_FIXGAUGE[]
DEFAULT_FIXGAUGE[] = new_value
return previous_value
end