1 | /*****************************************************************************\ |
---|
2 | * Computer Algebra System SINGULAR |
---|
3 | \*****************************************************************************/ |
---|
4 | /** @file Fan.h |
---|
5 | * |
---|
6 | * This file provides the class Fan for storing Gröbner fans. |
---|
7 | * |
---|
8 | * ABSTRACT: This file provides the class Fan for storing Gröbner fans. |
---|
9 | * Fans are given by a set of maximal cones, each of which can be given |
---|
10 | * by a collection of maximal rays and/or facet normals. Moreover, a fan |
---|
11 | * knows its lineality space L given by a matrix the columns of which span |
---|
12 | * L. |
---|
13 | * In this implementation, the user can store all maximal rays and facet |
---|
14 | * normals in a Fan so that any cone can be defined by providing indices |
---|
15 | * to these maximal rows and/or facet normals. Thereby, cones only need to |
---|
16 | * store integer indices instead of column vectors (which are all stored |
---|
17 | * at Fan). |
---|
18 | * Besides some properties which can be set to 'yes', 'no' or 'do not know' |
---|
19 | * (encoded by the three int values 1, 0, -1), there is a member m_adjacency |
---|
20 | * which stores an adjacency matrix for the neighbourhood relations among |
---|
21 | * the maximal cones. Each entry of this matrix is some c of type Cone*: |
---|
22 | * Normally, c stores the intersection facet of two adjacent maximal |
---|
23 | * cones. If they are not adjacent, then c->isNoAdj() evaluates to true. |
---|
24 | * If they are adjacent but the user did not store a concrete intersection |
---|
25 | * facet then c->isNoFacet() evaluates to true. |
---|
26 | * |
---|
27 | * @author Frank Seelisch |
---|
28 | * |
---|
29 | * @internal @version \$Id$ |
---|
30 | * |
---|
31 | **/ |
---|
32 | /*****************************************************************************/ |
---|
33 | |
---|
34 | #ifndef FAN_H |
---|
35 | #define FAN_H |
---|
36 | |
---|
37 | class Cone; |
---|
38 | |
---|
39 | class Fan |
---|
40 | { |
---|
41 | private: |
---|
42 | intvec* m_maxRays; /* matrix with maximal rays as columns */ |
---|
43 | intvec* m_facetNs; /* matrix with facet normals as columns */ |
---|
44 | intvec* m_linSpace; /* matrix with columns spanning the lin. sp. */ |
---|
45 | lists m_maxCones; /* list of max. cones; i.e. objcts of type Cone */ |
---|
46 | int m_dim; /* dim >= 0 or -1 if unknown */ |
---|
47 | int m_complete; /* = 0 if 'no', = 1 if 'yes', = -1 if unknown */ |
---|
48 | int m_simplicial; /* = 0 if 'no', = 1 if 'yes', = -1 if unknown */ |
---|
49 | int m_pure; /* = 0 if 'no', = 1 if 'yes', = -1 if unknown */ |
---|
50 | lists m_adjacency; /* a list of objects of type Cone; this list is |
---|
51 | treated as a matrix of size |
---|
52 | (number of max. cones)^2 */ |
---|
53 | /** |
---|
54 | * For checking whether an intvec contains a specific int. |
---|
55 | * |
---|
56 | * Returns true iff i is contained in iv. |
---|
57 | **/ |
---|
58 | static bool contains ( |
---|
59 | const intvec* iv, /**< [in] the intvec to be searched for i, */ |
---|
60 | const int i /**< [in] the int to be found in iv, */ |
---|
61 | ); |
---|
62 | |
---|
63 | /** |
---|
64 | * Getter for the member m_adjacency. |
---|
65 | * |
---|
66 | **/ |
---|
67 | lists getRawAdj () const; |
---|
68 | |
---|
69 | /** |
---|
70 | * For inserting s new rows and columns in m_adjacency. |
---|
71 | * |
---|
72 | * This method will be called prior to the insertion of |
---|
73 | * s new maximal cones in the given fan. |
---|
74 | * s rows will be appended at the bottom of m_adjacency and |
---|
75 | * s column at the right. All previous entries will remain |
---|
76 | * untouched. |
---|
77 | **/ |
---|
78 | void insertCrosses ( |
---|
79 | int s /**< [in] the number of crosses to be inserted, */ |
---|
80 | ); |
---|
81 | |
---|
82 | /** |
---|
83 | * For deleting rows and columns in m_adjacency with the |
---|
84 | * indices given in the argument intvec. |
---|
85 | * |
---|
86 | * This method will be called prior to the deletion of |
---|
87 | * maximal cones from the given fan. |
---|
88 | * Entries of m_adjacency which are on none of the specified |
---|
89 | * rows and columns will remain untouched. |
---|
90 | **/ |
---|
91 | void deleteCrosses ( |
---|
92 | const intvec* indices |
---|
93 | ); |
---|
94 | |
---|
95 | public: |
---|
96 | /** |
---|
97 | * Constructor for class Fan. |
---|
98 | * |
---|
99 | * Each of the arguments may be NULL but not both maxRays and |
---|
100 | * facetNs simultaneously. |
---|
101 | **/ |
---|
102 | Fan ( |
---|
103 | const intvec* maxRays, /**< [in] maximal rays given by columns */ |
---|
104 | const intvec* facetNs, /**< [in] facet normals given by columns */ |
---|
105 | const intvec* linSpace /**< [in] lineality space spannced by col.'s */ |
---|
106 | ); |
---|
107 | |
---|
108 | /** |
---|
109 | * Plain constructor for class Fan. |
---|
110 | * |
---|
111 | **/ |
---|
112 | Fan (); |
---|
113 | |
---|
114 | /** |
---|
115 | * Deep copy constructor for class Fan. |
---|
116 | * |
---|
117 | **/ |
---|
118 | Fan ( |
---|
119 | const Fan& f /**< [in] the fan to be deep copied */ |
---|
120 | ); |
---|
121 | |
---|
122 | /** |
---|
123 | * Destructor for class Fan. |
---|
124 | * |
---|
125 | **/ |
---|
126 | ~Fan (); |
---|
127 | |
---|
128 | /** |
---|
129 | * For obtaining a printable representation of the given fan. |
---|
130 | * |
---|
131 | * The caller of this method is responsible for destructing |
---|
132 | * the obtained char*. |
---|
133 | **/ |
---|
134 | char* toString () const; |
---|
135 | |
---|
136 | /** |
---|
137 | * For printing a string representation of the given fan |
---|
138 | * to the console. |
---|
139 | **/ |
---|
140 | void print () const; |
---|
141 | |
---|
142 | /** |
---|
143 | * For retrieving the ambient dimension of the given fan. |
---|
144 | * |
---|
145 | * At runtime this will be read off the number of rows of |
---|
146 | * the lineality space. |
---|
147 | **/ |
---|
148 | int getAmbientDim () const; |
---|
149 | |
---|
150 | /** |
---|
151 | * For retrieving the dimension of the given fan. |
---|
152 | * |
---|
153 | * Returns -1 for 'unknown', otherwise a number >= 0. |
---|
154 | **/ |
---|
155 | int getDim () const; |
---|
156 | |
---|
157 | /** |
---|
158 | * For retrieving whether the given fan is complete. |
---|
159 | * |
---|
160 | * Returns -1 for 'unknown', 1 for 'yes' and '0' for 'no'. |
---|
161 | * Completeness means that the fan covers the entire ambient |
---|
162 | * space. |
---|
163 | **/ |
---|
164 | int getComplete () const; |
---|
165 | |
---|
166 | /** |
---|
167 | * For retrieving whether the given fan is simplicial. |
---|
168 | * |
---|
169 | * Returns -1 for 'unknown', 1 for 'yes' and '0' for 'no'. |
---|
170 | * Simpliciality means that each maximal cone has dimension |
---|
171 | * ambient dim minus 1. |
---|
172 | **/ |
---|
173 | int getSimplicial () const; |
---|
174 | |
---|
175 | /** |
---|
176 | * For retrieving whether the given fan is pure. |
---|
177 | * |
---|
178 | * Returns -1 for 'unknown', 1 for 'yes' and '0' for 'no'. |
---|
179 | * Purity means that each maximal cone has the same dimension. |
---|
180 | **/ |
---|
181 | int getPure () const; |
---|
182 | |
---|
183 | /** |
---|
184 | * For setting the dimension of the given fan. |
---|
185 | * |
---|
186 | * Any negative input will be converted to -1. |
---|
187 | **/ |
---|
188 | void setDim ( |
---|
189 | const int dim /**< [in] target dim of the given fan */ |
---|
190 | ); |
---|
191 | |
---|
192 | /** |
---|
193 | * For setting the completeness of the given fan. |
---|
194 | * |
---|
195 | * Any input other than 0 and 1 will be converted to -1. |
---|
196 | **/ |
---|
197 | void setComplete ( |
---|
198 | const int complete /**< [in] target completeness */ |
---|
199 | ); |
---|
200 | |
---|
201 | /** |
---|
202 | * For setting the simpliciality of the given fan. |
---|
203 | * |
---|
204 | * Any input other than 0 and 1 will be converted to -1. |
---|
205 | **/ |
---|
206 | void setSimplicial ( |
---|
207 | const int simplicial /**< [in] target simpliciality */ |
---|
208 | ); |
---|
209 | |
---|
210 | /** |
---|
211 | * For setting the purity of the given fan. |
---|
212 | * |
---|
213 | * Any input other than 0 and 1 will be converted to -1. |
---|
214 | **/ |
---|
215 | void setPure ( |
---|
216 | const int pure /**< [in] target purity */ |
---|
217 | ); |
---|
218 | |
---|
219 | /** |
---|
220 | * For retrieving the maximal rays of the given fan. |
---|
221 | * |
---|
222 | * Returns a matrix the columns of which are the maximal rays. |
---|
223 | **/ |
---|
224 | intvec* getMaxRays () const; |
---|
225 | |
---|
226 | /** |
---|
227 | * For retrieving the facet normals of the given fan. |
---|
228 | * |
---|
229 | * Returns a matrix the columns of which are the facet normals. |
---|
230 | **/ |
---|
231 | intvec* getFacetNs () const; |
---|
232 | |
---|
233 | /** |
---|
234 | * For retrieving the lineality space of the given fan. |
---|
235 | * |
---|
236 | * Returns a matrix the columns of which span the lineality space. |
---|
237 | * If the lineality space is trivial, the matrix consists of a |
---|
238 | * single zero column. |
---|
239 | **/ |
---|
240 | intvec* getLinSpace () const; |
---|
241 | |
---|
242 | /** |
---|
243 | * For adding a new maximal cone to the given fan. |
---|
244 | * |
---|
245 | * If the given cone refers (in its member m_pFan) to a fan which |
---|
246 | * differs from this fan, then no maximal cone is added. In this |
---|
247 | * case the method returns false; otherwise true. |
---|
248 | **/ |
---|
249 | bool addMaxCone ( |
---|
250 | const Cone* pCone /**< [in] pointer to the new maximal cone */ |
---|
251 | ); |
---|
252 | |
---|
253 | /** |
---|
254 | * For adding new maximal cones to the given fan. |
---|
255 | * |
---|
256 | * If any of the given cones refers (in its member m_pFan) to a fan |
---|
257 | * which differs from this fan, then no maximal cone is added. In this |
---|
258 | * case the method returns the list index (1st entry -> index = 1) of |
---|
259 | * the invalid cone; otherwise 0. |
---|
260 | **/ |
---|
261 | int addMaxCones ( |
---|
262 | const lists L /**< [in] the list of new maximal cones */ |
---|
263 | ); |
---|
264 | |
---|
265 | /** |
---|
266 | * For deleting a maximal cone from the given fan. |
---|
267 | * |
---|
268 | * If the index is not in [1..number of maximal cones], then |
---|
269 | * no cone is deleted and false is returned; otherwise deletion |
---|
270 | * takes place and true is returned. |
---|
271 | **/ |
---|
272 | bool deleteMaxCone ( |
---|
273 | const int index /**< [in] the cone index to be deleted */ |
---|
274 | ); |
---|
275 | |
---|
276 | /** |
---|
277 | * For deleting maximal cones from the given fan. |
---|
278 | * |
---|
279 | * If any of the indices is not in [1..number of maximal cones], |
---|
280 | * then no cone is deleted and the position of the invalid index |
---|
281 | * (1st index -> position 1) is returned; otherwise deletion |
---|
282 | * takes place and 0 is returned. |
---|
283 | **/ |
---|
284 | int deleteMaxCones ( |
---|
285 | const intvec* indices /**< [in] the cone indices to be deleted */ |
---|
286 | ); |
---|
287 | |
---|
288 | /** |
---|
289 | * For retrieving the maximal cones of the given fan. |
---|
290 | * |
---|
291 | * Returns a list with entries of type Cone. These |
---|
292 | * represent the maximal cones of the given fan. |
---|
293 | **/ |
---|
294 | lists getMaxCones () const; |
---|
295 | |
---|
296 | /** |
---|
297 | * For retrieving adjacency information concerning two maximal |
---|
298 | * cones in the given fan. |
---|
299 | * |
---|
300 | * The method assumes that both arguments lie in |
---|
301 | * [1..number of max. cones] |
---|
302 | * Returns Cone::noAdjacency() if the two cones are not adjacent; |
---|
303 | * Cone::noFacet() if they are but no intersection facet is available. |
---|
304 | * Otherwise, the intersection facet will be returned (as an object of |
---|
305 | * type Cone). |
---|
306 | **/ |
---|
307 | Cone* getAdjacencyFacet ( |
---|
308 | int maxCone1, /**< [in] the 1st max. cone index */ |
---|
309 | int maxCone2 /**< [in] the 2nd max. cone index */ |
---|
310 | ) const; |
---|
311 | |
---|
312 | /** |
---|
313 | * For retrieving the adjacency matrix of the given fan. |
---|
314 | * |
---|
315 | * The method returns a matrix of size (number of max. cones)^2. |
---|
316 | * Entries are either 1 (adjacent and intersection facet available), |
---|
317 | * -1 (adjacent but no intersection facet available), or |
---|
318 | * 0 (not adjacent). |
---|
319 | **/ |
---|
320 | intvec* getAdjacency () const; |
---|
321 | |
---|
322 | /** |
---|
323 | * For adding adjacency information concerning two maximal |
---|
324 | * cones in the given fan. |
---|
325 | * |
---|
326 | * The method assumes that both int arguments are in the set |
---|
327 | * [1..number of max. cones]. |
---|
328 | * The 3rd argument may be NULL signaling that an intersection |
---|
329 | * facet is not available. |
---|
330 | **/ |
---|
331 | void addAdjacency ( |
---|
332 | const int i, /**< [in] the 1st max. cone index */ |
---|
333 | const int j, /**< [in] the 2nd max. cone index */ |
---|
334 | const Cone* c /**< [in] the intersection facet or NULL */ |
---|
335 | ); |
---|
336 | |
---|
337 | /** |
---|
338 | * For adding adjacency information concerning numerous pairs of |
---|
339 | * maximal cones of the given fan. |
---|
340 | * |
---|
341 | * The method assumes that all indices are in the valid set, i.e., in |
---|
342 | * [1..number of max. cones]. |
---|
343 | * The 3rd argument is a list of Cone* or int 0, where 0 signals |
---|
344 | * that an intersection facet is not available. |
---|
345 | **/ |
---|
346 | void addAdjacencies ( |
---|
347 | const intvec* iv, /**< [in] the 1st max. cone index */ |
---|
348 | const intvec* jv, /**< [in] the 2nd max. cone index */ |
---|
349 | const lists L /**< [in] a list of Cone* or NULL */ |
---|
350 | ); |
---|
351 | }; |
---|
352 | |
---|
353 | #endif |
---|
354 | /* FAN_H */ |
---|