numpy.tril_indices()函數返回(n,m)數組的lower-triangle的索引。
用法: numpy.tril_indices(n, k = 0, m = None)
參數:
n :[int] The row dimension of the arrays for which the returned indices will be valid.
k :[int, optional] Diagonal offset.
m :[int, optional] The column dimension of the arrays for which the returned arrays will be valid. By default m is taken equal to n.
Return :[tuple of arrays] The indices for the triangle. The returned tuple contains two arrays, each with the indices along one dimension of the array.
代碼1:
# Python program explaining
# numpy.tril_indices() function
# importing numpy as geek
import numpy as geek
gfg = geek.tril_indices(3)
print (gfg)
輸出:
(array([0, 1, 1, 2, 2, 2]), array([0, 0, 1, 0, 1, 2]))
代碼2:
# Python program explaining
# numpy.tril_indices() function
# importing numpy as geek
import numpy as geek
gfg = geek.tril_indices(3, 2)
print (gfg)
輸出:
(array([0, 0, 0, 1, 1, 1, 2, 2, 2]), array([0, 1, 2, 0, 1, 2, 0, 1, 2]))
相關用法
- Python Wand function()用法及代碼示例
- Python id()用法及代碼示例
- Python now()用法及代碼示例
- Python str()用法及代碼示例
- Python ord()用法及代碼示例
- Python int()用法及代碼示例
- Python map()用法及代碼示例
- Python hex()用法及代碼示例
- Python oct()用法及代碼示例
- Python sum()用法及代碼示例
- Python tell()用法及代碼示例
- Python dir()用法及代碼示例
- Python cmp()用法及代碼示例
- Python bytearray()用法及代碼示例
- Python math.gcd()用法及代碼示例
- Python numpy.ma.where()用法及代碼示例
- Python Wand arc()用法及代碼示例
注:本文由純淨天空篩選整理自sanjoy_62大神的英文原創作品 numpy.tril_indices() function | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。