ordqz — SciPy v1.15.2 Manual (original) (raw)
scipy.linalg.
scipy.linalg.ordqz(A, B, sort='lhp', output='real', overwrite_a=False, overwrite_b=False, check_finite=True)[source]#
QZ decomposition for a pair of matrices with reordering.
Parameters:
A(N, N) array_like
2-D array to decompose
B(N, N) array_like
2-D 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 pairsbeta
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.
outputstr {‘real’,’complex’}, optional
Construct the real or complex QZ decomposition for real matrices. Default is ‘real’.
overwrite_abool, optional
If True, the contents of A are overwritten.
overwrite_bbool, optional
If True, the contents of B are overwritten.
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.
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.
Notes
On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N
, will be the generalized eigenvalues. ALPHAR(j) + ALPHAI(j)*i
andBETA(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 jth eigenvalue is real; if positive, then the j
th and (j+1)
st eigenvalues are a complex conjugate pair, with ALPHAI(j+1)
negative.
Added in version 0.17.0.
Examples
import numpy as np from scipy.linalg import ordqz A = np.array([[2, 5, 8, 7], [5, 2, 2, 8], [7, 5, 6, 6], [5, 4, 4, 8]]) B = np.array([[0, 6, 0, 0], [5, 0, 2, 1], [5, 2, 6, 6], [4, 7, 7, 7]]) AA, BB, alpha, beta, Q, Z = ordqz(A, B, sort='lhp')
Since we have sorted for left half plane eigenvalues, negatives come first
(alpha/beta).real < 0 array([ True, True, False, False], dtype=bool)