]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/cone/schur.py
Add tests for the "K must be a Cone" TypeError.
[sage.d.git] / mjo / cone / schur.py
1 """
2 The Schur cone, as described in the "Critical angles..." papers by
3 Seeger and Sossa.
4 """
5
6 from sage.all import *
7
8 def is_pointed(P,Q):
9 newP = Cone([ list(p) for p in P ])
10 newQ = Cone([ list(q) for q in Q ])
11 return newP.intersection(-newQ).is_trivial()
12
13 def ext_angles(P,Q):
14 angles = []
15 for p in P:
16 for q in Q:
17 p = vector(SR, p)
18 q = vector(SR, q)
19 p = p/p.norm()
20 q = q/q.norm()
21 angles.append(arccos(p.inner_product(q)))
22
23 return angles
24
25 def schur(n):
26 r"""
27 Return the Schur cone in ``n`` dimensions.
28
29 INPUT:
30
31 - ``n`` -- the ambient dimension of the Schur cone and its ambient space.
32
33 OUTPUT:
34
35 A rational closed convex Schur cone of dimension ``n``.
36 """
37
38 hs = []
39 for i in range(1,n):
40 h_i = [0]*n
41 h_i[i-1] = QQ(1)
42 h_i[i] = -QQ(1)
43 hs.append(vector(QQ,n,h_i))
44
45 return Cone(hs)