Arrays of mpz_t

Richard Cavell richardcavell at
Sat Feb 19 01:11:06 CET 2005


I've been trying to create an array of mpz_t.  (See comp.lang.c++ for my threads).  The best solution I have is something like this:

#define MAXMPZ 1000
mpz_t mympz[MAXMPZ];
if (NumberOfMPZNeeded>MAXMPZ) {printf("Increase MAXMPZ"); abort();}
for (int i=0; i<NumberOfMPZNeeded; i++)

This is a bit wasteful of up to MAXMPZ * sizeof (mpz_t) bytes on my heap, plus it's amateurish programming.  Is there a better way?  The new operator fails, as does 
Sign-up for Ads Free at

More information about the gmp-discuss mailing list