- Notifications
You must be signed in to change notification settings - Fork441
ENH: addlinform
to compute linear system L-infinity norm#729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
66 changes: 65 additions & 1 deletioncontrol/statesp.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -55,6 +55,7 @@ | ||
from numpy.linalg import solve, eigvals, matrix_rank | ||
from numpy.linalg.linalg import LinAlgError | ||
import scipy as sp | ||
import scipy.linalg | ||
from scipy.signal import cont2discrete | ||
from scipy.signal import StateSpace as signalStateSpace | ||
from warnings import warn | ||
@@ -63,7 +64,12 @@ | ||
from . import config | ||
from copy import deepcopy | ||
try: | ||
from slycot import ab13dd | ||
except ImportError: | ||
ab13dd = None | ||
__all__ = ['StateSpace', 'tf2ss', 'ssdata', 'linfnorm'] | ||
# Define module default parameter values | ||
_statesp_defaults = { | ||
@@ -1888,3 +1894,61 @@ def ssdata(sys): | ||
""" | ||
ss = _convert_to_statespace(sys) | ||
return ss.A, ss.B, ss.C, ss.D | ||
def linfnorm(sys, tol=1e-10): | ||
"""L-infinity norm of a linear system | ||
Parameters | ||
---------- | ||
sys : LTI (StateSpace or TransferFunction) | ||
system to evalute L-infinity norm of | ||
tol : real scalar | ||
tolerance on norm estimate | ||
Returns | ||
------- | ||
gpeak : non-negative scalar | ||
L-infinity norm | ||
fpeak : non-negative scalar | ||
Frequency, in rad/s, at which gpeak occurs | ||
For stable systems, the L-infinity and H-infinity norms are equal; | ||
for unstable systems, the H-infinity norm is infinite, while the | ||
L-infinity norm is finite if the system has no poles on the | ||
imaginary axis. | ||
See also | ||
-------- | ||
slycot.ab13dd : the Slycot routine linfnorm that does the calculation | ||
""" | ||
if ab13dd is None: | ||
raise ControlSlycot("Can't find slycot module 'ab13dd'") | ||
a, b, c, d = ssdata(_convert_to_statespace(sys)) | ||
e = np.eye(a.shape[0]) | ||
n = a.shape[0] | ||
m = b.shape[1] | ||
p = c.shape[0] | ||
if n == 0: | ||
# ab13dd doesn't accept empty A, B, C, D; | ||
# static gain case is easy enough to compute | ||
gpeak = scipy.linalg.svdvals(d)[0] | ||
# max svd is constant with freq; arbitrarily choose 0 as peak | ||
fpeak = 0 | ||
return gpeak, fpeak | ||
Comment on lines +1936 to +1942 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Note that this will return a value even if | ||
dico = 'C' if sys.isctime() else 'D' | ||
jobe = 'I' | ||
equil = 'S' | ||
jobd = 'Z' if all(0 == d.flat) else 'D' | ||
gpeak, fpeak = ab13dd(dico, jobe, equil, jobd, n, m, p, a, e, b, c, d, tol) | ||
if dico=='D': | ||
fpeak /= sys.dt | ||
return gpeak, fpeak |
53 changes: 52 additions & 1 deletioncontrol/tests/statesp_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.