TorchLean API

NN.Examples.Factorization.QR

Example: QR factorization #

qrSpec A returns (Q, R) with $A=QR$, where $Q$ has orthonormal columns and $R$ is upper-triangular (classical Gram–Schmidt). We check both $A=QR$ and $Q^\mathsf{T}Q=I$.

A 3×3 test matrix (the classic Householder/QR example).

Instances For

    Reconstruction error $\lVert A-QR\rVert_{\max}$.

    Instances For

      Orthonormality error $\lVert Q^\mathsf{T}Q-I\rVert_{\max}$.

      Instances For

        Negative control: full column rank is necessary for orthonormality #

        qrSpec_orthonormal ($Q^\mathsf{T}Q=I$) requires full column rank — positive $R$-pivots ($0<R_{jj}$). The matrix below has a dependent column ($\mathrm{col}_2=2\,\mathrm{col}_1$), so Gram–Schmidt produces a zero $Q$ column where the pivot vanishes: $A=QR$ still holds, but $Q^\mathsf{T}Q$ has a zero on the diagonal, so orthonormality fails. This separates the two guarantees and shows the rank hypothesis genuinely bites.

        A rank-2 matrix ($\mathrm{col}_2=2\,\mathrm{col}_1$): reconstructs, but $Q$ cannot be orthonormal.

        Instances For

          Reconstruction still holds even without full rank.

          Instances For

            Orthonormality fails: $Q^\mathsf{T}Q$ has a zero diagonal entry, so it is far from $I$.

            Instances For