[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Too much vectorizing
From: |
Kim Hansen |
Subject: |
Too much vectorizing |
Date: |
Thu, 24 Apr 2008 15:28:16 +0200 |
I have "over vectorized" the following function, it allocates 1.2GB
when it runs and that is not at all necessary as the result is very
sparse.
The problem is that the size of A_capac, Lim and F is 2673x11385,
A_capac is sparse and uses only 848kB but Lim and F is full and uses
243MB each.
I could rewrite the function to use a lot of loops inside each other
and then it wouldn't use as much memory but is there a better way?
function cap_20 = cap_20(nb_locations, nb_mappings, nb_trips, a_capac, f, lim)
A_capac = spkron(a_capac, eye(nb_locations));
Lim = kron(lim, ones(nb_locations*(nb_trips), nb_locations));
F = kron(ones(1,nb_mappings), kron(f, ones(nb_locations,1)));
cap_20.A.c20 = A_capac .* (Lim .* 1 + !Lim .* F);
cap_20.A.flag_heavies_20 = A_capac .* (Lim .* (F-1));
endfunction
I have placed example data for the function in http://ange.dk/~kim/cap_20/
--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437
- Too much vectorizing,
Kim Hansen <=