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

Home » Public Forums » archive » Re: *replicate* but with arrays
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: *replicate* but with arrays [message #26616 is a reply to message #26615] Mon, 10 September 2001 17:41 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
aqueous0123@yahoo.com (aqueous) writes:
> If I have array a[3,50] and array b[3], how do I fill all rows of a
> with the row vector b? For example, what I want to do is
>
> a = intarr(3,50)
> b = [6,5,4]
> a[0:2,*] = b ;or a[*,*] = b
>
> a should now look like
>
> [6,5,4]
> [6,5,4]
> [6,5,4]
> [6,5,4]
> ...
>
> I thought I could use replicate or makearray, like..
> a = REPLICATE(b, n_elements(b), 50)
> or
> a = MAKE_ARRAY(n_elements(b), 50, /INTEGER, VALUE= b)

Mark and Pavel's responses are fine and dandy. I use REBIN all the
time to do exactly the kind of thing you are after. However, if you
just want a REPLICATE work-alike, then I might suggest the function
CMREPLICATE, available from my web page.

It is standalone and works just like you'd expect, even simpler
actually since you don't specify n_elements(b):

IDL> b = [6,5,4]
IDL> a = cmreplicate(b, 50)
IDL> help, a
A INT = Array[3, 50]

For numeric arrays it uses rebin so it is just as efficient as using
REBIN yourself. However it also works generally on structure arrays
and strings, which are processed differently.

Good luck,
Craig

http://cow.physics.wisc.edu/~craigm/idl/idl.html (under Arrays)

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: *replicate* but with arrays
Next Topic: compiling before needing

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

Current Time: Wed Dec 03 08:08:36 PST 2025

Total time taken to generate the page: 0.39998 seconds