Skip to content

Commit

Permalink
Merge 85384c8 into 8ae9c25
Browse files Browse the repository at this point in the history
  • Loading branch information
KybernetikJo committed Aug 23, 2023
2 parents 8ae9c25 + 85384c8 commit a0e3ef7
Showing 1 changed file with 186 additions and 165 deletions.
351 changes: 186 additions & 165 deletions slycot/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ def ab01nd(n, m, A, B, jobz='N', tol=0, ldwork=None):
tau : (n, ) ndarray
The elements of tau contain the scalar factors of the
elementary reflectors used in the reduction of B and A.
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value;
"""

hidden = ' (hidden by the wrapper)'
Expand All @@ -139,76 +144,84 @@ def ab01nd(n, m, A, B, jobz='N', tol=0, ldwork=None):
Z = None
return Ac, Bc, ncont, indcon, nblk, Z, tau


def ab05md(n1,m1,p1,n2,p2,A1,B1,C1,D1,A2,B2,C2,D2,uplo='U'):
""" n,a,b,c,d = ab05md(n1,m1,p1,n2,p2,a1,b1,c1,d1,a2,b2,c2,d2,[uplo])
To obtain the state-space model (A,B,C,D) for the cascaded
inter-connection of two systems, each given in state-space form.
Required arguments:
n1 : input int
The number of state variables in the first system, i.e. the order
of the matrix A1. n1 > 0.
m1 : input int
The number of input variables for the first system. m1 > 0.
p1 : input int
The number of output variables from the first system and the number
of input variables for the second system. p1 > 0.
n2 : input int
The number of state variables in the second system, i.e. the order
of the matrix A2. n2 > 0.
p2 : input int
The number of output variables from the second system. p2 > 0.
A1 : input rank-2 array('d') with bounds (n1,n1)
The leading n1-by-n1 part of this array must contain the state
transition matrix A1 for the first system.
B1 : input rank-2 array('d') with bounds (n1,m1)
The leading n1-by-m1 part of this array must contain the input/state
matrix B1 for the first system.
C1 : input rank-2 array('d') with bounds (p1,n1)
The leading p1-by-n1 part of this array must contain the state/output
matrix C1 for the first system.
D1 : input rank-2 array('d') with bounds (p1,m1)
The leading p1-by-m1 part of this array must contain the input/output
matrix D1 for the first system.
A2 : input rank-2 array('d') with bounds (n2,n2)
The leading n2-by-n2 part of this array must contain the state
transition matrix A2 for the second system.
B2 : input rank-2 array('d') with bounds (n2,p1)
The leading n2-by-p1 part of this array must contain the input/state
matrix B2 for the second system.
C2 : input rank-2 array('d') with bounds (p2,n2)
The leading p2-by-n2 part of this array must contain the state/output
matrix C2 for the second system.
D2 : input rank-2 array('d') with bounds (p2,p1)
The leading p2-by-p1 part of this array must contain the input/output
matrix D2 for the second system.
Optional arguments:
uplo := 'U' input string(len=1)
Indicates whether the user wishes to obtain the matrix A in
the upper or lower block diagonal form, as follows:
= 'U': Obtain A in the upper block diagonal form;
= 'L': Obtain A in the lower block diagonal form.
Return objects:
n : int
The number of state variables (n1 + n2) in the resulting system,
i.e. the order of the matrix A, the number of rows of B and
the number of columns of C.
A : rank-2 array('d') with bounds (n1+n2,n1+n2)
The leading N-by-N part of this array contains the state transition
matrix A for the cascaded system.
B : rank-2 array('d') with bounds (n1+n2,m1)
The leading n-by-m1 part of this array contains the input/state
matrix B for the cascaded system.
C : rank-2 array('d') with bounds (p2,n1+n2)
The leading p2-by-n part of this array contains the state/output
matrix C for the cascaded system.
D : rank-2 array('d') with bounds (p2,m1)
The leading p2-by-m1 part of this array contains the input/output
matrix D for the cascaded system.
Notes:
Parameters
----------
n1 : int
The number of state variables in the first system, i.e. the order
of the matrix A1. n1 > 0.
m1 : int
The number of input variables for the first system. m1 > 0.
p1 : int
The number of output variables from the first system and the number
of input variables for the second system. p1 > 0.
n2 : int
The number of state variables in the second system, i.e. the order
of the matrix A2. n2 > 0.
p2 : int
The number of output variables from the second system. p2 > 0.
A1 : (n1,n1) array_like
The leading n1-by-n1 part of this array must contain the state
transition matrix A1 for the first system.
B1 : (n1,m1) array_like
The leading n1-by-m1 part of this array must contain the input/state
matrix B1 for the first system.
C1 : (p1,n1) array_like
The leading p1-by-n1 part of this array must contain the state/output
matrix C1 for the first system.
D1 : (p1,m1) array_like
The leading p1-by-m1 part of this array must contain the input/output
matrix D1 for the first system.
A2 : (n2,n2) array_like
The leading n2-by-n2 part of this array must contain the state
transition matrix A2 for the second system.
B2 : (n2,p1) array_like
The leading n2-by-p1 part of this array must contain the input/state
matrix B2 for the second system.
C2 : (p2,n2) array_like
The leading p2-by-n2 part of this array must contain the state/output
matrix C2 for the second system.
D2 : (p2,p1) array_like
The leading p2-by-p1 part of this array must contain the input/output
matrix D2 for the second system.
uplo : {'U', 'L'}, optional
Indicates whether the user wishes to obtain the matrix A in
the upper or lower block diagonal form, as follows:
= 'U': Obtain A in the upper block diagonal form;
= 'L': Obtain A in the lower block diagonal form.
Default is `U`.
Returns
-------
n : int
The number of state variables (n1 + n2) in the resulting system,
i.e. the order of the matrix A, the number of rows of B and
the number of columns of C.
A : (n1+n2,n1+n2) ndarray
The leading N-by-N part of this array contains the state transition
matrix A for the cascaded system.
B : (n1+n2,m1) ndarray
The leading n-by-m1 part of this array contains the input/state
matrix B for the cascaded system.
C : (p2,n1+n2) ndarray
The leading p2-by-n part of this array contains the state/output
matrix C for the cascaded system.
D : (p2,m1) ndarray
The leading p2-by-m1 part of this array contains the input/output
matrix D for the cascaded system.
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value
Notes
-----
The implemented methods rely on accuracy enhancing square-root or
balancing-free square-root techniques.
The algorithms require less than 30N^3 floating point operations.
Expand All @@ -230,71 +243,77 @@ def ab05nd(n1,m1,p1,n2,A1,B1,C1,D1,A2,B2,C2,D2,alpha=1.0,ldwork=None):
To obtain the state-space model (A,B,C,D) for the feedback inter-connection
of two systems, each given in state-space form.
Required arguments:
n1 : input int
The number of state variables in the first system, i.e. the order
of the matrix A1. n1 > 0.
m1 : input int
The number of input variables for the first system and the number
of output variables from the second system. m1 > 0.
p1 : input int
The number of output variables from the first system and the number
of input variables for the second system. p1 > 0.
n2 : input int
The number of state variables in the second system, i.e. the order
of the matrix A2. n2 > 0.
A1 : input rank-2 array('d') with bounds (n1,n1)
The leading n1-by-n1 part of this array must contain the state
transition matrix A1 for the first system.
B1 : input rank-2 array('d') with bounds (n1,m1)
The leading n1-by-m1 part of this array must contain the input/state
matrix B1 for the first system.
C1 : input rank-2 array('d') with bounds (p1,n1)
The leading p1-by-n1 part of this array must contain the state/output
matrix C1 for the first system.
D1 : input rank-2 array('d') with bounds (p1,m1)
The leading p1-by-m1 part of this array must contain the input/output
matrix D1 for the first system.
A2 : input rank-2 array('d') with bounds (n2,n2)
The leading n2-by-n2 part of this array must contain the state
transition matrix A2 for the second system.
B2 : input rank-2 array('d') with bounds (n2,p1)
The leading n2-by-p1 part of this array must contain the input/state
matrix B2 for the second system.
C2 : input rank-2 array('d') with bounds (m1,n2)
The leading m1-by-n2 part of this array must contain the state/output
matrix C2 for the second system.
D2 : input rank-2 array('d') with bounds (m1,p1)
The leading m1-by-p1 part of this array must contain the input/output
matrix D2 for the second system.
Optional arguments:
alpha := 1.0 input float
A coefficient multiplying the transfer-function matrix (or the
output equation) of the second system. i.e alpha = +1 corresponds
to positive feedback, and alpha = -1 corresponds to negative
feedback.
ldwork := max(p1*p1,m1*m1,n1*p1) input int
The length of the cache array. ldwork >= max(p1*p1,m1*m1,n1*p1).
Return objects:
n : int
The number of state variables (n1 + n2) in the connected system, i.e.
the order of the matrix A, the number of rows of B and the number of
columns of C.
A : rank-2 array('d') with bounds (n1+n2,n1+n2)
The leading n-by-n part of this array contains the state transition
matrix A for the connected system.
B : rank-2 array('d') with bounds (n1+n2,m1)
The leading n-by-m1 part of this array contains the input/state
matrix B for the connected system.
C : rank-3 array('d') with bounds (p1,n1,n2)
The leading p1-by-n part of this array contains the state/output
matrix C for the connected system.
D : rank-2 array('d') with bounds (p1,m1)
The leading p1-by-m1 part of this array contains the input/output
matrix D for the connected system.
Parameters
----------
n1 : int
The number of state variables in the first system, i.e. the order
of the matrix A1. n1 > 0.
m1 : int
The number of input variables for the first system and the number
of output variables from the second system. m1 > 0.
p1 : int
The number of output variables from the first system and the number
of input variables for the second system. p1 > 0.
n2 : int
The number of state variables in the second system, i.e. the order
of the matrix A2. n2 > 0.
A1 : (n1,n1) array_like
The leading n1-by-n1 part of this array must contain the state
transition matrix A1 for the first system.
B1 : (n1,m1) array_like
The leading n1-by-m1 part of this array must contain the input/state
matrix B1 for the first system.
C1 : (p1,n1) array_like
The leading p1-by-n1 part of this array must contain the state/output
matrix C1 for the first system.
D1 : (p1,m1) array_like
The leading p1-by-m1 part of this array must contain the input/output
matrix D1 for the first system.
A2 : (n2,n2) array_like
The leading n2-by-n2 part of this array must contain the state
transition matrix A2 for the second system.
B2 : (n2,p1) array_like
The leading n2-by-p1 part of this array must contain the input/state
matrix B2 for the second system.
C2 : (m1,n2) array_like
The leading m1-by-n2 part of this array must contain the state/output
matrix C2 for the second system.
D2 : (m1,p1) array_like
The leading m1-by-p1 part of this array must contain the input/output
matrix D2 for the second system.
alpha : float, optional
A coefficient multiplying the transfer-function matrix (or the
output equation) of the second system. i.e alpha = +1 corresponds
to positive feedback, and alpha = -1 corresponds to negative
feedback.
Default is `1.0`.
ldwork : int, optional
The length of the cache array. ldwork >= max(p1*p1,m1*m1,n1*p1).
Default is max(p1*p1,m1*m1,n1*p1).
Returns
-------
n : int
The number of state variables (n1 + n2) in the connected system, i.e.
the order of the matrix A, the number of rows of B and the number of
columns of C.
A : (n1+n2,n1+n2) ndarray
The leading n-by-n part of this array contains the state transition
matrix A for the connected system.
B : (n1+n2,m1) ndarray
The leading n-by-m1 part of this array contains the input/state
matrix B for the connected system.
C : (p1,n1,n2) ndarray
The leading p1-by-n part of this array contains the state/output
matrix C for the connected system.
D : (p1,m1) ndarray
The leading p1-by-m1 part of this array contains the input/output
matrix D for the connected system.
Raises
------
SlycotParameterError
:info = -i: the i-th argument had an illegal value
SlycotArithmeticError
:1 <= info <= p1:
the system is not completely controllable. That is, the matrix
Expand All @@ -317,47 +336,49 @@ def ab05nd(n1,m1,p1,n2,A1,B1,C1,D1,A2,B2,C2,D2,alpha=1.0,ldwork=None):
return out[:-1]

