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

Home » Public Forums » archive » Re: initializing 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: initializing arrays [message #49066 is a reply to message #49012] Tue, 13 June 2006 15:42 Go to previous message
Marshall Perrin is currently offline  Marshall Perrin
Messages: 44
Registered: December 2005
Member
Ben Tupper <btupper@bigelow.org> wrote:
> johnadams_1980@yahoo.com wrote:
>> Hi All,
>>
>> How do you initialize an array to a specific value without using a for
>> loop?
>>
>> Thanks,
>> KL
>>
> You have choices...
>
> arr = REPLICATE(7.0, [32,5])
>
> arr = MAKE_ARRAY([32,5], VALUE = 7.0)
>
> arr = FLTARR(32,5) + 7.0

And somewhat oddly, all three of these seem to be about equal in
execution speed for me (tested on a Mac G4 creating a [1000,10000]
array of floats filled with 7s). I would've predicted the third one
to be substantially slower due to all thos the additions, but it
doesn't seem to be. Maybe the IDL compiler is doing something clever
under the hood? (Which is good news, anyway, since that's the one I use
most often myself!)

- Marshall
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Using Windows IDL to access a UNIX database using DLM's
Next Topic: is there a command in IDL like bitget command in matlab?

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

Current Time: Wed Oct 08 16:04:41 PDT 2025

Total time taken to generate the page: 0.00177 seconds