1 #include <CGAL/Polynomial.h>
2 #include <CGAL/Polynomial_traits_d.h>
3 #include <CGAL/Polynomial_type_generator.h>
4 
main()5 int main(){
6   CGAL::IO::set_pretty_mode(std::cout);
7 
8   typedef CGAL::Polynomial_type_generator<int,2>::Type Poly_2;
9   typedef CGAL::Polynomial_traits_d<Poly_2>            PT_2;
10   typedef PT_2::Coefficient_type                       Poly_1;
11   typedef PT_2::Innermost_coefficient_type             Integer;
12 
13   PT_2::Construct_polynomial construct_polynomial;
14   Poly_2 dc;
15 
16 
17   // constructing a constant polynomial from int
18   Poly_2 two(2); // = 2
19   std::cout << "A constant polynomial: " << two << std::endl;
20 
21 
22   // construction from an iterator range of univariate polynomials
23 
24   std::list<Poly_1> univariate_coeffs;
25   univariate_coeffs.push_back(Poly_1(3));
26   univariate_coeffs.push_back(Poly_1(0));
27   univariate_coeffs.push_back(Poly_1(5));
28   Poly_2 F = // 5*y^2 + 3
29     construct_polynomial(univariate_coeffs.begin(),univariate_coeffs.end());
30   std::cout << "The bivariate polynomial F: " << F << std::endl;
31 
32 
33   // construction from an iterator range over monomials
34 
35   std::list<std::pair<CGAL::Exponent_vector, Integer> > innermost_coeffs;
36   innermost_coeffs.push_back(std::make_pair(CGAL::Exponent_vector(0,0),-2));
37   innermost_coeffs.push_back(std::make_pair(CGAL::Exponent_vector(3,5),2));
38   Poly_2 G = // (2*x^3)*y^5 + (-2)
39     construct_polynomial(innermost_coeffs.begin(),innermost_coeffs.end());
40   std::cout << "The bivariate polynomial G: " << G << std::endl;
41 
42   //construction using shift
43   PT_2::Shift shift;
44   Poly_2 x = shift(Poly_2(1),1,0); // 'multiply' 1 by x_0^1
45   Poly_2 y = shift(Poly_2(1),1,1); // 'multiply' 1 by x_1^1
46 
47   Poly_2 H = 5 * x * y + 3 * y * y; // = 3*y^2 + (5*x)*y
48   std::cout << "The bivariate polynomial H: " << H << std::endl;
49 }
50