# Ticket #14353: trac_14353_fan_cone_intersection.patch

File trac_14353_fan_cone_intersection.patch, 2.7 KB (added by vbraun, 9 years ago)

Updated patch

• ## sage/geometry/fan.py

```# HG changeset patch
# User Volker Braun <vbraun@stp.dias.ie>
# Date 1364371924 -3600
# Node ID 13fa8bc25c89ba70c1cfd61643c39a529fd91d6f
# Parent  38d7d6e9f3308a153e06e2ccce893aa5b78c53b0
Implement intersection of fans and fan with cone

diff --git a/sage/geometry/fan.py b/sage/geometry/fan.py```
 a except AttributeError: # The result is either incomplete or unknown. return RationalPolyhedralFan(new_cones, rc.rays(), rc.lattice()) def intersection(self, fan): """ Return the intersection with the given cone. INPUT: - ``fan`` -- a :class:`rational polyhedral fan ` or a single :class:`cone `. OUTPUT: The intersection of the fan with the given cone as a new fan. This is the fan generated by the intersections of the cones of the fan with the specified ``cone``. EXAMPLES:: sage: fan1 = Fan([Cone([(1,0), (0,1)])]) sage: fan2 = Fan([Cone([(1,1), (-1,1)])]) sage: fan12 = fan1.intersection(fan2) sage: fan12.generating_cone(0).rays() N(0, 1), N(1, 1) in 2-d lattice N sage: fan21 = fan2.intersection(fan1) sage: fan12.is_equivalent(fan21) True sage: fan = toric_varieties.P2().fan() sage: fan.intersection(fan.generating_cone(0)).cones() ((0-d cone of Rational polyhedral fan in 2-d lattice N,), (1-d cone of Rational polyhedral fan in 2-d lattice N, 1-d cone of Rational polyhedral fan in 2-d lattice N), (2-d cone of Rational polyhedral fan in 2-d lattice N,)) sage: fan.intersection(Cone([(1,2)])).cones() ((0-d cone of Rational polyhedral fan in 2-d lattice N,), (1-d cone of Rational polyhedral fan in 2-d lattice N,)) The cone to intersect with need not be strictly convex:: sage: N2 = Cone([(1,0), (0,1), (-1,-1)]) sage: fan.intersection(N2).is_equivalent(fan) True """ if is_Cone(fan): fan_cones = [fan] else: fan_cones = fan.generating_cones() from sage.combinat.cartesian_product import CartesianProduct cones = [c1.intersection(c2) for c1, c2 in CartesianProduct(self.generating_cones(), fan_cones)] return Fan(cones, discard_faces=True) def _latex_(self): r""" Return a LaTeX representation of ``self``.