-
Notifications
You must be signed in to change notification settings - Fork 45
add ab08nz function to support complex state-space systems #96
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2f78306
add ab08nz function to support regular pencil for complex state-space…
lytex 42ee06f
add ab08n* tests (ab08nd executes successfully, ab08nz SEGFAULTs)
lytex 203dc75
clean __init__
bnavigator 8f06d66
rework signatures for ab08nd and ab08nz
bnavigator e2471dc
rework analysis.ab08nz() function
bnavigator da58b7d
extend tests for ab08nX
bnavigator 96ae4bf
fix docstring
bnavigator 96d9890
remove complex warning in ab08nz
bnavigator 021a5c4
add the test file to CMakeLists.txt
bnavigator d397dbb
readd tolerance calculation docstring, reformat lzwork docstring
bnavigator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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 |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ set(PYSOURCE | |
|
|
||
| __init__.py | ||
| test.py | ||
| test_ab08n.py | ||
| test_ag08bd.py | ||
| test_mb.py | ||
| test_mc.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 |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # =================================================== | ||
| # ag08bd tests | ||
|
|
||
| import unittest | ||
| from slycot import analysis | ||
| import numpy as np | ||
|
|
||
| from scipy.linalg import eig | ||
| from numpy.testing import assert_equal, assert_allclose | ||
|
|
||
|
|
||
| class test_ab08n(unittest.TestCase): | ||
| """ Test regular pencil construction ab08nX with input parameters | ||
| according to example in documentation """ | ||
|
|
||
| A = np.diag([1., 1., 3., -4., -1., 3.]) | ||
|
|
||
| B = np.array([[ 0., -1.], | ||
| [-1., 0.], | ||
| [ 1., -1.], | ||
| [ 0., 0.], | ||
| [ 0., 1.], | ||
| [-1., -1.]]) | ||
|
|
||
| C = np.array([[1., 0., 0., 1., 0., 0.], | ||
| [0., 1., 0., 1., 0., 1.], | ||
| [0., 0., 1., 0., 0., 1.]]) | ||
|
|
||
| D = np.zeros((3, 2)) | ||
|
|
||
| def normalize(self, w): | ||
| wi = np.flip(np.argsort(np.abs(w))) | ||
| wn = w[wi]/w[wi[0]] | ||
| return wn | ||
|
|
||
| def ab08nX(self, ab08fun, A, B, C, D): | ||
| n = 6 | ||
| m = 2 | ||
| p = 3 | ||
| # Check the observability and compute the ordered set of | ||
| # the observability indices (call the routine with M = 0). | ||
| out = ab08fun(n, 0, p, A, B, C, D) | ||
| nu, rank, dinfz, nkror, nkrol, infz, kronr, kronl, Af, Bf = out[:10] | ||
|
|
||
| assert_equal(kronl[:nkrol], np.array([1, 2, 2])) | ||
| assert_equal(n-nu, 5) | ||
| assert_allclose(Af[:nu, :nu], np.array([[-1.]])) | ||
| # Check the controllability and compute the ordered set of | ||
| # the controllability indices (call the routine with P = 0) | ||
| out = ab08fun(n, m, 0, A, B, C, D) | ||
| nu, rank, dinfz, nkror, nkrol, infz, kronr, kronl, Af, Bf = out[:10] | ||
| assert_equal(kronr[:nkror], np.array([2, 3])) | ||
| assert_equal(n-nu, 5) | ||
| assert_allclose(Af[:nu, :nu], np.array([[-4.]])) | ||
| # Compute the structural invariants of the given system. | ||
| out = ab08fun(n, m, p, A, B, C, D) | ||
| nu, rank, dinfz, nkror, nkrol, infz, kronr, kronl, Af, Bf = out[:10] | ||
| assert_equal(nu, 2) | ||
| # Compute the invariant zeros of the given system. | ||
| w = eig(Af[:nu, :nu], Bf[:nu, :nu], left=False, right=False) | ||
| w_ref = np.array([-2., 1.]) | ||
| assert_allclose(self.normalize(w), self.normalize(w_ref)) | ||
| # the examples value of infinite zeros does not match the code | ||
| # compare output formats to given strings | ||
| # assert_equal(sum(infz[:dinfz]), 2) | ||
| # assert_equal([[infz[i], i+1] for i in range(dinfz)], [[1, 1]]) | ||
| assert_equal(nkror, 0) | ||
| assert_equal(nkrol, 1) | ||
| assert_equal(kronl[:nkrol], np.array([2])) | ||
|
|
||
| def test_ab08nd(self): | ||
| "Test Construct regular pencil for real matrices" | ||
| self.ab08nX(analysis.ab08nd, self.A, self.B, self.C, self.D) | ||
|
|
||
| def test_ab08nz(self): | ||
| "Test Construct regular pencil for (pseudo) complex matrices" | ||
| Ac, Bc, Cc, Dc = [M.astype(np.complex128) for M in [self.A, self.B, | ||
| self.C, self.D]] | ||
| self.ab08nX(analysis.ab08nz, Ac, Bc, Cc, Dc) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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.
Uh oh!
There was an error while loading. Please reload this page.