Borderbasix

MPolyFunction.hpp
Go to the documentation of this file.
1 /*********************************************************************
2 * This file is part of the source code of BORDERBASIX software. *
3 * (C) B. Mourrain, INRIA *
4 **********************************************************************
5 History:
6 $Id: MPolyFunction.hpp,v 1.1.1.1 2006/10/06 08:01:40 trebuche Exp $
7 **********************************************************************/
8 #ifndef _MPolyFunction_hpp_
9 #define _MPolyFunction_hpp_
10 
11 //template <class R, class O>int Lvar (const MPoly<R,O> &);
12 
13 template <class P> inline
14 P Pdiv (const P & p, const typename P::monom_t & m) {
15  P res;
16  for (typename P::const_iterator i = p.begin(); i != p.end(); ++i)
17  res += div<typename P::monom_t>(*i,m);
18  return res;
19 }
20 
21 template <class R, class O> inline
22 int Degree (const MPoly<R,O> & P, int i) {
23  int deg = 0;
24  for (typename MPoly<R,O>::const_iterator p = P.begin(); p != P.end(); ++p)
25  {
26  int d = p->GetDegree(i);
27  if (d > deg)
28  deg = d;
29  }
30  return deg;
31 }
32 
33 template <class R, class O> inline
34 MPoly<R,O> Diff (const MPoly<R,O> & P, int i) {
35  MPoly<R,O> c,res=0;
36  int d;
37  int deg = 0;
38  for (typename MPoly<R,O>::const_iterator p = P.begin(); p != P.end(); ++p)
39  {
40  typename MPoly<R,O>::monom_t aux(*p);
41  d = aux.GetDegree(i);
42  c = aux.coeff;
43  //std::cout<<c<<std::endl;
44  if (d > deg)
45  {
46 
47  aux.SetDegree(i,d-1);
48  aux.coeff *=d;
49  // aux.SetCoeff((double)c);
50  res+=aux;
51  //cout<<"res"<<res<<endl;
52  }
53  }
54  return res;
55 }
56 
57 template <class R, class O> inline
58 int NbCoef (const MPoly<R,O> & P) {
59  int nc = 0;
60  for (typename MPoly<R,O>::const_iterator p = P.begin(); p != P.end(); ++p)
61  nc++;
62  return nc;
63 }
64 
65 template <class R, class O> inline
66 MPoly<R,O> Coeff(const MPoly<R,O> & P, int i) {
67  MPoly<R,O> res;
68  for (typename MPoly<R,O>::const_iterator j = P.begin(); j != P.end(); ++j)
69  if (j->GetDegree(i))
70  res += *j;
71  return res;
72 }
73 
74 template <class R, class O> inline
75 MPoly<R,O> Coeff(const MPoly<R,O> & P, int i, int d) {
76  MPoly<R,O> res;
77  for (typename MPoly<R,O>::const_iterator j = P.begin(); j != P.end(); ++j)
78  if (j->GetDegree(i) == d) {
79  typename MPoly<R,O>::monom_t aux(*j);
80  aux.SetDegree(i,0);
81  res += aux;
82  }
83  return res;
84 }
85 
86 
87 #endif //_MPolyFunction_hpp_
R::value_type monom_t
Definition: MPoly.hpp:31
Multivariate polynomials.
Definition: MPoly.hpp:28
iterator end()
Definition: MPoly.hpp:102
MSKconetypee MSKrealt MSKint32t MSKint32t j
Definition: mosek.h:2421
P Pdiv(const P &p, const typename P::monom_t &m)
Definition: MPolyFunction.hpp:14
MPoly< R, O > Coeff(const MPoly< R, O > &P, int i)
Definition: MPolyFunction.hpp:66
MPoly< R, O > Diff(const MPoly< R, O > &P, int i)
Definition: MPolyFunction.hpp:34
MSKrealt * c
Definition: mosek.h:2678
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
R::const_iterator const_iterator
Definition: MPoly.hpp:35
int Degree(const MPoly< R, O > &P, int i)
Definition: MPolyFunction.hpp:22
iterator begin()
Definition: MPoly.hpp:97
int NbCoef(const MPoly< R, O > &P)
Definition: MPolyFunction.hpp:58
Home  |  Download & InstallContributions