scipy.linalg.hessenberg¶
-
scipy.linalg.
hessenberg
(a, calc_q=False, overwrite_a=False, check_finite=True)[source]¶ Compute Hessenberg form of a matrix.
The Hessenberg decomposition is:
A = Q H Q^H
where Q is unitary/orthogonal and H has only zero elements below the first sub-diagonal.
Parameters: - a : (M, M) array_like
Matrix to bring into Hessenberg form.
- calc_q : bool, optional
Whether to compute the transformation matrix. Default is False.
- overwrite_a : bool, optional
Whether to overwrite a; may improve performance. Default is False.
- check_finite : bool, optional
Whether 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: - H : (M, M) ndarray
Hessenberg form of a.
- Q : (M, M) ndarray
Unitary/orthogonal similarity transformation matrix
A = Q H Q^H
. Only returned ifcalc_q=True
.
Examples
>>> from scipy.linalg import hessenberg >>> A = np.array([[2, 5, 8, 7], [5, 2, 2, 8], [7, 5, 6, 6], [5, 4, 4, 8]]) >>> H, Q = hessenberg(A, calc_q=True) >>> H array([[ 2. , -11.65843866, 1.42005301, 0.25349066], [ -9.94987437, 14.53535354, -5.31022304, 2.43081618], [ 0. , -1.83299243, 0.38969961, -0.51527034], [ 0. , 0. , -3.83189513, 1.07494686]]) >>> np.allclose(Q @ H @ Q.conj().T - A, np.zeros((4, 4))) True