// Copyright (c) 2002-2008 Max-Planck-Institute Saarbruecken (Germany) // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // SPDX-License-Identifier: LGPL-3.0+ // // // 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