np.triu_indices_from() 返回方阵的上三角矩阵的索引

np.triu_indices_from() 

返回方阵的上三角矩阵的索引

numpy.triu_indices_from(arr,k = 0 )

参数:

arr :ndarray,shape(N,N)

k: int,可选,对角线偏移

例子:

import numpy as np

a = np.array([[1,2],[4,5]])
np.triu_indices_from(a)
#(array([0, 0, 1], dtype=int64), array([0, 1, 1], dtype=int64))

https://numpy.org/doc/stable/reference/generated/numpy.triu_indices_from.html

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注