[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undocumented array indexing feature?



R.Bauer wrote:
> > Bill B. wrote:
> [...]
> > Oh, I knew that one, Alex.  Anyone know which method offers faster execution -
> >
> > a = 0 & b = 0    * OR *   a = (b = 0)
> >
> > this is important when applying the same principle to large arrays. At least
> > to those of us with slower PCs :(
> 
> Initializing of big arrays should be done by a=make_array(200,100000,/nozero)
> This is the fastest method
> 
> R.Bauer

but then you have them uninitialized! A fair comparison is 
   a = make_array(dim1,dim2,type)

Here is some timing info (IDL 5.1 on SGI Origin 2000):
[only one pass each, but these numbers don't change much]

A1 = FLTARR(1000,1000) & A2 = FLTARR(1000,1000)
     0.031656981 +      0.032227993 =      0.063884974 seconds

B2 = ( B1 = FLTARR(1000,1000) )
     0.085137010 seconds
 
C1 = MAKE_ARRAY(1000,1000,/FLOAT) & C2 = ...
     0.037186027 +      0.040596962 =      0.077782989 seconds

D1 = MAKE_ARRAY(1000,1000,/FLOAT,/NOZERO) & C2 = ...
   0.00017607212 +    0.00011897087 =    0.00029504299 seconds

                      
Regards,
Martin.

-- 
-------------------------------------------------------------------
Dr. Martin Schultz                   
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax  : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
-------------------------------------------------------------------