mpz_t C++ wrapper

Heiko Wundram modelnine at modelnine.org
Fri May 2 09:53:50 CEST 2008


Am Freitag, 2. Mai 2008 06:29:13 schrieben Sie:
> On Thu, May 1, 2008 at 7:36 AM, Roberto Bagnara <bagnara at cs.unipr.it> wrote:
> > Heiko Wundram wrote:
> >  > but if there's any code base
> >  > out there using mpz_class extensively (or someone knows of one they
> >  > can point me at; Google isn't especially helpful here), I'd happily
> >  > give any interested party access to the source so that they can test
> >  > how/if my reimplementation fares better for them.
> >
> >  The Parma Polyhedra Library uses mpz_class extensively.  However, care
> > has been taken to minimize the creation of temporaries.  Still, I think
> > it would constitute a good benchmark for your code.
> >  All the best,
>
> My impression is that the current C++ wrapper already uses template
> metaprogramming
> to eliminate temporaries; or am I looking at the wrong wrapper?

The current wrapper already uses stacked templates to eliminate temporaries 
(just like my wrapper does), just it doesn't take the elimination of 
temporaries to the possible limit (i.e., it creates spurious temporaries as 
soon as you have two or more mpz_class objects in an evaluation chain with 
the same operator).

Even though this wasn't the initial reason of rewriting the mpz_t wrapper for 
me (which was because I wanted the actual bigint object to be transparently 
castable to mpz_ptr and mpz_srcptr, so that get_mpz_t() isn't required 
anymore to pass a bigint object to one of the mpz_* functions), it happened 
to come around to optimizing temporaries "better" than the original wrapper 
does; see my example in the original mail in this thread.

-- 
Heiko Wundram


More information about the gmp-discuss mailing list