in reply to why does this array take up so much memory?
In case you were to try storing integers in a 2D array, may I tell you to look into vec(), as a way to store a one-dimensional array of integers in one scalar? The memory overhead would then become pretty much as you calculated, wasting only 30 bytes per row, while you still have handy single cell access. In case you're new to vec(): it is very much like what substr() is for character strings, except that now it's for arrays of integers, and you only have access to one individual cell at a time. You do have to specify the cell size with every vec() call.
Just to make it perfectly obvious: for a 2D array, you make a 1D (perl) array of such vec scalars.
But, since you really seem to be into floating point numbers, I won't. Take the other people's advice, and first of all, look into PDL, the number crunching suite for Perl.
Well... you could still use pack()/unpack() to store a 1D array of floating point numbers in a string, but it doesn't look very handy to me. You might as well write the stuff in C. ;-)
|
|---|