Matrix Multiplications

Stephen Boulet stephen.boulet at motorola.com
Mon Jun 10 10:01:14 EDT 2002


Did you try the "outer" function?

>From the NumPy docs:

<<
outer(a, b)
The third ufunc method is outer, which takes two arrays as arguments and
returns the “outer ufunc” of the two
arguments. Thus the outer method of the multiply ufunc, results in the
outer product. The outer method
is only supported for binary methods.
>>

-- Stephen

Gavin Lusby wrote:
> 
> Dear all,
> 
> I am an engineering student trying to further my research with python
> programming.  Would someone please tell me how I would do a certain
> matrix multiplication in Pythin/NumPy...
> 
> ----------------------------------------------------------------------
> 
> I have two large matricies A[n,n] and B[n,n]
> 
> I would like to get an outer product of:
> 
> C[k+1:,k:] = B[k+1:,k] * A[k,k:]
> 
> where,  k = 0,...,n-1
> 
> It is in effect, an outer product of two vectors of different length.
> 
> ----------------------------------------------------------------------
> 
> I keep getting errors and in the end it's probably something
> straightforward but I'm no Computer Scientist having been spoon-fed
> Fortran 77.
> 
> I would be most grateful if someone could tell me how to do this
> very efficiently in Python.
> 
> Many thaks in advance,
> 
> Gavin Lusby
> 
> *********************************************************
> Gavin Lusby
> University of Edinburgh
> email:    g.h.lusby at sms.ed.ac.uk



More information about the Python-list mailing list