[74a91c9] | 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; |
---|
[5ff68b] | 44 | mutable std::vector<std::vector<Integer> > multiplicities; // for maximal cones only |
---|
[74a91c9] | 45 | mutable std::vector<std::vector<IntVector > > coneOrbits; |
---|
| 46 | mutable std::vector<std::vector<IntVector > > maximalConeOrbits; |
---|
[5ff68b] | 47 | mutable std::vector<std::vector<Integer> > multiplicitiesOrbits; // for maximal cones orbits only |
---|
[74a91c9] | 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; |
---|
[e543dd] | 62 | void killComplex()const; |
---|
[74a91c9] | 63 | public: |
---|
[26b713] | 64 | std::vector<std::vector<IntVector> > &table(bool orbit, bool maximal)const; |
---|
[74a91c9] | 65 | ~ZFan(); |
---|
[26b713] | 66 | ZFan(): |
---|
| 67 | coneCollection(0), |
---|
| 68 | complex(0) |
---|
| 69 | {} |
---|
[74a91c9] | 70 | ZFan(ZFan const& f); |
---|
[c4d065] | 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); |
---|
[74a91c9] | 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; |
---|
[5ff68b] | 113 | /** |
---|
| 114 | * Returns the largest dimension of a cone in the fan. If the fan is empty, then -1 is returned. |
---|
| 115 | */ |
---|
[26b713] | 116 | int getDimension()const; |
---|
[5ff68b] | 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 | */ |
---|
[26b713] | 125 | int getLinealityDimension()const; |
---|
[5ff68b] | 126 | /** |
---|
| 127 | * Returns the f-Vector of the fan. |
---|
| 128 | */ |
---|
[26b713] | 129 | ZVector getFVector()const; |
---|
[5ff68b] | 130 | /** |
---|
| 131 | * Returns true, if the fan is simplicial. False otherwise. |
---|
| 132 | */ |
---|
[26b713] | 133 | bool isSimplicial()const; |
---|
[5ff68b] | 134 | /** |
---|
| 135 | * Returns true, if the fan is pure. False otherwise. |
---|
| 136 | */ |
---|
[26b713] | 137 | bool isPure()const; |
---|
[74a91c9] | 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); |
---|
[26b713] | 151 | void remove(ZCone const &c); |
---|
[74a91c9] | 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 | */ |
---|
[5ff68b] | 161 | // ZCone const &getConeInCollection(int index)const; |
---|
[74a91c9] | 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_ */ |
---|