[Numpy-discussion] array vs. matrix performance

Nils Wagner nwagner at iam.uni-stuttgart.de
Mon May 21 09:16:42 EDT 2007


Robert Cimrman wrote:
> I have come to a case where using a matrix would be easier than an
> array. The code uses lots of dot products, so I tested scipy.dot()
> performance with the code below and found that the array version is much
> faster (about 3 times for the given shape). What is the reason for this?
> Or is something wrong with my measurement?
>
> regards,
> r.
>
> ---
> import timeit
> setup = """
> import numpy as nm
> import scipy as sc
> X = nm.random.rand( 100, 3 )
> X = nm.asmatrix( X ) # (un)comment this line.
> print X.shape
> """
> tt = timeit.Timer( 'sc.dot( X.T, X )', setup )
> print tt.timeit()
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>   
Confirmed, but for what reason ?

0.5.3.dev3020
1.0.3.dev3792
Array version
6.84843301773
Matrix version
17.1273219585

Nils


 



More information about the NumPy-Discussion mailing list