help-octave
[Top][All Lists]
Advanced

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

Re: 'for' loop vectorization


From: Francesco Potorti`
Subject: Re: 'for' loop vectorization
Date: Wed, 24 Oct 2007 20:04:02 +0200

I managed to obtain a slight speedup of the triu function like this:

octave> n=3000
n =  3000
octave> t=cputime;a=triu(ones(n,n));cputime-t
ans =  0.77605
octave> 
t=cputime;b=ones(n,n);z=0:n*n-1;b((((0:n-1)'*ones(1,n))(:))'>z/n)=0;cputime-t
ans =  0.69204
octave> all(all(a==b))
ans =  1

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: address@hidden
Web: http://fly.isti.cnr.it/           Key:   fly.isti.cnr.it/public.key


reply via email to

[Prev in Thread] Current Thread [Next in Thread]