[Numpy-discussion] big picture? One proposal

Rick White rlw at stsci.edu
Fri Mar 8 05:22:15 CST 2002


On Fri, 8 Mar 2002, Konrad Hinsen wrote:

> "Perry Greenfield" <perry at stsci.edu> writes:
> 
> > Rick White has also convinced me that this alone isn't sufficient.
> > There are numerous occasions where people would like to use matrix
> > multiply, even in a predominately "array" context, enough so that this
> > would justify a special operator for matrix multiplication. If the 
> 
> Could you summarize those reasons please? I know that there are
> applications of matrix multiplication in array processing, but in my
> experience they are rare enough that writing dot(a, b) is not a major
> distraction.

A couple of quick examples: I do lots of image processing (e.g. deconvolution)
using arrays.  It is often helpful to take the outer product of two 1-D
vectors; e.g. if there is a separable function f(x,y) = g(x)*h(y), you can
compute separate g & h vectors and then combine them with outer product (a
special case of matrix multiply) to get the desired 2-D image.

Another example: when I'm working with either 2-D images or 1-D vectors, it
is helpful to be able to compute projections using a set of basis vectors
(e.g. for singular value decomposition, eigenvectors, etc.)  This is most
easily expressed using matrix multiplies - but most uses of the data still
treat them as simple arrays instead of matrices.  Being able to group these
operations together is helpful both for readability of the code and for
efficiency of execution.

Having said that, I think I actually agree with Konrad that these sorts of
operations are rare enough (in the data processing context) that it is no
great burden to write them using function calls instead of operators.  If we
could agree on a matrix-multiply operator, that would be nice -- but if we
can't, I can live with that too.  For my purposes, I certainly don't see the
need to add special operations to do things like transpose.  Those should be
limited to a separate matrix class as Konrad proposes and should be
available as function calls for arrays.
					Rick

------------------------------------------------------------------
Richard L. White    rlw at stsci.edu    http://sundog.stsci.edu/rick/
Space Telescope Science Institute
Baltimore, MD





More information about the Numpy-discussion mailing list