Skip to content

Commit

Permalink
Merge branch 'autodiff' into misc_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfalt committed Jul 30, 2018
2 parents 969db22 + 5bf3f01 commit 0db1de1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/simulators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ plot(t, s.y(sol, t)[:], lab="Open loop step response")
"""
function Simulator(P::StateSpace, u = (x,t) -> 0)
@assert iscontinuous(P) "Simulator only supports continuous-time system. See function `lsim` for simulation of discrete-time systems."
@assert all(P.D .== 0) "Can not simulate systems with direct term D != 0"
f = (dx,x,p,t) -> dx .= P.A*x .+ P.B*u(x,t)
y(x,t) = P.C*x .+ P.D*u(x,t)
y(x,t) = P.C*x #.+ P.D*u(x,t)
y(sol::ODESolution,t) = P.C*sol(t)
Simulator(P, f, y)
end
Expand Down
7 changes: 4 additions & 3 deletions src/types/SisoTfTypes/SisoRational.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ numpoly(f::SisoRational) = f.num
tzero(f::SisoRational) = roots(f.num)
pole(f::SisoRational) = roots(f.den)

function evalfr(f::SisoRational, s::Number)
S = promote_type(typeof(s), Float64)
function evalfr(f::SisoRational{T}, s::Number) where T
S = promote_type(T,typeof(s), Float64)
# S = typeof(s)
den = polyval(f.den, s)
if den == zero(S)
convert(S, Inf)
convert(S,Inf)
else
polyval(f.num, s)/den
end
Expand Down

0 comments on commit 0db1de1

Please sign in to comment.