in reply to why does this array take up so much memory?
The other thing I did was to pre-set the highest element first. I think you should do that anyway, even if you stick to the two-dimensional style. That prevents perl from doing lots of re-allocations behind the scenes, and pumping up the padding each time.$matrix[4000 + 4000*4000] = 1.0; foreach $x (0..4000) { foreach $y (0..4000) { $matrix[$x + 4000*$y] = 1.0; } }
|
|---|