Borderbasix

matmul.hpp
Go to the documentation of this file.
1 template<typename typMk>
2 int indice(const typename typMk::value_type & m, const typMk &stockmon)
3 {
4  int res=0;
5  for(typename typMk::const_iterator iter=stockmon.begin();
6  (iter->rep!=m.rep)&&(iter!=stockmon.end());iter++,res++);
7  return res;
8 }
9 
10 //on suppose stockmon vide
11 template<typename Base, typename typstock, typename typdump>
12 void computestockmon(typstock &stockmon, const Base &b, const typdump &dump)
13 {
14  typedef typename typdump::value_type::pol_t pol;
15  typedef typename pol::monom_t mon;
16  int maxdeg=0;
17  //int taillequo=0,tmp=0;
18  // mon *who=NULL;
19  list<mon> current;
20  current.push_back(mon(1));
21  stockmon.push_back(mon(1));
22  {
23  typename typdump::const_iterator iter;
24  for(iter=dump.begin();
25  iter!=dump.end();iter++);
26  maxdeg=(--iter)->k;
27  }
28  //on a le degre max
29  //le quotient est connexe a 1 donc on part
30  //de 1 et on decrit le reste en multipliant par les variables
31  for(int i=0;i<maxdeg;i++)
32  {
33  list<mon> tmpcurrent=current;
34  //my_merge(stockmon,current);
35  current.erase(current.begin(),current.end());
36  for(int i=0;i<b.nbvar();i++)
37  {
38  for(typename list<mon>::iterator iter=tmpcurrent.begin();
39  iter!=tmpcurrent.end();iter++)
40  current.push_back((*iter)*mon(i,1));
41  }
42  //maintenant on tri;
43  for(typename list<mon>::iterator iter=current.begin();iter!=current.end();iter++)
44  if((IsinB(*iter,b))&&(!member(stockmon,*iter)))
45  {
46  stockmon.push_back(*iter);
47  }
48  else
49  {
50  current.erase(iter--);
51  }
52  }
53  return;
54 }
55 
56 
57 //on suppose dqans un premier temps que le pol qui est donne
58 //en parametre est en fait une variable
59 template<typename typmat,typename typdump,typename Base, typename typstock>
60 void matmul(typmat & m,const int p,const typdump &dump,const Base &b
61  , const typstock &stockmon)
62 {
63  typedef typename typdump::value_type::pol_t pol;
64  typedef typename pol::monom_t mon;
65  typedef typename pol::coeff_t coeff;
66  list<mon> current;
67  //dans stockmon on a maintenant les monomes du quotient;
68  //on le multiplis par la variable p
69  current=stockmon;
70  for(typename list<mon>::iterator iter=current.begin();iter!=current.end();iter++)
71  {
72  *iter*=mon(p,1);
73  }
74  //maintenant on ecrit la matrice
75  {
76  int j=0;
77  m=typmat(current.size(),current.size());
78  for(typename list<mon>::iterator iter=current.begin()
79  ;iter!=current.end();iter++,j++)
80  {
81  if(!IsinB(*iter,b))
82  {
83  pol tmp;
84  findcorresppol(*iter,dump,tmp);
85  mon tmpmon;
86  for(int i=0;i<tmp.size;i++)
87  {
88  int2mon(i,tmpmon);
89  //cout<<"indice2 "<<tmpmon<<" "<<indice(tmpmon,current)<<endl;
90  if(IsinB(tmpmon,b))
91  m(indice(tmpmon,stockmon),j,tmp.nf[i]*(coeff)(-1));
92  }
93  }
94  else
95  {
96  //cout<<"indice "<<indice(*iter,current)<<endl;
97  m(indice(*iter,stockmon),j,iter->GetCoeff());
98  }
99  }
100  }
101  return;
102 }
103 
104 
105 template<typename typmat,typename typdump,typename Base, typename typstock>
106 void trans_matmul(typmat & m,const int p,const typdump &dump,const Base &b
107  , const typstock &stockmon)
108 {
109  typedef typename typdump::value_type::pol_t pol;
110  typedef typename pol::monom_t mon;
111  typedef typename pol::coeff_t coeff;
112  list<mon> current;
113  //dans stockmon on a maintenant les monomes du quotient;
114  //on le multiplis par la variable p
115  current=stockmon;
116  for(typename list<mon>::iterator iter=current.begin();iter!=current.end();iter++)
117  {
118  *iter*=mon(p,1);
119  }
120  //maintenant on ecrit la matrice
121  {
122  int j=0;
123  m=typmat(current.size(),current.size());
124  for(typename list<mon>::iterator iter=current.begin()
125  ;iter!=current.end();iter++,j++)
126  {
127  if(!IsinB(*iter,b))
128  {
129  pol tmp;
130  findcorresppol(*iter,dump,tmp);
131  mon tmpmon;
132  for(int i=0;i<tmp.size;i++)
133  {
134  int2mon(i,tmpmon);
135  //cout<<"indice2 "<<tmpmon<<" "<<indice(tmpmon,current)<<endl;
136  if(IsinB(tmpmon,b))
137  m(j,indice(tmpmon,stockmon),tmp.nf[i]*(coeff)(-1));
138  }
139  }
140  else
141  {
142  //cout<<"indice "<<indice(*iter,current)<<endl;
143  m(j,indice(*iter,stockmon),iter->GetCoeff());
144  }
145  }
146  }
147  return;
148 }
int indice(const typename typMk::value_type &m, const typMk &stockmon)
Definition: matmul.hpp:2
void computestockmon(typstock &stockmon, const Base &b, const typdump &dump)
Definition: matmul.hpp:12
void findcorresppol(const mon &m, const typdump &dump, pol &res)
Definition: corealgo.hpp:2031
int member(const typMk &tmpMk, const typename typMk::value_type mon)
Definition: corealgo.hpp:1391
T coeff_t
Definition: pol.hpp:9
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
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 size
Definition: pol.hpp:10
#define pol
Definition: pol2ter.hpp:3
Multivariate monomials.
Definition: Monom.hpp:21
T * nf
Definition: pol.hpp:12
void trans_matmul(typmat &m, const int p, const typdump &dump, const Base &b, const typstock &stockmon)
Definition: matmul.hpp:106
void matmul(typmat &m, const int p, const typdump &dump, const Base &b, const typstock &stockmon)
Definition: matmul.hpp:60
Home  |  Download & InstallContributions