-
Notifications
You must be signed in to change notification settings - Fork 45
Add ab04md #201
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
Add ab04md #201
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3598ac9
Add ab04md wrapper
KybernetikJo 52cc0f8
Unittest added for ab04md.
KybernetikJo 416b352
Add docstring, Change parameter name from type_bn to type_t
KybernetikJo 6643167
Update slycot/analysis.py
KybernetikJo fe5c56a
Update docstring (remove input mark from int types)
KybernetikJo 8ad0236
Improve docstring
KybernetikJo 2289d93
Update docstring, minor fixes
KybernetikJo 118bf58
cleanup test file
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
Unittest added for ab04md.
- Loading branch information
commit 52cc0f8fae101ee03dd2013bb83e43cc51527a4c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ set(PYSOURCE | |
|
||
__init__.py | ||
test_ab01.py | ||
test_ab04md.py | ||
test_ab08n.py | ||
test_ag08bd.py | ||
test_examples.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,71 @@ | ||
# =================================================== | ||
# ab08n* 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_ab04md(unittest.TestCase): | ||
"""Test ab04md. | ||
|
||
Example data taken from | ||
https://www.slicot.org/objects/software/shared/doc/AB04MD.html. | ||
""" | ||
|
||
Ac = np.array([[1.0, 0.5], | ||
[0.5, 1.0]]) | ||
Bc = np.array([[0.0, -1.0], | ||
[1.0, 0.0]]) | ||
Cc = np.array([[-1.0, 0.0], | ||
[0.0, 1.0]]) | ||
Dc = np.array([[1.0, 0.0], | ||
[0.0, -1.0]]) | ||
|
||
Ad = np.array([[-1.0, -4.0], | ||
[-4.0, -1.0]]) | ||
Bd = np.array([[2.8284, 0.0], | ||
[0.0, -2.8284]]) | ||
Cd = np.array([[0.0, 2.8284], | ||
[-2.8284, 0.0]]) | ||
Dd = np.array([[-1.0, 0.0], | ||
[0.0, -3.0]]) | ||
|
||
def test_ab04md_cont_disc_cont(self): | ||
"""Test transformation from continuous - to discrete - to continuous time. | ||
""" | ||
|
||
n, m = self.Bc.shape | ||
p = self.Cc.shape[0] | ||
|
||
Ad_t, Bd_t, Cd_t, Dd_t = analysis.ab04md('C',n,m,p,self.Ac,self.Bc,self.Cc,self.Dc) | ||
|
||
Ac_t, Bc_t, Cc_t, Dc_t = analysis.ab04md('D',n,m,p,Ad_t,Bd_t,Cd_t,Dd_t) | ||
|
||
assert_allclose(self.Ac, Ac_t) | ||
assert_allclose(self.Bc, Bc_t) | ||
assert_allclose(self.Cc, Cc_t) | ||
assert_allclose(self.Dc, Dc_t) | ||
|
||
def test_ab04md_disc_cont_disc(self): | ||
"""Test transformation from discrete - to continuous - to discrete time. | ||
""" | ||
|
||
n, m = self.Bc.shape | ||
p = self.Cc.shape[0] | ||
|
||
Ac_t, Bc_t, Cc_t, Dc_t = analysis.ab04md('D',n,m,p,self.Ad,self.Bd,self.Cd,self.Dd) | ||
|
||
Ad_t, Bd_t, Cd_t, Dd_t = analysis.ab04md('C',n,m,p,Ac_t,Bc_t,Cc_t,Dc_t) | ||
|
||
assert_allclose(self.Ad, Ad_t) | ||
assert_allclose(self.Bd, Bd_t) | ||
assert_allclose(self.Cd, Cd_t) | ||
assert_allclose(self.Dd, Dd_t) | ||
|
||
|
||
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.
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.
unittest.TestCase
not needed