Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
73e969a
add exception classes
bnavigator May 3, 2020
e07206a
migrate analysis to new exceptions
bnavigator May 3, 2020
1f356f2
migrate math to new exceptions
bnavigator May 3, 2020
a8edfb4
migrate synthesis to the new exceptions
bnavigator May 3, 2020
de6e3df
migrate transform to new exceptions
bnavigator May 4, 2020
37e45d1
unify exception call signature
bnavigator May 4, 2020
2f44753
exception messages extracted from docstrings
repagh May 5, 2020
89429ad
count exception messages in synthesis
repagh May 5, 2020
0fd2ea5
Only on indexError should we report unhandled code
repagh May 5, 2020
d1b9ab1
simplify negative info parameter checks
bnavigator May 5, 2020
dbf643b
actually test error message/info matching. Did reveal some fixes to
repagh May 5, 2020
42cfb49
only check docstring if provided
bnavigator May 5, 2020
b9bfaae
correct sb01bd copy and paste error
repagh May 5, 2020
8b5b8f9
rework exception docstring parser
bnavigator May 5, 2020
ed027fb
fix python 2 compatibility in regexp
bnavigator May 6, 2020
1877bc3
adding a more extensive check of docstring parsing
repagh May 6, 2020
d2f684d
extend the parser to warnings
bnavigator May 6, 2020
0e8d63c
update exceptions doc and test [skip ci]
bnavigator May 6, 2020
7ad1517
more work on exception and warning handling
bnavigator May 7, 2020
18f054e
more cleanup, including file attributes for source files
bnavigator May 7, 2020
a44c952
dont assertRaisesRegex in Py2
bnavigator May 7, 2020
d81c7d1
optional type
bnavigator May 7, 2020
ad24193
typo in range [skip ci]
bnavigator May 7, 2020
ec8c968
only parse docstring when iwarn or info
bnavigator May 7, 2020
c0b1069
bring synthesis.py closer to numpydoc
bnavigator May 7, 2020
ad28baa
minor cosmetics in math.py and synthesis.py docstrings [skip ci]
bnavigator May 7, 2020
82b653a
fix infospec detection regex
bnavigator May 7, 2020
8f60923
fix iwarn catchall and checkvars initialization
bnavigator May 7, 2020
91fb7e6
revert file mode changes for py files [skip ci]
bnavigator May 7, 2020
fd74855
comma in mb05nd docstring [skip ci]
bnavigator May 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more cleanup, including file attributes for source files
  • Loading branch information
bnavigator committed May 7, 2020
commit 18f054e20bc2984616af0caff45eb55ec1efc549
132 changes: 63 additions & 69 deletions slycot/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def ab09ax(dico,job,n,m,p,A,B,C,nr=None,tol=0.0,ldwork=None):
arg_list = ['dico', 'job', 'ordsel', 'n', 'm', 'p', 'nr',
'A', 'lda' + hidden, 'B', 'ldb' + hidden, 'C', 'ldc' + hidden,
'hsv', 'T', 'ldt' + hidden, 'Ti', 'ldti' + hidden, 'tol',
'iwork'+hidden, 'dwork'+hidden, 'ldwork', 'iwarn', 'info']
'iwork' + hidden, 'dwork' + hidden, 'ldwork', 'iwarn', 'info']
if ldwork is None:
ldwork = max(1, n*(2*n + max(n, max(m, p))+5)+n*(n+1)/2)
if nr is None:
Expand Down Expand Up @@ -922,7 +922,7 @@ def ab09bd(dico,job,equil,n,m,p,A,B,C,D,nr=None,tol1=0,tol2=0,ldwork=None):

Raises
------
SlycotArithmeticError : e
SlycotArithmeticError
:info == 1:
The reduction of A to the real Schur form failed
:info == 2 and dico == 'C':
Expand All @@ -934,7 +934,7 @@ def ab09bd(dico,job,equil,n,m,p,A,B,C,D,nr=None,tol1=0,tol2=0,ldwork=None):

Warns
-----
SlycotResultWarning : e
SlycotResultWarning
:iwarn == 1:
The selected order {nr} is greater
than the order of a minimal realization of the
Expand Down Expand Up @@ -1304,47 +1304,42 @@ def ab13bd(dico, jobn, n, m, p, A, B, C, D, tol = 0.0):
a discrete-time system. If the H2-norm is computed, the system
must be stable.

Required arguments
------------------

