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.
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 Batched Linear Operations for details.
- Parameters:
- a(M, M) array_like
Matrix to bring into Hessenberg form.
- calc_qbool, optional
Whether to compute the transformation matrix. Default is False.
- overwrite_abool, optional
Whether to overwrite a; may improve performance. Default is False.
- check_finitebool, 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
>>> import numpy as np >>> 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