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

« back to all changes in this revision

Viewing changes to traverser_secondaryfan.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:
 
1
#include "traverser_secondaryfan.h"
 
2
#include <iostream>
 
3
#include "wallideal.h"
 
4
#include "tropical2.h"
 
5
#include "log.h"
 
6
 
 
7
Triangulation2 triangulationWithFullDimensionalIntersection(Triangulation2 g, PolyhedralCone const &c)
 
8
{
 
9
        debug<<"A\n";
 
10
        PolyhedralCone A=intersection(c,g.secondaryFanSupport());
 
11
        debug<<"B\n";
 
12
        IntegerVector v=A.getRelativeInteriorPoint();
 
13
        IntegerVectorList l=c.generatorsOfSpan();
 
14
        l.push_front(v);
 
15
        MatrixTermOrder T(l);
 
16
debug<<T;
 
17
        g.changeToTriangulationInducedBy(T);
 
18
        return g;
 
19
}
 
20
 
 
21
SecondaryFanTraverser::SecondaryFanTraverser(Triangulation2 const &triangulation_):
 
22
        theTriangulation(triangulation_),
 
23
        theCone(triangulation_.getN()),
 
24
        theRestrictingCone(triangulation_.getN())
 
25
        {
 
26
          isHomogeneous=theTriangulation.isHomogeneous();
 
27
          //    debug<<"SUPPORT"<<theTriangulation.secondaryFanSupport();
 
28
 
 
29
 
 
30
          theRestrictingCone=intersection(theRestrictingCone,theTriangulation.secondaryFanSupport());
 
31
                //debug<<"SUPPORT"<<theTriangulation.secondaryFanSupport();
 
32
                //debug<<"RESTRICTING"<<theRestrictingCone;
 
33
                n=triangulation_.getN();
 
34
//              d=n;
 
35
                d=theRestrictingCone.dimension();
 
36
                updatePolyhedralCone();
 
37
        }
 
38
 
 
39
SecondaryFanTraverser::SecondaryFanTraverser(Triangulation2 const &triangulation_, PolyhedralCone const &restrictingCone):
 
40
        theTriangulation(triangulation_),
 
41
        theCone(triangulation_.getN()),
 
42
        theRestrictingCone(restrictingCone)
 
43
        {
 
44
          isHomogeneous=theTriangulation.isHomogeneous();
 
45
        theRestrictingCone=intersection(theRestrictingCone,theTriangulation.secondaryFanSupport());
 
46
                d=theRestrictingCone.dimension();
 
47
                n=triangulation_.getN();
 
48
                updatePolyhedralCone();
 
49
        }
 
50
 
 
51
 
 
52
void SecondaryFanTraverser::updatePolyhedralCone()
 
53
{
 
54
        IntegerVectorList empty;
 
55
 
 
56
        theCone=theTriangulation.secondaryCone().negated();
 
57
        //debug<<"THECONE"<<theCone;
 
58
 
 
59
        theCone=intersection(theCone,theRestrictingCone);
 
60
        theCone.canonicalize();
 
61
 
 
62
        //debug<<theCone;
 
63
if(theCone.dimension()!=d)
 
64
        {
 
65
                cerr<<"WARNING THIS CONE HAS THE WRONG DIMENSION!"<<endl;
 
66
 
 
67
                cerr<<"d"<<d<<"n"<<n;
 
68
 
 
69
                AsciiPrinter P(Stderr);
 
70
                theRestrictingCone.print(&P);
 
71
                assert(0);
 
72
        }
 
73
}
 
74
 
 
75
void SecondaryFanTraverser::changeCone(IntegerVector const &ridgeVector, IntegerVector const &rayVector)
 
76
{
 
77
//  debug<<"changeCone\n";
 
78
  assert(theCone.contains(ridgeVector));
 
79
  //      debug<<"ridgeVector"<<ridgeVector<<"\n";
 
80
  //      debug<<"rayVector"<<rayVector<<"\n";
 
81
  if(d==n)
 
82
    {
 
83
      /* If we are traversing a full-dimensional fan, then the rayVector is
 
84
       * the unique (up to scaling) normal vector of the lineality space.*/
 
85
      theTriangulation.flipNew(-rayVector);
 
86
    }
 
87
  else
 
88
    {
 
89
        IntegerVectorList m;
 
90
        m.push_back(ridgeVector);
 
91
        m.push_back(rayVector);
 
92
        m.push_back(IntegerVector::allOnes(n));//Tie break with degree order - this might not be necessary.
 
93
        MatrixTermOrder T(m);
 
94
        theTriangulation.changeToTriangulationInducedBy(T);
 
95
    }
 
96
  updatePolyhedralCone();
 
97
//      debug<<"END changeCone\n";
 
98
}
 
99
 
 
100
IntegerVectorList SecondaryFanTraverser::link(IntegerVector const &ridgeVector)
 
101
{
 
102
        IntegerVectorList ret;
 
103
        IntegerVector v=theCone.link(ridgeVector).getUniquePoint();
 
104
 
 
105
        ret.push_back(v);
 
106
 
 
107
        if(!theRestrictingCone.containsRelatively(ridgeVector))return ret;
 
108
 
 
109
 
 
110
if(isHomogeneous)
 
111
          {
 
112
                ret.push_back(-v);
 
113
                return ret;
 
114
          }
 
115
  // If the ideal is known to be homogeneous in a positive grading then we don't have to make the following test
 
116
        // Furthermore, for restricted traversals the following test test the ridge for having a positive vector - another definitions of flipability would be to check the lifting of the ridge to the full space.
 
117
        PolyhedralCone temp=theCone.faceContaining(ridgeVector);
 
118
        if(temp.containsPositiveVector())ret.push_back(-v);
 
119
//      cerr<<"THIS NEEDS TO BE FIXED!!!\n";
 
120
//      ret.push_back(-v);
 
121
        return ret;
 
122
}
 
123
 
 
124
PolyhedralCone & SecondaryFanTraverser::refToPolyhedralCone()
 
125
{
 
126
        return theCone;
 
127
}