// Copyright (c) 2002-2008 Max-Planck-Institute Saarbruecken (Germany) // // This file is part of CGAL (www.cgal.org) // // $URL: https://github.com/CGAL/cgal/blob/v5.1/Polynomial/include/CGAL/Polynomial/modular_gcd_utils.h $ // $Id: modular_gcd_utils.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Michael Hemmer // Dominik Huelse // // ============================================================================ /*! \file CGAL/Polynomial/modular_gcd_utils.h * \brief Provides additional utils for the modular GCD calculation */ #ifndef CGAL_POLYNOMIAL_MODULAR_GCD_UTILS_H #define CGAL_POLYNOMIAL_MODULAR_GCD_UTILS_H #include #include #include #include namespace CGAL{ namespace internal { template void euclidean_division_obstinate(const NT& F1, const NT& F2, NT& Q, NT& R){ CGAL_precondition(F2 != 0); CGAL::div_mod(F1, F2, Q, R); CGAL_postcondition(F1 == F2*Q + R); } template void euclidean_division_obstinate(const Polynomial& F1, const Polynomial& F2, Polynomial& Q, Polynomial& R){ // std::cout<<" my_modular_gcd_utils "<(NT(0)); R = F1; CGAL_postcondition( !(boost::is_same< typename Algebraic_structure_traits::Is_exact, CGAL::Tag_true >::value) || F1 == Q*F2 + R); return; } typedef std::vector Vector; Vector V_R, V_Q; V_Q.reserve(d1); if(d2==0){ for(int i=d1;i>=0;--i){ V_Q.push_back(F1[i]/F2[0]); } V_R.push_back(NT(0)); } else{ V_R.reserve(d1); V_R=Vector(F1.begin(),F1.end()); Vector tmp1; tmp1.reserve(d2); for(int k=0; k<=d1-d2; ++k){ V_Q.push_back(V_R[d1-k]/F2[d2]); for(int j=0;j(V_Q.rbegin(),V_Q.rend()); R = Polynomial(V_R.begin(),V_R.end()); CGAL_postcondition(F1 == F2*Q + R); } } // namespace internal } // namespace CGAL #endif //#ifnedef CGAL_POLYNOMIAL_MODULAR_GCD_UTILS_H 1 // EOF