From 1793da5074e4de209949b0956a234df79c6f4ef0 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Thu, 2 Aug 2007 14:38:41 +0000 Subject: [PATCH] Removed files with outdated algorithms/data structures, as pre-decided with Michael Hemmer. --- .../include/CGAL/Chinese_remainder_traits.h | 125 ----- .../include/CGAL/chinese_remainder.h | 56 --- .../include/CGAL/euclidean_algorithm.h | 104 ----- .../CGAL/extended_euclidean_algorithm.h | 59 --- Modular_arithmetic/include/CGAL/modular_gcd.h | 427 ------------------ .../Chinese_remainder_traits.C | 69 --- .../Modular_arithmetic/chinese_remainder.C | 62 --- .../Modular_arithmetic/euclidean_algorithm.C | 77 ---- .../extended_euclidean_algorithm.C | 77 ---- .../test/Modular_arithmetic/makefile | 29 +- .../test/Modular_arithmetic/modular_gcd.C | 128 ------ .../test/Modular_arithmetic/src_Modular.C | 5 - 12 files changed, 1 insertion(+), 1217 deletions(-) delete mode 100644 Modular_arithmetic/include/CGAL/Chinese_remainder_traits.h delete mode 100644 Modular_arithmetic/include/CGAL/chinese_remainder.h delete mode 100644 Modular_arithmetic/include/CGAL/euclidean_algorithm.h delete mode 100644 Modular_arithmetic/include/CGAL/extended_euclidean_algorithm.h delete mode 100644 Modular_arithmetic/include/CGAL/modular_gcd.h delete mode 100644 Modular_arithmetic/test/Modular_arithmetic/Chinese_remainder_traits.C delete mode 100644 Modular_arithmetic/test/Modular_arithmetic/chinese_remainder.C delete mode 100644 Modular_arithmetic/test/Modular_arithmetic/euclidean_algorithm.C delete mode 100644 Modular_arithmetic/test/Modular_arithmetic/extended_euclidean_algorithm.C delete mode 100644 Modular_arithmetic/test/Modular_arithmetic/modular_gcd.C delete mode 100644 Modular_arithmetic/test/Modular_arithmetic/src_Modular.C diff --git a/Modular_arithmetic/include/CGAL/Chinese_remainder_traits.h b/Modular_arithmetic/include/CGAL/Chinese_remainder_traits.h deleted file mode 100644 index f5d231aa13a..00000000000 --- a/Modular_arithmetic/include/CGAL/Chinese_remainder_traits.h +++ /dev/null @@ -1,125 +0,0 @@ -// Author(s) : Michael Hemmer - -#ifndef CGAL_CHINESE_REMAINDER_TRAITS_H -#define CGAL_CHINESE_REMAINDER_TRAITS_H 1 - -#include -#include -#include -#include -#include -#include - -namespace CGAL{ - -//TODO: 'm' is recomputed again and again in the current scheme. - -template class Chinese_remainder_traits; -template class Chinese_remainder_traits_base; - - -template class Chinese_remainder_traits - :public Chinese_remainder_traits_base::Algebraic_category>{}; - -template -struct Chinese_remainder_traits_base{ - typedef T_ T; - typedef T_ Scalar_type; - - struct Chinese_remainder{ - void operator() ( - Scalar_type m1, T u1, - Scalar_type m2, T u2, - Scalar_type& m, T& u){ - CGAL::chinese_remainder(m1,u1,m2,u2,m,u); - } - }; -}; - -template -class Chinese_remainder_traits_base{ - typedef T_ T; - typedef void Scalar_type; - typedef Null_functor Chinese_remainder; -}; - - -// Spec for Sqrt_extension -// TODO mv to Sqrt_extension.h - -template class Sqrt_extension; -template -struct Chinese_remainder_traits >{ - typedef Sqrt_extension T; - typedef Chinese_remainder_traits CRT_NT; - typedef Chinese_remainder_traits CRT_ROOT; - - // SAME AS CRT_ROOT::Scalar_type - typedef typename CRT_NT::Scalar_type Scalar_type; - - struct Chinese_remainder{ - void operator() ( - Scalar_type m1, T u1, - Scalar_type m2, T u2, - Scalar_type& m, T& u){ - - NT a0,a1; - ROOT root; - - typename CRT_NT::Chinese_remainder chinese_remainder_nt; - chinese_remainder_nt(m1,u1.a0(),m2,u2.a0(),m,a0); - if(u1.is_extended() || u2.is_extended()){ - chinese_remainder_nt(m1,u1.a1(),m2,u2.a1(),m,a1); - typename CRT_ROOT::Chinese_remainder chinese_remainder_root; - chinese_remainder_root(m1,u1.root(),m2,u2.root(),m,root); - u=T(a0,a1,root); - }else{ - u=T(a0); - } - } - }; - -}; - - - -// Spec for Polynomial -// TODO mv to Polynomial.h - -template class Polynomial; -template -struct Chinese_remainder_traits >{ - typedef Polynomial T; - typedef Chinese_remainder_traits CRT_NT; - - typedef typename CRT_NT::Scalar_type Scalar_type; - - struct Chinese_remainder{ - void operator() ( - Scalar_type m1, T u1, - Scalar_type m2, T u2, - Scalar_type& m, T& u){ - - typename CRT_NT::Chinese_remainder chinese_remainder_nt; - - CGAL_precondition(u1.degree() == u2.degree()); - - std::vector coeffs; - coeffs.reserve(u1.degree()+1); - for(int i = 0; i <= u1.degree(); i++){ - NT c; - chinese_remainder_nt(m1,u1[i],m2,u2[i],m,c); - coeffs.push_back(c); - } - u = Polynomial(coeffs.begin(),coeffs.end()); - } - }; -}; - - - -} // namespace CGAL - -#endif // CGAL_CHINESE_REMAINDER_TRAITS_H // - diff --git a/Modular_arithmetic/include/CGAL/chinese_remainder.h b/Modular_arithmetic/include/CGAL/chinese_remainder.h deleted file mode 100644 index a7ea8cc9966..00000000000 --- a/Modular_arithmetic/include/CGAL/chinese_remainder.h +++ /dev/null @@ -1,56 +0,0 @@ -//Author(s) : Michael Hemmer - -#ifndef CGAL_CHINESE_REMAINDER_H -#define CGAL_CHINESE_REMAINDER_H 1 - -#include -#include - -namespace CGAL { - -// this is just the version for 'integers' -// NT must be model of RealEmbeddable -// NT must be model of EuclideanRing -template -void chinese_remainder( - NT m1, NT u1, - NT m2, NT u2, - NT& m , NT& u ){ - typedef Algebraic_structure_traits AST; - typename AST::Mod mod; - //typename AST::Unit_part unit_part; - typename AST::Integral_division idiv; - - if(u1 < NT(0) ) u1 += m1; - if(u2 < NT(0) ) u2 += m2; - - CGAL_precondition(0 < m1); - CGAL_precondition(u1 < m1); - CGAL_precondition(u1 >= NT(0)); - - CGAL_precondition(0 < m2); - CGAL_precondition(u2 < m2); - CGAL_precondition(u2 >= NT(0)); - - - NT tmp,c,dummy; - tmp = CGAL::extended_euclidean_algorithm(m1,m2,c,dummy); - CGAL_postcondition(tmp == NT(1)); - CGAL_postcondition(m1*c + m2*dummy == NT(1)); - - - m = m1*m2; - NT v = mod(c*(u2-u1),m2); - u = m1*v + u1; - - // u is not unique yet! - NT m_half = idiv(m-mod(m,NT(2)),NT(2)); - if (u > m_half) u -= m ; - if (u <= -m_half) u += m ; - -} - -}///namespace CGAL - -#endif //#ifnedef CGAL_CHINESE_REMAINDER_H 1 - diff --git a/Modular_arithmetic/include/CGAL/euclidean_algorithm.h b/Modular_arithmetic/include/CGAL/euclidean_algorithm.h deleted file mode 100644 index 652250cba00..00000000000 --- a/Modular_arithmetic/include/CGAL/euclidean_algorithm.h +++ /dev/null @@ -1,104 +0,0 @@ - -// Author(s) : Lutz Kettner -// Author(s) : Michael Hemmer - - -/*! \file CGAL/euclidean_algorithm.h - \brief Defines funciton related to euclids algorithm. -*/ - -#ifndef CGAL_EUCLIDEAN_ALGORITHM_H -#define CGAL_EUCLIDEAN_ALGORITHM_H 1 - -// This forward declaration is required to resolve the circular dependency -// between euclidean_algorithm and the partial specializations of NT_Traits -// for the built-in number types. - -namespace CGAL { - template - NT euclidean_algorithm( const NT& a, const NT& b); -} - -#include -#include - - -namespace CGAL { - -// We have a circular header file inclusion dependency with -// CGAL/Algebraic_structure_traits.h. -// As a consequence, we might not get the declaration for -// CGAL::Algebraic_structure_traits -// although we include the header file above. We repeat the declaration -// here. We still include the header file to hide this dependency from users -// such that they get the full Algebraic_structure_traits declaration after -// including euclid_algorithm.h. - -template class Algebraic_structure_traits; - - -/*! \brief generic Euclids algorithm, returns the unit - normal greatest common devisor (gcd) of \a a and \a b. - - Requires the number type \c NT to be a model of the concepts - \c EuclideanRing, however, it uses only - the functors \c Mod and \c Unit_part from the \c - Algebraic_structure_traits, and the equality comparison operator. - The implementation uses loop unrolling to avoid swapping the local - variables all the time. -*/ -template -NT euclidean_algorithm( const NT& a, const NT& b) { - typedef Algebraic_structure_traits AST; - typename AST::Mod mod; - typename AST::Unit_part unit_part; - typename AST::Integral_division idiv; - // First: the extreme cases and negative sign corrections. - if (a == NT(0)) { - if (b == NT(0)) - return NT(0); - return idiv(b,unit_part(b)); - } - if (b == NT(0)) - return idiv(a,unit_part(a)); - NT u = idiv(a,unit_part(a)); - NT v = idiv(b,unit_part(b)); - // Second: assuming mod is the most expensive op here, we don't compute it - // unnecessarily if u < v - if (u < v) { - v = mod(v,u); - // maintain invariant of v > 0 for the loop below - if ( v == 0) - return idiv(u,unit_part(u)); - } - // Third: generic case of two positive integer values and u >= v. - // The standard loop would be: - // while ( v != 0) { - // int tmp = mod(u,v); - // u = v; - // v = tmp; - // } - // return u; - // - // But we want to save us all the variable assignments and unroll - // the loop. Before that, we transform it into a do {...} while() - // loop to reduce branching statements. - NT w; - do { - w = mod(u,v); - if ( w == 0) - return idiv(v,unit_part(v)); - u = mod(v,w); - if ( u == 0) - return idiv(w,unit_part(w)); - v = mod(w,u); - } while (v != 0); - return idiv(u,unit_part(u));; -} - -// TODO: do we need a variant for unit normal inputs? - -} // namespace CGAL - -#endif // CGAL_EUCLIDEAN_ALGORITHM_H // -// EOF diff --git a/Modular_arithmetic/include/CGAL/extended_euclidean_algorithm.h b/Modular_arithmetic/include/CGAL/extended_euclidean_algorithm.h deleted file mode 100644 index c257406b2ae..00000000000 --- a/Modular_arithmetic/include/CGAL/extended_euclidean_algorithm.h +++ /dev/null @@ -1,59 +0,0 @@ -//Author(s) : Michael Hemmer - -#ifndef CGAL_EXTENDED_EUCLIDEAN_ALGORITHM_H -#define CGAL_EXTENDED_EUCLIDEAN_ALGORITHM_H 1 - -#include - -namespace CGAL { - -template< class NT > -NT extended_euclidean_algorithm(const NT& a_, const NT& b_, NT& u, NT& v){ - - typedef Algebraic_structure_traits AST; - typename AST::Div_mod div_mod; - typename AST::Unit_part unit_part; - typename AST::Integral_division idiv; - - NT unit_part_a(unit_part(a_)); - NT unit_part_b(unit_part(b_)); - - NT a(idiv(a_,unit_part_a)); - NT b(idiv(b_,unit_part_b)); - - - NT x(0),y(1),last_x(1),last_y(0); - NT temp, quotient; -// typename AST::Div div; -// typename AST::Mod mod; - - //TODO: unroll to avoid swapping - while (b != 0){ - temp = b; - div_mod(a,b,quotient,b); - a = temp; - temp = x; - x = last_x-quotient*x; - last_x = temp; - - temp = y; - y = last_y-quotient*y; - last_y = temp; - } - u = last_x * unit_part_a; - v = last_y * unit_part_b; - -// std::cout <<"a_: "< - -/*! \file CGAL/modular_gcd.h - provides gcd for Polynomials, based on Modular arithmetic. -*/ - - -#ifndef CGAL_MODULAR_GCD_H -#define CGAL_MODULAR_GCD_H 1 - -#include -#include -#include -#include -#include -#include - -//#include - -namespace CGAL { - -template -typename Scalar_factor_traits::Scalar -scalar_factor(const NT& x){ - typename Scalar_factor_traits::Scalar_factor scalar_factor; - return scalar_factor(x); -} -template -typename Scalar_factor_traits::Scalar -scalar_factor(const NT& x,const typename Scalar_factor_traits::Scalar& d){ - typename Scalar_factor_traits::Scalar_factor scalar_factor; - return scalar_factor(x,d); -} - -template -typename Modular_traits::Modular_NT -modular_image(const NT& x){ - typename Modular_traits::Modular_image modular_image; - return modular_image(x); -} - -template class MY_INT_TAG{}; - -template -bool operator < (const std::vector& a, const std::vector& b){ - for(unsigned int i = 0; i < a.size(); i++){ - if (a[i] < b[i]) return true; - } - return false; -} - -template -std::vector min(const std::vector& a, const std::vector& b){ - return (a < b)?a:b; -} - -//ALGORITHM P (TODO) -template -Polynomial algorithm_x( - const Polynomial & p1, const Polynomial & p2, TAG){ - CGAL_precondition(Polynomial_traits_d< Polynomial >::d > 1); - - typedef Polynomial Poly; - typedef Polynomial_traits_d PT; - typedef typename PT::Innermost_coefficient IC; - - const int num_of_vars = PT::d; - typename PT::Innermost_leading_coefficient ilcoeff; - typename PT::Degree_vector degree_vector; - - // will play the role of content - typedef typename Scalar_factor_traits::Scalar Scalar; - - typedef typename Modular_traits::Modular_NT MPoly; - typename Polynomial_traits_d::Degree_vector mdegree_vector; - typedef typename Modular_traits::Modular_NT MScalar; - - typedef Chinese_remainder_traits CRT; - typename CRT::Chinese_remainder chinese_remainder; - - typename Polynomial_traits_d::Canonicalize canonicalize; - Poly F1 = canonicalize(p1); - Poly F2 = canonicalize(p2); - - //std::cout <<" F1 : " << F1 <::Denominator_for_algebraic_integers dfai; - typename Algebraic_extension_traits::Normalization_factor nfac; - - // in case IC is an algebriac extension it may happen, that - // Fx=G*Hx is not possible if the coefficients are algebraic integers - Poly tmp = F1+F2; - - IC denom = dfai(begin(tmp),end(tmp)); // TODO use this - //IC denom = dfai(tmp.begin(),tmp.end()); - denom *= nfac(denom); - tmp = Poly(denom); - F1 *=tmp; - F2 *=tmp; - } - - //std::cout <<" F1*denom*nafc: " << F1 < dv_F1 = degree_vector(F1); - std::vector dv_F2 = degree_vector(F2); - std::vector dv_e = min(dv_F1,dv_F2);; - - MScalar mg_; - MPoly mF1,mF2,mG_,mH1,mH2; - - typename CRT::Scalar_type p,q,pq; - Poly Gs,H1s,H2s; // s =^ star - while(!solved){ - do{ - //--------------------------------------- - //choose prime not deviding f1 or f2 - do{ - prime_index++; - CGAL_precondition(0<= prime_index && prime_index < 64); - int current_prime = primes[prime_index]; - Modular::set_current_prime(current_prime); - } - while(!(( modular_image(f1) != 0 ) && ( modular_image(f2) != 0 ))); - // -------------------------------------- - // invoke gcd for current prime - mg_ = CGAL::modular_image(g_); - mF1 = CGAL::modular_image(F1_); - mF2 = CGAL::modular_image(F2_); - // replace mG_ = gcd (mF1,mF2)*MPoly(mg_); for multivariat - mG_ = algorithm_x(mF1,mF2,MY_INT_TAG())*MPoly(mg_); - mH1 = CGAL::integral_division(mF1,mG_); - mH2 = CGAL::integral_division(mF2,mG_); - //--------------------------------------- - // return if G is constant - if (mG_ == MPoly(1)) return Poly(1); - // -------------------------------------- - }// repeat until mG_ degree is less equal the known bound - // check prime - while( mdegree_vector(mG_) > dv_e); - - if(mdegree_vector(mG_) < dv_e ){ - // restart chinese remainder - // ignore previous unlucky primes - n=1; - dv_e= mdegree_vector(mG_); - }else{ - CGAL_postcondition( mdegree_vector(mG_)== dv_e); - n++; // increase number of lucky primes - } - - // -------------------------------------- - // try chinese remainder - - //std::cout <<" chinese remainder round :" << n << std::endl; - typename Modular_traits::Modular_image_inv inv_map; - if(n == 1){ - // init chinese remainder - q = Modular::get_current_prime(); // implicit ! - Gs = inv_map(mG_); - H1s = inv_map(mH1); - H2s = inv_map(mH2); - }else{ - // continue chinese remainder - - int p = Modular::get_current_prime(); // implicit! - //std::cout <<" p: "<< p< -Polynomial algorithm_x( - const Polynomial & p1, const Polynomial & p2, MY_INT_TAG<1> ){ - typedef Polynomial Poly; - BOOST_STATIC_ASSERT(Polynomial_traits_d::d == 1); - typedef Algebraic_structure_traits AST; - typedef typename AST::Algebraic_category TAG; - BOOST_STATIC_ASSERT((boost::is_same::value)); - return gcd(p1,p2); -} - -// TODO: ALGORITHM M -template -Polynomial modular_gcd_utcf( - const Polynomial& FF1 , - const Polynomial& FF2 ){ - CGAL_precondition(Polynomial_traits_d >::d == 1); - - typedef Polynomial Poly; - typedef Polynomial_traits_d PT; - - const int num_of_vars = PT::d; - typedef typename PT::Innermost_coefficient IC; - typename PT::Innermost_leading_coefficient ilcoeff; - typename PT::Degree_vector degree_vector; - - // will paly the role of content - typedef typename Scalar_factor_traits::Scalar Scalar; - - typedef typename Modular_traits::Modular_NT MPoly; - typename Polynomial_traits_d::Degree_vector mdegree_vector; - typedef typename Modular_traits::Modular_NT MScalar; - - typedef Chinese_remainder_traits CRT; - typename CRT::Chinese_remainder chinese_remainder; - - typename Polynomial_traits_d::Canonicalize canonicalize; - Poly F1 = canonicalize(FF1); - Poly F2 = canonicalize(FF2); - - //std::cout <<" F1 : " << F1 < POLY; - //typename Polynomial_traits_d::Innermost_coefficient_to_polynomial ictp; - //typename Polynomial_traits_d::Innermost_coefficient_begin begin; - //typename Polynomial_traits_d::Innermost_coefficient_end end; - typename Algebraic_extension_traits::Denominator_for_algebraic_integers dfai; - typename Algebraic_extension_traits::Normalization_factor nfac; - - // in case IC is an algebriac extension it may happen, that - // Fx=G*Hx is not possible if the coefficients are algebraic integers - Poly tmp = F1+F2; - - //IC denom = dfai(begin(tmp),end(tmp)); // TODO use this - IC denom = dfai(tmp.begin(),tmp.end()); - denom *= nfac(denom); - tmp = Poly(denom); - F1 *=tmp; - F2 *=tmp; - } - - //std::cout <<" F1*denom*nafc: " << F1 < dv_F1 = degree_vector(F1); - std::vector dv_F2 = degree_vector(F1); - std::vector dv_e = min(dv_F1,dv_F2);; - - MScalar mg_; - MPoly mF1,mF2,mG_,mH1,mH2; - - typename CRT::Scalar_type p,q,pq; - Poly Gs,H1s,H2s; // s =^ star - while(!solved){ - do{ - //--------------------------------------- - //choose prime not deviding f1 or f2 - do{ - prime_index++; - CGAL_precondition(0<= prime_index && prime_index < 64); - int current_prime = primes[prime_index]; - Modular::set_current_prime(current_prime); - } - while(!(( modular_image(f1) != 0 ) && ( modular_image(f2) != 0 ))); - // -------------------------------------- - // invoke gcd for current prime - mg_ = CGAL::modular_image(g_); - mF1 = CGAL::modular_image(F1_); - mF2 = CGAL::modular_image(F2_); - // replace mG_ = gcd (mF1,mF2)*MPoly(mg_); for multivariat - mG_ = algorithm_x(mF1,mF2,MY_INT_TAG())*MPoly(mg_); - mH1 = CGAL::integral_division(mF1,mG_); - mH2 = CGAL::integral_division(mF2,mG_); - //--------------------------------------- - // return if G is constant - if (mG_ == MPoly(1)) return Poly(1); - // -------------------------------------- - }// repeat until mG_ degree is less equal the known bound - // check prime - while( mdegree_vector(mG_) > dv_e); - - if(mdegree_vector(mG_) < dv_e ){ - // restart chinese remainder - // ignore previous unlucky primes - n=1; - dv_e= mdegree_vector(mG_); - }else{ - CGAL_postcondition( mdegree_vector(mG_)== dv_e); - n++; // increase number of lucky primes - } - - // -------------------------------------- - // try chinese remainder - - //std::cout <<" chinese remainder round :" << n << std::endl; - typename Modular_traits::Modular_image_inv inv_map; - if(n == 1){ - // init chinese remainder - q = Modular::get_current_prime(); // implicit ! - Gs = inv_map(mG_); - H1s = inv_map(mH1); - H2s = inv_map(mH2); - }else{ - // continue chinese remainder - - int p = Modular::get_current_prime(); // implicit! - //std::cout <<" p: "<< p< - -#include -#include -#include - -#ifdef CGAL_USE_LEDA -#include -#endif - -#ifdef CGAL_USE_CORE -#include -#endif - -template -void test_chinese_remainder_traits(){ - typedef typename CRT::T T; - typedef typename CRT::Scalar_type Scalar_type; - typedef typename CRT::Chinese_remainder Chinese_remainder; - Chinese_remainder chinese_remainder; - - T x(-574); - Scalar_type m1 = Scalar_type(23); - Scalar_type m2 = Scalar_type(17); - Scalar_type m3 = Scalar_type(29); - T u1 = -T(22); - T u2 = -T(13); - T u3 = -T(23); - Scalar_type m; - T u; - - chinese_remainder(m1,u1,m2,u2,m,u); - chinese_remainder(m ,u ,m3,u3,m,u); - - CGAL_test_assert( m == m1*m2*m3 ); - CGAL_test_assert( x == u ); - -} - - -int main(){ - - test_chinese_remainder_traits >(); - typedef CGAL::Sqrt_extension Extn_1; - typedef CGAL::Sqrt_extension Extn_2; - typedef CGAL::Sqrt_extension Extn_n2; - - test_chinese_remainder_traits >(); - test_chinese_remainder_traits >(); - test_chinese_remainder_traits >(); - - typedef CGAL::Polynomial Poly_1; - typedef CGAL::Polynomial Poly_2; - test_chinese_remainder_traits >(); - test_chinese_remainder_traits >(); - - -#ifdef CGAL_USE_CORE - test_chinese_remainder_traits< - CGAL::Chinese_remainder_traits >(); -#endif - -#ifdef CGAL_USE_LEDA - test_chinese_remainder_traits< - CGAL::Chinese_remainder_traits >(); -#endif - - -} diff --git a/Modular_arithmetic/test/Modular_arithmetic/chinese_remainder.C b/Modular_arithmetic/test/Modular_arithmetic/chinese_remainder.C deleted file mode 100644 index 8203794f5c2..00000000000 --- a/Modular_arithmetic/test/Modular_arithmetic/chinese_remainder.C +++ /dev/null @@ -1,62 +0,0 @@ -// Author(s) : Michael Hemmer - - -#include - -#include -#include -#include - -#ifdef CGAL_USE_LEDA -#include -#endif - -#ifdef CGAL_USE_CORE -#include -#endif - -template -void test_chinese_remainder(NT x){ - typedef CGAL::Algebraic_structure_traits AST; - typename AST::Mod mod; - - NT m1 = 23; - NT m2 = 17; - NT m3 = 29; - NT u1 = mod(x,m1); - NT u2 = mod(x,m2); - NT u3 = mod(x,m3); - NT m,u; - - CGAL::chinese_remainder(m1,u1,m2,u2,m,u); - CGAL::chinese_remainder(m ,u ,m3,u3,m,u); - - CGAL_test_assert( m == m1*m2*m3 ); - CGAL_test_assert( x == u ); -} - -template -void test_chinese_remainder(){ - test_chinese_remainder(NT(0)); - test_chinese_remainder(NT(1)); - test_chinese_remainder(NT(-1)); - test_chinese_remainder(NT(23)); - test_chinese_remainder(NT(17)); - test_chinese_remainder(NT(-29)); - test_chinese_remainder(NT(2456)); - test_chinese_remainder(NT(-2456)); -} - -int main(){ - test_chinese_remainder(); - -#ifdef CGAL_USE_LEDA - test_chinese_remainder(); -#endif - -#ifdef CGAL_USE_CORE - test_chinese_remainder(); -#endif - - return 0; -} diff --git a/Modular_arithmetic/test/Modular_arithmetic/euclidean_algorithm.C b/Modular_arithmetic/test/Modular_arithmetic/euclidean_algorithm.C deleted file mode 100644 index d8cd29b6221..00000000000 --- a/Modular_arithmetic/test/Modular_arithmetic/euclidean_algorithm.C +++ /dev/null @@ -1,77 +0,0 @@ -// Author(s) : Michael Hemmer - - -#include - -#include -#include - -#ifdef CGAL_USE_LEDA -#include -#endif - -#ifdef CGAL_USE_CORE -#include -#endif - -#include - - -template -void test_euclidean_algorithm(){ - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 0),NT(0)) == NT( 0)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 7),NT(0)) == NT( 7)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT(-7),NT(0)) == NT( 7)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 0),NT(7)) == NT( 7)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT(0),NT(-7)) == NT( 7)); - - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 1),NT(1)) == NT( 1)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 7),NT(1)) == NT( 1)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT(-7),NT(1)) == NT( 1)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 1),NT(7)) == NT( 1)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT(1),NT(-7)) == NT( 1)); - - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 7),NT(7)) == NT( 7)); - - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 3),NT(1)) == NT( 1)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 3),NT(6)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 6),NT(9)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 9),NT(15)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 15),NT(24)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 24),NT(39)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 39),NT(63)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 6),NT(3)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 9),NT(6)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 15),NT(9)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 24),NT(15)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 39),NT(24)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 63),NT(39)) == NT( 3)); - - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -3),NT(6)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -6),NT(9)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -9),NT(15)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -15),NT(24)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -6),NT(3)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -9),NT(6)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -15),NT(9)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -24),NT(15)) == NT( 3)); - - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 3),NT(-1)) == NT( 1)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 3),NT(-6)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 6),NT(-9)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 6),NT(-3)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( 9),NT(-6)) == NT( 3)); - - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -3),NT(-6)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -6),NT(-9)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -6),NT(-3)) == NT( 3)); - CGAL_test_assert( CGAL::euclidean_algorithm(NT( -9),NT(-6)) == NT( 3)); -} - - -int main(){ - test_euclidean_algorithm(); - test_euclidean_algorithm(); - test_euclidean_algorithm(); - return 0; -} diff --git a/Modular_arithmetic/test/Modular_arithmetic/extended_euclidean_algorithm.C b/Modular_arithmetic/test/Modular_arithmetic/extended_euclidean_algorithm.C deleted file mode 100644 index 4d1bfa9abee..00000000000 --- a/Modular_arithmetic/test/Modular_arithmetic/extended_euclidean_algorithm.C +++ /dev/null @@ -1,77 +0,0 @@ -// Author(s) : Michael Hemmer - - -#include - -#include -#include -#include - - -template -void test_extended_euclidean_algorithm -(const NT& a, const NT& b, const NT& g_){ - NT u,v; - NT g = CGAL::extended_euclidean_algorithm(a,b,u,v); - CGAL_test_assert(g_ == g) ; - CGAL_test_assert(g_ == u*a+v*b); -} - - -template -void test_extended_euclidean_algorithm(){ - - test_extended_euclidean_algorithm(NT( 0),NT(0) , NT( 0)); - test_extended_euclidean_algorithm(NT( 7),NT(0) , NT( 7)); - test_extended_euclidean_algorithm(NT(-7),NT(0) , NT( 7)); - test_extended_euclidean_algorithm(NT( 0),NT(7) , NT( 7)); - test_extended_euclidean_algorithm(NT(0),NT(-7) , NT( 7)); - - test_extended_euclidean_algorithm(NT( 1),NT(1) , NT( 1)); - test_extended_euclidean_algorithm(NT( 7),NT(1) , NT( 1)); - test_extended_euclidean_algorithm(NT(-7),NT(1) , NT( 1)); - test_extended_euclidean_algorithm(NT( 1),NT(7) , NT( 1)); - test_extended_euclidean_algorithm(NT(1),NT(-7) , NT( 1)); - - test_extended_euclidean_algorithm(NT( 7),NT(7) , NT( 7)); - - test_extended_euclidean_algorithm(NT( 3),NT(1) , NT( 1)); - test_extended_euclidean_algorithm(NT( 3),NT(6) , NT( 3)); - test_extended_euclidean_algorithm(NT( 6),NT(9) , NT( 3)); - test_extended_euclidean_algorithm(NT( 9),NT(15) , NT( 3)); - test_extended_euclidean_algorithm(NT( 15),NT(24) , NT( 3)); - test_extended_euclidean_algorithm(NT( 24),NT(39) , NT( 3)); - test_extended_euclidean_algorithm(NT( 39),NT(63) , NT( 3)); - test_extended_euclidean_algorithm(NT( 6),NT(3) , NT( 3)); - test_extended_euclidean_algorithm(NT( 9),NT(6) , NT( 3)); - test_extended_euclidean_algorithm(NT( 15),NT(9) , NT( 3)); - test_extended_euclidean_algorithm(NT( 24),NT(15) , NT( 3)); - test_extended_euclidean_algorithm(NT( 39),NT(24) , NT( 3)); - test_extended_euclidean_algorithm(NT( 63),NT(39) , NT( 3)); - - test_extended_euclidean_algorithm(NT( -3),NT(6) , NT( 3)); - test_extended_euclidean_algorithm(NT( -6),NT(9) , NT( 3)); - test_extended_euclidean_algorithm(NT( -9),NT(15) , NT( 3)); - test_extended_euclidean_algorithm(NT( -15),NT(24) , NT( 3)); - test_extended_euclidean_algorithm(NT( -6),NT(3) , NT( 3)); - test_extended_euclidean_algorithm(NT( -9),NT(6) , NT( 3)); - test_extended_euclidean_algorithm(NT( -15),NT(9) , NT( 3)); - test_extended_euclidean_algorithm(NT( -24),NT(15) , NT( 3)); - - test_extended_euclidean_algorithm(NT( 3),NT(-1) , NT( 1)); - test_extended_euclidean_algorithm(NT( 3),NT(-6) , NT( 3)); - test_extended_euclidean_algorithm(NT( 6),NT(-9) , NT( 3)); - test_extended_euclidean_algorithm(NT( 6),NT(-3) , NT( 3)); - test_extended_euclidean_algorithm(NT( 9),NT(-6) , NT( 3)); - - test_extended_euclidean_algorithm(NT( -3),NT(-6) , NT( 3)); - test_extended_euclidean_algorithm(NT( -6),NT(-9) , NT( 3)); - test_extended_euclidean_algorithm(NT( -6),NT(-3) , NT( 3)); - test_extended_euclidean_algorithm(NT( -9),NT(-6), NT( 3)); -} - - -int main(){ - test_extended_euclidean_algorithm(); - return 0; -} diff --git a/Modular_arithmetic/test/Modular_arithmetic/makefile b/Modular_arithmetic/test/Modular_arithmetic/makefile index 5b425559112..221bd16d686 100644 --- a/Modular_arithmetic/test/Modular_arithmetic/makefile +++ b/Modular_arithmetic/test/Modular_arithmetic/makefile @@ -15,7 +15,6 @@ include $(CGAL_MAKEFILE) CXXFLAGS = \ -I../../include \ - -I../../../Polynomial/include \ -I../../../Number_types/test/Number_types/include \ $(CGAL_CXXFLAGS) \ $(LONG_NAME_PROBLEM_CXXFLAGS) @@ -36,44 +35,18 @@ LDFLAGS = \ #---------------------------------------------------------------------# all: \ - chinese_remainder$(EXE_EXT) \ - Chinese_remainder_traits$(EXE_EXT) \ - euclidean_algorithm$(EXE_EXT) \ - extended_euclidean_algorithm$(EXE_EXT) \ Modular$(EXE_EXT) \ - modular_gcd$(EXE_EXT) \ Modular_traits$(EXE_EXT) -chinese_remainder$(EXE_EXT): chinese_remainder$(OBJ_EXT) - $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)chinese_remainder chinese_remainder$(OBJ_EXT) $(LDFLAGS) - -Chinese_remainder_traits$(EXE_EXT): Chinese_remainder_traits$(OBJ_EXT) - $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)Chinese_remainder_traits Chinese_remainder_traits$(OBJ_EXT) $(LDFLAGS) - -euclidean_algorithm$(EXE_EXT): euclidean_algorithm$(OBJ_EXT) - $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)euclidean_algorithm euclidean_algorithm$(OBJ_EXT) $(LDFLAGS) - -extended_euclidean_algorithm$(EXE_EXT): extended_euclidean_algorithm$(OBJ_EXT) - $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)extended_euclidean_algorithm extended_euclidean_algorithm$(OBJ_EXT) $(LDFLAGS) - Modular$(EXE_EXT): Modular$(OBJ_EXT) $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)Modular Modular$(OBJ_EXT) $(LDFLAGS) -modular_gcd$(EXE_EXT): modular_gcd$(OBJ_EXT) - $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)modular_gcd modular_gcd$(OBJ_EXT) $(LDFLAGS) - Modular_traits$(EXE_EXT): Modular_traits$(OBJ_EXT) $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)Modular_traits Modular_traits$(OBJ_EXT) $(LDFLAGS) clean: \ - chinese_remainder.clean \ - Chinese_remainder_traits.clean \ - euclidean_algorithm.clean \ - extended_euclidean_algorithm.clean \ Modular.clean \ - modular_gcd.clean \ - Modular_traits.clean \ - src_Modular.clean + Modular_traits.clean #---------------------------------------------------------------------# # suffix rules diff --git a/Modular_arithmetic/test/Modular_arithmetic/modular_gcd.C b/Modular_arithmetic/test/Modular_arithmetic/modular_gcd.C deleted file mode 100644 index 91d6d209227..00000000000 --- a/Modular_arithmetic/test/Modular_arithmetic/modular_gcd.C +++ /dev/null @@ -1,128 +0,0 @@ -// Author(s) : Michael Hemmer - -/*! \file CGAL/Modular.C - test for number type modul -*/ - -#include -#include -#include -#include -#include - -#ifdef CGAL_USE_LEDA -#include -#endif // CGAL_USE_LEDA - -#include - -#include - -int main() -{ - { - typedef leda::integer Integer; - typedef CGAL::Polynomial Polynomial; - Polynomial p1(123,431,2134); - Polynomial p2(123,421,234); - Polynomial g(1); - Polynomial result = modular_gcd_utcf(p1,p2); - //std::cout <<" result : " << result < Polynomial; - - Polynomial f1(5,234,445); - Polynomial f2(12,-234,345); - f1 *= Polynomial(Integer(CGAL::primes[0]+3),Integer(1)); - f2 *= Polynomial(Integer(3),Integer(1)); - Polynomial g(13,96,2345); - Polynomial p1 = f1*g; - Polynomial p2 = f2*g; - - Polynomial result = modular_gcd_utcf(p1,p2); - //std::cout <<" result : " << result < Polynomial; - - Polynomial f1(5,234,-26,243,745); - Polynomial f2(12,-234,26,243,-731); - Polynomial g(13,-5676,234,96); - Polynomial p1 = Polynomial(8)*f1*f1*g; - Polynomial p2 = Polynomial(5)*f2*f2*g; - - Polynomial result = modular_gcd_utcf(p1,p2); - //std::cout <<" result : " << result < EXT; - typedef CGAL::Polynomial Polynomial; - - Integer root(Integer(789234)); - Polynomial f1(EXT(235143,-2234,root),EXT(232543,-2334,root),EXT(235403,-2394,root),EXT(235483,-2364,root),EXT(223443,-2234,root)); - Polynomial f2(EXT(25143,-2134,root),EXT(212543,-2315,root),EXT(255453,-5394,root),EXT(535483,-2354,root),EXT(22333,-2214,root)); - Polynomial g(EXT(215143,-2134,root),EXT(2122422543,-2115,root),EXT(255453,-1394,root),EXT(135483,-2354,root),EXT(7)); - g=g*g;g=g*g;g=g*g; - - Polynomial p1 = Polynomial(8)*f1*f1*g; - Polynomial p2 = Polynomial(5)*f2*f2*g; - - Polynomial result = modular_gcd_utcf(p1,p2); - //std::cout <<" result : " << result < EXT; - typedef CGAL::Polynomial Polynomial; - - Integer root(4*3); - Polynomial f1(EXT(0,1,root),EXT(2)); - Polynomial f2(EXT(0,1,root),EXT(4)); - Polynomial g(EXT(0,-1,root),EXT(2)); - - - //std::cout <<" f1 : " << f1 <