借助Numpy matrix.dot()
方法,我們能夠找到一個product
兩個給定矩陣的和,並給出新的維矩陣輸出
用法: matrix.dot()
返回: 兩個矩陣的返回乘積
範例1:
在此示例中,我們可以借助matrix.dot()
方法我們能夠找到兩個給定矩陣的乘積。
# import the important module in python
import numpy as np
# make matrix with numpy
gfg1 = np.matrix('[6, 2, 3]')
gfg2 = np.matrix('[4; 5; 9]')
# applying matrix.dot() method
geeks = gfg1.dot(gfg2)
print(geeks)
輸出:
[[61]]
範例2:
# import the important module in python
import numpy as np
# make a matrix with numpy
gfg1 = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
gfg2 = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
# applying matrix.dot() method
geeks = gfg1.dot(gfg2)
print(geeks)
輸出:
[[ 30 36 42] [ 66 81 96] [102 126 150]]
相關用法
- Python Numpy numpy.ndarray.__add__()用法及代碼示例
- Python Numpy numpy.ndarray.__sub__()用法及代碼示例
- Python Numpy numpy.ndarray.__mul__()用法及代碼示例
- Python Numpy numpy.ndarray.__truediv__()用法及代碼示例
- Python Numpy numpy.ndarray.__xor__()用法及代碼示例
- Python Numpy numpy.ndarray.__pos__()用法及代碼示例
- Python Numpy numpy.ndarray.__and__()用法及代碼示例
- Python Numpy numpy.ndarray.__neg__()用法及代碼示例
- Python Numpy numpy.ndarray.__isub__()用法及代碼示例
- Python Numpy numpy.ndarray.__rshift__()用法及代碼示例
- Python Numpy numpy.ndarray.__iadd__()用法及代碼示例
- Python Numpy numpy.ndarray.__pow__()用法及代碼示例
- Python Numpy numpy.ndarray.__lshift__()用法及代碼示例
- Python Numpy numpy.ndarray.__divmod__()用法及代碼示例
- Python Numpy numpy.ndarray.__invert__()用法及代碼示例
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | Numpy matrix.dot()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。