Daniel Corona Daniel Corona - 16 days ago 5
Python Question

Transform 1x4 matrix into a 4x1 matrix

I'm trying to multiply two matrices in Python 3.x with numpy like this:

res = A.dot(vertice)


'A' beign a 4x4 matrix and 'vertice' beign a 1x4 matrix.

The problem is when I try running the program, I get the next error message:

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


As far as I know, the only way to multiply two matrices by having the same number of columns in matrix 1 as the number of rows in matrix 2.

Can you give me some advice on how to transform the 'vertice' matrix to a 4x1 one?

Thanks

Answer

Calculate transpose:

res = A.dot(vertice.T)
Comments