next | previous | forward | backward | up | top | index | toc | Macaulay2 website
OldPolyhedra :: Working with fans

Working with fans

We start by constructing a fan, which consists of a single cone and all of its faces:
i1 : C = posHull matrix {{1,0,0},{0,1,0},{0,0,1}}

o1 = {ambient dimension => 3           }
      dimension of lineality space => 0
      dimension of the cone => 3
      number of facets => 3
      number of rays => 3

o1 : Cone
i2 : F = fan C

o2 = {ambient dimension => 3         }
      number of generating cones => 1
      number of rays => 3
      top dimension of the cones => 3

o2 : Fan

By this, we have already constructed the fan consisting of the positive orthant and all of its faces. The package saves the generating cones of the fan, which can be accessed by:

i3 : maxCones F

o3 = {{ambient dimension => 3           }}
       dimension of lineality space => 0
       dimension of the cone => 3
       number of facets => 3
       number of rays => 3

o3 : List

Now we could expand the fan by adding more cones, for example the following:

i4 : C1 = posHull matrix {{1,0,0},{1,1,0},{0,0,-1}}

o4 = {ambient dimension => 3           }
      dimension of lineality space => 0
      dimension of the cone => 3
      number of facets => 3
      number of rays => 3

o4 : Cone

But in this case we can not, because the two cones are not compatible, i.e. their intersection is not a face of each. So, when one tries to add a cone to a fan that is not compatible with one of the generating cones of the fan, the function addCone gives an error. For two cones one can check if their intersection is a common face by using commonFace:

i5 : commonFace(C,C1)

o5 = false

Since the intersection of both is already computed in this function there is a different function, which also returns the intersection, to save computation time when one needs the intersection afterward anyway:

i6 : (b,C2) = areCompatible(C,C1)

o6 = (false, {ambient dimension => 3           })
              dimension of lineality space => 0
              dimension of the cone => 2
              number of facets => 2
              number of rays => 2

o6 : Sequence
i7 : rays C2

o7 = | 0 1 |
     | 1 1 |
     | 0 0 |

              3        2
o7 : Matrix ZZ  <--- ZZ

So we can make the cone compatible and add it to the fan.

i8 : C1 = posHull matrix {{1,0,0},{0,1,0},{0,0,-1}}

o8 = {ambient dimension => 3           }
      dimension of lineality space => 0
      dimension of the cone => 3
      number of facets => 3
      number of rays => 3

o8 : Cone
i9 : F = addCone(C1,F)

o9 = {ambient dimension => 3         }
      number of generating cones => 2
      number of rays => 4
      top dimension of the cones => 3

o9 : Fan

Instead of creating a fan with one cone and then adding more cones, we can also make a fan out of a list of cones:

i10 : C2 = posHull matrix {{-1,0,0},{0,1,0},{0,0,1}};
i11 : C3 = posHull matrix {{-1,0,0},{0,1,0},{0,0,-1}};
i12 : C4 = posHull matrix {{-1,0,0},{0,-1,0},{0,0,1}};
i13 : C5 = posHull matrix {{-1,0,0},{0,-1,0},{0,0,-1}};
i14 : F1 = fan {C2,C3,C4,C5}

o14 = {ambient dimension => 3         }
       number of generating cones => 4
       number of rays => 5
       top dimension of the cones => 3

o14 : Fan

Furthermore, we could add a list of cones to an existing fan:

i15 : C6 = posHull matrix {{1,0,0},{0,-1,0},{0,0,1}};
i16 : C7 = posHull matrix {{1,0,0},{0,-1,0},{0,0,-1}};
i17 : F1 = addCone( {C6,C7}, F1)

o17 = {ambient dimension => 3         }
       number of generating cones => 6
       number of rays => 6
       top dimension of the cones => 3

o17 : Fan

Finally, we can add a whole fan to another fan:

i18 : F1 = addCone(F,F1)

o18 = {ambient dimension => 3         }
       number of generating cones => 8
       number of rays => 6
       top dimension of the cones => 3

o18 : Fan

So, fan and addCone are the methods to construct fans ''from scratch'', but there are also methods to get fans directly, for example normalFan, which constructs the inner normal fan of a polytope.

i19 : P = hypercube 4

o19 = {ambient dimension => 4           }
       dimension of lineality space => 0
       dimension of polyhedron => 4
       number of facets => 8
       number of rays => 0
       number of vertices => 16

o19 : Polyhedron
i20 : F2 = normalFan P

o20 = {ambient dimension => 4          }
       number of generating cones => 16
       number of rays => 8
       top dimension of the cones => 4

o20 : Fan

Now we have seen how to construct fans, so we turn to functions on fans, for example the direct product (directProduct:

i21 : F3 = fan {posHull matrix {{1}},posHull matrix {{-1}}}

o21 = {ambient dimension => 1         }
       number of generating cones => 2
       number of rays => 2
       top dimension of the cones => 1

o21 : Fan
i22 : F1 = F3 * F1

o22 = {ambient dimension => 4          }
       number of generating cones => 16
       number of rays => 8
       top dimension of the cones => 4

o22 : Fan

The result is in the direct product of the ambient spaces.

i23 : ambDim F1

o23 = 4

Of course, we can check if two fans are the same:

i24 : F1 == F2

o24 = true

A bit more on fans can be found in part 2: Working with fans - Part 2.