mindspore/docs/api/api_python/numpy/mindspore.numpy.tri.rst

19 lines
982 B
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.numpy.tri
=================================
.. py:function:: mindspore.numpy.tri(N, M=None, k=0, dtype=mstype.float32)
返回一个Tensor在给定的对角线处及以下元素值为1在其他位置为0。
参数:
- **N** (int) - 输入数组的行数。
- **M** (int, 可选) - 输入数组的列数。默认情况下 ``M`` 等于 ``N``
- **k** (int, 可选) - 对角线的偏移量: :math:`k=0` 即为主对角线, :math:`k<0` 即对角线向下偏移, :math:`k>0` 即对角线向上偏移。默认值: ``0``
- **dtype** (mindspore.dtype, 可选) - 指定的Tensor数据类型。默认值 ``mstype.float32``
返回:
Tensorshape为 ``(N, M)`` 其中他的下三角区域填充为1其余位置填充为0用公式表达就是当 :math:`j<=i+k` 时, :math:`T[i,j]=1` 否则为0。
异常:
- **TypeError** - 如果输入参数非上述给定的类型。