00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SYNAPS_MPOL_MPOL_FCT_H
00009 #define SYNAPS_MPOL_MPOL_FCT_H
00010
00011 #include <synaps/init.h>
00012 #include <synaps/mpol/MPOLDST.m>
00013 #include <synaps/arithm/binomial.h>
00014
00015 __BEGIN_NAMESPACE_SYNAPS
00016
00017 template <class C, class O, class R> inline
00018 int nbcoef (const MPol<C,O,R> & P) {
00019 int nc = 0;
00020 for (typename MPol<C,O,R>::const_iterator p = P.begin();
00021 p != P.end(); ++p)
00022 nc++;
00023 return nc;
00024 }
00025
00026 template <class C, class O, class R> inline
00027 MPol<C,O,R> Coeff(const MPol<C,O,R> & P, int i) {
00028 MPol<C,O,R> res;
00029 for (typename MPol<C,O,R>::const_iterator j = P.begin(); j != P.end(); ++j)
00030 if ((*j)[i])
00031 res += *j;
00032 return res;
00033 }
00034
00035 template <class C, class O, class R> inline
00036 MPol<C,O,R> Coeff(const MPol<C,O,R> & P, int i, int d)
00037 {
00038 MPol<C,O,R> res;
00039 for (typename MPol<C,O,R>::const_iterator j = P.begin();
00040 j != P.end(); ++j)
00041 if ((*j)[i] == d) {
00042 typename MPol<C,O,R>::monom_t aux(*j);
00043 aux.setdegree(i,0);
00044 res += aux;
00045 }
00046 return res;
00047 }
00048 __END_NAMESPACE_SYNAPS
00049
00050 #endif // SYNAPS_MPOL_MPOL_FCT_H
00051
00052