jax.scipy.linalg.hessenberg#
- jax.scipy.linalg.hessenberg(a: ArrayLike, *, calc_q: Literal[False], overwrite_a: bool = False, check_finite: bool = True) Array [source]#
- jax.scipy.linalg.hessenberg(a: ArrayLike, *, calc_q: Literal[True], overwrite_a: bool = False, check_finite: bool = True) tuple[Array, Array]
Compute the Hessenberg form of the matrix
JAX implementation of
scipy.linalg.hessenberg()
.The Hessenberg form H of a matrix A satisfies:
\[A = Q H Q^H\]where Q is unitary and H is zero below the first subdiagonal.
- Parameters:
a – array of shape
(..., N, N)
calc_q – if True, calculate the
Q
matrix (default: False)overwrite_a – unused by JAX
check_finite – unused by JAX
- Returns:
A tuple of arrays
(H, Q)
ifcalc_q
is True, else an arrayH
H
has shape(..., N, N)
and is the Hessenberg form ofa
Q
has shape(..., N, N)
and is the associated unitary matrix
Examples
Computing the Hessenberg form of a 4x4 matrix
>>> a = jnp.array([[1., 2., 3., 4.], ... [1., 4., 2., 3.], ... [3., 2., 1., 4.], ... [2., 3., 2., 2.]]) >>> H, Q = jax.scipy.linalg.hessenberg(a, calc_q=True) >>> with jnp.printoptions(suppress=True, precision=3): ... print(H) [[ 1. -5.078 1.167 1.361] [-3.742 5.786 -3.613 -1.825] [ 0. -2.992 2.493 -0.577] [ 0. 0. -0.043 -1.279]]
Notice the zeros in the subdiagonal positions. The original matrix can be reconstructed using the
Q
vectors:>>> a_reconstructed = Q @ H @ Q.conj().T >>> jnp.allclose(a_reconstructed, a) Array(True, dtype=bool)