[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fast matrix filling in IDL
- Subject: Re: Fast matrix filling in IDL
- From: steinhh(at)ulrik.uio.no (Stein Vidar Hagfors Haugan)
- Date: 12 Dec 1998 14:48:01 GMT
- In-reply-to: davidf@dfanning.com's message of Fri, 11 Dec 1998 17:45:13 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of Oslo, Norway
- References: <74s97q$h6j$1@nnrp1.dejanews.com><MPG.10db6a874dcb8bb89896a6@news.frii.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:13116
A slight modification of David's program, and adding
my favourite speedup method:
PRO TEST
m = 1000
n = 500
array = Fltarr(m, n)
v = RandomU(seed, m)
time = systime(1)
FOR i=0,n-1 DO array[*,i] = v
Print, 'Time for Loop: ', systime(1) - time
time = systime(1)
vector = Replicate(1, n)
array = v ## vector
Print, 'Time for Matrix Operations: ', systime(1) - time
time = systime(1)
array = rebin(reform(v,m,1,/overwrite),m,n,/sample)
print, 'Time for Rebin Operations: ', systime(1) - time
END
On { alpha OSF unix 5.2 Oct 30 1998}, this gives:
Time for Loop: 0.27343702
Time for Matrix Operations: 0.093750000
Time for Rebin Operations: 0.067382932
Note that the relative speeds can vary quite a lot on
different architectures.
Regards,
Stein Vidar