mindspore.ops.orgqr

mindspore.ops.orgqr(input, input2)[源代码]

计算 mindspore.ops.Geqrf 返回的正交矩阵 \(Q\) 的显式表示。

下面以输入无batch维的情况为例, 计算 Householder 矩阵的前 \(N\) 列。 假设输入 input 的shape经过 Householder转换 之后为:\((M, N)\) 。 当 input 的对角线被置为1, input 中下三角形的每一列都表示为: \(w_j\) ,其中 \(j\)\(j=1, \ldots, M\) 范围内,此函数返回Householder矩阵乘积的前 \(N\) 列:

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

其中:\(\mathrm{I}_{M}\)\(M\) 维单位矩阵。当 \(w\) 是复数的时候,\(w^{\mathrm{H}}\) 是共轭转置,否则是一般转置。输出矩阵的shape与输入矩阵 input 相同。 \(tau\) 即输入 input2

参数:
  • input (Tensor) - shape \((*, M, N)\) 的Tensor,表示二维或者三维矩阵。数据类型为float32、float64、complex64或者complex128。

  • input2 (Tensor) - Householder转换的反射系数,其shape为 \((*, K)\) ,其中 K 小于等于 N 。数据类型与 input 一致。

返回:

Tensor,数据类型与shape与 input 一致。

异常:
  • TypeError - input 或者 input2 不是Tensor。

  • TypeError - inputinput2 的数据类型不是float64、float32、complex64或者complex128。

  • ValueError - inputinput2 的batch维度不同。

  • ValueError - input.shape[-2] < input.shape[-1]。

  • ValueError - input.shape[-1] < input2.shape[-1]。

  • ValueError - rank(input) - rank(input2) != 1。

  • ValueError - rank(input) != 2 or 3。

支持平台:

Ascend GPU CPU

样例:

>>> 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]]