1 /*
2  * gfanlib_symmetriccomplex.h
3  *
4  *  Created on: Nov 16, 2010
5  *      Author: anders
6  */
7 
8 #ifndef GFANLIB_SYMMETRICCOMPLEX_H_INCLUDED
9 #define GFANLIB_SYMMETRICCOMPLEX_H_INCLUDED
10 
11 #include <set>
12 #include <string>
13 #include <map>
14 
15 #include "gfanlib_symmetry.h"
16 #include "gfanlib_matrix.h"
17 #include "gfanlib_zcone.h"
18 
19 namespace gfan{
20   enum FanPrintingFlags{
21     FPF_conesCompressed=1,
22     FPF_conesExpanded=2,
23     FPF_cones=4,
24     FPF_maximalCones=8,
25     FPF_boundedInfo=16,
26     FPF_values=32,
27     FPF_group=64,
28     FPF_multiplicities=128,
29     FPF_xml=256,
30     FPF_tPlaneSort=512,
31     FPF_primitiveRays=1024,
32 
33     FPF_default=2+4+8
34   };
35 
36   class SymmetricComplex{
37   int n;
38   ZMatrix linealitySpace; // Has full row rank.
39   ZMatrix vertices;
40   std::map<ZVector,int> indexMap;
41   SymmetryGroup sym;
42   IntVector dimensionsAtInfinity()const;
43  public:
getAmbientDimension()44    int getAmbientDimension()const{return n;}
45    class Cone
46   {
47     bool isKnownToBeNonMaximalFlag;
48   public:
49     IntVector indices;//always sorted
50     Cone(std::set<int> const &indices_, int dimension_, Integer multiplicity_, bool sortWithSymmetry, SymmetricComplex const &complex);
51     std::set<int> indexSet()const;
52     int dimension;
53     Integer multiplicity;
isKnownToBeNonMaximal()54     bool isKnownToBeNonMaximal()const{return isKnownToBeNonMaximalFlag;}
setKnownToBeNonMaximal()55     void setKnownToBeNonMaximal(){isKnownToBeNonMaximalFlag=true;}
56     bool isSubsetOf(Cone const &c)const;
57     SymmetricComplex::Cone permuted(Permutation const &permutation, SymmetricComplex const &complex, bool withSymmetry)const;
58     ZVector sortKey;
59     Permutation sortKeyPermutation;
60     bool operator<(const Cone & b)const;
61     bool isSimplicial(int linealityDim)const;
62     void remap(SymmetricComplex &complex);
63 /**
64  * This routine computes a basis for the orthogonal complement of the cone.
65  * Notice that the lineality space, which is unknown at the time, is ignored.
66  * This routine is deterministic and used for orienting the faces when computing homology.
67  */
68     ZMatrix orthogonalComplement(SymmetricComplex &complex)const;
69   };
70   typedef std::set<Cone> ConeContainer;
71   ConeContainer cones;
72   int dimension;
73   SymmetricComplex(ZMatrix const &rays, ZMatrix const &linealitySpace, SymmetryGroup const &sym_);
74   /**
75    * Returns a reference to the matrix of vertices on which the complex is build.
76    * The reference is valid as the Symmetric complex object exists.
77    */
getVertices()78   ZMatrix const &getVertices()const{return vertices;}
79   bool contains(Cone const &c)const;
80   void insert(Cone const &c);
81   int getMaxDim()const;
82   int getMinDim()const;
83   int getLinDim()const;
84   bool isMaximal(Cone const &c)const;
85   bool isPure()const;
86   ZVector fvector(bool boundedPart=false)const;
87   void buildConeLists(bool onlyMaximal, bool compressed, std::vector<std::vector<IntVector > >*conelist, std::vector<std::vector<Integer > > *multiplicities=0)const;
88   std::string toStringJustCones(int dimLow, int dimHigh, bool onlyMaximal, bool group, std::ostream *multiplicities=0, bool compressed=false, bool tPlaneSort=false)const;
89   std::string toString(int flags=0)const;
90   bool isSimplicial()const;
91   /**
92      Calling this function will change the representative of each cone
93      orbit by "applying" the permutation which will give the sortkey to
94      the set of indices of the cone.
95    */
96   void remap();
97   /**
98    * Looks up the index of the vector among the vertices.
99    */
100   int indexOfVertex(ZVector const &v)const;
101   int numberOfConesOfDimension(int d)const;
102   /**
103    * Given a cone this returns its index among all cones of that dimension.
104    * Used for assigning "names" to cones.
105    */
106   int dimensionIndex(Cone const &c);
107 #if 0
108   /**
109    * This routine is used for constructing the boundary map for homology computations.
110    */
111   void boundary(Cone const &c, IntVector &indices, IntVector &signs);
112 /**
113  * This routine computes the ith boundary map for homology as a matrix.
114  */
115   ZMatrix boundaryMap(int i);
116 #endif
117   ZCone makeZCone(IntVector const &indices)const;
118 };
119 }
120 
121 #endif
122