Re: vectorising versus loops [message #38442 is a reply to message #38129] |
Sun, 07 March 2004 05:07  |
nasalmon
Messages: 33 Registered: August 2003
|
Member |
|
|
David Fanning <david@dfanning.com> wrote in message news:<MPG.1aa3b24b992bd018989699@news.frii.com>...
> Edd Edmondson writes:
>
>> Funny, that. "I'm just an average astrophysicist" too, and last week I
>> took my IDL program that took a *fortnight* to run and got it down to 21
>> seconds. That's a speed up of 55,000 times.
>
> Well, there you go! I'll have a reporter out later
> this afternoon. :-)
>
> Cheers,
>
> David
Many thanks all for these very useful comments. My software is well on
the way to being vectorised, using all the stuff like WHERE statements
and matrix multiplications, mainly on inner most loops.
However, there is one small outstanding problem in the vectorisation,
and this involves vectorisation of a routine that uses the cross or
vector product, the IDL routine being CROSSP, generating a vector from
the cross product of two vectors.
Currently i am forced to use this in a loop, as my vectorising
attempts (see below) have failed. The loop statement below gives the
correct result (i being the counter of one of the outer loops):
for j = 0,jtot-1 do vec_pip[*,j] = crossp(pixpoly[*,j],normal[*,i])
Naively, putting this in the vector structure i have:
vec_pip[*,0:jtot-1] = crossp(pixpoly[*,0:jtot-1],normal[*,i])
which gives the IDL error message: "% Array subscript for VEC_PIP must
have same size as source expression." - well of course i know that!
Would anybody have any ideas as to how this might be resolved, without
having to resort to working out the cross product from first
principles using determinants and matrix multiplication. Is there any
way the IDL routine could be made to see this as a vectorising process
and compute it without making a fuss.
many thanks, Neil
|
|
|