[Numpy-discussion] multiply a lign matrix with a column matrix should return a scalar( matlab yes, numpy no)!!!

Nikolas Tezak Nikolas.Tezak at gmx.de
Wed Feb 3 03:21:17 EST 2010


Hi Laurent,
I'm not sure why this was implemented this way (probably due to  
numerical precision, because the numpy datatypes offer a greater  
variety than python), but in any case you can easily convert the  
result to a float:
 >>> float(line*col)
10
(You probably knew this, but well... :) )

Regards,
Nikolas

Am 03.02.2010 um 09:08 schrieb laurent.feron at free.fr:

> Hello,
>
> if i multiply two matrix, one with a unique line and the second one  
> with a unique column, i should have a scalar:
>
>>>> line
> matrix([[1, 3, 1]])
>>>> col
> matrix([[2],
>        [2],
>        [2]])
>>>> line*col
> matrix([[10]])
>
> Matlab give me a scalar, Numpy does not...
>
> Do you know why?
>
> Regards,
> Laurent
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list