This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/schur

The real Schur decomposition, by Householder and Francis

Every real square matrix can be written A = Q T Q^T with Q orthogonal and T quasi-triangular: upper triangular except for 2 by 2 blocks on the diagonal, one for each complex conjugate pair of eigenvalues. This is the decomposition that control theory runs on. SLICOT's Riccati, Lyapunov and Sylvester solvers all begin by computing it, because it is the only way anyone knows to get at an invariant subspace without inverting something that may be nearly singular.

It is computed in two stages, and this module does both.

hessenberg reduces A to upper Hessenberg form — zero below the subdiagonal -- by n - 2 Householder reflections. This is a finite computation; it ends.

schur then runs the implicit double-shift QR iteration, which is Francis's, on the Hessenberg matrix. Each sweep introduces a bulge at the top left and chases it off the bottom right, and the subdiagonal entries go to zero one after another. This does not end in a fixed number of steps — there is no finite algorithm for eigenvalues of order five and above — so it iterates until each subdiagonal entry is negligible against its neighbors, and deflates.

Every transformation here is orthogonal, applied on both sides. That is what makes the whole thing backward stable, and it is why Q is carried along rather than reconstructed at the end.

Each reflector is applied only to the rows and columns that can be nonzero. That is not for speed. Reach outside the window and the reflector writes a little dust back into the subdiagonal entries deflation has already set to zero, and the iteration never finishes: the residual stays perfect, because a similarity is a similarity, while the factor is quietly not quasi-triangular.

Used with import schur.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 37–817