mindspore.ops.orgqr

mindspore.ops.orgqr(input, input2)[source]

Calculates the explicit representation of the orthogonal matrix \(Q\) returned by mindspore.ops.Geqrf.

Take the case of input without batch dimension as an example, computes the first \(N\) columns of a product of Householder matrices. Suppose input input is a matrix of size \((M, N)\) after householder transformation. When the diagonal of input is set to 1, every colunm of lower triangular in input is denoted as \(w_j\) for \(j\) for \(j=1, \ldots, M\), this function returns the first \(N\) columns of the matrix

\[H_{1} H_{2} \ldots H_{k} \quad \text { with } \quad H_{j}=\mathrm{I}_{M}-\tau_{j} w_{j} w_{j}^{\mathrm{H}}\]

where \(\mathrm{I}_{M}\) is the \(M\)-dimensional identity matrix. And when \(w\) is complex, \(w^{\mathrm{H}}\) is the conjugate transpose, otherwise the transpose. The output matrix is the same size as the input matrix input. \(tau\) is corresponding to input2.

Parameters
  • input (Tensor) – Tensor of shape \((*, M, N)\), indicating 2D or 3D matrices, with float32, float64, complex64 and complex128 data type.

  • input2 (Tensor) – Tensor of shape \((*, K)\), where K is less than or equal to N, indicating the reflecting coefficient in Householder transformation, which have the same type as input.

Returns

Tensor, has the same shape and data type as input.

Raises
  • TypeError – If input or input2 are not Tensors.

  • TypeError – If dtype of input and input2 is not one of: float64, float32, complex64, complex128.

  • ValueError – If input and input2 have different batch size.

  • ValueError – If input.shape[-2] < input.shape[-1].

  • ValueError – If input.shape[-1] < input2.shape[-1].

  • ValueError – If rank(input) - rank(input2) != 1.

  • ValueError – If rank(input) != 2 or 3.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input = Tensor(np.array([[-114.6, 10.9, 1.1], [-0.304, 38.07, 69.38], [-0.45, -0.17, 62.]]),
... mindspore.float32)
>>> input2 = Tensor(np.array([1.55, 1.94, 0.0]), mindspore.float32)
>>> y = ops.orgqr(input, input2)
>>> print(y)
[[-0.54999995 -0.2128925   0.8137956 ]
 [ 0.47119996 -0.8752807   0.08240613]
 [ 0.69749993  0.42560163  0.57772595]]