Macaulay2 » Documentation
Packages » Polyhedra :: Working with fans
next | previous | forward | backward | up | index | toc

Working with fans

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

o1 = C

o1 : Cone
i2 : F = fan C

o2 = F

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 = {{0, 1, 2}}

o3 : List

Now we could expand the fan by adding more cones, for example the following:
i4 : C1 = coneFromVData matrix {{1,0,0},{1,1,0},{0,0,-1}}

o4 = C1

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, C2)

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 = coneFromVData matrix {{1,0,0},{0,1,0},{0,0,-1}}

o8 = C1

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

o9 = F

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 = coneFromVData matrix {{-1,0,0},{0,1,0},{0,0,1}};
i11 : C3 = coneFromVData matrix {{-1,0,0},{0,1,0},{0,0,-1}};
i12 : C4 = coneFromVData matrix {{-1,0,0},{0,-1,0},{0,0,1}};
i13 : C5 = coneFromVData matrix {{-1,0,0},{0,-1,0},{0,0,-1}};
i14 : F1 = fan {C2,C3,C4,C5}

o14 = F1

o14 : Fan

Furthermore, we could add a list of cones to an existing fan:
i15 : C6 = coneFromVData matrix {{1,0,0},{0,-1,0},{0,0,1}};
i16 : C7 = coneFromVData matrix {{1,0,0},{0,-1,0},{0,0,-1}};
i17 : F1 = addCone( {C6,C7}, F1)

o17 = F1

o17 : 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.
i18 : P = hypercube 4

o18 = P

o18 : Polyhedron
i19 : F2 = normalFan P

o19 = F2

o19 : Fan

Now we have seen how to construct fans, so we turn to functions on fans, for example the direct product (directProduct:
i20 : F3 = fan {coneFromVData matrix {{1}},coneFromVData matrix {{-1}}}

o20 = F3

o20 : Fan
i21 : F1 = F3 * F1

o21 = F1

o21 : Fan

The result is in the direct product of the ambient spaces.
i22 : ambDim F1

o22 = 4

Of course, we can check if two fans are the same:
i23 : F1 == F2

o23 = false

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