scipy.linalg.qz¶
-
scipy.linalg.
qz
(A, B, output='real', lwork=None, sort=None, overwrite_a=False, overwrite_b=False, check_finite=True)[source]¶ QZ decomposition for generalized eigenvalues of a pair of matrices.
The QZ, or generalized Schur, decomposition for a pair of n-by-n 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.- Parameters
- A(N, N) array_like
2-D array to decompose
- B(N, N) array_like
2-D array to decompose
- output{‘real’, ‘complex’}, optional
Construct the real or complex QZ decomposition for real matrices. Default is ‘real’.
- lworkint, 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 eigenvaluex = (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_abool, optional
Whether to overwrite data in a (may improve performance)
- overwrite_bbool, optional
Whether to overwrite data in b (may improve performance)
- check_finitebool, 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.
- Returns
- 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.
See also
Notes
Q is transposed versus the equivalent function in Matlab.
New in version 0.11.0.
Examples
>>> from scipy import linalg >>> rng = np.random.default_rng() >>> A = np.arange(9).reshape((3, 3)) >>> B = rng.standard_normal((3, 3))
>>> AA, BB, Q, Z = linalg.qz(A, B) >>> AA array([[ 8.99591445e+00, -1.07917902e+01, -2.18309912e+00], [ 0.00000000e+00, -8.60837546e-01, 1.05063006e+00], [ 0.00000000e+00, 0.00000000e+00, -1.40584278e-15]]) >>> BB array([[ 0.2058989 , -0.6007898 , -0.5771396 ], [ 0. , 1.6997737 , -1.12160842], [ 0. , 0. , 1.76304656]]) >>> Q array([[ 0.10356118, 0.90697763, -0.40824829], [ 0.48575095, 0.31205664, 0.81649658], [ 0.86794072, -0.28286434, -0.40824829]]) >>> Z array([[ 0.78900531, 0.16010775, -0.59315776], [-0.21754047, -0.83009894, -0.51343148], [ 0.57458399, -0.53413598, 0.62012256]])