Performance
Herr Witten
lingwitt at bellsouth.net
Sat Feb 21 23:29:18 CET 2004
Thanks. However, the number of numbers grows according to the user, so
I think I'm going to use an array of allocated mpf's that can be used.
In fact, it may be a good feature to add to gmp: The number of
preallocated numbers can be specified and then init methods could
simply grab one.
Herr Witten
On 19 Feb 2004, at 6:07 PM, delta trinity wrote:
> One way, efficient, could be to declare them static. Initialize them
> only once.
>
> Ex:
>
> ...
> static mpf_t A,B,C;
> static int Initialized=0;
>
> if (!Initialized)
> {
> mpf_init_set(A,...
> mpf_init_set(B,...
> mpf_init_set(C,...
> Initialized=1;
> }
> ... (The rest of the function)
>
> Then, the first time, and only the first time the function is called,
> the variables get initialized.
>
> Of course, when the progam terminate, thw structs don't get cleared,
> but usually, the OS clear any memory used locally by the program when
> program terminate.
>
> Eric
More information about the gmp-discuss
mailing list