dico : {'D', 'C'} input string(len=1)
Indicate whether the system is discrete 'D' or continuous 'C'.
jobn : {'H', 'L'} input string(len=1)
H2-norm 'H' or L2-norm 'L' to be computed.
n : input int
The number of state variables. n >= 0.
m : input int
The number of system inputs. m >= 0.
p : input int
The number of system outputs. p >= 0.
A : input rank-2 array('d') with bounds (n,n)
The leading n-by-n part of this array must contain the state
dynamics matrix A of the system.
B : input rank-2 array('d') with bounds (n,m)
The leading n-by-m part of this array must contain the input/state
matrix B of the system.
C : input rank-2 array('d') with bounds (p,n)
The leading p-by-n part of this array must contain the state/output
matrix C of the system.
D : input rank-2 array('d') with bounds (p,m)
The leading p-by-m part of this array must contain the direct
transmission matrix D of the system.

Optional arguments
------------------

tol : The absolute tolerance level below which the elements of
B are considered zero (used for controllability tests).
If the user sets tol <= 0, then an implicitly computed,
default tolerance, defined by toldef = n*eps*norm(B),
is used instead, where eps is the machine precision
(see LAPACK Library routine DLAMCH) and norm(B) denotes
the 1-norm of B.
Parameters
----------
dico : {'D', 'C'}
Indicate whether the system is discrete 'D' or continuous 'C'.
jobn : {'H', 'L'}
H2-norm 'H' or L2-norm 'L' to be computed.
n : int
The number of state variables. n >= 0.
m : int
The number of system inputs. m >= 0.
p : int
The number of system outputs. p >= 0.
A : (n,n) ndarray
The leading n-by-n part of this array must contain the state
dynamics matrix A of the system.
B : (n,m) ndarray
The leading n-by-m part of this array must contain the input/state
matrix B of the system.
C : (p,n) ndarray
The leading p-by-n part of this array must contain the state/output
matrix C of the system.
D : (p,m) ndarray
The leading p-by-m part of this array must contain the direct
transmission matrix D of the system.
tol : float, optional
The absolute tolerance level below which the elements of
B are considered zero (used for controllability tests).
If the user sets tol <= 0, then an implicitly computed,
default tolerance, defined by toldef = n*eps*norm(B),
is used instead, where eps is the machine precision
(see LAPACK Library routine DLAMCH) and norm(B) denotes
the 1-norm of B.

Returns
-------

norm: H2 or L2 norm of thes ystem (A,B,C,D)
norm: H2 or L2 norm of the system (A,B,C,D)

Raises
------
Expand Down Expand Up @@ -1493,9 +1488,9 @@ def ab13dd(dico, jobe, equil, jobd, n, m, p, A, E, B, C, D, tol = 1e-10):
if jobd != 'D' and jobd != 'Z':
raise SlycotParameterError('jobd must be "D" or "Z"', -4)
out = _wrapper.ab13dd(dico, jobe, equil, jobd,
n, m, p, [0.0, 1.0], A, E, B, C, D, tol)
n, m, p, [0.0, 1.0], A, E, B, C, D, tol)
raise_if_slycot_error(out[-1], arg_list, ab13dd.__doc__)

fpeak = out[0][0] if out[0][1] > 0 else float('inf')
gpeak = out[1][0] if out[1][1] > 0 else float('inf')
return gpeak, fpeak
Expand All @@ -1509,15 +1504,15 @@ def ab13ed(n, A, tol = 9.0):
the nearest complex matrix with an eigenvalue on the imaginary
axis. The estimate is given as

low <= beta(A) <= high,
``low <= beta(A) <= high,``

where either

(1 + tol) * low >= high,
``(1 + tol) * low >= high,``

or

low = 0 and high = delta,
``low = 0 and high = delta,``

and delta is a small number approximately equal to the square root
of machine precision times the Frobenius norm (Euclidean norm)
Expand All @@ -1526,40 +1521,38 @@ def ab13ed(n, A, tol = 9.0):
to the nearest unstable complex matrix, i.e., the complex
stability radius.

Required arguments:
n : input int
The order of the matrix A. n >= 0.
A : input rank-2 array('d') with bounds (n,n)
The leading n-by-n part of this array must contain the matrix A.

Optional arguments:
tol : Specifies the accuracy with which low and high approximate
beta(A). If the user sets tol to be less than sqrt(eps),
where eps is the machine precision (see LAPACK Library
Routine DLAMCH), then the tolerance is taken to be
sqrt(eps).
The recommended value is tol = 9, which gives an estimate
of beta(A) correct to within an order of magnitude.
Parameters
----------
n : int
The order of the matrix A. ``n >= 0.``
A : (n,n) array_like
The leading n-by-n part of this array must contain the matrix A.
tol : float optional
Specifies the accuracy with which low and high approximate
beta(A). If the user sets tol to be less than sqrt(eps),
where eps is the machine precision (see LAPACK Library
Routine DLAMCH), then the tolerance is taken to be
sqrt(eps).
The recommended value is tol = 9, which gives an estimate
of beta(A) correct to within an order of magnitude.

