Skip to main content
Log in

Mojo function

qr_factorization

qr_factorization[dtype: DType, element_layout: Layout](sigma: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment], A: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment])

Performs QR factorization of a matrix A using the Householder reflector method.

This function computes the QR factorization of matrix A in-place using Householder reflections. The result is stored directly in the input matrix A, with scaling factors in sigma. The implementation follows the LAPACK algorithm for generating Householder reflectors in-place.

Algorithm: The Householder reflector is defined as: U = I - σww^H where: w = (x + νe₁)/ξ σ = ξ/ν ξ = x₀ + ν ν = sign(x₀)‖x‖₂

This ensures that U^H x = -νe₁ and U^H U = I.
This ensures that U^H x = -νe₁ and U^H U = I.

References: [1] Lehoucq, R. B. (1996). The computation of elementary unitary matrices. ACM Transactions on Mathematical Software, 22(4), 393-400. https://www.netlib.org/lapack/lawnspdf/lawn72.pdf https://library.eecs.utk.edu/files/ut-cs-94-233.pdf

Note: There is a typo in reference [lawn72]. The correct result is U^H x = -νe₁.