使用 SciPy 库查找方阵的行列式
矩阵的行列式,用|A|表示,是一个可以从方阵计算的标量值。借助矩阵的行列式,我们可以找到矩阵的逆以及其他在线性方程组、微积分等系统中有用的东西。名为scipy的函数。计算方阵的行列式。linalg.det()
让我们用下面给出的例子来理解它-
示例
计算2x2矩阵的行列式
#Importing the scipy package
import scipy
#Importing the numpy package
import numpy as np
#Declaring the numpy array (Square Matrix)
X = np.array([[5,1],[8,4]])
#Passing the values to scipy.linalg.det() function
M = scipy.linalg.det(X)
#Printing the result
print('Determinant of \n{} \n is {}'.format(X,M))输出结果Determinant of [[5 1] [8 4]] is 12.0
示例
计算3x3矩阵的行列式
import scipy
import numpy as np
Y = np.array([[1,2,9],[5,4,3],[1,5,3]])
M = scipy.linalg.det(Y)
print('Determinant of \n{} \n is {}'.format(Y,M))输出结果Determinant of [[1 2 9] [5 4 3] [1 5 3]] is 162.0
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