help-octave
[Top][All Lists]
Advanced

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

FYI: caching index vectors


From: Jaroslav Hajek
Subject: FYI: caching index vectors
Date: Mon, 15 Jun 2009 13:37:48 +0200

hi all,

for everyone concerned, I just checked in the following changes:
http://hg.savannah.gnu.org/hgweb/octave/rev/16a5f9e1fdb3
http://hg.savannah.gnu.org/hgweb/octave/rev/e2344f4af0cb

Summary:
real, integer and logical matrices, when used in indexing, will now
cache the internal index_vector value (zero-based indices) when
successfully queried, eliminating the unneeded penalty for subsequent
indexing by the same matrix.
In particular, this means it is no longer needed to avoid indexing by
logical arrays using find() for performance reasons, which seems to be
commonly done in scripts.

A demo benchmark (Core 2 Duo @ 2.83 GHz):

n = 5e3
a = randn(n);
pos = a > 0;
tic;
apos = a(pos);
apos = a(pos);
apos = a(pos);
apos = a(pos);
printf ("without find: %f\n", toc)

tic;
ipos = find(pos);
apos = a(ipos);
apos = a(ipos);
apos = a(ipos);
apos = a(ipos);
printf ("with find: %f\n", toc)


with recent tip, I get:

n =  5000
without find: 1.423126
with find: 0.832042

with the new patches, I get:

n =  5000
without find: 0.621649
with find: 0.629606

so, indexing is once again a bit smarter.

enjoy

PS. I would like to start writing new improvements into NEWS file
again. Should NEWS be renamed to NEWS.32 and new NEWS started?

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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