fn

householder_product

Tensor
householder_product(H: Tensor, tau: Tensor)
source

Reconstruct an orthogonal matrix from Householder reflectors.

Computes the implicit product

Q=H1H2Hk,Hi=Iτivivi,Q \,=\, H_1\,H_2\,\cdots\,H_k, \qquad H_i \,=\, I - \tau_i\, v_i\, v_i^\top,

where each viv_i is a Householder vector stored in the ii-th column of the packed input H and τi\tau_i is its scalar factor. This is the standard way to materialise the QQ factor from a packed QR (geqrf) result.

Parameters

HTensor
Packed reflector matrix of shape (*, m, k) — columns contain the Householder vectors (typically the output of an unpacked geqrf).
tauTensor
Scalar factors of shape (*, k).

Returns

Tensor

Orthogonal matrix QQ of shape (*, m, k).

Notes

Backed by LAPACK orgqr. Cost is O(mk2)O(m k^2). Useful when a routine returns the packed Householder form (cheaper to store) but the explicit QQ is needed downstream.

Examples

>>> import lucid
>>> from lucid.linalg import qr, householder_product
>>> A = lucid.randn(4, 3)
>>> Q, R = qr(A, mode="reduced")
>>> # The same Q can be reconstructed from packed Householder reflectors
>>> # returned by lower-level geqrf-style factorisations.
>>> Q.shape
(4, 3)