Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix return shape for place_acker (#1190)
  • Loading branch information
murrayrm committed Jan 19, 2026
commit 3215681a496615cf72d6e6cf3ef6593abda35756
2 changes: 1 addition & 1 deletion control/statefbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def place_acker(A, B, poles):
pmat = pmat + p[n-i-1] * np.linalg.matrix_power(A, i)
K = np.linalg.solve(ct, pmat)

K = K[-1, :] # Extract the last row
K = K[-1:, :] # Extract the last row
return K


Expand Down
17 changes: 17 additions & 0 deletions control/tests/statefbk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,3 +1272,20 @@ def test_create_statefbk_params(unicycle):
assert [k for k in clsys.params.keys()] == ['K', 'a', 'b']
assert clsys.params['a'] == 2
assert clsys.params['b'] == 1


@pytest.mark.parametrize('ny, nu', [(1, 1), (2, 2), (2, 1)])
@pytest.mark.parametrize('method', [place, place_varga, place_acker])
def test_place_variants(ny, nu, method):
sys = ct.rss(states=2, inputs=nu, outputs=ny)
desired_poles = -np.arange(1, sys.nstates + 1, 1)

if method == place_acker and sys.ninputs != 1:
with pytest.raises(np.linalg.LinAlgError, match="must be square"):
K = method(sys.A, sys.B, desired_poles)
else:
K = method(sys.A, sys.B, desired_poles)

placed_poles = np.linalg.eigvals(sys.A - sys.B @ K)
np.testing.assert_array_almost_equal(
np.sort(desired_poles), np.sort(placed_poles))
Loading