Contents

# Operators and functions for type CONE

This is the basic type of the convex package. A CONE represents a polyhedral cone in a finite-dimensional rational ambient space. It needs neither be full-dimensional nor pointed. The basic fact about polyhedral cones is that they admit two equivalent descriptions: as the positive hull of (lines and) rays, or as the intersection of (hyperplanes and) halfspaces. The Convex package provides the functions poshull and intersection to create a CONE from these descriptions. Moreover, there are functions constructing new cones out of other ones, for instance image and preimage.

There are also functions to deal with the faces of a cone. They are of type CFACE. Moreover, cones may be grouped together to give a FAN.

&<
```&<(C1::CONE, C2::CONE)::boolean
&>(C2::CONE, C1::CONE)::boolean
C1 &< C2
C2 &> C1
```

Test whether C1 is strictly contained C2. Both cones must lie in the same ambient space.

Contrary to the Maple comparison operators, this functions directly returns a boolean value. Hence there is no need to apply evalb.

Examples
 fullcone(1) &< fullcone(2);
Error, (in CONE[`&<=`]) arguments must lie in the same space
&<=
```&<=(C1::CONE, C2::CONE)::boolean
&>=(C2::CONE, C1::CONE)::boolean
C1 &<= C2
C2 &>= C1
```

Test whether C1 is contained in C2. Both cones must lie in the same ambient space.

Contrary to the Maple comparison operators, this functions directly returns a boolean value. Hence there is no need to apply evalb.

&<>
```&<>(C1::CONE, C2::CONE)::boolean
C1 &<> C2
```

Test whether C1 and C2 represent different cones, considered as subsets of Euclidean space. This is not the same as comparing C1 and C2 as Maple expressions, see the discussion under &=.

One can compare cones lying in different ambient spaces. The result is always true.

Contrary to the Maple comparison operators, this functions directly returns a boolean value. Hence there is no need to apply evalb.

&=
```&=(C1::CONE, C2::CONE)::boolean
C1 &= C2
```

Test whether C1 and C2 represent the same cone, considered as subset of Euclidean space. Note that two CONEs may be equal in this sense without being equal as Maple expressions. The reason is that some details of the CONE data structure depend on the way the CONE was defined.

One can compare cones lying in different ambient spaces. The result is always false.

Contrary to the Maple comparison operators, this functions directly returns a boolean value. Hence there is no need to apply evalb.

Examples
 C1 := poshull([1, 2], [2, 1]); C2 := poshull([2, 1], [1, 2]);
C1 := CONE(2,2,0,2,2)
C2 := CONE(2,2,0,2,2)
 C1 &= C2;
true
 evalb(C1 = C2);
false
 zerocone(1) &= zerocone(2);
false
&x
```&x(C1::CONE, ...)::CONE
C1 &x C2
```

The Cartesian product of the given cones, lying in the Cartesian product of their ambient spaces.

Examples
 C := posorthant(1) &x posorthant(2);
C := CONE(3,3,0,3,3)
 C &= posorthant(3);
true
 &x(posorthant(1)\$4) &= posorthant(4);
true
Without any arguments, the function must be called like this:
 CONE[`&x`]();
CONE(0,0,0,0,0)
ambientdim
```ambientdim(C::CONE)::nonnegint
```

The dimension of the space in which C lies.

arecompatible
```arecompatible(C1::CONE, C2::CONE)::boolean
arecompatible(C1::CONE, C2::CONE, C::name)::boolean
```

Two cones are compatible if their intersection is a common face of both. If C1 and C2 are compatible and a third argument C is given, it receives the intersection (of type CONE).

boundary
```boundary(C::CONE1)::FAN
```

The fan of all proper faces of the non-zero cone C.

codim
```codim(C::CONE)::nonnegint
```

The codimension of C is that of its linear hull.

contains
```contains(C::CONE, arg2::{vec, line, CONE})::boolean
contains(arg1::{vec, line, CONE}, C::CONE)::boolean
```

