linalg._decomp_qz

Module Contents

Functions

_select_function(sort)
_lhp(x,y)
_rhp(x,y)
_iuc(x,y)
_ouc(x,y)
_qz(A,B,output=”real”,lwork=None,sort=None,overwrite_a=False,overwrite_b=False,check_finite=True)
qz(A,B,output=”real”,lwork=None,sort=None,overwrite_a=False,overwrite_b=False,check_finite=True) QZ decomposition for generalized eigenvalues of a pair of matrices.
ordqz(A,B,sort=”lhp”,output=”real”,overwrite_a=False,overwrite_b=False,check_finite=True) QZ decomposition for a pair of matrices with reordering.
_select_function(sort)
_lhp(x, y)
_rhp(x, y)
_iuc(x, y)
_ouc(x, y)
_qz(A, B, output="real", lwork=None, sort=None, overwrite_a=False, overwrite_b=False, check_finite=True)
qz(A, B, output="real", lwork=None, sort=None, overwrite_a=False, overwrite_b=False, check_finite=True)

QZ decomposition for generalized eigenvalues of a pair of matrices.

The QZ, or generalized Schur, decomposition for a pair of N x N nonsymmetric matrices (A,B) is:

(A,B) = (Q*AA*Z', Q*BB*Z')

where AA, BB is in generalized Schur form if BB is upper-triangular with non-negative diagonal and AA is upper-triangular, or for real QZ decomposition (output='real') block upper triangular with 1x1 and 2x2 blocks. In this case, the 1x1 blocks correspond to real generalized eigenvalues and 2x2 blocks are ‘standardized’ by making the corresponding elements of BB have the form:

[ a 0 ]
[ 0 b ]

and the pair of corresponding 2x2 blocks in AA and BB will have a complex conjugate pair of generalized eigenvalues. If (output='complex') or A and B are complex matrices, Z’ denotes the conjugate-transpose of Z. Q and Z are unitary matrices.

A : (N, N) array_like
2d array to decompose
B : (N, N) array_like
2d array to decompose
output : {‘real’, ‘complex’}, optional
Construct the real or complex QZ decomposition for real matrices. Default is ‘real’.
lwork : int, optional
Work array size. If None or -1, it is automatically computed.
sort : {None, callable, ‘lhp’, ‘rhp’, ‘iuc’, ‘ouc’}, optional

NOTE: THIS INPUT IS DISABLED FOR NOW. Use ordqz instead.

Specifies whether the upper eigenvalues should be sorted. A callable may be passed that, given a eigenvalue, returns a boolean denoting whether the eigenvalue should be sorted to the top-left (True). For real matrix pairs, the sort function takes three real arguments (alphar, alphai, beta). The eigenvalue x = (alphar + alphai*1j)/beta. For complex matrix pairs or output=’complex’, the sort function takes two complex arguments (alpha, beta). The eigenvalue x = (alpha/beta). Alternatively, string parameters may be used:

  • ‘lhp’ Left-hand plane (x.real < 0.0)
  • ‘rhp’ Right-hand plane (x.real > 0.0)
  • ‘iuc’ Inside the unit circle (x*x.conjugate() < 1.0)
  • ‘ouc’ Outside the unit circle (x*x.conjugate() > 1.0)

Defaults to None (no sorting).

overwrite_a : bool, optional
Whether to overwrite data in a (may improve performance)
overwrite_b : bool, optional
Whether to overwrite data in b (may improve performance)
check_finite : bool, optional
If true checks the elements of A and B are finite numbers. If false does no checking and passes matrix through to underlying algorithm.
AA : (N, N) ndarray
Generalized Schur form of A.
BB : (N, N) ndarray
Generalized Schur form of B.
Q : (N, N) ndarray
The left Schur vectors.
Z : (N, N) ndarray
The right Schur vectors.

Q is transposed versus the equivalent function in Matlab.

New in version 0.11.0.

>>> from scipy import linalg
>>> np.random.seed(1234)
>>> A = np.arange(9).reshape((3, 3))
>>> B = np.random.randn(3, 3)
>>> AA, BB, Q, Z = linalg.qz(A, B)
>>> AA
array([[-13.40928183,  -4.62471562,   1.09215523],
       [  0.        ,   0.        ,   1.22805978],
       [  0.        ,   0.        ,   0.31973817]])
>>> BB
array([[ 0.33362547, -1.37393632,  0.02179805],
       [ 0.        ,  1.68144922,  0.74683866],
       [ 0.        ,  0.        ,  0.9258294 ]])
>>> Q
array([[ 0.14134727, -0.97562773,  0.16784365],
       [ 0.49835904, -0.07636948, -0.86360059],
       [ 0.85537081,  0.20571399,  0.47541828]])
>>> Z
array([[-0.24900855, -0.51772687,  0.81850696],
       [-0.79813178,  0.58842606,  0.12938478],
       [-0.54861681, -0.6210585 , -0.55973739]])

ordqz

ordqz(A, B, sort="lhp", output="real", overwrite_a=False, overwrite_b=False, check_finite=True)

QZ decomposition for a pair of matrices with reordering.

New in version 0.17.0.

A : (N, N) array_like
2d array to decompose
B : (N, N) array_like
2d array to decompose
sort : {callable, ‘lhp’, ‘rhp’, ‘iuc’, ‘ouc’}, optional

Specifies whether the upper eigenvalues should be sorted. A callable may be passed that, given an ordered pair (alpha, beta) representing the eigenvalue x = (alpha/beta), returns a boolean denoting whether the eigenvalue should be sorted to the top-left (True). For the real matrix pairs beta is real while alpha can be complex, and for complex matrix pairs both alpha and beta can be complex. The callable must be able to accept a numpy array. Alternatively, string parameters may be used:

  • ‘lhp’ Left-hand plane (x.real < 0.0)
  • ‘rhp’ Right-hand plane (x.real > 0.0)
  • ‘iuc’ Inside the unit circle (x*x.conjugate() < 1.0)
  • ‘ouc’ Outside the unit circle (x*x.conjugate() > 1.0)

With the predefined sorting functions, an infinite eigenvalue (i.e. alpha != 0 and beta = 0) is considered to lie in neither the left-hand nor the right-hand plane, but it is considered to lie outside the unit circle. For the eigenvalue (alpha, beta) = (0, 0) the predefined sorting functions all return False.

output : str {‘real’,’complex’}, optional
Construct the real or complex QZ decomposition for real matrices. Default is ‘real’.
overwrite_a : bool, optional
If True, the contents of A are overwritten.
overwrite_b : bool, optional
If True, the contents of B are overwritten.
check_finite : bool, optional
If true checks the elements of A and B are finite numbers. If false does no checking and passes matrix through to underlying algorithm.
AA : (N, N) ndarray
Generalized Schur form of A.
BB : (N, N) ndarray
Generalized Schur form of B.
alpha : (N,) ndarray
alpha = alphar + alphai * 1j. See notes.
beta : (N,) ndarray
See notes.
Q : (N, N) ndarray
The left Schur vectors.
Z : (N, N) ndarray
The right Schur vectors.

On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will be the generalized eigenvalues. ALPHAR(j) + ALPHAI(j)*i and BETA(j),j=1,...,N are the diagonals of the complex Schur form (S,T) that would result if the 2-by-2 diagonal blocks of the real generalized Schur form of (A,B) were further reduced to triangular form using complex unitary transformations. If ALPHAI(j) is zero, then the j-th eigenvalue is real; if positive, then the j-th and (j+1)-st eigenvalues are a complex conjugate pair, with ALPHAI(j+1) negative.

qz