Folks,
a script that Marcin sent me privately a few days back prompted Allin and
myself to do some work on optimising certain cases of matrix slicing. We
made a few changes so that if you use constructs such as
X[3:5,]
where you refer to subsets of rows of a matrix you might get a
considerable speedup; here's a little test script to exemplify the change:
<hansl>
set verbose off
ROWS = {10, 100, 1000, 10000}
H = 100000
loop i = 1 .. nelem(ROWS) --quiet
ri = ROWS[i]
C = zeros(ri, 5)
limits = ceil(muniform(H, 2) * ri)
tt0 = 0
tt1 = 0
loop h = 1..H --quiet
ini = minr(limits[h,])
fin = maxr(limits[h,])
s = seq(ini,fin)
set stopwatch
matrix tmp = C[s, 3]
tt0 += $stopwatch
matrix tmp = C[ini:fin, 3]
tt1 += $stopwatch
endloop
printf "%6d rows: seq = %7.5f, range = %7.5f\n", ri, tt0, tt1
endloop
</hansl>
On my laptop, this is what you get before and after the change:
BEFORE:
10 rows: seq = 0.05446, range = 0.05860
100 rows: seq = 0.09540, range = 0.09755
1000 rows: seq = 0.27118, range = 0.25175
10000 rows: seq = 1.82294, range = 1.65042
AFTER:
10 rows: seq = 0.05649, range = 0.04842
100 rows: seq = 0.09460, range = 0.06303
1000 rows: seq = 0.25984, range = 0.11708
10000 rows: seq = 1.78409, range = 0.70894
Now, here's the important part: we're fairly confident that the change
shouldn't break anything, but it's pretty low-level, so if you could try
current git with all the scripts you have and report anything weird, that
would be a big help.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------