# jax.scipy.linalg.hessenberg#

jax.scipy.linalg.hessenberg(a: ArrayLike, *, calc_q: Literal[False], overwrite_a: bool = False, check_finite: bool = True) [source]#
jax.scipy.linalg.hessenberg(a: ArrayLike, *, calc_q: Literal[True], overwrite_a: bool = False, check_finite: bool = True)

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) if calc_q is True, else an array H

• H has shape (..., N, N) and is the Hessenberg form of a

• Q has shape (..., N, N) and is the associated unitary matrix

Example

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)