The first form returns true if C contains the vector, line or cone arg2, and false otherwise. The second form yields true if C is contained in the halfspace resp. hyperplane determined by the vector or line arg1, or in the cone arg1, and false otherwise. If both arguments are cones, one may also use the relational operators &<= and &>=.

containsrelint
```containsrelint(C::CONE, r::vec)::boolean
```

Decides whether the vector r is contained in the relative interior of C.

convert/CONE
```convert(C::CONE, CONE)::CONE
```

This function transforms its argument to be strictly of type CONE. For true CONEs, this is the identity operation. But if C is a FANCONE, then all additional information is lost.

convert/POLYHEDRON
```convert(C::CONE, POLYHEDRON)::POLYHEDRON
```

Internally, a POLYHEDRON is stored as the CONE given by its homogenization. This function returns the POLYHEDRON whose internal representation is C (or rather the intersection of C with the halfspace at infinity). Accordingly, the ambient dimension goes down by one, and the dimension of C by at least one.

Note that the precise result depends on which coordinate is the additional one used for the homogenization.

convert/affine
```convert(C::CONE, affine)::POLYHEDRON1
convert(C::CONE, v::vec, affine)::POLYHEDRON1
```

This function converts the cone C into a polyhedron representing the same point set. If a second argument v is given, the origin of the cone is translated to v.

dim
```dim(C::CONE)::nonnegint
```

The dimension of C is that of its linear hull.

dual
```dual(C::CONE)::CONE
```

The dual of C is the polyhedral cone of all vectors whose inner product with all vectors in C is non-negative. This operation interchanges lines and hplanes, and rays and hspaces.

edges
```edges(C::CONE)::list(CFACE)
```

The list of rankĀ 1 faces of C. They correspond to the entries of rays(C) (in the same order), but are of type CFACE. This function is similar to facets. See also rays and CFACE[rank].

faces
```faces(C::CONE)::Array(list(CFACE))
```

An Array indexed from 0 to ambientdim(C). The k-th entry is a list of all k-dimensional faces of C. Warning: cones may have a huge number of faces! See also ambientdim.

Examples
 faces(posorthant(3));
Array(0 .. 3,{0 = [CFACE(0,3)], 1 = [CFACE(1,2), CFACE(1,2), CFACE(1,2)], 2 = [CFACE(2,1), CFACE(2,1), CFACE(2,1)], 3 = [CFACE(3,0)]},datatype = anything,storage = rectangular,order = Fortran_order)
facets
```facets(C::CONE)::list(CFACE)
```

A list of the facets of C. The order corresponds to that of hspaces(C), i.e., facets(C)[i] is the facet induced by intersecting C with the hyperplane defined by hspaces(C)[i]. See hspaces.

Examples
 C := posorthant(2); rays(C); hspaces(C);
C := CONE(2,2,0,2,2)
[[1, 0], [0, 1]]
[[1, 0], [0, 1]]
 L := facets(C);
L := [CFACE(1,1), CFACE(1,1)]
 rays(L[1]); hspaces(L[1]);
[[0, 1]]
[[1, 0]]
flagf
```flagf(C::CONE, S::set(integer))::nonnegint
```

The entry of the flag f-vector of C corresponding to S. See FAN[flagf].

flagh
```flagf(C::CONE, S::set(integer))::integer
```

The entry of the flag h-vector of C corresponding to S. See FAN[flagh].

fullcone
```fullcone(n::integer)::CONE
```

The whole space as full-dimensional cone in n-space.

Examples
 fullcone(0) &= zerocone(0);
true
fvector
```fvector(C::CONE)::Array(nonnegint)
```

The f-vector of C counts the number of faces of C of the various dimensions. See FAN[fvector].

genhvector
```genhvector(F::)::Array
```

Stanley's generalized h-vector. See FAN[genhvector] for details.

hilbertbasis
```hilbertbasis(C::CONE)::list(vec)
hilbertbasis(C::CONE, B::name)::list(vec)
```

