1
+ # Linear Verbosity
2
+
3
+ linear_defaults = Dict (
4
+ :default_lu_fallback => Verbosity. Warn (),
5
+ :no_right_preconditioning => Verbosity. Warn (),
6
+ :using_iterative_solvers => Verbosity. Warn (),
7
+ :using_IterativeSolvers => Verbosity. Warn (),
8
+ :IterativeSolvers_iterations => Verbosity. Warn (),
9
+ :KrylovKit_verbosity => Verbosity. Warn (),
10
+ :KrylovJL_verbosity => Verbosity. None ()
11
+ )
12
+ mutable struct LinearErrorControlVerbosity
13
+ default_lu_fallback:: Verbosity.Type
14
+
15
+ function LinearErrorControlVerbosity (;
16
+ default_lu_fallback = linear_defaults[:default_lu_fallback ])
17
+ new (default_lu_fallback)
18
+ end
19
+
20
+ function LinearErrorControlVerbosity (verbose:: Verbosity.Type )
21
+ @match verbose begin
22
+ Verbosity. None () => new (fill (
23
+ Verbosity. None (), length (fieldnames (LinearErrorControlVerbosity)))... )
24
+
25
+ Verbosity. Info () => new (fill (
26
+ Verbosity. Info (), length (fieldnames (LinearErrorControlVerbosity)))... )
27
+
28
+ Verbosity. Warn () => new (fill (
29
+ Verbosity. Warn (), length (fieldnames (LinearErrorControlVerbosity)))... )
30
+
31
+ Verbosity. Error () => new (fill (
32
+ Verbosity. Error (), length (fieldnames (LinearErrorControlVerbosity)))... )
33
+
34
+ Verbosity. Default () => LinearErrorControlVerbosity ()
35
+
36
+ Verbosity. Edge () => LinearErrorControlVerbosity ()
37
+
38
+ _ => @error " Not a valid choice for verbosity."
39
+ end
40
+ end
41
+ end
42
+
43
+ mutable struct LinearPerformanceVerbosity
44
+ no_right_preconditioning:: Verbosity.Type
45
+
46
+ function LinearPerformanceVerbosity (;
47
+ no_right_preconditioning = linear_defaults[:no_right_preconditioning ])
48
+ new (no_right_preconditioning)
49
+ end
50
+
51
+ function LinearPerformanceVerbosity (verbose:: Verbosity.Type )
52
+ @match verbose begin
53
+ Verbosity. None () => new (fill (
54
+ Verbosity. None (), length (fieldnames (LinearPerformanceVerbosity)))... )
55
+
56
+ Verbosity. Info () => new (fill (
57
+ Verbosity. Info (), length (fieldnames (LinearPerformanceVerbosity)))... )
58
+
59
+ Verbosity. Warn () => new (fill (
60
+ Verbosity. Warn (), length (fieldnames (LinearPerformanceVerbosity)))... )
61
+
62
+ Verbosity. Error () => new (fill (
63
+ Verbosity. Error (), length (fieldnames (LinearPerformanceVerbosity)))... )
64
+
65
+ Verbosity. Default () => LinearPerformanceVerbosity ()
66
+
67
+ Verbosity. Edge () => LinearPerformanceVerbosity ()
68
+
69
+ _ => @error " Not a valid choice for verbosity."
70
+ end
71
+ end
72
+ end
73
+
74
+ mutable struct LinearNumericalVerbosity
75
+ using_IterativeSolvers:: Verbosity.Type
76
+ IterativeSolvers_iterations:: Verbosity.Type
77
+ KrylovKit_verbosity:: Verbosity.Type
78
+ KrylovJL_verbosity:: Verbosity.Type
79
+
80
+ function LinearNumericalVerbosity (;
81
+ using_IterativeSolvers = linear_defaults[:using_IterativeSolvers ],
82
+ IterativeSolvers_iterations = linear_defaults[:IterativeSolvers_iterations ],
83
+ KrylovKit_verbosity = linear_defaults[:KrylovKit_verbosity ],
84
+ KrylovJL_verbosity = linear_defaults[:KrylovJL_verbosity ])
85
+ new (using_IterativeSolvers, IterativeSolvers_iterations,
86
+ KrylovKit_verbosity, KrylovJL_verbosity)
87
+ end
88
+
89
+ function LinearNumericalVerbosity (verbose:: Verbosity.Type )
90
+ @match verbose begin
91
+ Verbosity. None () => new (fill (
92
+ Verbosity. None (), length (fieldnames (LinearNumericalVerbosity)))... )
93
+
94
+ Verbosity. Info () => new (fill (
95
+ Verbosity. Info (), length (fieldnames (LinearNumericalVerbosity)))... )
96
+
97
+ Verbosity. Warn () => new (fill (
98
+ Verbosity. Warn (), length (fieldnames (LinearNumericalVerbosity)))... )
99
+
100
+ Verbosity. Error () => new (fill (
101
+ Verbosity. Error (), length (fieldnames (LinearNumericalVerbosity)))... )
102
+
103
+ Verbosity. Default () => LinearNumericalVerbosity ()
104
+
105
+ Verbosity. Edge () => LinearNumericalVerbosity ()
106
+
107
+ _ => @error " Not a valid choice for verbosity."
108
+ end
109
+ end
110
+ end
111
+
112
+ struct LinearVerbosity{T} <: AbstractVerbositySpecifier{T}
113
+ error_control:: LinearErrorControlVerbosity
114
+ performance:: LinearPerformanceVerbosity
115
+ numerical:: LinearNumericalVerbosity
116
+ end
117
+
118
+ function LinearVerbosity (verbose:: Verbosity.Type )
119
+ @match verbose begin
120
+ Verbosity. Default () => LinearVerbosity {true} (
121
+ LinearErrorControlVerbosity (Verbosity. Default ()),
122
+ LinearPerformanceVerbosity (Verbosity. Default ()),
123
+ LinearNumericalVerbosity (Verbosity. Default ())
124
+ )
125
+
126
+ Verbosity. None () => LinearVerbosity {false} (
127
+ LinearErrorControlVerbosity (Verbosity. None ()),
128
+ LinearPerformanceVerbosity (Verbosity. None ()),
129
+ LinearNumericalVerbosity (Verbosity. None ()))
130
+
131
+ Verbosity. All () => LinearVerbosity {true} (
132
+ LinearErrorControlVerbosity (Verbosity. Info ()),
133
+ LinearPerformanceVerbosity (Verbosity. Info ()),
134
+ LinearNumericalVerbosity (Verbosity. Info ())
135
+ )
136
+
137
+ _ => @error " Not a valid choice for LinearVerbosity. Available choices are `Default`, `None`, and `All`."
138
+ end
139
+ end
140
+
141
+ function LinearVerbosity (;
142
+ error_control = Verbosity. Default (), performance = Verbosity. Default (),
143
+ numerical = Verbosity. Default (), kwargs... )
144
+ if error_control isa Verbosity. Type
145
+ error_control_verbosity = LinearErrorControlVerbosity (error_control)
146
+ else
147
+ error_control_verbosity = error_control
148
+ end
149
+
150
+ if performance isa Verbosity. Type
151
+ performance_verbosity = LinearPerformanceVerbosity (performance)
152
+ else
153
+ performance_verbosity = performance
154
+ end
155
+
156
+ if numerical isa Verbosity. Type
157
+ numerical_verbosity = LinearNumericalVerbosity (numerical)
158
+ else
159
+ numerical_verbosity = numerical
160
+ end
161
+
162
+ if ! isempty (kwargs)
163
+ for (key, value) in pairs (kwargs)
164
+ if hasfield (LinearErrorControlVerbosity, key)
165
+ setproperty! (error_control_verbosity, key, value)
166
+ elseif hasfield (LinearPerformanceVerbosity, key)
167
+ setproperty! (performance_verbosity, key, value)
168
+ elseif hasfield (LinearNumericalVerbosity, key)
169
+ setproperty! (numerical_verbosity, key, value)
170
+ else
171
+ error (" $key is not a recognized verbosity toggle." )
172
+ end
173
+ end
174
+ end
175
+
176
+ LinearVerbosity {true} (error_control_verbosity,
177
+ performance_verbosity, numerical_verbosity)
178
+ end
0 commit comments