bundles / scipy latest / scipy / linalg / _decomp_schur / schur
function
scipy.linalg._decomp_schur:schur
Signature
def schur ( a , output = real , lwork = None , overwrite_a = False , sort = None , check_finite = True ) Summary
Compute Schur decomposition of a matrix.
Extended Summary
The Schur decomposition is
A = Z T Z^Hwhere Z is unitary and T is either upper-triangular, or for real Schur decomposition (output='real'), quasi-upper triangular. In the quasi-triangular form, 2x2 blocks describing complex-valued eigenvalue pairs may extrude from the diagonal.
The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. Note that calls with zero-size batches are unsupported and will raise a ValueError.
Parameters
a: (M, M) array_likeMatrix to decompose
output: {'real', 'complex'}, optionalWhen the dtype of
ais real, this specifies whether to compute the real or complex Schur decomposition. When the dtype ofais complex, this argument is ignored, and the complex Schur decomposition is computed.lwork: int, optionalWork array size. If None or -1, it is automatically computed.
overwrite_a: bool, optionalWhether to overwrite data in a (may improve performance).
sort: {None, callable, 'lhp', 'rhp', 'iuc', 'ouc'}, optionalSpecifies whether the upper eigenvalues should be sorted. A callable may be passed that, given an eigenvalue, returns a boolean denoting whether the eigenvalue should be sorted to the top-left (True).
If
output='complex'OR the dtype ofais complex, the callable should have one argument: the eigenvalue expressed as a complex number.If
output='real'AND the dtype ofais real, the callable should have two arguments: the real and imaginary parts of the eigenvalue, respectively.
Alternatively, string parameters may be used
'lhp' Left-hand plane (real(eigenvalue) < 0.0) 'rhp' Right-hand plane (real(eigenvalue) >= 0.0) 'iuc' Inside the unit circle (abs(eigenvalue) <= 1.0) 'ouc' Outside the unit circle (abs(eigenvalue) > 1.0)
Defaults to None (no sorting).
check_finite: bool, optionalWhether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.
Returns
T: (M, M) ndarraySchur form of A. It is real-valued for the real Schur decomposition.
Z: (M, M) ndarrayA unitary Schur transformation matrix for A. It is real-valued for the real Schur decomposition.
sdim: intIf and only if sorting was requested, a third return value will contain the number of eigenvalues satisfying the sort condition. Note that complex conjugate pairs for which the condition is true for either eigenvalue count as 2.
Raises
: LinAlgErrorError raised under three conditions:
The algorithm failed due to a failure of the QR algorithm to compute all eigenvalues.
If eigenvalue sorting was requested, the eigenvalues could not be reordered due to a failure to separate eigenvalues, usually because of poor conditioning.
If eigenvalue sorting was requested, roundoff errors caused the leading eigenvalues to no longer satisfy the sorting condition.
Examples
import numpy as np from scipy.linalg import schur, eigvals A = np.array([[0, 2, 2], [0, 1, 2], [1, 0, 1]]) T, Z = schur(A)✓
T Z✗
T2, Z2 = schur(A, output='complex')
✓T2 eigvals(T2)✗
_, _, sdim = schur(A, output='complex', sort=lambda x: x.imag > 1e-15) sdim✓
_, _, sdim = schur(A, output='real', sort=lambda x, y: y > 1e-15) sdim✓
See also
- rsf2csf
Convert real Schur form to complex Schur form
Aliases
-
scipy.linalg.schur
Referenced by
Other packages
- numpy numpy.linalg:eig
- numpy numpy.linalg:eig
- numpy numpy.linalg:eig