@@ -23,35 +23,39 @@ end >= 94
2323
2424
2525# #
26- sys = ssrand (2 ,3 ,40 , stable= true )
27- sysus = ssrand (2 ,3 ,2 , stable= true )
28- sysus. A .*= - 1
29- sys = sys + sysus
30-
31- sysr, hs = RobustAndOptimalControl. baltrunc_coprime (sys, n= 20 , factorization = RobustAndOptimalControl. DescriptorSystems. glcf)
32-
33- @test sysr. nx <= 20
34- @test linfnorm (sysr - sys)[1 ] < 3e-3
35-
36- e = poles (sysr)
37- @test count (e-> real (e)> 0 , e) == 2 # test that the two unstable poles were preserved
38-
39- # bodeplot([sys, sysr])
40-
41- # # stab_unstab
42- sys = ssrand (2 ,3 ,40 , stable= false )
43- stab, unstab = stab_unstab (sys)
44- @test all (real (poles (stab)) .< 0 )
45- @test all (real (poles (unstab)) .>= 0 )
46- @test linfnorm (stab + unstab - sys)[1 ] < 1e-8
47-
48- # # baltrunc_unstab
49- sys = ssrand (2 ,3 ,40 , stable= true )
50- sysus = ssrand (2 ,3 ,2 , stable= true )
51- sysus. A .*= - 1
52- sys = sys + sysus
53- sysr, hs = baltrunc_unstab (sys, n= 20 )
54- @test sysr. nx <= 20
55- @test linfnorm (sysr - sys)[1 ] < 1e-3
56- # bodeplot([sys, sysr])
26+ @testset " unstable baltrunc" begin
27+ @info " Testing unstable baltrunc"
28+ for proper = [true , false ]
29+ sys = ssrand (2 ,3 ,40 ; stable= true , proper)
30+ sysus = ssrand (2 ,3 ,2 ; stable= true , proper)
31+ sysus. A .*= - 1
32+ sys = sys + sysus
33+
34+ sysr, hs = RobustAndOptimalControl. baltrunc_coprime (sys, n= 20 , factorization = RobustAndOptimalControl. DescriptorSystems. glcf)
35+
36+ @test sysr. nx <= 20
37+ @test linfnorm (sysr - sys)[1 ] < 9e-3
38+
39+ e = poles (sysr)
40+ @test count (e-> real (e)> 0 , e) == 2 # test that the two unstable poles were preserved
41+ # bodeplot([sys, sysr])
42+ end
5743
44+ # # stab_unstab
45+ sys = ssrand (2 ,3 ,40 , stable= false )
46+ stab, unstab = stab_unstab (sys)
47+ @test all (real (poles (stab)) .< 0 )
48+ @test all (real (poles (unstab)) .>= 0 )
49+ @test linfnorm (stab + unstab - sys)[1 ] < 1e-8
50+
51+ # # baltrunc_unstab
52+ sys = ssrand (2 ,3 ,40 , stable= true )
53+ sysus = ssrand (2 ,3 ,2 , stable= true )
54+ sysus. A .*= - 1
55+ sys = sys + sysus
56+ sysr, hs = baltrunc_unstab (sys, n= 20 )
57+ @test sysr. nx <= 20
58+ @test linfnorm (sysr - sys)[1 ] < 1e-3
59+ # bodeplot([sys, sysr])
60+
61+ end
0 commit comments