comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Using two different arrays in tha same calculation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Using two different arrays in tha same calculation [message #2282 is a reply to message #2243] Thu, 09 June 1994 09:09 Go to previous messageGo to previous message
landers is currently offline  landers
Messages: 45
Registered: May 1993
Member
In article <2t49er$dp5@due.uninett.no>, ragnar@kvark.fi.uib.no (Ragnar Aas) writes:
|> I have the following problem :
|>
|> I have two different arrays, (8) of float and (300,8) of float.
|> I want to vectorize the equation and therefore I need to use both
|> arrays in the same equation. For example :
|>
|> newarray=cos(small_array)*sin(large_array)
|>
|> where I want the data in small_array to be used over and over 300 times
|> in this calculation.
|>
|> Hope somebody can help me.
|>
|> Ragnar Aas

Try like this:

a = fltarr(8)
b = fltarr(300,8)

ia = lindgen(300,8) / 300L

c = a(ia) * b

Here's why.... ia is a 300,8 array of indices into the 8-element array.
So ia(*,0) = 0, ia(*,1) = 1, etc.

Then a(ia) becomes a 300,8 array that repeats the 8-element array 300 times.

Note that you'd have to play with this if the index orders were reversed (like
you were trying to operate on an 8-element and a (8,300) arrays). You'd need
to change ia to be lindgen(8,300) mod 8

;Dave
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Does PVWAVE V4.2 work with Motif V1.2 under VMS?
Next Topic: Re: Problems with Idl and Irix 5.2-alpha

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 11:25:07 PDT 2025

Total time taken to generate the page: 0.55666 seconds