python矩阵中插入矩阵_Python | 矩阵等级

python矩阵中插入矩阵

The rank of a Matrix is defined as the number of linearly independent columns present in a matrix. The number of linearly independent columns is always equal to the number of linearly independent rows. In this article, we are going to find Rank of a Matrix.

矩阵等级定义为矩阵中存在的线性独立列的数量。 线性独立列的数量始终等于线性独立行的数量。 在本文中,我们将找到矩阵的等级

Rank of matrix in Python

There is an inbuilt function defined in numpy.linalg package as shown below,

numpy.linalg包中定义了一个内置函数,如下所示,

rank = numpy.linalg.matrix_rank(a)

Python代码查找矩阵的等级 (Python code to find rank of a matrix)

# Linear Algebra Learning Sequence
# Rank of a Matrix

import numpy as np

a = np.array([[4,5,8], [7,1,4], [5,5,5], [2,3,6]])

rank = np.linalg.matrix_rank(a)

print('Matrix : ', a)
print('Rank of the given Matrix : ',rank)

Output:

输出:

Matrix :  [[4 5 8]
 [7 1 4]
 [5 5 5]
 [2 3 6]]
Rank of the given Matrix :  3


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

python矩阵中插入矩阵