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

Home » Public Forums » archive » Initialize new variable array with nan or -9999 values
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: Initialize new variable array with nan or -9999 values [message #87653 is a reply to message #87648] Thu, 20 February 2014 17:36 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Thu, 20 Feb 2014 14:14:54 -0800 (PST), wlandsman wrote:

> For large arrays, there is a speed advantage to using REPLICATE or MAKE_ARRAY in which the array is initialized with the correct value, as opposed to
>
> fltarr(304,336,500) - 9999
>
> in which the array is first initialized with zeros, and then 9999 is subtracted from each element.

Yes, one should think so. But it is not true. "fltarr()-9999" ist
faster than make_array():

IDL> t0=systime(1) &for i=0,9 do a=fltarr(1000,1000,100)-9999.
&print,systime(1)-t0 &help,a
1.8280001
A FLOAT = Array[1000, 1000, 100]
IDL> t0=systime(1) &for i=0,9 do
a=make_array(1000,1000,100,value=-9999.) &print,systime(1)-t0 &help,a
2.7969999
A FLOAT = Array[1000, 1000, 100]
IDL> print,!version
{ x86 Win32 Windows Microsoft Windows 8.0.1 Oct 5 2010 32
64}

Don't ask me why.

Cheers, Heinz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem with cgcmdwindow__define
Next Topic: Position, normal coordinates, and multiple images

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

Current Time: Fri Oct 10 15:46:11 PDT 2025

Total time taken to generate the page: 0.95819 seconds