This file is indexed.

/usr/include/singular/gfanlib/gfanlib_zcone.h is in libsingular4-dev-common 1:4.1.0-p3+ds-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/*
 * lib_cone.h
 *
 *  Created on: Sep 28, 2010
 *      Author: anders
 */

#ifndef LIB_CONE_H_
#define LIB_CONE_H_

#include "gfanlib_matrix.h"

namespace gfan{
/**
 * Returns true if cddlib is needed for the ZCone implementation.
 */
        bool isCddlibRequired();
        /**
         * Only call this function if gfanlib is the only code in your program using cddlib.
         * Should be paired with a deinitializeCddlibIfRequired() call.
         * Calling the function repeatedly may cause memory leaks even if deinitializeCddlibIfRequired() is also called.
         */
        void initializeCddlibIfRequired();
        /**
         * This function may do nothing.
         */
        void deinitializeCddlibIfRequired();

/**
A PolyhedralCone is represented by linear inequalities and equations. The inequalities are non-strict
and stored as the rows of a matrix and the equations are stored as rows of a second matrix.

A cone can be in one of the four states:
0) Nothing has been done to remove redundancies. This is the initial state.
1) A basis for the true, implied equations space has been computed. This means that
   the implied equations have been computed. In particular the dimension of the cone is known.
2) Redundant inequalities have been computed and have been eliminated.
   This means that the true set of facets is known - one for each element in halfSpaces.
3) The inequalities and equations from 2) have been transformed into a canonical form. Besides having
   a unique representation for the cone this also allows comparisons between cones with operator<().

Since moving for one state to the next is expensive, the user of the PolyhedralCone can specify flags
at the construction of the cone informing about which things are known.

PCP_impliedEquationsKnown means that the given set of equations generate the space of implied equations.
PCP_facetsKnown means that each inequalities describe define a (different) facet of the cone.

Each cone has the additional information: multiplicity and linear forms.
The multiplicity is an integer whose default value is one. It can be set by the user.
When a cone is projected, it can happen that the multiplicity changes according to a lattice index.
The linear forms are stored in a matrix linearForms, whose width equals the dimension of the ambient space.
The idea is that a collection of cones in this way can represent a piecewise linear function (a tropical rational function).

Caching:
When new properties are computed by changing state the information is stored in the object by updating equations and inequalities.
When some other properties are computed, such as rays the result is cached in the object. Each cached property has a corresponding flag telling if a cached value has been stored.
These methods
for these properties are considered const. Caching only works for extreme rays at the moment.

Notice:
The lineality space of a cone C is C\cap(-C).
A cone is ray if its dimension is 1+the dimension of the its lineality space.

Should the user of this class know about the states?

need to think about this...
Always putting the cone in state 1 after something has changed helps a lot.
Then all operations can be performed except comparing and getting facets with
out taking the cone to a special state.


Things to change:
- Thomas wants operations where the natural description is the dual to be fast.
  One way to achieve this is as Frank suggests to have a state -1, in which only
  the generator description is known. These should be stored in the cache. If it
  is required to move to state 0, then the inequality description is computed.
  This sounds like a reasonable solution, but of course, what we are really storing is the dual.

 - Basically all data in the object should be mutable, while almost every method should be const.

 - A method should set the cone in a given state if required. The reason for this is that
   it will be difficult for the user to figure out which state is required and therefore
   will tend to call canonicalize when not needed.

 - Cache should be added for more properties.

Optimization:
- When inequalities can be represented in 32 bit some optimizations can be done.

More things to consider:
- Does it make sense to do dimension reduction when lineality space / linear span has been
  computed?


When calling generated by rays, two flags should be passed.

 */

enum PolyhedralConePreassumptions{
  PCP_none=0,
  PCP_impliedEquationsKnown=1,
  PCP_facetsKnown=2
};

class ZCone;
ZCone intersection(const ZCone &a, const ZCone &b);
class ZCone
{
  int preassumptions;
  mutable int state;
  int n;
  Integer multiplicity;
  ZMatrix linearForms;
  mutable ZMatrix inequalities;
  mutable ZMatrix equations;
  mutable ZMatrix cachedExtremeRays;
/**
 * If this bool is true it means that cachedExtremeRays contains the extreme rays as found by extremeRays().
 */
  mutable bool haveExtremeRaysBeenCached;
  void ensureStateAsMinimum(int s)const;

