diff --git a/Modular_arithmetic/include/CGAL/Modular_traits.h b/Modular_arithmetic/include/CGAL/Modular_traits.h index e0c12e39f32..312eb2f73ad 100644 --- a/Modular_arithmetic/include/CGAL/Modular_traits.h +++ b/Modular_arithmetic/include/CGAL/Modular_traits.h @@ -5,10 +5,18 @@ #include #include -#include #include #include +#ifdef CGAL_USE_LEDA +#include +#endif// CGAL_USE_LEDA + +#ifdef CGAL_USE_CORE +#include +#endif// CGAL_USE_CORE + + namespace CGAL { /*! \ingroup CGAL_Modular_traits_spec @@ -80,7 +88,7 @@ public: }; }; - +#ifdef CGAL_USE_LEDA // TODO: mv to leda_integer.h template<> class Modular_traits< ::leda::integer > { @@ -101,6 +109,43 @@ class Modular_traits< ::leda::integer > { } }; }; +#endif // CGAL_USE_LEDA + +#ifdef CGAL_USE_CORE +// --------------------------------- +// TODO: mv to CORE_BigInt.h + +/*! \ingroup NiX_Modular_traits_spec + * \brief a model of concept ModularTraits, + * specialization of NiX::Modular_traits. + */ +template<> +class Modular_traits< ::CORE::BigInt > { + typedef Modular MOD; + public: + typedef ::CORE::BigInt NT; + typedef CGAL::Tag_true Is_modularizable; + typedef MOD Modular_NT; + + struct Modular_image{ + Modular_NT operator()(const NT& a){ + NT tmp = a % NT(MOD::get_current_prime()); +// TODO: reactivate this assertion +// it fails with core_v1.6x_20040329 +// NiX_assert(tmp.isInt()); + int mi(tmp.longValue()); + if (mi < 0) mi += MOD::get_current_prime(); + return Modular_NT(mi); + } + }; + struct Modular_image_inv{ + NT operator()(const Modular& x){ + return NT(x.get_value()); + } + }; +}; +#endif // CGAL_USE_CORE + //-------------------------------- // TODO : mv to Sqrt_extension.h