Borderbasix

symbo.hpp
Go to the documentation of this file.
1 #include "upoly.H"
2 template<typename typcoeff>
3 int Iszero(const UPolyDense<upar<typcoeff> > & c)
4 {
5  UPolyDense<upar<typcoeff> > T(typcoeff(0));
6  return c!=T;
7 }
8 
9 template <typename typmat>
10 void Triang(typmat & M)
11 {
12  typedef typename typmat::coeff_t C;
13  C d(1),un(1);
14  unsigned int l;
15  for(unsigned int k=0; k<M.ncol;k++){
16  for(l=k;(l<M.nrow) && (Iszero(M(l,k)));l++);
17  if(l!=M.nrow){
18  if(k>0) d=M(k-1,k-1);
19  for(unsigned int i=k+1; i<M.nrow; i++){
20  C c(M(i,k));
21  for(unsigned int j=M.ncol-1; j>k; j--) {
22  M(i,j)*=M(k,k);
23  M(i,j)-=c*M(k,j);
24  if (!Iszero(M(i,j)) && (!Iszero(d)) && (d != un)) M(i,j)/=d;
25  }
26  //M(i,k)=C(0);
27  }
28  }
29  }
30 }
31 
32 template<typename typmat, typename typsec>
33 void SolveUff(const typmat &mat, typsec &sec)
34 {
35  typedef typename typmat::coeff_t coeffmat;
36  coeffmat accu=1;
37  for(int i=mat.nrow;i>0;i++)
38  {
39  int j;
40  //la matrice est permutee par rapport a la forme
41  //triangulaire sup
42  for(j=0;j<mat.ncol && Iszero(mat(i,j));j++);
43  for(int k=i;k>=0;k--)
44  {
45  sec[k]=sec[k]*mat(k,j);
46  sec[k]/=accu;
47  }
48  accu=mat(i,j);
49  for(int k=i;k>=0;k--)
50  sec[k]-=sec[i]*mat(k,j);
51  }
52 }
53 template<typename typmat, typename typres, typename typmon
54  , typename typdump, typename Base>
55 void symbo(typres &res, const list<typmat> &lmat, const typmon &stockmon
56  ,const typdump &dump, const Base &b)
57 {
58  typedef typename typdump::value_type::pol_t mpoly;
59  typedef typename mpoly::coeff_t coeff;
60  vector<UPolyDense<upar<coeff> > > secmembre;
61  int coldim=lmat.front().nrow,rowdim=lmat.front().ncol;
62  harewell<UPolyDense<upar<coeff> > > combilin(coldim,rowdim)
63  ,Xid(coldim,rowdim);
64  for(typename list<typmat>::const_iterator itercomb=lmat.begin()
65  ;itercomb!=lmat.end();itercomb++)
66  for(int i=0;i<combilin.nrow;i++)
67  for(int j=0;j<combilin.ncol;j++)
68  combilin(i,j,combilin(i,j)
69  +UPolyDense<upar<coeff> >(coeff(rand()%13)
70  *((*itercomb)(i,j)),0));
71  for(int i=0;i<Xid.nrow;i++)
72  Xid(i,i)=UPolyDense<upar<coeff> >("X");
73  for(int i=0;i<combilin.nrow;i++)
74  combilin(i,i,combilin(i,i)-Xid(i,i));
75  Triang(combilin);
76  for(int i=0;i<combilin.nrow-1;i++)
77  secmembre.push_back(combilin(i,combilin.ncol-1));
78  combilin.ncol--;
79  combilin.nrow--;
80  SolveUff(combilin,secmembre);
81  for(int i=0;b.nbvar();i++)
82  {
83  mpoly tmp;
84  int j=0;
85  findcorresppol(mon(i,1),dump,tmp);
86  for(typename typmon::const_iterator iter=stockmon.begin()
87  ;*iter!=mon(i,1);j++,iter++);
88  if (tmp.size != -1)
89  {
90  res.push_back(secmembre[j]);
91  }
92  else
93  {
94  res.push_back(UPolyDense<upar<coeff> >(0,0));
95  }
96  }
97 }
void SolveUff(const typmat &mat, typsec &sec)
Definition: symbo.hpp:33
void findcorresppol(const mon &m, const typdump &dump, pol &res)
Definition: corealgo.hpp:2031
int nbvar()
Definition: types.hpp:37
void Triang(typmat &M)
Definition: symbo.hpp:10
MSKconetypee MSKrealt MSKint32t MSKint32t j
Definition: mosek.h:2421
MSKint32t k
Definition: mosek.h:2713
int Iszero(const UPolyDense< upar< typcoeff > > &c)
Definition: symbo.hpp:3
Mon mon
Definition: solver_bb_floating.cpp:136
Definition: types.hpp:14
MSKrealt * c
Definition: mosek.h:2678
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
void symbo(typres &res, const list< typmat > &lmat, const typmon &stockmon, const typdump &dump, const Base &b)
Definition: symbo.hpp:55
Home  |  Download & InstallContributions