Borderbasix

proj.hpp
Go to the documentation of this file.
1 template<typename typPk,typename typdump,typename Base>
2 void rewrite(typPk &Pk,const typdump &dump,const Base &b)
3 {
4  typedef typename typPk::value_type polyalp;
5  typedef typename polyalp::monom_t mon;
6  typedef typename typdump::value_type dumpstruct;
7  typedef typename dumpstruct::pol_t pol;
8  typename typPk::iterator iter=Pk.begin();
9  //cout<<"Pk.size dans rewrite "<<Pk.size()<<endl;
10  for(;iter!=Pk.end();iter++)
11  //pour chaque poly de Pk
12  {
13  polyalp tmp(mon(0));
14  for(typename polyalp::iterator itermon=iter->begin();
15  itermon!=iter->end();itermon++)
16  //pour chaque mon du polynome *iter
17  {
18  if (!IsinB(*itermon,b))
19  {
20  pol ttmp;
21  ttmp.size=-1;
22  ttmp.nf=NULL;
23  //cout<<"findcorresppol "<<*itermon<<endl;
24  findcorresppol(*itermon,dump,ttmp);
25  //cout<<"invconv"<<endl;
26  //fincorresppol ne touche pas son parametre de sortie qd
27  //le monome recherche n'existe pas
28  //il existe ce monome?
29  if(ttmp.size!=-1)
30  {
31  // cout<<"trouve "<<endl;
32  //tmp*=mon(ttmp.ind.GetCoeff());
33  tmp+=invconv<polyalp>(ttmp)*mon(itermon->GetCoeff()/ttmp.ind.GetCoeff());
34  }
35  }
36 
37  }
38  //cout<<"le pol que je vais enlever"<<endl;
39  //cout<<tmp<<endl;
40  //cout<<"fin du pol"<<endl;
41  //cout<<"le poly avant reecriture "<<*iter<<endl;
42  (*iter)-=tmp;
43  //cout<<"poly apres reecriture!!\n"<<(*iter)<<endl;
44  }
45  return;
46 }
47 #ifdef uninf
48 void reinit_multiple();
49 #endif
50 template<typename T,typename typdump,typename Base>
51 void proj(T &Crochet,const typdump &dump, const Base &b)
52 {
53  typedef typename typdump::value_type::pol_t pol;
54  typedef typename T::value_type polyalp;
55  typedef typename polyalp::monom_t mon;
56  typedef typename mon::coeff_t coeff;
57  typename T::iterator iter=Crochet.begin();
58 #ifdef unimul
59  reinit_multiple();
60 #endif
61 #ifdef uninf
62  reinit_nf<pol>();
63 #endif
64  for(;iter!=Crochet.end();iter++)
65  {
66  list<mon> monared;
67  //cout<<"le pol que je vais reduire"<<endl;
68  //cout<<*iter<<endl;
69  for(typename polyalp::iterator iterpol=iter->begin();iterpol!=iter->end();iterpol++)
70  {
71  if (!IsinB(*iterpol,b)) monared.push_back(*iterpol);
72  //cout<<"mon dans proj "<<*iterpol<<" b? "<<IsinB(*iterpol,b)<<endl;
73  }
74  for(typename list<mon>::iterator itermon=monared.begin();itermon!=monared.end();itermon++)
75  {
76  // cout<<"dans le for sur monared "<<b.nbvar()<<endl;
77 #ifdef projfast
78  polyalp result(0);
79  pol accumul;
80  mon *exce;
81  int sizeex;
82  accumul.size=1;
83  accumul.nf=(coeff*)MAC_REV_MALLOC<coeff>(sizeof(coeff));
84  accumul.nf[0]=1;
85  for(int i=0;i<b.nbvar();i++)
86  for(int j=0;j<itermon->GetDegree(i);j++)
87  {
88  pol tmp;
89  //if(result.size()!=0)
90  result*=mon(i,1);
91  tmp=mult(i,accumul,dump,b,&exce,sizeex);
92  MAC_REV_FREE<coeff>(accumul.nf,accumul.size*sizeof(coeff));
93  accumul=tmp;
94  for(int k=0;k<sizeex-1;k++)
95  result+=exce[k];
96  MAC_REV_FREE<mon>(exce,sizeex*sizeof(mon));
97  }
98  for(int k=0;k<accumul.size;k++)
99  if(!Iszero(accumul.nf[k]))
100  {
101  mon tmpmon;
102  int2mon(k,tmpmon);
103  // cout<<"tmpmon "<<tmpmon<<endl;
104  result+=tmpmon*accumul.nf[k];
105  }
106  MAC_REV_FREE<coeff>(accumul.nf,accumul.size*sizeof(coeff));
107 #else
108  polyalp result(1);
109  for(int i=0;i<b.nbvar();i++)
110  for(int j=0;j<itermon->GetDegree(i);j++)
111  {
112  result*=mon(i,1);
113  int flag=0;
114  //cout<<"nbtour dans la boucle "<<itermon->GetDegree(i)<<"J"<<j<<endl;
115  for (typename polyalp::iterator iterres=result.begin();
116  iterres!=result.end();iterres++)
117  {
118  if (!IsinB(*iterres,b)) flag=1;
119  // cout<<"IsinB("<<*iterres<<") "<<IsinB(*iterres,b)<<endl;
120  }
121  if (flag)
122  {
123  T tmp;
124  tmp.push_back(result);
125  //cout<<"rewrite"<<endl;
126  rewrite(tmp,dump,b);
127  //cout<<"sortie rewrite"<<endl;
128  result=tmp.front();
129  }
130  }
131 #endif
132  coeff Coeff;
133  for(typename polyalp::iterator iterpol=iter->begin();
134  iterpol!=iter->end();iterpol++)
135  if ((itermon->rep)==(iterpol->rep))
136  {
137  Coeff=iterpol->GetCoeff();
138  break;
139  }
140  //cout<<"iter avant reecriture "<<*iter<<endl;
141  *iter+=result*mon(Coeff);
142  *iter-=polyalp(mon((*itermon)*(coeff)(Coeff/itermon->GetCoeff())));
143  //cout<<"iter apres reecriture "<<*iter<<endl<<endl;
144  }
145  }
146  //stab(Crochet);
147  return;
148 
149 }
Definition: dump.hpp:2
void proj(T &Crochet, const typdump &dump, const Base &b)
Definition: proj.hpp:51
C GetCoeff() const
Definition: Monom.hpp:67
Definition: pol.hpp:6
void findcorresppol(const mon &m, const typdump &dump, pol &res)
Definition: corealgo.hpp:2031
typpol mult(int i, const typpol &pol, const typdump &dump, const Base &b, mon **exce, int &exsize)
Definition: corealgo.hpp:1077
void rewrite(typPk &Pk, const typdump &dump, const Base &b)
Definition: proj.hpp:2
long flag
Definition: alp_f2c.H:52
int nbvar()
Definition: types.hpp:37
MSKconetypee MSKrealt MSKint32t MSKint32t j
Definition: mosek.h:2421
void int2mon(const int &i, mon &res)
Definition: placemon.hpp:288
MSKint32t k
Definition: mosek.h:2713
C coeff_t
Definition: Monom.hpp:26
MPoly< R, O > Coeff(const MPoly< R, O > &P, int i)
Definition: MPolyFunction.hpp:66
int IsinB(const mon &m, const Base &b)
Definition: IsinB3.hpp:68
Mon mon
Definition: solver_bb_floating.cpp:136
Definition: types.hpp:14
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
int Iszero(const Scl< MPQ > &c)
Definition: Iszero.hpp:14
int size
Definition: pol.hpp:10
cont< pol< mon, T > > Crochet(const cont< pol< mon, T > > &P, int k)
Definition: corealgo.hpp:6
#define pol
Definition: pol2ter.hpp:3
mon ind
Definition: pol.hpp:11
T * nf
Definition: pol.hpp:12
Home  |  Download & InstallContributions