  bool isInStateMinimum(int s)const;
  int getState()const;
public:
   /**
    * Constructs a polyhedral cone with specified equations and ineqalities. They are read off as rows
    * of the matrices. For efficiency it is possible to specifying a PolyhedralConePreassumptions flag
    * which tells what is known about the description already.
    */
     ZCone(ZMatrix const &inequalities_, ZMatrix const &equations_, int preassumptions_=PCP_none);

     /**
      * Get the multiplicity of the cone.
      */
     Integer getMultiplicity()const;
     /**
      * Set the multiplicity of the cone.
      */
     void setMultiplicity(Integer const &m);
     /**
      * Returns the matrix of linear forms stored in the cone object.
      */
     ZMatrix getLinearForms()const;
     /**
      * Store a matrix of linear forms in the cone object.
      */
     void setLinearForms(ZMatrix const &linearForms_);

     /**
      * Get the inequalities in the description of the cone.
      */
     ZMatrix getInequalities()const;
     /**
      * Get the equations in the description of the cone.
      */
     ZMatrix getEquations()const;
     /**
      * Compute generators of the span of the cone. They are stored as rows of the returned matrix.
      */
     ZMatrix generatorsOfSpan()const;
     /**
      * Compute generators of the lineality space of the cone. The returned set of generators is a vector spaces basis. They are stored as rows of the returned matrix.
      */
     ZMatrix generatorsOfLinealitySpace()const;
     /**
      * Returns true iff it is known that every inequalities in the description defines a different facets of the cone.
      */
     bool areFacetsKnown()const{return (state>=2)||(preassumptions&PCP_facetsKnown);}
     /**
      * Returns true iff it is known that the set of equations span the space of implied equations of the description.
      */
     bool areImpliedEquationsKnown()const{return (state>=1)||(preassumptions&PCP_impliedEquationsKnown);}
     /**
      * Returns true iff the extreme rays are known.
      */
     bool areExtremeRaysKnown()const{return haveExtremeRaysBeenCached;}

     /**
      * Takes the cone to a canonical form. After taking cones to canonical form, two cones are the same
      * if and only if their matrices of equations and inequalities are the same.
      */
     void canonicalize();
     /**
      * Computes and returns the facet inequalities of the cone.
      */
     ZMatrix getFacets()const;
     /**
      * After this function has been called all inequalities describe different facets of the cone.
      */
     void findFacets();
     /**
      * The set of linear forms vanishing on the cone is a subspace. This routine returns a basis
      * of this subspace as the rows of a matrix.
      */
     ZMatrix getImpliedEquations()const;
     /**
      * After this function has been called a minimal set of implied equations for the cone is known and is
      * returned when calling getEquations(). The returned equations form a basis of the space of implied
      * equations.
      */
     void findImpliedEquations();

     /**
      * Constructor for polyhedral cone with no inequalities or equations. Tthat is, the full space of some dimension.
      */
     ZCone(int ambientDimension=0);

     /**
      * Computes are relative interior point of the cone.
      */
     ZVector getRelativeInteriorPoint()const;
  /**
     Assuming that this cone C is in state at least 3 (why not 2?), this routine returns a relative interior point v(C) of C with the following properties:
     1) v is a function, that is v(C) is found deterministically
     2) for any angle preserving, lattice preserving and lineality space preserving transformation T of R^n we have that v(T(C))=T(v(C)). This makes it easy to check if two cones in the same fan are equal up to symmetry. Here preserving the lineality space L just means T(L)=L.
  */
     ZVector getUniquePoint()const;
  /**
   * Takes a list of possible extreme rays and add up those actually contained in the cone.
   */
     ZVector getUniquePointFromExtremeRays(ZMatrix const &extremeRays)const;
     /**
      * Returns the dimension of the ambient space.
      */
     int ambientDimension()const;
     /**
      * Returns the dimension of the cone.
      */
     int dimension()const;
     /**
      * Returns (ambient dimension)-(dimension).
      */
     int codimension()const;
     /**
      * Returns the dimension of the lineality space of the cone.
      */
     int dimensionOfLinealitySpace()const;
     /**
      * Returns true iff the cone is the origin.
      */
     bool isOrigin()const;
     /**
      * Returns true iff the cone is the full space.
      */
     bool isFullSpace()const;

