Repository navigation
Allow np.array or np.matrix for state space matrices, operations #314
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
0c1e983
4c9c2c8
4f48c5d
7c9d9a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ | |
| from warnings import warn | ||
| import numpy as np | ||
| from numpy import angle, array, empty, ones, \ | ||
| real, imag, matrix, absolute, eye, linalg, where, dot | ||
| real, imag, absolute, eye, linalg, where, dot | ||
| from scipy.interpolate import splprep, splev | ||
| from .lti import LTI | ||
|
|
||
|
|
@@ -81,6 +81,10 @@ class FRD(LTI): | |
|
|
||
| """ | ||
|
|
||
| # Allow NDarray * StateSpace to give StateSpace._rmul_() priority | ||
| # https://docs.scipy.org/doc/numpy/reference/arrays.classes.html | ||
| __array_priority__ = 11 # override ndarray and matrix types | ||
|
|
||
| epsw = 1e-8 | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
|
|
@@ -436,12 +440,13 @@ def feedback(self, other=1, sign=-1): | |
| # TODO: vectorize this | ||
| # TODO: handle omega re-mapping | ||
| for k, w in enumerate(other.omega): | ||
| fresp[:, :, k] = self.fresp[:, :, k].view(type=matrix)* \ | ||
| fresp[:, :, k] = np.dot( | ||
| self.fresp[:, :, k], | ||
| linalg.solve( | ||
| eye(self.inputs) + | ||
| other.fresp[:, :, k].view(type=matrix) * | ||
| self.fresp[:, :, k].view(type=matrix), | ||
| eye(self.inputs)) | ||
| eye(self.inputs) | ||
| + np.dot(other.fresp[:, :, k], self.fresp[:, :, k]), | ||
| eye(self.inputs)) | ||
|
Contributor
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 know this is not the point of this change, but is
Member
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 agree that this could use |
||
| ) | ||
|
|
||
| return FRD(fresp, other.omega, smooth=(self.ifunc is not None)) | ||
|
|
||
|
|
||
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.
trailing parenthesis here looks wrong. Do we run these with doctest?
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.
Fixed.
We are not currently using doctest, but I ran the revised version manually to make sure it was OK.