• 学个p-np.triu(m, k),np.tirl()


    np.triu(m, k),取矩阵a的上三角数据。斜线开始列位置由k确定

    Signature: np.triu(m, k=0)
    Docstring:
    Upper triangle of an array.

    Return a copy of an array with the elements below the k-th diagonal
    zeroed.

    Please refer to the documentation for tril for further details.

    See Also
    --------
    tril : lower triangle of an array

    Examples

    np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1)

    >>>array([[ 1, 2, 3],

    ​ [ 4, 5, 6],

    ​ [ 0, 8, 9],

    ​ [ 0, 0, 12]])

    np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], 1)

    >>>array([[0, 2, 3],

    ​ [0, 0, 6],

    ​ [0, 0, 0],

    ​ [0, 0, 0]])

    np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], 0)

    >>>array([[1, 2, 3],

    ​ [0, 5, 6],

    ​ [0, 0, 9],

    ​ [0, 0, 0]])

    np.tirl(),取矩阵a的下三角数据

    • 整理自网络
  • 相关阅读:
    JVM
    OLAP
    rocketMq学习
    redis的使用小记
    CRT配置端口转发
    冒泡排序
    spring AOP-切面编程
    linux下对jar包和war包进行重新打包
    oracle-sql性能优化
    遍历List,根据子项的某个属性分组
  • 原文地址:https://www.cnblogs.com/leefree/p/14971145.html
Copyright © 2020-2023  润新知