Skip to content

Commit 0f94b02

Browse files
authored
Merge pull request #2317 from SciML/fb/scalarlin
allow scalar IO in `linearize`
2 parents a0a95b5 + dd23d21 commit 0f94b02

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/systems/abstractsystem.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,8 @@ function linearization_function(sys::AbstractSystem, inputs,
12911291
p = DiffEqBase.NullParameters(),
12921292
zero_dummy_der = false,
12931293
kwargs...)
1294+
inputs isa AbstractVector || (inputs = [inputs])
1295+
outputs isa AbstractVector || (outputs = [outputs])
12941296
ssys, diff_idxs, alge_idxs, input_idxs = io_preprocessing(sys, inputs, outputs;
12951297
simplify,
12961298
kwargs...)
@@ -1486,7 +1488,7 @@ end
14861488
(; A, B, C, D), simplified_sys = linearize(sys, inputs, outputs; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false, kwargs...)
14871489
(; A, B, C, D) = linearize(simplified_sys, lin_fun; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false)
14881490
1489-
Return a NamedTuple with the matrices of a linear statespace representation
1491+
Linearize `sys` between `inputs` and `outputs`, both vectors of variables. Return a NamedTuple with the matrices of a linear statespace representation
14901492
on the form
14911493
14921494
```math

test/linearize.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ lsys, ssys = linearize(sys, [r], [r])
2626
@test lsys.C[] == 0
2727
@test lsys.D[] == 1
2828

29+
lsys, ssys = linearize(sys, r, r) # Test allow scalars
30+
31+
@test lsys.A[] == -2
32+
@test lsys.B[] == 1
33+
@test lsys.C[] == 0
34+
@test lsys.D[] == 1
35+
2936
##
3037
```
3138

0 commit comments

Comments
 (0)