File: degree.cpp

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (35 lines) | stat: -rw-r--r-- 1,213 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <CGAL/Polynomial.h>
#include <CGAL/Polynomial_traits_d.h>
#include <CGAL/Polynomial_type_generator.h>

int main(){
  CGAL::IO::set_pretty_mode(std::cout);
  typedef CGAL::Polynomial_type_generator<int,2>::Type Poly_2;
  typedef CGAL::Polynomial_traits_d<Poly_2>            PT_2;

  //construction using shift
  Poly_2 x = PT_2::Shift()(Poly_2(1),1,0); // x_0^1
  Poly_2 y = PT_2::Shift()(Poly_2(1),1,1); // x_1^1

  Poly_2 F // = (11*x^2 + 5*x)*y^4 + (7*x^2)*y^3
    = 11 * CGAL::ipower(y,4) * CGAL::ipower(x,2)
    + 5 * CGAL::ipower(y,4)  * CGAL::ipower(x,1)
    + 7 * CGAL::ipower(y,3)  * CGAL::ipower(x,2);
  std::cout << "The bivariate polynomial F: " << F <<"\n"<< std::endl;

  PT_2::Degree degree;
  PT_2::Total_degree total_degree;
  PT_2::Degree_vector degree_vector;

  std::cout << "The degree of F with respect to y: "<< degree(F)       // = 4
            << std::endl;
  std::cout << "The degree of F with respect to x: "<< degree(F,0)     // = 2
            << std::endl;
  std::cout << "The total degree of F            : "<< total_degree(F) // = 6
            << std::endl;
  std::cout << "The degree vector of F           : "<< degree_vector(F)// = (2,4)
            << std::endl;



}