Repository navigation
H-infinity mixed-synthesis #151
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
77d0ccd
78f0c7f
7b883ef
e24c7de
7d70fb4
36e0b0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ | |
| import math | ||
| import numpy as np | ||
| from numpy import all, angle, any, array, asarray, concatenate, cos, delete, \ | ||
| dot, empty, exp, eye, matrix, ones, poly, poly1d, roots, shape, sin, \ | ||
| dot, empty, exp, eye, matrix, ones, pi, poly, poly1d, roots, shape, sin, \ | ||
| zeros, squeeze | ||
| from numpy.random import rand, randn | ||
| from numpy.linalg import solve, eigvals, matrix_rank | ||
|
|
@@ -69,6 +69,19 @@ | |
|
|
||
| __all__ = ['StateSpace', 'ss', 'rss', 'drss', 'tf2ss', 'ssdata'] | ||
|
|
||
|
|
||
| def _matrix(a): | ||
| """_matrix(a) -> numpy.matrix | ||
| a - passed to numpy.matrix | ||
| Wrapper around numpy.matrix; unlike that function, _matrix([]) will be 0x0 | ||
|
Member
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. Not clear to my why this is useful? Can you say a bit here (or in a comment in the code)?
Contributor
Author
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. I'll expand the commentary; it's just a helper to make it easier to get 0x0 matrices, which are needed for empty state space systems. |
||
| """ | ||
| from numpy import matrix | ||
| am = matrix(a) | ||
| if (1,0) == am.shape: | ||
| am.shape = (0,0) | ||
| return am | ||
|
|
||
|
|
||
| class StateSpace(LTI): | ||
| """StateSpace(A, B, C, D[, dt]) | ||
|
|
||
|
|
@@ -130,7 +143,7 @@ def __init__(self, *args): | |
| else: | ||
| raise ValueError("Needs 1 or 4 arguments; received %i." % len(args)) | ||
|
|
||
| A, B, C, D = map(matrix, [A, B, C, D]) | ||
| A, B, C, D = [_matrix(M) for M in (A, B, C, D)] | ||
|
|
||
| # TODO: use super here? | ||
| LTI.__init__(self, inputs=D.shape[1], outputs=D.shape[0], dt=dt) | ||
|
|
@@ -336,7 +349,7 @@ def __rmul__(self, other): | |
|
|
||
| # try to treat this as a matrix | ||
| try: | ||
| X = matrix(other) | ||
| X = _matrix(other) | ||
| C = X * self.C | ||
| D = X * self.D | ||
| return StateSpace(self.A, self.B, C, D, self.dt) | ||
|
|
@@ -727,11 +740,9 @@ def _convertToStateSpace(sys, **kw): | |
|
|
||
| # If this is a matrix, try to create a constant feedthrough | ||
| try: | ||
| D = matrix(sys) | ||
| outputs, inputs = D.shape | ||
|
|
||
| return StateSpace(0., zeros((1, inputs)), zeros((outputs, 1)), D) | ||
| except Exception(e): | ||
| D = _matrix(sys) | ||
| return StateSpace([], [], [], D) | ||
| except Exception as e: | ||
| print("Failure to assume argument is matrix-like in" \ | ||
| " _convertToStateSpace, result %s" % e) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid using
numpy.pisince this can generate errors whennumpyis incorporated as amockfunction. See PR 171, commit b881b7. Replace withmath.pi.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unqualified
pino longer used following your aa6e0df anyway. Will remove.