借助numpy.matrix.I()函數,我們可以獲得與給定矩陣相同大小的乘法逆。
用法: numpy.matrix.I()
返回:[矩陣對象]如果self不為奇數,則ret使得ret * self == self * ret == np.matrix(np.eye(self [0,:]。size)都返回True。給定矩陣。
代碼1:
# Python program explaining
# numpy.matrix.I() function
# importing numpy as geek
import numpy as geek
mat = geek.matrix('[3, 4; 5, 6]')
# applying matrix.getI() method
gfg = mat.getI()
print(gfg)
輸出:
[[-3. 2. ] [ 2.5 -1.5]]
代碼2:
# Python program explaining
# numpy.matrix.I() function
# importing numpy as geek
import numpy as geek
mat = geek.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
# applying matrix.getI() method
gfg = mat.getI()
print(gfg)
輸出:
[[ -4.50359963e+15 9.00719925e+15 -4.50359963e+15] [ 9.00719925e+15 -1.80143985e+16 9.00719925e+15] [ -4.50359963e+15 9.00719925e+15 -4.50359963e+15]]
相關用法
- Python numpy.cov()用法及代碼示例
- Python numpy.ix_()用法及代碼示例
- Python numpy.ma.notmasked_edges()用法及代碼示例
- Python numpy.ma.flatnotmasked_edges()用法及代碼示例
- Python numpy.nanmean()用法及代碼示例
- Python numpy.ma.flatnotmasked_contiguous()用法及代碼示例
- Python Numpy recarray.dot()用法及代碼示例
- Python numpy.ma.mask_or()用法及代碼示例
- Python numpy.ma.make_mask_none()用法及代碼示例
- Python numpy.ma.mask_cols()用法及代碼示例
- Python numpy.ma.clump_unmasked()用法及代碼示例
- Python Numpy recarray.mean()用法及代碼示例
- Python numpy.ma.clump_masked()用法及代碼示例
注:本文由純淨天空篩選整理自sanjoy_62大神的英文原創作品 Numpy matrix.I function | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。