1 | /* |
---|
2 | * gfanlib_zfan.cpp |
---|
3 | * |
---|
4 | * Created on: Nov 17, 2010 |
---|
5 | * Author: anders |
---|
6 | */ |
---|
7 | |
---|
8 | #include "gfanlib_zfan.h" |
---|
9 | |
---|
10 | namespace gfan |
---|
11 | { |
---|
12 | static int numberOf(std::vector<std::vector<IntVector> > T, int dimension) |
---|
13 | { |
---|
14 | assert(dimension>=0); |
---|
15 | if(dimension>=T.size())return 0; |
---|
16 | return T[dimension].size(); |
---|
17 | } |
---|
18 | std::vector<std::vector<IntVector> > &ZFan::table(bool orbit, bool maximal)const |
---|
19 | { |
---|
20 | if(orbit) |
---|
21 | { |
---|
22 | if(maximal)return maximalConeOrbits; |
---|
23 | return coneOrbits; |
---|
24 | } |
---|
25 | if(maximal)return maximalCones; |
---|
26 | return cones; |
---|
27 | } |
---|
28 | int ZFan::numberOfConesOfDimension(int d, bool orbit, bool maximal)const |
---|
29 | { |
---|
30 | return numberOf(table(orbit,maximal),d); |
---|
31 | } |
---|
32 | ZCone ZFan::getCone(int dimension, int index, bool orbit, bool maximal)const |
---|
33 | { |
---|
34 | IntVector indices=getConeIndices(dimension,index,orbit,maximal); |
---|
35 | return this->complex->makeZCone(indices); |
---|
36 | } |
---|
37 | IntVector ZFan::getConeIndices(int dimension, int index, bool orbit, bool maximal)const |
---|
38 | { |
---|
39 | assert(index>=0); |
---|
40 | assert(index<numberOfConesOfDimension(dimension,orbit,maximal)); |
---|
41 | return table(orbit,maximal)[dimension][index]; |
---|
42 | } |
---|
43 | void ZFan::ensureConeCollection()const |
---|
44 | { |
---|
45 | if(!coneCollection) |
---|
46 | { |
---|
47 | assert(0); |
---|
48 | } |
---|
49 | } |
---|
50 | void ZFan::ensureComplex()const |
---|
51 | { |
---|
52 | if(!complex) |
---|
53 | { |
---|
54 | assert(coneCollection); |
---|
55 | complex = new SymmetricComplex(coneCollection->toSymmetricComplex()); |
---|
56 | complex->buildConeLists(false,false,&cones); |
---|
57 | complex->buildConeLists(true,false,&maximalCones); |
---|
58 | complex->buildConeLists(false,true,&coneOrbits); |
---|
59 | complex->buildConeLists(true,true,&maximalConeOrbits); |
---|
60 | } |
---|
61 | } |
---|
62 | ZFan::~ZFan() |
---|
63 | { |
---|
64 | if(coneCollection) |
---|
65 | { |
---|
66 | delete coneCollection; |
---|
67 | coneCollection=0; |
---|
68 | } |
---|
69 | if(complex) |
---|
70 | { |
---|
71 | delete complex; |
---|
72 | complex=0; |
---|
73 | } |
---|
74 | } |
---|
75 | ZFan::ZFan(ZFan const& f): |
---|
76 | complex(0), |
---|
77 | coneCollection(0) |
---|
78 | { |
---|
79 | if(f.coneCollection) |
---|
80 | { |
---|
81 | coneCollection=new PolyhedralFan(*f.coneCollection); |
---|
82 | } |
---|
83 | if(f.complex) |
---|
84 | { |
---|
85 | complex=new SymmetricComplex(*f.complex); |
---|
86 | } |
---|
87 | } |
---|
88 | ZFan& ZFan::operator=(ZFan const &f) |
---|
89 | { |
---|
90 | if(this!=&f) |
---|
91 | { |
---|
92 | if(complex) |
---|
93 | { |
---|
94 | delete complex; |
---|
95 | complex=0; |
---|
96 | } |
---|
97 | if(coneCollection) |
---|
98 | { |
---|
99 | delete coneCollection; |
---|
100 | coneCollection=0; |
---|
101 | } |
---|
102 | if(f.coneCollection) |
---|
103 | { |
---|
104 | coneCollection=new PolyhedralFan(*f.coneCollection); |
---|
105 | } |
---|
106 | if(f.complex) |
---|
107 | { |
---|
108 | complex=new SymmetricComplex(*f.complex); |
---|
109 | } |
---|
110 | } |
---|
111 | return *this; |
---|
112 | } |
---|
113 | ZFan::ZFan(int ambientDimension): |
---|
114 | complex(0) |
---|
115 | { |
---|
116 | coneCollection=new PolyhedralFan(ambientDimension); |
---|
117 | } |
---|
118 | ZFan::ZFan(SymmetryGroup const &sym_): |
---|
119 | complex(0) |
---|
120 | { |
---|
121 | coneCollection=new PolyhedralFan(sym_); |
---|
122 | } |
---|
123 | ZFan ZFan::fullFan(int n) |
---|
124 | { |
---|
125 | ZFan ret(n); |
---|
126 | ret.insert(ZCone(ZMatrix(0,n),ZMatrix(0,n))); |
---|
127 | return ret; |
---|
128 | } |
---|
129 | ZFan ZFan::fullFan(SymmetryGroup const &sym_) |
---|
130 | { |
---|
131 | ZFan ret(sym_); |
---|
132 | ret.insert(ZCone(ZMatrix(0,sym_.sizeOfBaseSet()),ZMatrix(0,sym_.sizeOfBaseSet()))); |
---|
133 | return ret; |
---|
134 | } |
---|
135 | int ZFan::getAmbientDimension()const |
---|
136 | { |
---|
137 | if(complex) |
---|
138 | return complex->getAmbientDimension(); |
---|
139 | if(coneCollection) |
---|
140 | return coneCollection->getAmbientDimension(); |
---|
141 | assert(0); |
---|
142 | return 0; |
---|
143 | } |
---|
144 | void ZFan::insert(ZCone const &c) |
---|
145 | { |
---|
146 | ensureConeCollection(); |
---|
147 | coneCollection->insert(c); |
---|
148 | } |
---|
149 | |
---|
150 | /* ZFan::ZFan(int ambientDimension): |
---|
151 | theFan(ambientDimension) |
---|
152 | { |
---|
153 | |
---|
154 | }*/ |
---|
155 | /* |
---|
156 | ZFan::ZFan(SymmetryGroup const &sym): |
---|
157 | theFan(sym) |
---|
158 | { |
---|
159 | } |
---|
160 | */ |
---|
161 | |
---|
162 | std::string ZFan::toString(int flags)const |
---|
163 | { |
---|
164 | ensureComplex(); |
---|
165 | return complex->toString(flags);//complex->getMinDim(),complex->getMaxDim(),0,0); |
---|
166 | // return "NEEDTOFIXTHIS"; |
---|
167 | //return theFan.toString(); |
---|
168 | } |
---|
169 | |
---|
170 | /*int ZFan::getAmbientDimension()const |
---|
171 | { |
---|
172 | return theFan.getAmbientDimension(); |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | void ZFan::insert(ZCone const &c) |
---|
177 | { |
---|
178 | theFan.insert(c); |
---|
179 | } |
---|
180 | */ |
---|
181 | /* |
---|
182 | void ZFan::remove(ZCone const &c) |
---|
183 | { |
---|
184 | theFan.remove(c); |
---|
185 | } |
---|
186 | */ |
---|
187 | /* |
---|
188 | ZFan::coneIterator ZFan::conesBegin()const |
---|
189 | { |
---|
190 | return theFan.conesBegin(); |
---|
191 | } |
---|
192 | |
---|
193 | ZFan::coneIterator ZFan::conesEnd()const |
---|
194 | { |
---|
195 | return theFan.conesEnd(); |
---|
196 | } |
---|
197 | */ |
---|
198 | // static PolyhedralFan readFan(string const &filename, bool onlyMaximal=true, IntegerVector *w=0, set<int> const *conesIndice=0, SymmetryGroup const *sym=0, bool readCompressedIfNotSym=false); |
---|
199 | |
---|
200 | } |
---|