1 /* 2 * gfanlib_zfan.h 3 * 4 * Created on: Nov 17, 2010 5 * Author: anders 6 */ 7 8 #ifndef GFANLIB_ZFAN_H_ 9 #define GFANLIB_ZFAN_H_ 10 11 /* 12 * gfanlib_polyhedralfan.h 13 * 14 * Created on: Nov 16, 2010 15 * Author: anders 16 */ 17 18 #ifndef GFANLIB_ZFAN_H_INCLUDED 19 #define GFANLIB_ZFAN_H_INCLUDED 20 21 #include <set> 22 #include <list> 23 #include <map> 24 #include "gfanlib_polyhedralfan.h" 25 #include "gfanlib_symmetriccomplex.h" 26 27 namespace gfan{ 28 29 /** 30 * This class represents a Polyhedral fan with the combined features of a SymmetricComplex, and 31 * a PolyhedralFan (which we regards as some collection of cones of the fan with the property that every cone 32 * of the fan is a face of these (up to action by the group)). 33 * It is important to distinguis between the cones of the collection, the cones of the fan as a mathematical object, and the orbits of cones of the fan. 34 * 35 * 36 * TEMPLATES SHOULD BE HIDDEN 37 */ 38 class ZFan 39 { 40 mutable PolyhedralFan *coneCollection; 41 mutable SymmetricComplex *complex; 42 mutable std::vector<std::vector<IntVector > > cones; 43 mutable std::vector<std::vector<IntVector > > maximalCones; 44 mutable std::vector<std::vector<Integer> > multiplicities; // for maximal cones only 45 mutable std::vector<std::vector<IntVector > > coneOrbits; 46 mutable std::vector<std::vector<IntVector > > maximalConeOrbits; 47 mutable std::vector<std::vector<Integer> > multiplicitiesOrbits; // for maximal cones orbits only 48 49 50 // SymmetryGroup sym; 51 52 /** 53 * Functions that makes the symmetric complex invalid: 54 * insert() and construction 55 * 56 * Functions that make the cone collection invalid: 57 * readFan() 58 * 59 */ 60 void ensureConeCollection()const; 61 void ensureComplex()const; 62 void killComplex()const; 63 public: 64 std::vector<std::vector<IntVector> > &table(bool orbit, bool maximal)const; 65 ~ZFan(); ZFan()66 ZFan(): 67 coneCollection(0), 68 complex(0) 69 {} 70 ZFan(ZFan const& f); 71 /** 72 * 73 * To read from string, do the following: 74 * std::string test="TEST"; 75 * std::istringstream s(test); 76 * ZFan G(s); 77 * 78 */ 79 ZFan(std::istream &f); 80 ZFan& operator=(ZFan const &f); 81 /** 82 * Creates an empty fan in the ambient space of dimension n. 83 * It is a mistake to: 84 * specify a negative ambientDimension. 85 */ 86 ZFan(int ambientDimension); 87 /** 88 * Creates an empty fan in the ambient space with dimension equal to the number of elements being permuted by the group. 89 * The fan will have the symmmetries given by sym_ associated. 90 */ 91 ZFan(SymmetryGroup const &sym_); 92 /** 93 * Creates the fan in dimension n consisting of the n-dimensional space. 94 */ 95 static ZFan fullFan(int n); 96 /** 97 * Creates the full space as a fan in the ambient space with dimension equal to the number of elements being permuted by the group. 98 * The fan will have the symmetries given by sym_ associated. 99 */ 100 static ZFan fullFan(SymmetryGroup const &sym_); 101 /** 102 * Reads from stream 103 */ 104 // static ZFan readFan(string const &filename, bool onlyMaximal=true, IntegerVector *w=0, set<int> const *conesIndice=0, SymmetryGroup const *sym=0, bool readCompressedIfNotSym=false); 105 /** 106 * Writes to string 107 */ 108 std::string toString(int flags=0)const; 109 /** 110 * Returns the dimension of the ambient space. 111 */ 112 int getAmbientDimension()const; 113 /** 114 * Returns the largest dimension of a cone in the fan. If the fan is empty, then -1 is returned. 115 */ 116 int getDimension()const; 117 /** 118 * Returns the smallest codimension of a cone in the fan. If the fan is empty, then -1 is returned. 119 */ 120 int getCodimension()const; 121 /** 122 * Returns the dimension of the lineality space of the fan. Notice that the lineality space of the 123 * empty fan is the ambient space. 124 */ 125 int getLinealityDimension()const; 126 /** 127 * Returns the f-Vector of the fan. 128 */ 129 ZVector getFVector()const; 130 /** 131 * Returns true, if the fan is simplicial. False otherwise. 132 */ 133 bool isSimplicial()const; 134 /** 135 * Returns true, if the fan is pure. False otherwise. 136 */ 137 bool isPure()const; 138 /** 139 * Inserts c into the fan. 140 * It is a mistake to insert a cone which live in a space of the wrong dimension. 141 * It is a mistake to insert a cone which does not result in a fan satisfying the nice intersection properties of a fan. 142 * However, the second mistake will not cause the code to crash, but only give undefined results. 143 * 144 * The method insert() is expensive in the sense that calling it may require part of the representation 145 * of the fan to be recomputed. The recomputation only happens on request. Therefore it is expensive 146 * to have alternating calls to for example "insert()" and "numberOfConesOfDimension()". 147 * 148 * Notice that insert() has the effect of reordering cones, orbits and rays of the fan. 149 */ 150 void insert(ZCone const &c); 151 void remove(ZCone const &c); 152 /** 153 * Returns the number of cones of dimension d in the collection. 154 */ 155 int numberOfConesOfDimension(int d, bool orbit, bool maximal)const; 156 int numberOfConesInCollection()const; 157 /** 158 * Returns the cone in the collection given by the index. It is a mistake to specify an index which 159 * is out of range. 160 */ 161 // ZCone const &getConeInCollection(int index)const; 162 /** 163 * Returns the cone in the cone of the fan 164 */ 165 ZCone getCone(int dimension, int index, bool orbit, bool maximal)const; 166 IntVector getConeIndices(int dimension, int index, bool orbit, bool maximal)const; 167 168 // ZFan expand()const; 169 // SymmetryGorup recoverAllSymmetries()const; 170 171 /* typedef PolyhedralConeList::const_iterator coneIterator; 172 PolyhedralFan::coneIterator conesBegin()const; 173 PolyhedralFan::coneIterator conesEnd()const; 174 */ 175 176 }; 177 178 } 179 180 #endif 181 182 #endif /* GFANLIB_ZFAN_H_ */ 183