[Numpy-discussion] BLAS

R.M.Everson R.M.Everson at exeter.ac.uk
Thu Feb 20 15:43:14 CST 2003


As Paul Dubois says, some Numeric functions can be configured to use the
BLAS library.  However, the BLAS is not used for, perhaps the most common
and important operation: matrix/vector multiplication.

We have written a small patch to interface to replace the
matrixproduct/dot/innerproduct functions in multiarraymodule.c with the
appropriate BLAS calls.

The patch (against Numeric 21.1b) can be found at
http://www.dcs.ex.ac.uk/~aschmolc/Numeric and can give a speed up of a
factor of 40 on 1000 by 1000 matrices using the Atlas BLAS.  More details
of the (naive!) timings can be found there too.

We had planned on making a general announcement of this patch (updated to
suit Numeric 22) in a week or so.  However, we have just noticed that
Numeric.dot (=Numeric.innerproduct = Numeric.matrixmultiply) does not take
the complex conjugate of its first argument.  Taking the complex conjugate
seems to me to be the right thing for a routine named dot or innerproduct.
Indeed, until we were bitten by it not taking the conjugate, I thought it

Can someone here explain the rational behind having dot, innerproduct and
matrixmultiply all do the same thing and none of them taking the conjugate?
(Matlab dot() takes the conjugate, although Matlab mtimes() (called for A*B)
does not).

I would propose that innerproduct and dot be changed to take the conjugate
and a new function that doesn't (say, mtimes) be introduced.  I suspect,
however, that this would break too much existing code.  It would be nice to
get it right in Numarray.   Alternatively, can someone suggest how both
functions can be conveniently and non-confusingly exposed?


Paul F Dubois <Paul> writes:
  >> -----Original Message----- From:
  >> numpy-discussion-admin at lists.sourceforge.net
  >> [mailto:numpy-discussion-admin at lists.sourceforge.net] On Behalf Of
  >> Jens Jorgen Mortensen Sent: Thursday, February 20, 2003 3:59 AM To:
  >> numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion]
  >> BLAS
  >> Hi,
  >> When doing matrix-matrix multiplications with large matrices, using
  >> the BLAS library (Basic Linear Algebra Subprograms) can speed up
  >> things a lot. I don't think Numeric takes advantage of this (is this
  >> correct?).

   > No. You can configure it at installation to use the BLAS of choice.

  >> Will numarray be able to do that?
  >> Jens

More information about the Numpy-discussion mailing list