     /**
      * Returns the intersection of cone a and b as a cone object.
      */
     friend ZCone intersection(const ZCone &a, const ZCone &b);
     /**
      * Returns the Cartesian product of the two cones a and b.
      */
     friend ZCone product(const ZCone &a, const ZCone &b);
     /**
      * Returns the positive orthant of some dimension as a polyhedral cone.
      */
     static ZCone positiveOrthant(int dimension);
     /**
      * Returns the cone which is the sum of row span of linealitySpace and
      * the non-negative span of the rows of generators.
      */
     static ZCone givenByRays(ZMatrix const &generators, ZMatrix const &linealitySpace);

     /**
      * To use the comparison operator< the cones must have been canonicalized.
      */
     friend bool operator<(ZCone const &a, ZCone const &b);
     /**
      * To use the comparison operator!= the cones must have been canonicalized.
      */
     friend bool operator!=(ZCone const &a, ZCone const &b);

     /**
      * Returns true iff the cone contains a positive vector.
      */
     bool containsPositiveVector()const;
     /**
      * Returns true iff the cone contains the specified vector v.
      */
     bool contains(ZVector const &v)const;
     /**
      * Returns true iff the cone contains all rows of the matrix l.
      */
     bool containsRowsOf(ZMatrix const &l)const;
     /**
      * Returns true iff c is contained in the cone.
      */
     bool contains(ZCone const &c)const;
     /**
      * Returns true iff the PolyhedralCone contains v in its relative interior. False otherwise. The cone must be in state at least 1.
      */
     bool containsRelatively(ZVector const &v)const;
     /*
      * Returns true iff the cone is simplicial. That is, iff the dimension of the cone equals the number of facets.
      */
     bool isSimplicial()const;

     //PolyhedralCone permuted(IntegerVector const &v)const;

     /**
      * Returns the lineality space of the cone as a polyhedral cone.
      */
     ZCone linealitySpace()const;

     /**
      * Returns the dual cone of the cone.
      */
     ZCone dualCone()const;
     /**
      * Return -C, where C is the cone.
      */
     ZCone negated()const;
     /**
      * Compute the extreme rays of the cone, and return generators of these as the rows of a matrix.
      * The returned extreme rays are represented by vectors which are orthogonal to the lineality
      * space and which are primitive primitive.
      * This makes them unique and invariant under lattice and angle preserving linear transformations
      * in the sense that a transformed cone would give the same set of extreme rays except the
      * extreme rays have been transformed.
      * If generators for the lineality space are known, they can be supplied. This can
      * speed up computations a lot.
      */
    ZMatrix extremeRays(ZMatrix const *generatorsOfLinealitySpace=0)const;
    /**
       The cone defines two lattices, namely Z^n intersected with the
       span of the cone and Z^n intersected with the lineality space of
       the cone. Clearly the second is contained in the
       first. Furthermore, the second is a saturated lattice of the
       first. The quotient is torsion-free - hence a lattice. Generators
       of this lattice as vectors in the span of the cone are computed
       by this routine. The implied equations must be known when this
       function is called - if not the routine asserts.
     */
    ZMatrix quotientLatticeBasis()const;
    /**
       For a ray (dim=linealitydim +1)
       the quotent lattice described in quotientLatticeBasis() is
       isomorphic to Z. In fact the ray intersected with Z^n modulo the
       lineality space intersected with Z^n is a semigroup generated by
       just one element. This routine computes that element as an
       integer vector in the cone. Asserts if the cone is not a ray.
       Asserts if the implied equations have not been computed.
     */
    ZVector semiGroupGeneratorOfRay()const;

    /**
       Computes the link of the face containing v in its relative
       interior.
     */
    ZCone link(ZVector const &w)const;

    /**
       Tests if f is a face of the cone.
     */
    bool hasFace(ZCone const &f)const;
    /**
       Computes the face of the cone containing v in its relative interior.
       The vector MUST be contained in the cone.
    */
    ZCone faceContaining(ZVector const &v)const;
    /**
     * Computes the projection of the cone to the first newn coordinates.
     * The ambient space of the returned cone has dimension newn.
     */
    // PolyhedralCone projection(int newn)const;
    friend std::ostream &operator<<(std::ostream &f, ZCone const &c);
    std::string toString()const;
};

}




#endif /* LIB_CONE_H_ */