Re: The usual vectorising headache [message #43787] |
Mon, 25 April 2005 07:16 |
Edd Edmondson
Messages: 50 Registered: January 2003
|
Member |
|
|
Edd <eddedmondson@hotmail.com> wrote:
> I've ended up with a situation I'm having trouble vectorising effectively.
> The operation I want to do is a
> transpose(p)##q##p
> where p is Array[4] q is Array[4,4]
> Now I need to do this operation with a few tens of thousands of different
> p's, so I've got actually got a p which is Array[bignum,4].
> Obviously I want to vectorise it so I loop over 4s, rather than loop over
> bignums if I have to loop at all, but I don't want to have to completely
> specify the whole operation in individual 0,1,2,3 elements or the code
> looks pretty unreadable (but I'll do that if necessary).
> Anyone got any clever tricks I might use?
Hmm, well I think I've got something that makes sense, but can someone
take a peek and check this comes out right?
tot=0
for j=0,3 do tot+=p[*,j]*(q[0,j]*p[*,0]+q[1,j]*p[*,1]+q[2,j]*p[*,2]$
+q[3,j]*p[*,3])
Still a bit ugly though... hohum.
--
Edd
|
|
|