[SciPy-user] Re: [Numpy-discussion] numarray interface and performance issues (for dot product and transpose)

R.M.Everson R.M.Everson at exeter.ac.uk
Fri Mar 1 03:41:17 CST 2002


Hi,

On 28 Feb 2002, Travis Oliphant wrote:
   > On 28 Feb 2002, A.Schmolck wrote:
  >> Two essential matrix operations (matrix-multiplication and
  >> transposition (which is what I am mainly using) are both
  >> considerably
  >>
  >> a) less efficient and
  >> b) less notationally elegant

   > You are not alone in your concerns.  The developers of SciPy are
   > quite concerned about speed, hence the required linking to ATLAS.

   > The question of notational elegance is stickier because we just
   > can't add new operators.

   > The solution I see is to use other classes.
At the moment, I agree this is probably the best solution, although it
would be nice if the core python was able to add operators :)

  >> The following Matlab fragment
  >> M * (C' * C) * V' * u
  >>

   > This becomes (using SciPy which defines Mat = Matrix.Matrix and
   > could later redefine it to use the ATLAS libraries for matrix
   > multiplication).

   > C, V, u, M = apply(Mat, (C, V, u, M))

   > M * (C.H * C) * V.H * M

Yes, much better.
   > not bad..  and with a Mat class that uses the ATLAS blas (not a
   > very hard thing to do now.), this could be made as fast as
   > MATLAB.

   > Perhaps, as as start we could look at how you make the current
   > Numeric use blas if it is installed to do dot on real and complex
   > arrays (I know you can get rid of lapack_lite and use your own
   > lapack) but, the dot function is defined in multiarray and would
   > have to be modified to use the BLAS instead of its own homegrown
   > algorithm.

This is precisely what Alex and I have done.   Please see the patch to
Numeric and timings on http://www.dcs.ex.ac.uk/~aschmolc/Numeric/
It's not beautiful but about 40 times faster on 1000 by 1000 matrix
multiplies.  I'll attempt to provide a similar patch for numarray over
the next week or so.

Many thanks for your comments.

Richard.




More information about the SciPy-user mailing list