Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent Matlab dot function in numpy?

Is there an equivalent Matlab dot function in numpy?

The dot function in Matlab: For multidimensional arrays A and B, dot returns the scalar product along the first non-singleton dimension of A and B. A and B must have the same size.

In numpy the following is similar but not equivalent:

dot (A.conj().T, B)
like image 301
Kicsi Mano Avatar asked Jul 03 '12 08:07

Kicsi Mano


1 Answers

In MATLAB, dot(A,B) of two matrices A and B of same size is simply:

sum(conj(A).*B)

Equivalent Python/Numpy:

np.sum(A.conj()*B, axis=0)
like image 190
Amro Avatar answered Nov 09 '22 06:11

Amro