Skip to content

Add high-level Pythonic API layer #14

@jamestjsp

Description

@jamestjsp

Summary

Wrap the 587 low-level SLICOT routines with a high-level Pythonic API module (ctrlsys/control.py) so users don't need to know SLICOT routine names or parameter conventions.

Before:

from ctrlsys import sb02od
rcond, x, alfar, alfai, beta, s, t, u, iwarn, info = sb02od(
    'D', 'G', 'N', 'U', 'Z', 'S', n, m, a, b, q, r, l
)

After:

import ctrlsys
K, X, ev = ctrlsys.lqr(A, B, Q, R)

Why

  • Multiplies audience 100x — control engineers know lqr(), not sb02od
  • python-control killer — same SLICOT routines MATLAB uses, but with a modern Python API
  • Pure Python, zero risk — thin wrappers over existing C bindings, no build changes
  • AI-agent friendly — agents call ctrlsys.lqr() without memorizing 587 routine signatures
  • guide.rst already has the mapping — implementation is straightforward

Proposed functions (priority order)

Function Description Underlying routine(s)
lqr(A, B, Q, R) Continuous LQR SB02OD
dlqr(A, B, Q, R) Discrete LQR SB02OD (DICO='D')
lqe(A, C, Q, R) Kalman filter gain SB02OD
solve_care(A, B, Q, R) Continuous algebraic Riccati SB02MD/SB02OD
solve_dare(A, B, Q, R) Discrete algebraic Riccati SB02MD/SB02OD
hinf_norm(A, B, C, D) H-infinity norm AB13DD
h2_norm(A, B, C, D) H2 norm AB13BD
balred(A, B, C, nr) Balanced truncation AB09AD
hinf_syn(A, B, C, D) H-infinity synthesis SB10AD/SB10DD
pole_place(A, B, poles) Pole placement SB01BD
ctrb(A, B) Controllability matrix/test AB01MD
obsv(A, C) Observability matrix/test AB01MD (dual)
gram(A, B, C, type) Gramians SB03MD
lyap(A, Q) Lyapunov solver SB03MD
dlyap(A, Q) Discrete Lyapunov SB03MD (DICO='D')

Implementation notes

  • Pure Python module, ~20-40 lines per function
  • Input validation + sensible defaults for SLICOT parameters
  • Return named tuples or simple tuples matching MATLAB conventions
  • NumPy arrays in, NumPy arrays out (F-order handled internally)
  • Errors raised as Python exceptions, not info codes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions