octave-maintainers
[Top][All Lists]
Advanced

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

octave patch


From: Jaroslav Hajek
Subject: octave patch
Date: Fri, 25 Jan 2008 11:38:56 +0100

hello all developers,
I have noticed that while Octave handles Ranges (l:s:u) as special
objects in a smart way,
they are still being converted to integer vectors whenever used for indexing.
The behaviour can easily be observed using a System Monitor which shows memory:
do
n = 4e7; a = ones(n,1); b = ones(n,1);
now, the sysmon shows that a statement
a(1:n) = b;
allocates several mbytes of memory, while
a(:) = b;
does not.

The problem seems to be that idx_vector is not specialized to hold an
integer range (just single colon).
I have modified the idx_vector_rep class so to be specialized for
ranges (i.e. instead of data array,
store only base and step). The attached two patches (made with diff
-cp as advised in Octave's manual)
show the changes against the "Development" sources from
ftp://ftp.octave.org/pub/octave/bleeding-edge/octave-3.0.0.tar.bz2
Compiled and "make check"ed, all tests pass normally (only my normal
12 fails with test-sparse occur, caused probably
by miscompilation of some of the UMFPACK et al. sparse libraries...]

The redundant allocation problem described above disappears.

I don't know about any octave benchmarks, but there might (hopefully)
be some positive performance impact.

If you find the patch worth applying, please point me to any further
instructions if necessary.

regards,

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

Attachment: idx_vector.h.patch
Description: Text Data

Attachment: idx_vector.cc.patch
Description: Text Data


reply via email to

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