logo       

Re: Re: matrixmultiply problem: msg#00035

python.numeric.general

Subject: Re: Re: matrixmultiply problem

On Thu, Aug 12, 2004 at 04:05:41PM -0400, Alan G Isaac wrote:
> > The patch is in CVS now.
>
> Can the conditions under which this problem occurs
> be simply stated?
>
> Thank you,
> Alan Isaac

a = some matrix
b = some other matrix
transpose(b) is not contiguous

The numarray 1.0 (and earlier behaviour) is this:
dot(a,b) transposes b internally, finds it's not contiguous, and
makes a contiguous copy. Unfortunately, when it finishes, it
untransposes the *copy* of b back, not b itself.

So after dot(a, b), b is now the transpose of the original matrix

A quick fix is to define your own dot:
def dot(a, b):
return numarray.dot(a, b.view())

The original b is then not touched, and the screwed-up matrix is
discarded. Note that transpose happens by fiddling with the layout of
the dimensions and strides in the array object; the data itself is not
touched.

[This all applies to matrixmultiply also, as matrixmultiply == dot]

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/
|cookedm@xxxxxxxxxxxxxxxxxxx


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise