Skip to content

Commit

Permalink
Merge 367bd71 into 60a5c71
Browse files Browse the repository at this point in the history
  • Loading branch information
KybernetikJo committed Sep 9, 2023
2 parents 60a5c71 + 367bd71 commit 97ab01a
Show file tree
Hide file tree
Showing 20 changed files with 441 additions and 90 deletions.
2 changes: 1 addition & 1 deletion slycot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
sb02md, sb02mt, sb02od,
sb03md, sb03md57, sb03od,
sb04md, sb04qd,
sb10ad, sb10dd, sb10fd, sb10hd, sb10yd,
sb10ad, sb10dd, sb10fd, sb10hd, sb10jd, sb10yd,
sg02ad,
sg03ad, sg03bd)

Expand Down
59 changes: 48 additions & 11 deletions slycot/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def sb01bd(n,m,np,alpha,A,B,w,dico,tol=0.0,ldwork=None):
:= 'C': continuous-time system;
:= 'D': discrete-time system.
tol : float, optional
The absolute tolerance level below which the elements of A or B are
considered zero (used for controllability tests).
If tol <= 0 the default value is used.
The absolute tolerance level below which the elements of A or B are
considered zero (used for controllability tests).
If tol <= 0 the default value is used.
Default is `0.0`.
ldwork : int, optional
The length of the cache array. The default value is
max(1,5*m,5*n,2*n+4*m), for optimum performance it should be larger.
Expand Down Expand Up @@ -96,6 +97,8 @@ def sb01bd(n,m,np,alpha,A,B,w,dico,tol=0.0,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
the reduction of A to a real Schur form failed;
Expand Down Expand Up @@ -128,7 +131,6 @@ def sb01bd(n,m,np,alpha,A,B,w,dico,tol=0.0,ldwork=None):
Example
-------
>>> import numpy as np
>>> import slycot
>>> A = np.array([[0, 1, 0], [0, 0, 1], [-2, 1, 3]])
Expand Down Expand Up @@ -304,7 +306,6 @@ def sb02md(n,A,G,Q,dico,hinv='D',uplo='U',scal='N',sort='S',ldwork=None):
Example
-------
>>> import numpy as np
>>> import slycot
>>> A = np.array([[0, 1], [0, 0]])
Expand Down Expand Up @@ -440,6 +441,8 @@ def sb02mt(n,m,B,R,A=None,Q=None,L=None,fact='N',jobl='Z',uplo='U',ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:1 <= info <= m:
The {info}-th element of the `d` factor is
Expand Down Expand Up @@ -599,6 +602,8 @@ def sb02od(n,m,A,B,Q,R,dico,p=None,L=None,fact='N',uplo='U',sort='S',tol=0.0,ldw
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
The computed extended matrix pencil is singular,
Expand All @@ -622,7 +627,6 @@ def sb02od(n,m,A,B,Q,R,dico,p=None,L=None,fact='N',uplo='U',sort='S',tol=0.0,ldw
Example
-------
>>> import numpy as np
>>> import slycot
>>> A = np.array([[0, 1], [0, 0]])
Expand Down Expand Up @@ -760,6 +764,11 @@ def sb03md57(A, U=None, C=None,
w : (n, ) complex ndarray
If fact = 'N', this array contains the eigenvalues of A.
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
Warns
-----
SlycotResultWarning
Expand Down Expand Up @@ -905,7 +914,7 @@ def sb03od(n,m,A,Q,B,dico,fact='N',trans='N',ldwork=None):
For optimum performance ldwork should sometimes be larger.
Returns
_______
-------
U : (n, n) ndarray
The leading n-by-n part of this array contains
the upper triangular Cholesky factor U of the solution
Expand All @@ -918,6 +927,8 @@ def sb03od(n,m,A,Q,B,dico,fact='N',trans='N',ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 4:
FACT = 'F' and the Schur factor S supplied in
Expand Down Expand Up @@ -1027,6 +1038,8 @@ def sb04md(n,m,A,B,C,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:0 < info <= m:
The QR algorithm failed to compute all the eigenvalues
Expand Down Expand Up @@ -1076,6 +1089,8 @@ def sb04qd(n,m,A,B,C,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:0 < info <= m:
The QR algorithm failed to compute all the eigenvalues
Expand Down Expand Up @@ -1222,6 +1237,8 @@ def sb10ad(n,m,np,ncon,nmeas,gamma,A,B,C,D,job=3,gtol=0.0,actol=0.0,liwork=None,
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
The matrix
Expand Down Expand Up @@ -1431,6 +1448,8 @@ def sb10dd(n,m,np,ncon,nmeas,gamma,A,B,C,D,tol=0.0,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
The matrix
Expand Down Expand Up @@ -1587,6 +1606,8 @@ def sb10hd(n,m,np,ncon,nmeas,A,B,C,D,tol=0.0,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
The matrix D12 had not full column rank in
Expand Down Expand Up @@ -1681,6 +1702,8 @@ def sb10jd(n,m,np,A,B,C,D,E,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info == 1:
The iteration for computing singular value
Expand Down Expand Up @@ -1766,6 +1789,8 @@ def sb10yd(discfl,flag,lendat,rfrdat,ifrdat,omega,n,tol,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info == 0: successful exit;
:info < 0: if info = -i, the i-th argument had an illegal value
Expand Down Expand Up @@ -1984,6 +2009,8 @@ def sg03ad(dico,job,fact,trans,uplo,N,A,E,Q,Z,X,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
FACT = 'F' and the matrix contained in the upper
Expand Down Expand Up @@ -2206,6 +2233,7 @@ def sg02ad(dico,jobb,fact,uplo,jobl,scal,sort,acc,N,M,P,A,E,B,Q,R,L,ldwork=None,
LDR >= MAX(1,M) if JOBB = 'B' and FACT = 'N' or 'C';
LDR >= MAX(1,P) if JOBB = 'B' and FACT = 'D' or 'B';
LDR >= 1 if JOBB = 'G'.
L : (n, M) array_like
If JOBL = 'N' and JOBB = 'B', the leading N-by-M part of
this array must contain the cross weighting matrix L.
Expand All @@ -2217,6 +2245,7 @@ def sg02ad(dico,jobb,fact,uplo,jobl,scal,sort,acc,N,M,P,A,E,B,Q,R,L,ldwork=None,
LDWORK >= MAX(7*(2*N+1)+16,16*N), if JOBB = 'G';
LDWORK >= MAX(7*(2*N+1)+16,16*N,2*N+M,3*M), if JOBB = 'B'.
For optimum performance LDWORK should be larger.
Default: ``max(7*(2*n+1)+16,16*n)``
tol : float, optional
Expand Down Expand Up @@ -2316,6 +2345,8 @@ def sg02ad(dico,jobb,fact,uplo,jobl,scal,sort,acc,N,M,P,A,E,B,Q,R,L,ldwork=None,
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 1:
The computed extended matrix pencil is singular,
Expand Down Expand Up @@ -2432,7 +2463,7 @@ def sg03bd(n,m,A,E,Q,Z,B,dico,fact='N',trans='N',ldwork=None):
than one).
Parameters
__________
----------
n : int
The order of the matrix A. n >= 0.
m : int
Expand Down Expand Up @@ -2495,11 +2526,13 @@ def sg03bd(n,m,A,E,Q,Z,B,dico,fact='N',trans='N',ldwork=None):
on entry or not:
:= 'N': Factorization is not supplied;
:= 'F': Factorization is supplied.
Default is 'N'.
trans : {'N', 'T'}, optional
Specifies whether the transposed equation is to be solved
or not:
:= 'N': op(A) = A, op(E) = E;
:= 'T': op(A) = A**T, op(E) = E**T.
Default is 'N'.
ldwork : int, optional
The dimension of the array dwork::
Expand All @@ -2508,7 +2541,7 @@ def sg03bd(n,m,A,E,Q,Z,B,dico,fact='N',trans='N',ldwork=None):
For good performance, ldwork should be larger.
Returns
_______
-------
U : (n, n) ndarray
The leading n-by-b part of this array contains
the Cholesky factor U of the solution matrix X of the
Expand All @@ -2521,9 +2554,12 @@ def sg03bd(n,m,A,E,Q,Z,B,dico,fact='N',trans='N',ldwork=None):
If INFO = 0, 3, 5, 6, or 7, then
((j), j=1,...,n, are the
eigenvalues of the matrix pencil A - lambda * E.
Default is None.
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
SlycotArithmeticError
:info = 2:
fact = 'F' and the matrix contained in the upper
Expand Down Expand Up @@ -2647,7 +2683,7 @@ def sb10fd(n,m,np,ncon,nmeas,gamma,A,B,C,D,tol=0.0,ldwork=None):
whose reciprocal condition numbers are less than tol are
not allowed. If tol <= 0, then a default value equal to
sqrt(eps) is used, where eps is the relative machine
precision.
precision. Default is `0.0`.
ldwork : int, optional
The dimension of the cache array::
Expand Down Expand Up @@ -2683,7 +2719,7 @@ def sb10fd(n,m,np,ncon,nmeas,gamma,A,B,C,D,tol=0.0,ldwork=None):
if the default (None) value is used, the size for good performance
is automatically used, when ldwork is set to zero, the minimum
cache size will be used.
cache size will be used. Default is None.
Returns
-------
Expand Down Expand Up @@ -2712,6 +2748,7 @@ def sb10fd(n,m,np,ncon,nmeas,gamma,A,B,C,D,tol=0.0,ldwork=None):
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
:info = -27:
The dimension ldwork of the cache array is too small.
Use ldwork=0 for the minimum size or ldwork=None for automatic
Expand Down
17 changes: 16 additions & 1 deletion slycot/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ set(PYSOURCE
test_exceptions.py
test_mb.py
test_mc.py
test_sb.py
test_analysis.py
test_transform.py
test_sb.py
test_sb01bd.py
test_sb02md.py
test_sb02mt.py
test_sb02od.py
test_sb03md.py
test_sb03md57.py
test_sb03od.py
test_sb04md.py
test_sb04qd.py
test_sb10ad.py
test_sb10dd.py
test_sb10fd.py
test_sb10hd.py
test_sb10jd.py
test_sb10yd.py
test_sg02ad.py
test_sg03ad.py
test_tb05ad.py
Expand Down
19 changes: 19 additions & 0 deletions slycot/tests/test_sb01bd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import numpy as np
import pytest
from scipy import signal

from slycot import synthesis
from slycot.exceptions import (SlycotArithmeticError, SlycotParameterError,
SlycotResultWarning, raise_if_slycot_error)

from .test_exceptions import assert_docstring_parse


class Test_sb01bd():

@pytest.mark.parametrize(
'fun, exception_class, erange, checkvars',
((synthesis.sb01bd, SlycotArithmeticError, 2, {}),
(synthesis.sb01bd, SlycotResultWarning, [3, 4, [1, 0]], {'nap': '1'}),))
def test_sb01bd_docparse(self, fun, exception_class, erange, checkvars):
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)
18 changes: 18 additions & 0 deletions slycot/tests/test_sb02md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
import pytest
from scipy import signal

from slycot import synthesis
from slycot.exceptions import (SlycotArithmeticError, SlycotParameterError,
SlycotResultWarning, raise_if_slycot_error)

from .test_exceptions import assert_docstring_parse


class Test_sb02md():

@pytest.mark.parametrize(
'fun, exception_class, erange, checkvars',
((synthesis.sb02md, SlycotArithmeticError, 5, {}),))
def test_sb02md_docparse(self, fun, exception_class, erange, checkvars):
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)
12 changes: 12 additions & 0 deletions slycot/tests/test_sb02mt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np
import pytest
from scipy import signal

from slycot import synthesis


class Test_sb02mt():

@pytest.mark.skip("no implementation yet")
def test_sb02mt():
pass
18 changes: 18 additions & 0 deletions slycot/tests/test_sb02od.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
import pytest
from scipy import signal

from slycot import synthesis
from slycot.exceptions import (SlycotArithmeticError, SlycotParameterError,
SlycotResultWarning, raise_if_slycot_error)

from .test_exceptions import assert_docstring_parse


class Test_sb02od():

@pytest.mark.parametrize(
'fun, exception_class, erange, checkvars',
((synthesis.sb02od, SlycotArithmeticError, 6, {}),))
def test_sb02od_docparse(self, fun, exception_class, erange, checkvars):
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars)
12 changes: 12 additions & 0 deletions slycot/tests/test_sb03md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np
import pytest
from scipy import signal

from slycot import synthesis


class Test_sb03md():

@pytest.mark.skip("no implementation yet")
def test_sb03md():
pass
Loading

0 comments on commit 97ab01a

Please sign in to comment.