If C is pointed, this function computes the Hilbert basis of the additive monoid of integral points in C. For general C, such a basis is computed for the intersection of C with a lattice complement of the lineality space of C (in the linear hull of C). In order to obtain a complete Hilbert basis of C, one must add a lattice basis (and its negative) of the lineality space of C. Such a basis (of type list(vec)) is stored in the optional argument B.

Examples
 C := poshull([1, 2], [2, 1]); hilbertbasis(C);
C := CONE(2,2,0,2,2)
[[1, 1], [1, 2], [2, 1]]
 C := poshull([1, 2, 0], [2, 1, 0], line([3, -4, -1])); hilbertbasis(C, 'B'); B;
C := CONE(3,3,1,2,2)
[[-2, 5, 1], [-2, 6, 1], [-4, 9, 2]]
[[3, -4, -1]]
hplanes
```hplanes(C::CONE)::list(vec)
```

A basis of the linear subspace of all vectors whose scalar product with all vectors of C vanish. The normalization is as for lineality spaces, see lines.

hspaces
```hspaces(C::CONE)::list(vec)
```

This list contains, for each facet f of C, a vector normal to f. The normalization (with respect to hyperplanes in this case) is as for rays. See hplanes and rays.

hvector
```hvector(C::CONE)::Array(nonnegint)
```

image
```image(C::CONE, A::{mat, rational, real_infinity})::CONE
```

This gives the image of C under the linear map defined by A. A rational number is interpreted as homothety. If A equals real_infinity, then the result is the whole ambient space.

incidencematrix
```incidencematrix(C::CONE)::matrix({0,1})
```

The incidence matrix of C. It has one row for each facet of C and one column for each ray. The ordering is that of hspaces and rays, respectively. The entry in row i and column j is 1 if the j-th ray is incident to the i-th facet, and 0 otherwise.

Examples
 C := posorthant(2); rays(C); hspaces(C);
C := CONE(2,2,0,2,2)
[[1, 0], [0, 1]]
[[1, 0], [0, 1]]
 incidencematrix(C);
matrix([[0, 1], [1, 0]])
A matrix may have no rows:
 incidencematrix(posorthant(0));
matrix([])
incidentfacets
```incidentfacets(C::CONE)::list(set(posint))
```

The i-th entry of this list is the set of indices of all facets of C incident to the i-th ray of C. The ordering is that of hspaces and rays, respectively. This corresponds to all facets normals whose scalar product with rays(C)[i] is zero. See also incidentrays.

incidentrays
```incidentrays(C::CONE)::list(set(posint))
```

The i-th entry of this list is the set of indices of all rays of C incident to the i-th facet of C. The ordering is that of rays and hspaces, respectively. This corresponds to all rays whose scalar product with the i-th facet normal hspaces(C)[i] is zero.

Examples
 C := convert(cube(3), CONE); incidentrays(C);
C := CONE(4,4,0,8,6)
[{2, 4, 6, 8}, {5, 6, 7, 8}, {3, 4, 7, 8}, {1, 3, 5, 7}, {1, 2, 5, 6}, {1, 2, 3, 4}]
 for v in hspaces(C) do map(dotprod, rays(C), v) od;
[2, 0, 2, 0, 2, 0, 2, 0]
[2, 2, 2, 2, 0, 0, 0, 0]
[2, 2, 0, 0, 2, 2, 0, 0]
[0, 2, 0, 2, 0, 2, 0, 2]
[0, 0, 2, 2, 0, 0, 2, 2]
[0, 0, 0, 0, 2, 2, 2, 2]
intersection
```intersection(arg1::{vec, line, CONE}, ...)::CONE
```

The intersection of the given arguments. A vec is interpreted as the positive halfspace defined by it, and analogously a line as a hyperplane. In order to determine the ambient dimension, at least one argument must be given. If you have a possibly empty sequence of arguments in d-space, simply add fullcone(d).

