gmp-discuss Digest, Vol 52, Issue 8

Jim White mathimagics at yahoo.co.uk
Mon Dec 17 23:45:04 CET 2007


Re: Need help for benchmarking multiplication 
  
> 1) if precision is set to 9999999 (7 nines) the
> multiplication needs 0.4seconds. 
>
> However if I set the precision to 9999999 (7 nines) 
> the function needs 5,4 seconds.

I assume the second test should read "9 nines", in
which case the times seem to be consistent.

In my experience, if GMP arithmetic operations at
precision N take time T, then at precision 10 x N they
will take somewhere between 3T and 4T, and at
precision 100 x N they will take around 10T.

> 2) if I generate a number which is 100000 digits
> long, then the problem crashes when it executes 
> mpf_init_set_str(x, createStringDecimal(100000),0);

If it works for smaller lengths then this would seem
to be a bug in your string-creating function, or some
local implementation limit.

In any case, a more reliable way of generating
floating-point test operands of arbitrary precision is
to simply use integer division. 

For example:

   mpf_set_ui (x, 11);
   mpf_div_ui (x, x, 7);

Since 11/7 has no exact f.p. representation, the
result will be calculated to the full declared
precision of x.


Cheers

Jim White
MSI, ANU
Canberra


More information about the gmp-discuss mailing list