Re: New & question

new topic     » goto parent     » topic index » view thread      » older message » newer message

Rolf Schroeder writes:
> Still not quite clear to me:
> I'm using sequences for matrix calculations and therefor would
> like to estimate the memory consumption by sequences (representing
> vektors or matrices).
> My question:  how many bytes will be occupied im memory (except small
> overhead) by the sequence s used in the following code?
> Here the code:
>    constant PI = arctan(1)     -- a double presision float (8 byte)
>    sequence s
>    s = {}
>    for i = 1 to 1024 do
>        s = s & i*PI            -- 1024 different doub. pres. floats
>    end for                     --   in a one-dim-sequence

This example is different from the one you presented
yesterday. In the above example, all the floating-point atoms
in sequence s will have different values, so no sharing can take place.
Each f.p. atom will consume 8 bytes for the f.p. value, plus 8 bytes
of overhead for reference count & storage allocation.
So it will be 16*1024 =16K. Also the sequence s will contain
1024*4 bytes = 4K of pointers to these f.p. atoms. So the total
will be 20K.

The memory overhead for f.p. atoms is fairly high, but
suppose you are manipulating sparse matrices (most elements are 0),
or matrices where some rows are the same as other rows, or
matrices where many of the values are integers. You might save
a lot of memory. e.g.

s = repeat(repeat(i, 100), 100)
where i is an integer, will only need a sequence of
100 pointers to a single sequence of 100 4-byte integers.
i.e. about 200x4 =  800 bytes,
not the 10,000*4 = 40000 bytes
that might be needed in some other language.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu