diff --git a/Polynomial/test/Polynomial/include/CGAL/new_resultant.h b/Polynomial/test/Polynomial/include/CGAL/new_resultant.h deleted file mode 100644 index f2b996c24b8..00000000000 --- a/Polynomial/test/Polynomial/include/CGAL/new_resultant.h +++ /dev/null @@ -1,285 +0,0 @@ -#ifndef CGAL_NEW_RESULTANT_H -#define CGAL_NEW_RESULTANT_H - -#include -#include -#include -#include -#include - -CGAL_BEGIN_NAMESPACE - -template -inline Coeff new_resultant( const CGAL::Polynomial&, const CGAL::Polynomial&, int); -namespace CGALi{ - -template -inline Coeff new_resultant_interpolate( const CGAL::Polynomial&, const CGAL::Polynomial& ); -template -inline Coeff new_resultant_modularize( const CGAL::Polynomial&, const CGAL::Polynomial&, CGAL::Tag_true); -template -inline Coeff new_resultant_modularize( const CGAL::Polynomial&, const CGAL::Polynomial&, CGAL::Tag_false); -template -inline Coeff new_resultant_decompose( const CGAL::Polynomial&, const CGAL::Polynomial&, CGAL::Tag_true); -template -inline Coeff new_resultant_decompose( const CGAL::Polynomial&, const CGAL::Polynomial&, CGAL::Tag_false); -template -inline Coeff new_resultant_( const CGAL::Polynomial&, const CGAL::Polynomial&); - -} // namespace CGALi - -namespace CGALi{ - -template -inline IC -new_resultant_interpolate( const CGAL::Polynomial& F, const CGAL::Polynomial& G){ - CGAL_precondition(CGAL::Polynomial_traits_d >::d == 1); - return CGALi::resultant(F,G); -} - -template -inline -CGAL::Polynomial new_resultant_interpolate( - const CGAL::Polynomial >& F, - const CGAL::Polynomial >& G){ - - typedef CGAL::Polynomial Coeff_1; - typedef CGAL::Polynomial POLY; - typedef CGAL::Polynomial_traits_d PT; - typedef typename PT::Innermost_coefficient IC; - - CGAL_precondition(PT::d >= 2); - - typename PT::Degree degree; - typename CGAL::Polynomial_traits_d::Degree_vector degree_vector; - - int maxdegree = degree(F,0)*degree(G,PT::d-1) + degree(F,PT::d-1)*degree(G,0); - - typedef std::pair Point; - std::vector points; // interpolation points - - - int i(0); - CGAL::Exponent_vector ev_f(degree_vector(Coeff_1())); - CGAL::Exponent_vector ev_g(degree_vector(Coeff_1())); - - - while((int) points.size() <= maxdegree + 1){ - i++; - // timer1.start(); - Coeff_1 Fat_i = F.evaluate(Coeff_1(i)); - Coeff_1 Gat_i = G.evaluate(Coeff_1(i)); - // timer1.stop(); - - if(degree_vector(Fat_i) > ev_f || degree_vector(Gat_i) > ev_g){ - points.clear(); - ev_f = degree_vector(Fat_i); - ev_g = degree_vector(Gat_i); - CGAL_postcondition(points.size() == 0); - } - if(degree_vector(Fat_i) == ev_f && degree_vector(Gat_i) == ev_g){ - // timer2.start(); - Coeff_2 res_at_i = new_resultant_interpolate(Fat_i, Gat_i); - // timer2.stop(); - points.push_back(Point(IC(i),res_at_i)); - } - } - - // timer3.start(); - CGAL::Interpolator interpolator(points.begin(),points.end()); - Coeff_1 result = interpolator.get_interpolant(); - // timer3.stop(); - -#ifndef CGAL_NDEBUG - while((int) points.size() <= maxdegree + 3){ - i++; - Coeff_1 Fat_i = typename PT::Evaluate()(F,IC(i)); - Coeff_1 Gat_i = typename PT::Evaluate()(G,IC(i)); - - assert(degree_vector(Fat_i) <= ev_f); - assert(degree_vector(Gat_i) <= ev_g); - - if(degree_vector(Fat_i) == ev_f && degree_vector(Gat_i) == ev_g){ - Coeff_2 res_at_i = new_resultant(Fat_i, Gat_i, 0); - points.push_back(Point(IC(i), res_at_i)); - } - } - CGAL::Interpolator interpolator_(points.begin(),points.end()); - Coeff_1 result_= interpolator_.get_interpolant(); - - // the interpolate polynomial has to be stable ! - assert(result_ == result); -#endif - return result; -} - - -template -inline -Coeff new_resultant_modularize( - const CGAL::Polynomial& F, const CGAL::Polynomial& G, CGAL::Tag_false){ - return new_resultant_interpolate(F,G); -}; - -template -inline -Coeff new_resultant_modularize( - const CGAL::Polynomial& F, const CGAL::Polynomial& G, CGAL::Tag_true){ - - typedef Polynomial_traits_d > PT; - typedef typename PT::Polynomial_d Polynomial; - typedef typename PT::Innermost_coefficient IC; - - - typedef Chinese_remainder_traits CRT; - typedef typename CRT::Scalar_type Scalar; - - - typedef typename CGAL::Modular_traits::Modular_NT MPolynomial; - typedef typename CGAL::Modular_traits::Modular_NT MCoeff; - typedef typename CGAL::Modular_traits::Modular_NT MScalar; - - typename CRT::Chinese_remainder chinese_remainder; - typename CGAL::Modular_traits::Modular_image_inv inv_map; - - - typename PT::Degree_vector degree_vector; - typename CGAL::Polynomial_traits_d::Degree_vector mdegree_vector; - - bool solved = false; - int prime_index = 0; - int n = 0; - Scalar p,q,pq,s,t; - Coeff R, R_old; - - CGAL::Timer timer_evaluate, timer_resultant, timer_cr; - - do{ - MPolynomial mF, mG; - MCoeff mR; - timer_evaluate.start(); - do{ - // select a prime number - int current_prime = -1; - prime_index++; - if(prime_index >= 2000){ - std::cerr<<"primes in the array exhausted"< ceea; - ceea(q,p,s,t); - pq =p*q; - chinese_remainder(q,p,pq,s,t,R_old,inv_map(mR),R); - q=pq; - } - solved = (R==R_old); - timer_cr.stop(); - } while(!solved); - - std::cout << "Time Evaluate : " << timer_evaluate.time() << std::endl; - std::cout << "Time Resultant : " << timer_resultant.time() << std::endl; - std::cout << "Time Chinese R : " << timer_cr.time() << std::endl; - // CGAL_postcondition(R == new_resultant_interpolate(F,G)); - return R; - // return new_resultant_interpolate(F,G); -} - - -template -inline -Coeff new_resultant_decompose( - const CGAL::Polynomial& F, const CGAL::Polynomial& G, CGAL::Tag_false){ -#ifdef CGAL_RESULTANT_NUSE_MODULAR_ARITHMETIC - return new_resultant_modularize(F,G,CGAL::Tag_false()); -#else - typedef CGAL::Polynomial Polynomial; - typedef typename Modular_traits::Is_modularizable Is_modularizable; - return new_resultant_modularize(F,G,Is_modularizable()); -#endif -} - -template -inline -Coeff new_resultant_decompose( - const CGAL::Polynomial& F, const CGAL::Polynomial& G, CGAL::Tag_true){ - - typedef Polynomial POLY; - typedef typename Fraction_traits::Numerator_type Numerator; - typedef typename Fraction_traits::Denominator_type Denominator; - typename Fraction_traits::Decompose decompose; - typedef typename Numerator::NT RES; - - Denominator a, b; - // F.simplify_coefficients(); not const - // G.simplify_coefficients(); not const - Numerator F0; decompose(F,F0,a); - Numerator G0; decompose(G,G0,b); - Denominator c = CGAL::ipower(a, G.degree()) * CGAL::ipower(b, F.degree()); - typedef typename Algebraic_structure_traits::Algebraic_category Algebraic_category; - RES res0 = CGAL::CGALi::new_resultant_(F0, G0); - typename Fraction_traits::Compose comp_frac; - Coeff res = comp_frac(res0, c); - typename Algebraic_structure_traits::Simplify simplify; - simplify(res); - return res; -} - - -template -inline -Coeff new_resultant_( - const CGAL::Polynomial& F, const CGAL::Polynomial& G){ - typedef CGAL::Fraction_traits > FT; - typedef typename FT::Is_fraction Is_fraction; - return new_resultant_decompose(F,G,Is_fraction()); -} - - -} // namespace CGALi - -template -inline -Coeff new_resultant( - const CGAL::Polynomial& F_, - const CGAL::Polynomial& G_, - int index = CGAL::Polynomial_traits_d< CGAL::Polynomial >::d-1){ - typedef CGAL::Polynomial_traits_d > PT; - CGAL::Polynomial F = typename PT::Move()(F_, index, 0); - CGAL::Polynomial G = typename PT::Move()(G_, index, 0); - return CGALi::new_resultant_(F,G); -} - -CGAL_END_NAMESPACE - - - -#endif // CGAL_NEW_RESULTANT_H -