mpz_t size

delta trinity deltatrinity at hotmail.com
Thu Feb 19 18:32:52 CET 2004


It seem that those specific functions use the stack a lot (stack-memory 
intensive).

You could increase the stack space in your program.  This is usually a 
linker option.


>From: "william" <yAAm at ifrance.Com>
>To: <gmp-discuss at swox.com>
>Subject: mpz_t size
>Date: Mon, 16 Feb 2004 18:23:56 +0100
>
>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
>_______________________________________________
>gmp-discuss mailing list
>gmp-discuss at swox.com
>https://gmplib.org/mailman/listinfo/gmp-discuss

_________________________________________________________________
Get fast, reliable access with MSN 9 Dial-up. Click here for Special Offer! 
http://click.atdmt.com/AVE/go/onm00200361ave/direct/01/



More information about the gmp-discuss mailing list