mpz_t size

william yAAm at ifrance.Com
Mon Feb 16 18:23:56 CET 2004


Ibuild gmp with cygwin (lib 4.2) and make a program like this : 


unsigned long long int w,i,base,pow,un,q;w=2;un=1;q=4;base=10; 
  mpz_t a,mers,c;
  scanf ("%d",&pow);
  mpz_init(mers);
  mpz_set_ui (mers,un);
  mpz_mul_2exp (mers,mers,pow);
  gmp_printf("\nok pour calcul du mersenne : %d",mpz_sizeinbase(mers,base));
  printf("Puissance : %d",pow);
  mpz_sub_ui (mers,mers,un);
  mpz_init(a);mpz_set_ui (a,q);
    
  for(i=2;i<pow;i++) 
  {
    
    printf ("\n..%d..",i);
    mpz_powm_ui (a,a,w,mers);
    mpz_sub_ui (a,a,w);
  }
  gmp_printf("\n... : %Zd\n",a);
  return 0;
}

But the program refuse to compute number of 2^5 000 000

if i try, the program return a segmentation fault. to my mind, the pb is in the function powm, on each iteration the boucle compute the square  of the number and compute modulo (2^n-1), a traditional mersene algo. 
1 - why cant i compute number over 2 000 000, 
2 - is the powm fuction is the best way to compute square, modulo ? 
thanks a lots for your answers, and sorry for my poor english :)
yaam 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /list-archives/gmp-discuss/attachments/20040216/047e7a24/attachment.htm


More information about the gmp-discuss mailing list