File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 252
252
@testset " Fit Candidates" begin
253
253
test_fit_candidates ()
254
254
end
255
+
256
+ @testset " Approximate Spectral Radius" begin
257
+ test_approximate_spectral_radius ()
258
+ end
255
259
end
256
260
257
261
end
Original file line number Diff line number Diff line change @@ -183,4 +183,36 @@ function generate_fit_candidates_cases()
183
183
end
184
184
185
185
cases
186
+ end
187
+
188
+ # Test approximate spectral radius
189
+ function test_approximate_spectral_radius ()
190
+
191
+ cases = []
192
+ srand (0 )
193
+
194
+ push! (cases, [2. 0.
195
+ 0. 1. ])
196
+
197
+ push! (cases, [- 2. 0.
198
+ 0 1 ])
199
+
200
+ push! (cases, [100. 0. 0.
201
+ 0. 101. 0.
202
+ 0. 0. 99. ])
203
+
204
+ for i in 2 : 5
205
+ push! (cases, rand (i,i))
206
+ end
207
+
208
+ for A in cases
209
+ E,V = eig (A)
210
+ E = abs .(E)
211
+ largest_eig = find (E .== maximum (E))[1 ]
212
+ expected_eig = E[largest_eig]
213
+
214
+ @test isapprox (approximate_spectral_radius (A), expected_eig)
215
+
216
+ end
217
+
186
218
end
You can’t perform that action at this time.
0 commit comments