def ab07nd(n,m,A,B,C,D,ldwork=None):
""" A_i,B_i,C_i,D_i,rcond = ab07nd(n,m,A,B,C,D,[ldwork])
""" Ai,Bi,Ci,Di,rcond = ab07nd(n,m,A,B,C,D,[ldwork])
To compute the inverse (A_i,B_i,C_i,D_i) of a given system (A,B,C,D).
To compute the inverse (Ai,Bi,Ci,Di) of a given system (A,B,C,D).
Required arguments:
n : input int
The order of the state matrix A. n >= 0.
m : input int
The number of system inputs and outputs. m >= 0.
A : input rank-2 array('d') with bounds (n,n)
The leading n-by-n part of this array must contain the state matrix
A of the original system.
B : input rank-2 array('d') with bounds (n,m)
The leading n-by-m part of this array must contain the input matrix
B of the original system.
C : input rank-2 array('d') with bounds (m,n)
The leading m-by-n part of this array must contain the output matrix
C of the original system.
D : input rank-2 array('d') with bounds (m,m)
The leading m-by-m part of this array must contain the feedthrough
matrix D of the original system.
Optional arguments:
ldwork := None input int
The length of the cache array. The default value is max(1,4*m),
for better performance should be larger.
Return objects:
A_i : rank-2 array('d') with bounds (n,n)
The leading n-by-n part of this array contains the state matrix A_i
of the inverse system.
B_i : rank-2 array('d') with bounds (n,m)
The leading n-by-m part of this array contains the input matrix B_i
of the inverse system.
C_i : rank-2 array('d') with bounds (m,n)
The leading m-by-n part of this array contains the output matrix C_i
of the inverse system.
D_i : rank-2 array('d') with bounds (m,m)
The leading m-by-m part of this array contains the feedthrough
matrix D_i of the inverse system.
rcond : float
The estimated reciprocal condition number of the feedthrough matrix
D of the original system.
Parameters
----------
n : int
The order of the state matrix A. n >= 0.
m : int
The number of system inputs and outputs. m >= 0.
A : (n,n) array_like
The leading n-by-n part of this array must contain the state matrix
A of the original system.
B : (n,m) array_like
The leading n-by-m part of this array must contain the input matrix
B of the original system.
C : (m,n) array_like
The leading m-by-n part of this array must contain the output matrix
C of the original system.
D : (m,m) array_like
The leading m-by-m part of this array must contain the feedthrough
matrix D of the original system.
ldwork : int, optional
The length of the cache array. The default value is max(1,4*m),
for better performance should be larger.
Returns
-------
Ai : (n,n) ndarray
The leading n-by-n part of this array contains the state matrix Ai
of the inverse system.
Bi : (n,m) ndarray
The leading n-by-m part of this array contains the input matrix Bi
of the inverse system.
Ci : (m,n) ndarray
The leading m-by-n part of this array contains the output matrix Ci
of the inverse system.
Di : (m,m) ndarray
The leading m-by-m part of this array contains the feedthrough
matrix Di of the inverse system.
rcond : float
The estimated reciprocal condition number of the feedthrough matrix
D of the original system.
Warns
-----
Expand Down

0 comments on commit a0e3ef7

Please sign in to comment.