Skip to content

Commit 1a5af82

Browse files
authored
Merge pull request #221 from SciML/fb/MGfix
avoid using array variable
2 parents 9cc3833 + 3c88a9a commit 1a5af82

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Blocks/math.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ end
2424
Gain.f(k; name) = Gain.f(; k, name)
2525

2626
"""
27-
MatrixGain(K::AbstractArray; name)
27+
MatrixGain(; K::AbstractArray, name)
2828
2929
Output the product of a gain matrix with the input signal vector.
3030
31-
# Parameters:
31+
# Structural parameters:
3232
3333
- `K`: Matrix gain
3434
@@ -38,19 +38,19 @@ Output the product of a gain matrix with the input signal vector.
3838
- `output`
3939
"""
4040
@mtkmodel MatrixGain begin
41-
@parameters begin
42-
K, [description = "Matrix gain"]
41+
@structural_parameters begin
42+
K
4343
end
4444
begin
45-
nout = size(getdefault(K), 1)
46-
nin = size(getdefault(K), 2)
45+
nout = size(K, 1)
46+
nin = size(K, 2)
4747
end
4848
@components begin
4949
input = RealInput(; nin = nin)
5050
output = RealOutput(; nout = nout)
5151
end
5252
@equations begin
53-
[output.u[i] ~ sum(getdefault(K)[i, j] * input.u[j] for j in 1:nin)
53+
[output.u[i] ~ sum(K[i, j] * input.u[j] for j in 1:nin)
5454
for i in 1:nout]...
5555
end
5656
end

0 commit comments

Comments
 (0)