python矩阵中插入矩阵_Python | 矩阵的痕迹

本文介绍了如何使用Python的numpy库来计算矩阵的迹线,即对角元素之和,这在特征值和矩阵运算中有重要应用。
摘要由CSDN通过智能技术生成

python矩阵中插入矩阵

The sum of diagonal elements of a matrix is commonly known as the trace of the matrix. It is mainly used in eigenvalues and other matrix applications. In this article, we are going to find the trace of a matrix using inbuilt function numpy.trace(a).

矩阵的对角元素之和通常称为矩阵的迹线。 它主要用于特征值和其他矩阵应用中。 在本文中,我们将使用内置函数numpy.trace(a)查找矩阵轨迹

Python代码查找矩阵的痕迹 (Python code to find trace of a matrix)

# Linear Algebra Learning Sequence
# Trace of matrix

import numpy as np

print('Trace of an 3x3 identity matrix : ', np.trace(np.eye(3)))

a = np.arange(9).reshape((3,3))

print(' Matrix a :\n', a)
print('Trace of Matrix a : ', np.trace(a))

Output:

输出:

Trace of an 3x3 identity matrix :  3.0
 Matrix a :
 [[0 1 2]
 [3 4 5]
 [6 7 8]]
Trace of Matrix a :  12


翻译自: https://www.includehelp.com/python/trace-of-a-matrix.aspx

python矩阵中插入矩阵

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值