householder_product

paddle.linalg. householder_product ( x, tau, name=None ) [source]

Computes the first n columns of a product of Householder matrices.

This function can get the vector \(\omega_{i}\) from matrix x (m x n), the \(i-1\) elements are zeros, and the i-th is 1, the rest of the elements are from i-th column of x. And with the vector tau can calculate the first n columns of a product of Householder matrices.

\(H_i = I_m - \tau_i \omega_i \omega_i^H\)

Parameters
  • x (Tensor) – A tensor with shape (*, m, n) where * is zero or more batch dimensions.

  • tau (Tensor) – A tensor with shape (*, k) where * is zero or more batch dimensions.

  • name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.

Returns

Tensor, the dtype is same as input tensor, the Q in QR decomposition.

\(out = Q = H_1H_2H_3...H_k\)

Examples

>>> import paddle
>>> x = paddle.to_tensor([[-1.1280,  0.9012, -0.0190],
...         [ 0.3699,  2.2133, -1.4792],
...         [ 0.0308,  0.3361, -3.1761],
...         [-0.0726,  0.8245, -0.3812]])
>>> tau = paddle.to_tensor([1.7497, 1.1156, 1.7462])
>>> Q = paddle.linalg.householder_product(x, tau)
>>> print(Q)
Tensor(shape=[4, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [[-0.74969995, -0.02181768,  0.31115776],
        [-0.64721400, -0.12367040, -0.21738708],
        [-0.05389076, -0.37562513, -0.84836429],
        [ 0.12702821, -0.91822827,  0.36892807]])