mindspore.ops.Geqrf

class mindspore.ops.Geqrf[source]

Decomposes a matrix into the product of an orthogonal matrix Q and an upper triangular matrix R. The process is called QR decomposition: \(A = QR\).

Both Q and R matrices are stored in the same output tensor y. The elements of R are stored on and above the diagonal, whereas elementary reflectors (or Householder vectors) implicitly defining matrix Q are stored below the diagonal.

This function returns two tensors (y, tau).

Warning

This is an experimental API that is subject to change or deletion.

Inputs:
  • x (Tensor) - Tensor of shape \((*, m, n)\), input must be a matrix greater than or equal to 2D, with dtype of float32, float64, complex64, complex128.

Outputs:
  • y (Tensor) - Tensor of shape \((*, m, n)\), has the same dtype as the x.

  • tau (Tensor) - Tensor of shape \((*, p)\) and \(p = min(m, n)\), has the same dtype as the x.

Raises
  • TypeError – If x is not a Tensor.

  • TypeError – If the dtype of x is neither float32, float64, complex64, complex128.

  • ValueError – If x dimension is less than 2

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([[-2.0, -1.0], [1.0, 2.0]]).astype(np.float32))
>>> geqrf = ops.Geqrf()
>>> y, tau = geqrf(input_x)
>>> print(y)
[[ 2.236068   1.7888544]
 [-0.236068   1.3416407]]
>>> print(tau)
[1.8944271 0.       ]