[SciPy-user] Matlab and Python

Fernando Perez Fernando.Perez at colorado.edu
Wed Jul 13 11:53:43 CDT 2005


Zhiwen Chong wrote:
> On 13-Jul-05, at 8:45 AM, Howey, David A wrote:
> 
>>1) can matrices/vectors be handled in the same way (this is the  
>>power of matlab of course). eg. the matlab 'dot' notation which  
>>operates element by element on matrices. using vectors greatly  
>>speeds up code over for loops and makes it more compact.
> 
> 
> The situation is the reverse in SciPy. A multiplication of two SciPy  
> array objects defaults to an element-by-element multiplication (dot  
> notation in MATLAB, .*, ./ etc.). If you want to do linear algebra in  
> SciPy, you have to explicitly specify a Matrix object.

Just to note that if you want to use normal numeric arrays, and occasionally 
need to multiply them as matrices, you can use dot(A,B) without having to turn 
them into Matrix objects.  It's a function call and not an operator, but it 
may serve better some usage cases where having a Matrix object is unwieldy for 
other reasons (I personally never use Matrix).

Cheers,

f



More information about the SciPy-user mailing list