~ubuntu-branches/ubuntu/saucy/gfan/saucy-proposed

« back to all changes in this revision

Viewing changes to multiplicity.cpp

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2013-07-09 10:44:01 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130709104401-5q66ozz5j5af0dak
Tags: 0.5+dfsg-3
* Upload to unstable.
* modify remove_failing_tests_on_32bits.patch to replace command of
  0009RenderStairCase test with an empty one instead of deleting it.
* remove lintian override about spelling error

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include "polyhedralcone.h"
4
4
#include "wallideal.h"
5
5
#include "saturation.h"
 
6
#include "linalg.h"
 
7
#include "log.h"
6
8
 
7
9
IntegerVector writeInTermsOf(IntegerVector const &v, IntegerMatrix const &b)
8
10
{//write the row vector v as a integer linear combination of the basis elements of the basis b. Asserts if v is not in the lattice generated by b
12
14
    Q.printVector(v);
13
15
    Q.printVectorList(b.getRows());
14
16
  */
15
 
  
 
17
 
16
18
  int m=b.getHeight();//dimension of lattice
17
19
  assert(v.size()==b.getWidth());
18
20
  IntegerVectorList equations=b.getRows();
57
59
    {
58
60
      IntegerVector rel=p.terms.begin()->first.exponent;
59
61
      for(TermMap::const_iterator i=p.terms.begin();i!=p.terms.end();i++)
60
 
        ret+=Term(i->second,Monomial(theRing,writeInTermsOf(i->first.exponent-rel,lattice)));
 
62
        ret+=Term(i->second,Monomial(r2,writeInTermsOf(i->first.exponent-rel,lattice)));
61
63
    }
62
64
  return ret;
63
65
}
64
66
 
 
67
/*
 
68
//Old implementation
65
69
PolynomialSet multiplicativeChangeInv(PolynomialSet const &g, IntegerMatrix const &lattice, PolynomialRing const &r2)
66
70
{
67
71
  PolynomialRing theRing=g.getRing();
71
75
 
72
76
  return ret;
73
77
}
 
78
*/
 
79
 
 
80
PolynomialSet multiplicativeChangeInv(PolynomialSet const &g, IntegerMatrix const &lattice, PolynomialRing const &r2)
 
81
{
 
82
  PolynomialRing theRing=g.getRing();
 
83
  PolynomialSet ret(r2);
 
84
  FieldMatrix bigMatrix=combineLeftRight(integerMatrixToFieldMatrix(lattice,Q),FieldMatrix::identity(Q,lattice.getHeight()));
 
85
  bigMatrix.reduce();
 
86
  FieldMatrix reducedLatticeBasis=bigMatrix.submatrix(0,0,lattice.getHeight(),lattice.getWidth());
 
87
  FieldMatrix inverseMatrix=bigMatrix.submatrix(0,lattice.getWidth(),lattice.getHeight(),lattice.getWidth()+lattice.getHeight());
 
88
  for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++)
 
89
    {
 
90
      Polynomial q(r2);
 
91
      Polynomial const &p=*i;
 
92
      if(!p.isZero())
 
93
        {
 
94
          IntegerVector rel=p.terms.begin()->first.exponent;
 
95
          for(TermMap::const_iterator i=p.terms.begin();i!=p.terms.end();i++)
 
96
            {
 
97
              IntegerVector diff=i->first.exponent-rel;
 
98
              FieldVector diff2=integerVectorToFieldVector(diff,Q);
 
99
              FieldVector temp(Q,0);
 
100
              reducedLatticeBasis.normalForm(diff2,&temp);
 
101
              FieldVector temp2=temp*inverseMatrix;
 
102
              q+=Term(i->second,Monomial(r2,fieldVectorToIntegerVector(temp2)));
 
103
            }
 
104
        }
 
105
      ret.push_back(q);
 
106
    }
 
107
  return ret;
 
108
}
74
109
 
75
110
 
76
111
PolynomialSet notLaurent(PolynomialSet const &s)
84
119
}
85
120
 
86
121
 
87
 
int multiplicity(PolynomialSet const &g)
 
122
PolynomialSet idealWithSameMultiplicity(PolynomialSet const &g)
88
123
{
89
124
  PolynomialRing r1=g.getRing();
90
125
  PolyhedralCone H=homogeneitySpace(g).dualCone();
93
128
 
94
129
  IntegerVectorList a=H.getEquations();
95
130
 
96
 
  //  IntegerMatrix latticeBasis=rowsToIntegerMatrix(a);
97
 
 
 
131
  //log3  IntegerMatrix latticeBasis=rowsToIntegerMatrix(a);
98
132
 
99
133
  IntegerMatrix temp(H.ambientDimension(),0);
100
134
  if(a.size()!=0)temp=rowsToIntegerMatrix(a).transposed();
102
136
 
103
137
  mlll(latticeBasis);
104
138
 
105
 
  //  AsciiPrinter(Stderr).printVectorList(latticeBasis.getRows());
 
139
//  log3  AsciiPrinter(Stderr).printVectorList(latticeBasis.getRows());
106
140
 
107
141
  PolynomialRing r2(r1.getField(),latticeBasis.getHeight());
108
142
 
109
 
  PolynomialSet g2=notLaurent(multiplicativeChangeInv(g,latticeBasis,r2));
 
143
  return notLaurent(multiplicativeChangeInv(g,latticeBasis,r2));
 
144
}
110
145
 
111
 
  //  AsciiPrinter(Stderr).printPolynomialSet(g2);
 
146
int multiplicity(PolynomialSet const &g)
 
147
{
 
148
  PolynomialSet g2=idealWithSameMultiplicity(g);
 
149
  log3 AsciiPrinter(Stderr).printPolynomialSet(g2);
112
150
 
113
151
  PolynomialSet g3=nonHomogeneousSaturation(g2);
114
152
 
115
 
  //  AsciiPrinter(Stderr).printPolynomialSet(g3);
 
153
  log3  AsciiPrinter(Stderr).printPolynomialSet(g3);
116
154
 
117
155
  return numberOfStandardMonomials(g3);
118
156
}