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 252252@testset " Fit Candidates" begin
253253 test_fit_candidates ()
254254end
255+
256+ @testset " Approximate Spectral Radius" begin
257+ test_approximate_spectral_radius ()
258+ end
255259end
256260
257261end
Original file line number Diff line number Diff line change @@ -183,4 +183,36 @@ function generate_fit_candidates_cases()
183183 end
184184
185185 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+
186218end
You can’t perform that action at this time.
0 commit comments