diff --git a/lib/ControlSystemsBase/src/matrix_comps.jl b/lib/ControlSystemsBase/src/matrix_comps.jl index 3cc8c307c..7db1cb510 100644 --- a/lib/ControlSystemsBase/src/matrix_comps.jl +++ b/lib/ControlSystemsBase/src/matrix_comps.jl @@ -542,7 +542,7 @@ Compute a similarity transform `T = S*P` resulting in `B = T\\A*T` such that the and column norms of `B` are approximately equivalent. If `perm=false`, the transformation will only scale `A` using diagonal `S`, and not permute `A` (i.e., set `P=I`). """ -function balance(A, perm::Bool=true) +function balance(A::AbstractMatrix{<:LinearAlgebra.BlasFloat}, perm::Bool=true) n = LinearAlgebra.checksquare(A) B = copy(A) job = perm ? 'B' : 'S' @@ -570,6 +570,11 @@ function cswap!(i::Integer, j::Integer, X::StridedMatrix) end end +function balance(A::AbstractMatrix, perm::Bool=true) + Ac = Float64.(A) + balance(Ac, perm) +end + """ diff --git a/lib/ControlSystemsBase/test/test_matrix_comps.jl b/lib/ControlSystemsBase/test/test_matrix_comps.jl index 5595d21d0..1614cca97 100644 --- a/lib/ControlSystemsBase/test/test_matrix_comps.jl +++ b/lib/ControlSystemsBase/test/test_matrix_comps.jl @@ -15,6 +15,11 @@ sysb,T = ControlSystemsBase.balance_statespace(sys) @test similarity_transform(sysb, T) ≈ sys Ab,Bb,Cb,T = ControlSystemsBase.balance_statespace(A,B,C) +sysbb,Tb = ControlSystemsBase.balance_statespace(big(1.0)*sys) +@test Tb ≈ T +@test sysbb ≈ sysb + + @test Ab*T ≈ T*A @test Bb ≈ T*B @test Cb*T ≈ C