python 矩阵 取对数
In this article, we are going to find the natural logarithm and sign of the Determinant of a Matrix using a single function numpy.linalg.slogdet(a). It returns a tuple in order of (sign and log(det)).
在本文中,我们将使用单个函数numpy.linalg.slogdet(a)来查找矩阵的行列式的自然对数和符号。 它按(sign和log(det))的顺序返回一个元组。
Example: The determinant of a 2-D array [[a, b], [c, d]] is ad - bc
示例:二维数组[[a,b],[c,d]]的行列式为ad-bc
矩阵行列式的符号和自然对数的Python代码 (Python code for sign and natural logarithm of determinant of a matrix)
# Linear Algebra Learning Sequence
# Sign and Log of Determinant
import numpy as np
a = np.array([[1, 2], [3, 4]])
(sign, logdet) = np.linalg.slogdet(a)
print('Matrix : ', a)
prin