Boost logo

Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-08-29 06:48:01

--- In boost_at_y..., helmut.zeisel_at_a... wrote:
> The Euclidian algorithm works for every Euclidian
> ring.
> I do not see, why the specific implementation should not work
> e.g. for polynomials.

I see one problem in the current implementation
that restricts it from being applicable to
every Euclidian ring:

    IntegerType a_abs = ( (a < zero) ? -a : +a );

"a < zero" is not meaningful in every Euclidian ring
(consider e.g. the field of arithmetics modulo a prime number
and the Euclidian ring defined by the polynomials over
that field).

One possible solution to that problem would be
to provide a IntegerType-specific function, say normalize:

  IntegerType a_abs = normalize(a);

that is equivalent to abs in the default case
but can be specialized/overloaded for other types.

If not suitable normalization for a specific
Euclidian ring exists,
normalize(x) can just return x;
in that case, gcd will not return
"the" greatest common divisor, but just
one greatest common divisor.


Boost list run by bdawes at, gregod at, cpdaniel at, john at