Skip to content

Commit

Permalink
Merge pull request #592 from JuliaControl/baltrunc_disc
Browse files Browse the repository at this point in the history
fix for discrete systems in baltrunc
  • Loading branch information
baggepinnen authored Jan 5, 2022
2 parents 77b3932 + d26f619 commit f3f7e4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/matrix_comps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -540,16 +540,17 @@ function baltrunc(sys::ST; atol = sqrt(eps()), rtol = 1e-3, n = nothing, residua
A11 = A[i1, i1]
A12 = A[i1, i2]
A21 = A[i2, i1]
A22 = A[i2, i2]
A22 = -A[i2, i2]
isdiscrete(sys) && (A22 += I)
B1 = B[i1, :]
B2 = B[i2, :]
C1 = C[:, i1]
C2 = C[:, i2]
A2221 = A22\A21
A = A11 - A12*(A2221)
B = B1 - (A12/A22)*B2
C = C1 - C2*A2221
D = D - (C2/A22)*B2
A = A11 + A12*(A2221)
B = B1 + (A12/A22)*B2
C = C1 + C2*A2221
D = D + (C2/A22)*B2
else
A = sysbal.A[i1,i1]
B = sysbal.B[i1,:]
Expand Down
4 changes: 4 additions & 0 deletions test/test_simplification.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,9 @@ y2,x2 = step(sysmin,t)[[1,3]]
@test sysr.nx == 3
@test dcgain(sysr)[] dcgain(sys)[] rtol=1e-10

sys = c2d(sys, 0.01)
sysr,Σ = baltrunc(sys, n=3, residual=true)
@test sysr.nx == 3
@test dcgain(sysr)[] dcgain(sys)[] rtol=1e-10

end

2 comments on commit f3f7e4e

@baggepinnen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/51692

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.9 -m "<description of version>" f3f7e4e356905266525bb4103ac648e37e7dd8c0
git push origin v0.11.9

Please sign in to comment.