isface
```isface(C1::CONE, C2::CONE)::boolean
isface(C1::CONE, C2::CONE, f::name)::boolean
```

Test whether C1 is a face of C2. If this is the case and a third argument is given, it receives the CFACE with domain C2 representing this face. C1 and C2 must lie in the same ambient space.

isfulldim
```isfulldim(C::CONE)::boolean
```

A full-dimensional cone is one of codimension 0.

islinear
```islinear(C::CONE)::boolean
```

Test whether C is a linear subspace.

ispointed
```ispointed(C::CONE)::boolean
```

A cone is pointed if it contains no line, i.e., if its smallest face is the origin. See also lines.

isregular
```isregular(C::CONE)::boolean
isregular(C::CONE, B::name)::boolean
```

A cone is regular if it is pointed and its rays can be extended to a basis of the lattice of integral points of its ambient space. If this is true and a second argument is given, it receives such a basis (of type list(vec)) starting with the rays of C.

Examples
 C := poshull([1, 2, 3], [3, 1, 2]);
C := CONE(3,2,0,2,2)
 isregular(C, 'B'); B;
true
[[1, 2, 3], [3, 1, 2], [0, -2, -3]]
issimple
```issimple(C::CONE)::boolean
```

Test whether C is simple. A cone is simple if it is full-dimensional and each proper face f is the intersection of exactly dim(f) facets. This is dual to issimplicial1.

issimplicial
```issimplicial(C::CONE)::boolean
```

Test whether C is simplicial. A cone is simplicial if it is pointed and has exactly dim(C) rays. See ispointed.

issimplicial1
```issimplicial1(C::CONE)::boolean
```

Test whether C is simplicial in codimension 1, that is, whether C is pointed and all its facets are simplicial. (The second condition implies the first unless C is a linear subspace.) See ispointed, issimple and issimplicial.

lensspace
```lensspace(p::posint, w1::integer, ..., wn::integer)::CONE
```

The cone whose associated toric variety is the unbounded cone (in the sense of topology) over the lens space of order p with weights w1, ..., wn. See also wprojspace.

lineality
```lineality(C::CONE)::CONE
```

The lineality space of a cone is the largest linear subspace contained in it. It is returned as a CONE.

linearhull
```linearhull(arg1::{vec, ray, line, CONE}, ...)::CONE
```

The linear hull of the given arguments, considered as CONE.

lines
```lines(C::CONE)::list(vec)
```

A basis of the lineality space of C, which is the largest linear subspace contained in C. The basis is in row echelon form with each row multiplied by a positive integer so that the coefficients of each row are relatively prime integers. Note that this determines the resulting basis completely. In other words, two cones C1 and C2 have the same lineality space if and only lines(C1) and lines(C2) are identical.

Examples
 lines(posorthant(2));
[]
 lines(fullcone(2));
[[1, 0], [0, 1]]
 C := poshull(line([-2, -6, 10]), line([1/3, 1, 1/5]), [-7, 8, -9]); lines(C);
C := CONE(3,3,2,1,1)
[[1, 3, 0], [0, 0, 1]]
maximal
```maximal(C::CONE)::CFACE
```

This function returns the maximal element of the face lattice of C, i.e., C itself, considered as an element of its face lattice.

minimal
```minimal(C::CONE)::CFACE
```

This function returns the minimal element of the face lattice of C, i.e., its lineality space, considered as an element of the face lattice of C. See lines.

polar
```polar(C::CONE)::CONE
```

The polar cone of C is the negative of its dual.

poshull
```poshull(arg1::{vec, ray, line, CONE, POLYHEDRON}, ...)::CONE
```

The cone generated by the given arguments, i.e., the smallest cone containing all the arguments ("their positive hull"). Note that giving a ray ray(v) is equivalent to giving the vec v defining it. The cone generated by a polyhedron is the cone generated by its vertices, rays and lines. In order to determine the ambient dimension, at least one argument must be given. If you have a possibly empty sequence of arguments in d-space, simply add zerocone(d).