Return objects:
low : float
A lower bound for beta(A).
high : float
An upper bound for beta(A).
Returns
-------
low : float
A lower bound for beta(A).
high : float
An upper bound for beta(A).

Raises
------

SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
The QR algorithm fails to converge
"""
hidden = ' (hidden by the wrapper)'
arg_list = ['n', 'A', 'lda' + hidden, 'low' + hidden, 'high' + hidden, 'tol',
'dwork' + hidden, 'ldwork' + hidden, 'info' + hidden]
out = _wrapper.ab13ed(n, A, tol)
out = _wrapper.ab13ed(n, A, tol)
raise_if_slycot_error(out[-1], arg_list, ab13ed.__doc__)
return out[:-1]

Expand Down Expand Up @@ -1616,6 +1609,7 @@ def ab13fd(n, A, tol = 0.0):
SlycotArithmeticError
:info = 2:
Either the QR or SVD algorithm fails to converge

Warns
-----
SlycotResultWarning
Expand Down
Empty file modified slycot/exceptions.py
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions slycot/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def mb03rd(n, A, X=None, jobx='U', sort='N', pmax=1.0, tol=0.0):

**Numerical Aspects**

The algorithm usually requires :math:`\mathcal{O}(N^3)` operations,
but :math:`\mathcal{O}(N^4)` are
The algorithm usually requires :math:`\\mathcal{O}(N^3)` operations,
but :math:`\\mathcal{O}(N^4)` are
possible in the worst case, when all diagonal blocks in the real
Schur form of `A` are 1-by-1, and the matrix cannot be diagonalized
by well-conditioned transformations.
Expand All @@ -206,7 +206,7 @@ def mb03rd(n, A, X=None, jobx='U', sort='N', pmax=1.0, tol=0.0):

**Revisions**

\V. Sima, Research Institute for Informatics, Bucharest, Apr. 2003.
\\V. Sima, Research Institute for Informatics, Bucharest, Apr. 2003.

References
----------
Expand Down
Empty file modified slycot/src/AB08MZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/AB08NZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/AB8NXZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/AG08BZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/AG8BYZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MA02BZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MA02CZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MA02ID.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MA02JD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB01MD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB01ND.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB01UX.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03TD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03TS.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03WA.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03XD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03XP.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03XU.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03YA.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03YD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03YT.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03ZA.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB03ZD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04DD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04DI.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04DS.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04IZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04PA.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04PB.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04PU.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04QB.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04QC.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04QF.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04QU.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04TB.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04TS.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04WD.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04WP.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04WR.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB04WU.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB3OYZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/MB3PYZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/SB04OW.f
100755 → 100644
Empty file.
Empty file modified slycot/src/TB01IZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/TB01XZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/TG01AZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/TG01FZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/UD01MZ.f
100755 → 100644
Empty file.
Empty file modified slycot/src/UE01MD.f
100755 → 100644
Empty file.
15 changes: 5 additions & 10 deletions slycot/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,6 @@ def sb03md(n,C,A,U,dico,job='X',fact='N',trana='N',ldwork=None):
w : rank-1 array('c'), shape (n)
If fact = 'N', this array contain the eigenvalues of A.

Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;

Warns
-----
SlycotResultWarning
Expand Down Expand Up @@ -1549,19 +1544,19 @@ def sb10hd(n,m,np,ncon,nmeas,A,B,C,D,tol=0.0,ldwork=None):
------
SlycotArithmeticError
:info = 1:
if the matrix D12 had not full column rank in
The matrix D12 had not full column rank in
respect to the tolerance tol;
:info = 2:
if the matrix D21 had not full row rank in respect
The matrix D21 had not full row rank in respect
to the tolerance tol;
:info = 3:
if the singular value decomposition (SVD) algorithm
The singular value decomposition (SVD) algorithm
did not converge (when computing the SVD of one of
the matrices D12 or D21).
:info = 4:
if the X-Riccati equation was not solved successfully;
The X-Riccati equation was not solved successfully;
:info = 5:
if the Y-Riccati equation was not solved successfully.
The Y-Riccati equation was not solved successfully.
"""

hidden = ' (hidden by the wrapper)'
Expand Down
Empty file modified slycot/tests/__init__.py
100755 → 100644
Empty file.