2
A = numpy.matrix([[36, 34, 26],
[18, 44, 1],
[11, 31, 41]])
X1 = numpy.matrix([[46231154], [26619349], [37498603]])
需要將矩陣乘以一個向量。我試過了:Python:當矩陣乘以一個具有numpy的向量時的負數
>>>A*X1
matrix([[ -750624208],
[ 2040910731],
[-1423782060]])
>>> numpy.dot(A,X1)
matrix([[ -750624208],
[ 2040910731],
[-1423782060]])
爲什麼是負數?例如:可以使用較低的數字,例如:
A = numpy.matrix([[36, 34, 26],
[18, 44, 1],
[11, 31, 41]])
X1 = numpy.matrix([[8], [6], [6]])
>>>A*X1
matrix([[58],
[38],
[40]])
謝謝你,羅伯特,現在是確定與D型= np.int64。 –
我同意羅伯特。以下是我機器上64位Python的結果:>>> A = numpy.matrix([[36,34,26],[18,44,1],[11,31,41]])> >> >>> X1 = numpy.matrix([[46231154],[26619349],[37498603]])>>> A * X1矩陣([[3544343088],[2040910731],[2871185236]])>>> numpy.dot(A,X1)矩陣([[3544343088],[2040910731],[2871185236]])>>>這裏是32位Python2.7-32的結果:>>> A = numpy.matrix ([[36,34,26],... [18,44,1],... [11,31,41]])>>> >>> X1 = numpy.matrix([[46231154], [26619349],[37498603]])>>> A * X1矩陣([[-750624208],[2040910731],[ - 1423782060]])>>> numpy.d – redrivercrayon