Boost logo

Boost :

From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 2006-05-29 17:39:07


"Christoph Ludwig" <cludwig_at_[hidden]> wrote in message
news:20060529163902.GE7459_at_castellio.textgrid.it.fh-worms.de...
> On Mon, May 29, 2006 at 03:55:01PM +0200, Maarten Kronenburg wrote:
> > In my opinion the unsigned integer with a modulus
> > is required, which is generalizing the base type
> > unsigned int (which is modular) to any modulus.
>
> I don't understand your motivation for such a type. IIUC there are two
lines
> of reasoning:
>
> 1) There are applications where integers with negative values don't make
any
> sense.
>
> But that is merely a special case of variables with a restricted
> range. There are also bigint applications where a variable can only
take
> prime values or square free values or... Such restrictions are no less
> common than the case of non-negative integers, at least in my
experience
> from computer algebra and cryptography.
>
> Therefore, as David Abrahms pointed out, there should rather be a
generic
> solution for restricted types.
The unsigned_integer is actually a modular_integer with
any modulus, although when the modulus is zero,
it can be any non-negative integer.
But users can make other integer classes with other
restrictions.
This is why these member functions and operators
are virtual in the first place.

>
> 2) The native unsigned type is an integral type with mod 2^n semantics.
Thus,
> there should also be a bigint type with mod 2^n semantics.
>
> Then why restrict yourself to the modulus 2^n? All arbitrary length
integer
> packages I am familiar with also provide modular arithmetic for
arbitrary
> modulus N. (Even if you cannot exploit the factorization of the
modulus,
> modular arithmetic is much more efficient than integer arithmetic
followed
> by a modulus operation. In fact, I would have no use for a bigint
> implementation without efficient modular arithmetic.) Most important is
> certainly the case that N is prime, but composed moduli are also often
> needed. The special case N = 2^n may perhaphs be the easiest one to
> implement, but from a potential user's point of view such a choice
seems
> arbitrary and gratuitous.

As mentioned above, the unsigned_integer is
actually a modular_integer with any modulus,
that can be set with the static function
set_modulus.
So it is not restricted to modulus of form 2^n.
Users can also make a template with an
unsigned_integer data member, and provide
the modulus as a template non-type parameter.

>
> Christoph
>
>
> --
> FH Worms - University of Applied Sciences
> Fachbereich Informatik / Telekommunikation
> Erenburgerstr. 19, 67549 Worms, Germany
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk