TorchLean API

NN.Examples.Factorization.QR

QR Factorization #

Check whether Tensor.qr A reconstructs $A$ as $QR$ and gives orthonormal columns in $Q$. The checks use Float with an explicit tolerance. Reduced QR uses Q : Tensor Float [rows, min rows columns] and R : Tensor Float [min rows columns, columns].

Run lake exe torchlean factorizations. The rank-deficient negative control still reconstructs the input, but fails orthonormality: reconstructing a matrix alone does not establish both QR properties. This file tests the implementation; it does not prove a real-arithmetic QR theorem.

Full-rank matrix used for the positive QR check.

Instances For

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

    Instances For

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

      Instances For

        Wide Matrix #

        This case also places a dependent column before a later independent column. A reduced implementation that merely truncates the old square factors loses that later basis direction.

        Reduced QR of a wide matrix: Q is 2 x 2 and R is 2 x 3.

        Instances For

          How far Q R is from the original matrix; should be at rounding level.

          Instances For

            How far Qᵀ Q is from the identity, the other half of what QR promises.

            Instances For

              Negative Control #

              The orthonormality property requires full column rank. The following matrix has one dependent column. Gram-Schmidt still reconstructs it, but the corresponding column of Q vanishes and $Q^\mathsf{T}Q\ne I$.

              A matrix whose second column is twice its first.

              Instances For

                QR of a rank-deficient matrix. Reconstruction survives; orthonormality does not, because the dependent column contributes a zero column to Q.

                Instances For

                  Reconstruction still holds without full rank.

                  Instances For

                    Orthonormality fails because Q has a zero column.

                    Instances For

                      Run square and wide full-rank checks plus the dependent-column negative control.

                      Instances For