Skip to content

Commit f18f27b

Browse files
committed
type handling fix
1 parent 0b9cea2 commit f18f27b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/ControlSystemsBase/src/matrix_comps.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ The return value contains the field `iscontrollable` which is `true` if the rank
182182
183183
Technically, this function checks for controllability from the origin, also called reachability.
184184
"""
185-
function controllability(A::AbstractMatrix{T}, B; atol::Real=0, rtol::Real=atol>0 ? 0 : size(A,1)*eps(T)) where T
185+
function controllability(A::AbstractMatrix{T}, B; atol::Real=0, rtol::Real=atol>0 ? 0 : size(A,1)*eps(float(T))) where T
186186
n = LinearAlgebra.checksquare(A)
187187
p = eigvals(A)
188188
ranks = zeros(Int, n)
189-
sigma_min = similar(A, n)
189+
sigma_min = similar(A, float(T), n)
190190
for i = 1:n
191191
sigmas = svdvals([(p[i]*I - A) B])
192192
r = count(>=(max(atol, rtol*sigmas[1])), sigmas)
@@ -206,11 +206,11 @@ Check for observability of the pair `(A, C)` or `sys` using the PHB test.
206206
207207
The return value contains the field `isobservable` which is `true` if the rank condition is met at all eigenvalues of `A`, and `false` otherwise. The returned structure also contains the rank and smallest singular value at each individual eigenvalue of `A` in the fields `ranks` and `sigma_min`.
208208
"""
209-
function observability(A::AbstractMatrix{T}, C; atol::Real=0, rtol::Real=atol>0 ? 0 : size(A,1)*eps(T)) where T
209+
function observability(A::AbstractMatrix{T}, C; atol::Real=0, rtol::Real=atol>0 ? 0 : size(A,1)*eps(float(T))) where T
210210
n = LinearAlgebra.checksquare(A)
211211
p = eigvals(A)
212212
ranks = zeros(Int, n)
213-
sigma_min = similar(A, n)
213+
sigma_min = similar(A, float(T), n)
214214
for i = 1:n
215215
sigmas = svdvals([(p[i]*I - A); C])
216216
r = count(>=(max(atol, rtol*sigmas[1])), sigmas)

0 commit comments

Comments
 (0)