Skip to content
fn

householder_product

→Tensor
householder_product(input: Tensor, tau: Tensor)

Implementing kernel

C++ engine symbols that back this Python API.

Reconstruct an orthogonal matrix from Householder reflectors.

Computes the implicit product

Q = H1 H2 ⋯ Hr,Hi = I−τi vi vi⊤,Q \,=\, H_1\,H_2\,\cdots\,H_r, \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 input 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

inputTensor
Packed reflector matrix of shape (*, m, k) — columns contain the Householder vectors (typically the output of an unpacked geqrf).
Scalar factors of shape (*, r) with r <= n. Fewer than n reflectors multiply only the leading columns of the identity — none at all gives its first n columns.

Returns

Tensor

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

Notes

Raises DtypeMismatch if tau's dtype differs from input's, ValueError if input is wide (m < n) or tau is longer than n, and NotImplementedError if both are bool or integer tensors, whatever their shapes, as the reference does.

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)

Used by 1