matrix multiplication

Gregory Ewing greg.ewing at canterbury.ac.nz
Mon Feb 26 18:25:30 EST 2018


Seb wrote:
> I was wondering is whether there's a faster way of
> multiplying each row (1x3) of a matrix by another matrix (3x3), compared
> to looping through the matrix row by row as shown in the code.

Just multiply the two matrices together.

If A is an nx3 matrix and B is a 3x3 matrix, then
C = A @ B is an nx3 matrix where C[i] = A[i] @ B.

(This is a property of matrix multiplication in
general, nothing special about numpy.)

-- 
Greg



More information about the Python-list mailing list