Examples
One can define a cone in several steps, but it is more efficient to give all generators at once.
 C1 := poshull([1, 0]); C2 := poshull(C1, [1, 1]); rays(C2);
C1 := CONE(2,1,0,1,1)
C2 := CONE(2,2,0,2,2)
[[1, 0], [1, 1]]
 C3 := poshull([1, 0], [1, 1]); C2 &= C3;
C3 := CONE(2,2,0,2,2)
true
The cone generated by a polytope (or polyhedron) is generated by its vertices (and rays and lines):
 C := poshull(convhull([2, 0], ray([0, 1])));
C := CONE(2,2,0,2,2)
 rays(C);
[[0, 1], [1, 0]]
posorthant
```posorthant(n::integer)::CONE
```

The positive orthant in n-space. This is the cone containing all points with non-negative coordinates. It is a simplicial cone spanned by the canonical basis vectors.

preimage
```preimage(C::CONE, A::{mat, rational, real_infinity})::CONE
```

This gives the preimage of C under the linear map defined by A. A rational number is interpreted as homothety. If A equals real_infinity, then the result is the zero cone. See the description of the type mat on how to specify maps to 0-space.

rays
```rays(C::CONE)::list(vec)
```

If C is pointed, then its rays are its 1-dimensional faces, and for each ray r the minimal point with integral coordinates in r is returned. In the general case, the extremal rays are only defined modulo the lineality space of C. Here representative vectors of the rays are chosen such that the coordinates corresponding to the pivot columns of lines(C) are zero and the other coordinates relatively prime integers. (The pivot columns of lines(C) are those which are linearly independent from the preceding columns.) Note that this determines rays(C) up to order of the rows. In other words, two cones C1 and C2 with the same lineality space have the same rays (hence, are equal in the sense of &=) if and only convert(rays(C1), set) and convert(rays(C2), set) are identical. See also lines.

Examples
 rays(posorthant(2));
[[1, 0], [0, 1]]
 C := poshull(line([-2, -6, 10]), line([1/3, 1, 1/5]), [-7, 8, -9]);
C := CONE(3,3,2,1,1)
 lines(C); rays(C);
[[1, 3, 0], [0, 0, 1]]
[[0, 1, 0]]
 rays(zerocone(2));
[]
 rays(fullcone(2));
[]
relint
```relint(C::CONE)::vec
```

This function returns a vector in the relative interior of C. More precisely, it returns the sum of the rays in reduced form.

Example

 relint(poshull([1, 2], [2, 1]));
[1, 1]
skeleton
```skeleton(C::CONE, k::nonnegint)::FAN
```

This is the same as FAN[skeleton](fan(C), k).

support
```support(C::CONE, v1::vec, ...)::CFACE
```

This function returns the supporting face in C of the rays v1, etc. This is the smallest face of C containing of these rays. If such a face does not exist, FAIL is returned.

Examples
 C := posorthant(2);
C := CONE(2,2,0,2,2)
 f := support(C, [1, 1]); rays(f);
f := CFACE(2,0)
[[1, 0], [0, 1]]
 f := support(C, [1, 0]); rays(f);
f := CFACE(1,1)
[[1, 0]]
 f := support(C, [1, -1]);
f := FAIL
 f := support(C, [1, 0], [0, 1]); rays(f);
f := CFACE(2,0)
[[1, 0], [0, 1]]
Without further arguments, one gets the minimal face.
 support(C) &= minimal(C);
true
traverse
```traverse(C::CONE, g::procedure)
```

This is the same as traverse(fan(C), g), see FAN[traverse].

traverse2
```traverse2(C::CONE, g::procedure, g2::procedure)
```

This is the same as traverse2(fan(C), g, g2), see FAN[traverse2].

zerocone
```zerocone(n::integer)::CONE
```

The origin as 0-dimensional cone in n-space.