2016-11-18 242 views
0

我想乘用Python 3.x的兩個矩陣,像這樣numpy的:變換矩陣1×4成4X1矩陣

res = A.dot(vertice) 

'A' beign 4x4矩陣和 '頂點' beign 1×4矩陣。

問題是,當我嘗試運行該程序,我得到一個錯誤信息:

ValueError: shapes (4, 4) and (1, 4) are not alligned: 4 (dim1) != 1 (dim0) 

據我所知,有相同數量的矩陣列相乘兩個矩陣的唯一途徑1作爲矩陣2中的行數。

您能否就如何將'vertice'矩陣轉換爲4x1矩陣給出一些建議?

感謝

+0

規則最後暗淡*倒數第二。你穿過第一排,第二排。 'transpose'是你的朋友'vertice.T'。 – hpaulj

+0

'res = A.dot(vertice.T)' –

回答

0

計算轉:

res = A.dot(vertice.T) 
-1

如果您需要的代碼,你可以嘗試 B = np.mat(B) C = np.mat(C)

A = B.T*C.I