1 #include <CGAL/Polynomial.h> 2 #include <CGAL/Polynomial_traits_d.h> 3 #include <CGAL/Polynomial_type_generator.h> 4 main()5int main(){ 6 CGAL::IO::set_pretty_mode(std::cout); 7 typedef CGAL::Polynomial_type_generator<int,1>::Type Poly_1; 8 typedef CGAL::Polynomial_traits_d<Poly_1> PT_1; 9 10 PT_1::Shift shift; 11 PT_1::Gcd gcd; 12 PT_1::Gcd_up_to_constant_factor gcd_utcf; 13 PT_1::Multivariate_content mcontent; 14 PT_1::Canonicalize canonicalize; 15 16 //construction using shift 17 Poly_1 x = shift(Poly_1(1),1,0); // x^1 18 19 // common factor 7 * (x^2-2) 20 Poly_1 F = 21*(x-5)*(x*x-2); // = 21*x^3 + (-105)*x^2 + (-42)*x + 210 21 Poly_1 G = 14*(x-3)*(x*x-2); // = 14*x^3 + (-42)*x^2 + (-28)*x + 84 22 23 std::cout << "The univariate polynomial F: " << F << std::endl; 24 std::cout << "The univariate polynomial G: " << G << std::endl; 25 std::cout << "Common multivariate content: " 26 << CGAL::gcd(mcontent(F),mcontent(G)) // = 7 27 << std::endl; 28 std::cout << "The gcd of F and G: " 29 << gcd(F,G) // = 7*x^2 + (-14) 30 << std::endl; 31 std::cout << "The gcd up to constant factor of F and G: " 32 << gcd_utcf(F,G) // = x^2 + (-2) 33 << std::endl; 34 std::cout << "Same as canonicalized gcd of F and G: " 35 << canonicalize(gcd_utcf(F,G)) // = x^2 + (-2) 36 << std::endl; 37 38 } 39