Skip to content

Commit 48bca92

Browse files
committed
Change math.py docstrings to numpydoc style
1 parent 60a5c71 commit 48bca92

1 file changed

Lines changed: 104 additions & 87 deletions

File tree

slycot/math.py

Lines changed: 104 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -36,80 +36,85 @@ def mb03rd(n, A, X=None, jobx='U', sort='N', pmax=1.0, tol=0.0):
3636
3737
Parameters
3838
----------
39-
n : int
40-
The order of the matrices `A` and `X`. `n` >= 0.
41-
A : (n, n) array_like
42-
The matrix `A` to be block-diagonalized, in real Schur form.
43-
X : (n, n) array_like, optional
44-
A given matrix `X`, for accumulation of transformations (only if
45-
`jobx`='U'). Default value is identity matrix of order `n`.
46-
jobx : {'N', 'U'}, optional
47-
Specifies whether or not the transformations are
48-
accumulated, as follows:
49-
50-
:= 'N': The transformations are not accumulated
51-
:= 'U': The transformations are accumulated in `Xr` (default)
52-
53-
sort : {'N', 'S', 'C', 'B'}, optional
54-
Specifies whether or not the diagonal blocks of the real
55-
Schur form are reordered, as follows:
56-
57-
:= 'N': The diagonal blocks are not reordered (default);
58-
:= 'S': The diagonal blocks are reordered before each
59-
step of reduction, so that clustered eigenvalues
60-
appear in the same block;
61-
:= 'C': The diagonal blocks are not reordered, but the
62-
"closest-neighbour" strategy is used instead of
63-
the standard "closest to the mean" strategy
64-
(see Notes_);
65-
:= 'B': The diagonal blocks are reordered before each
66-
step of reduction, and the "closest-neighbour"
67-
strategy is used (see Notes_).
68-
69-
pmax : float, optional
70-
An upper bound for the infinity norm of elementary
71-
submatrices of the individual transformations used for
72-
reduction (see Notes_). `pmax` >= 1.0
73-
tol : float, optional
74-
The tolerance to be used in the ordering of the diagonal
75-
blocks of the real Schur form matrix.
76-
If the user sets `tol` > 0, then the given value of `tol` is
77-
used as an absolute tolerance: a block `i` and a temporarily
78-
fixed block 1 (the first block of the current trailing
79-
submatrix to be reduced) are considered to belong to the
80-
same cluster if their eigenvalues satisfy
81-
82-
.. math:: | \\lambda_1 - \\lambda_i | <= tol.
83-
84-
If the user sets `tol` < 0, then the given value of tol is
85-
used as a relative tolerance: a block i and a temporarily
86-
fixed block 1 are considered to belong to the same cluster
87-
if their eigenvalues satisfy, for ``j = 1, ..., n``
88-
89-
.. math:: | \\lambda_1 - \\lambda_i | <= | tol | * \\max | \\lambda_j |.
90-
91-
If the user sets `tol` = 0, then an implicitly computed,
92-
default tolerance, defined by ``tol = SQRT( SQRT( EPS ) )``
93-
is used instead, as a relative tolerance, where `EPS` is
94-
the machine precision (see LAPACK Library routine DLAMCH).
95-
If `sort` = 'N' or 'C', this parameter is not referenced.
39+
n : int
40+
The order of the matrices `A` and `X`. `n` >= 0.
41+
A : (n, n) array_like
42+
The matrix `A` to be block-diagonalized, in real Schur form.
43+
X : (n, n) array_like, optional
44+
A given matrix `X`, for accumulation of transformations (only if
45+
`jobx`='U'). Default value is identity matrix of order `n`.
46+
jobx : {'N', 'U'}, optional
47+
Specifies whether or not the transformations are
48+
accumulated, as follows:
49+
50+
:= 'N': The transformations are not accumulated
51+
:= 'U': The transformations are accumulated in `Xr` (default)
52+
53+
sort : {'N', 'S', 'C', 'B'}, optional
54+
Specifies whether or not the diagonal blocks of the real
55+
Schur form are reordered, as follows:
56+
57+
:= 'N': The diagonal blocks are not reordered (default);
58+
:= 'S': The diagonal blocks are reordered before each
59+
step of reduction, so that clustered eigenvalues
60+
appear in the same block;
61+
:= 'C': The diagonal blocks are not reordered, but the
62+
"closest-neighbour" strategy is used instead of
63+
the standard "closest to the mean" strategy
64+
(see Notes_);
65+
:= 'B': The diagonal blocks are reordered before each
66+
step of reduction, and the "closest-neighbour"
67+
strategy is used (see Notes_).
68+
69+
pmax : float, optional
70+
An upper bound for the infinity norm of elementary
71+
submatrices of the individual transformations used for
72+
reduction (see Notes_). `pmax` >= 1.0
73+
tol : float, optional
74+
The tolerance to be used in the ordering of the diagonal
75+
blocks of the real Schur form matrix.
76+
If the user sets `tol` > 0, then the given value of `tol` is
77+
used as an absolute tolerance: a block `i` and a temporarily
78+
fixed block 1 (the first block of the current trailing
79+
submatrix to be reduced) are considered to belong to the
80+
same cluster if their eigenvalues satisfy
81+
82+
.. math:: | \\lambda_1 - \\lambda_i | <= tol.
83+
84+
If the user sets `tol` < 0, then the given value of tol is
85+
used as a relative tolerance: a block i and a temporarily
86+
fixed block 1 are considered to belong to the same cluster
87+
if their eigenvalues satisfy, for ``j = 1, ..., n``
88+
89+
.. math:: | \\lambda_1 - \\lambda_i | <= | tol | * \\max | \\lambda_j |.
90+
91+
If the user sets `tol` = 0, then an implicitly computed,
92+
default tolerance, defined by ``tol = SQRT( SQRT( EPS ) )``
93+
is used instead, as a relative tolerance, where `EPS` is
94+
the machine precision (see LAPACK Library routine DLAMCH).
95+
If `sort` = 'N' or 'C', this parameter is not referenced.
9696
9797
Returns
9898
-------
99-
Ar : (n, n) ndarray
100-
Contains the computed block-diagonal matrix, in real Schur
101-
canonical form. The non-diagonal blocks are set to zero.
102-
Xr : (n, n) ndarray or None
103-
Contains the product of the given matrix `X` and the
104-
transformation matrix that reduced `A` to block-diagonal
105-
form. The transformation matrix is itself a product of
106-
non-orthogonal similarity transformations having elements
107-
with magnitude less than or equal to `pmax`.
108-
If `jobx` = 'N', this array is returned as None
109-
blsize : (n,) ndarray
110-
The orders of the resulting diagonal blocks of the matrix `Ar`.
111-
W : (n,) complex ndarray
112-
Contains the complex eigenvalues of the matrix `A`.
99+
Ar : (n, n) ndarray
100+
Contains the computed block-diagonal matrix, in real Schur
101+
canonical form. The non-diagonal blocks are set to zero.
102+
Xr : (n, n) ndarray or None
103+
Contains the product of the given matrix `X` and the
104+
transformation matrix that reduced `A` to block-diagonal
105+
form. The transformation matrix is itself a product of
106+
non-orthogonal similarity transformations having elements
107+
with magnitude less than or equal to `pmax`.
108+
If `jobx` = 'N', this array is returned as None
109+
blsize : (n,) ndarray
110+
The orders of the resulting diagonal blocks of the matrix `Ar`.
111+
W : (n,) complex ndarray
112+
Contains the complex eigenvalues of the matrix `A`.
113+
114+
Raises
115+
------
116+
SlycotParameterError
117+
:info = -i: the i-th argument had an illegal value;
113118
114119
Notes
115120
-----
@@ -260,11 +265,9 @@ def mb03vd(n, ilo, ihi, A):
260265
261266
Parameters
262267
----------
263-
264268
n : int
265269
The order of the square matrices A_1, A_2, ..., A_p.
266270
n >= 0.
267-
268271
ilo, ihi : int
269272
It is assumed that all matrices A_j, j = 2, ..., p, are
270273
already upper triangular in rows and columns [:ilo-1] and
@@ -274,15 +277,12 @@ def mb03vd(n, ilo, ihi, A):
274277
If this is not the case, ilo and ihi should be set to 1
275278
and n, respectively.
276279
1 <= ilo <= max(1,n); min(ilo,n) <= ihi <= n.
277-
278280
A : ndarray
279281
A[:n,:n,:p] must contain the matrices of factors to be reduced;
280282
specifically, A[:,:,j-1] must contain A_j, j = 1, ..., p.
281283
282-
283284
Returns
284285
-------
285-
286286
HQ : ndarray
287287
3D array with same shape as A. The upper triangle and the first
288288
subdiagonal of HQ[:n,:n,0] contain the upper Hessenberg
@@ -295,16 +295,19 @@ def mb03vd(n, ilo, ihi, A):
295295
below the diagonal, with the j-th column of the array TAU
296296
represent the orthogonal matrix Q_j as a product of
297297
elementary reflectors. See FURTHER COMMENTS.
298-
299298
Tau : ndarray
300299
2D array with shape (max(1, n-1), p).
301300
The leading n-1 elements in the j-th column contain the
302301
scalar factors of the elementary reflectors used to form
303302
the matrix Q_j, j = 1, ..., p. See FURTHER COMMENTS.
304303
305-
Further Comments
306-
----------------
304+
Raises
305+
------
306+
SlycotParameterError
307+
:info = -i: the i-th argument had an illegal value;
307308
309+
Notes
310+
-----
308311
Each matrix Q_j is represented as a product of (ihi-ilo)
309312
elementary reflectors,
310313
@@ -377,38 +380,36 @@ def mb03vy(n, ilo, ihi, A, Tau, ldwork=None):
377380
378381
Parameters
379382
----------
380-
381383
n : int
382384
The order of the matrices Q_1, Q_2, ..., Q_p. N >= 0.
383-
384385
ilo, ihi : int
385386
The values of the indices ilo and ihi, respectively, used
386387
in the previous call of the SLICOT Library routine MB03VD.
387388
1 <= ilo <= max(1,n); min(ilo,n) <= ihi <= n.
388-
389389
A : ndarray
390390
A[:n,:n,j-1] must contain the vectors which define the
391391
elementary reflectors used for reducing A_j, as returned
392392
by SLICOT Library routine MB03VD, j = 1, ..., p.
393-
394393
Tau : ndarray
395394
The leading N-1 elements in the j-th column must contain
396395
the scalar factors of the elementary reflectors used to
397396
form the matrix Q_j, as returned by SLICOT Library routine
398397
MB03VD.
399-
400398
ldwork : int, optional
401399
The length of the internal array DWORK. ldwork >= max(1, n).
402400
For optimum performance ldwork should be larger.
403401
404402
405403
Returns
406404
-------
407-
408405
Q : ndarray
409406
3D array with same shape as A. Q[:n,:n,j-1] contains the
410407
N-by-N orthogonal matrix Q_j, j = 1, ..., p.
411408
409+
Raises
410+
------
411+
SlycotParameterError
412+
:info = -i: the i-th argument had an illegal value;
412413
"""
413414

414415
hidden = ' (hidden by the wrapper)'
@@ -460,7 +461,7 @@ def mb03wd(job, compz, n, ilo, ihi, iloz, ihiz, H, Q, ldwork=None):
460461
= 'E': Compute the eigenvalues only;
461462
= 'S': Compute the factors T_1, ..., T_p of the full
462463
Schur form, T = T_1*T_2*...*T_p.
463-
compz : {'N', 'I', 'V'}
464+
compz : {'N', 'I', 'V'}
464465
Indicates whether or not the user wishes to accumulate
465466
the matrices Z_1, ..., Z_p, as follows:
466467
= 'N': The matrices Z_1, ..., Z_p are not required;
@@ -526,6 +527,11 @@ def mb03wd(job, compz, n, ilo, ihi, iloz, ihiz, H, Q, ldwork=None):
526527
If JOB = 'S', the eigenvalues are stored in the same order
527528
as on the diagonal of the Schur form returned in H.
528529
530+
Raises
531+
------
532+
SlycotParameterError
533+
:info = -i: the i-th argument had an illegal value;
534+
529535
Warns
530536
-----
531537
SlycotResultWarning
@@ -623,6 +629,11 @@ def mb05md(a, delta, balanc='N'):
623629
appear consecutively with the eigenvalue having positive
624630
imaginary part first.
625631
632+
Raises
633+
------
634+
SlycotParameterError
635+
:info = -i: the i-th argument had an illegal value;
636+
626637
Warns
627638
------
628639
SlycotResultWarning
@@ -687,6 +698,8 @@ def mb05nd(a, delta, tol=1e-7):
687698
688699
Raises
689700
------
701+
SlycotParameterError
702+
:info = -i: the i-th argument had an illegal value;
690703
SlycotArithmeticError
691704
:1 < info <=n:
692705
the ({info},{info}) element of the denominator of
@@ -730,7 +743,6 @@ def mc01td(dico, dp, p):
730743
731744
= 'C': continuous-time case;
732745
= 'D': discrete-time case.
733-
734746
dp : int
735747
The degree of the polynomial `P(x)`. ``dp >= 0``.
736748
p : (dp+1, ) array_like
@@ -747,6 +759,11 @@ def mc01td(dico, dp, p):
747759
nz : int
748760
The number of unstable zeros.
749761
762+
Raises
763+
------
764+
SlycotParameterError
765+
:info = -i: the i-th argument had an illegal value;
766+
750767
Warns
751768
-----
752769
SlycotResultWarning

0 commit comments

Comments
 (0)