Do repeat question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Do repeat question

Maclennan, Graeme S.
Dear all my problem is this:   I have two sets of variables h0 to h5 and a0
to a5, I want to multiply them together so that I have a new set of
variables s1 to s36 such that s1 = a0*h0 , s2 = a0*h1, s3 = a0*h3.... s7 =
a1*h0, s8 = a1*h1 and so on up to s36 = a5*h5.  I have done this before but
I cant remember how, and it's driving me potty.  I am sure I used do repeat,
but perhaps a vector solution would be better.

Suggestions welcomed!
Regards,
Graeme.
Reply | Threaded
Open this post in threaded view
|

Re: Do repeat question

Maguin, Eugene
Graeme,

This should work. I'll assume that h0 to h5 are contigious and a0 to a5 are
contigious. If they aren't things won't work.

Vector a=a0 to a5/h=h0 to h5/s(36).
Loop #i=1 to 6.
Loop #j=1 to 6.
+  compute #k=(#i-1)*6+#j.
+  compute s(#k)=a(#i)*h(#j).
End loop.
End loop.
Execute.


Gene Maguin