]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
Add work-in-progress code for the Schur cone (from David Sossa's work).
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 12 Feb 2017 21:20:01 +0000 (16:20 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 12 Feb 2017 21:20:01 +0000 (16:20 -0500)
mjo/cone/schur.py [new file with mode: 0644]

diff --git a/mjo/cone/schur.py b/mjo/cone/schur.py
new file mode 100644 (file)
index 0000000..bea76b6
--- /dev/null
@@ -0,0 +1,45 @@
+"""
+The Schur cone, as described in the "Critical angles..." papers by
+Seeger and Sossa.
+"""
+
+from sage.all import *
+
+def is_pointed(P,Q):
+    newP = Cone([ list(p) for p in P ])
+    newQ = Cone([ list(q) for q in Q ])
+    return newP.intersection(-newQ).is_trivial()
+
+def ext_angles(P,Q):
+    angles = []
+    for p in P:
+        for q in Q:
+            p = vector(SR, p)
+            q = vector(SR, q)
+            p = p/p.norm()
+            q = q/q.norm()
+            angles.append(arccos(p.inner_product(q)))
+
+    return angles
+
+def schur(n):
+    r"""
+    Return the Schur cone in ``n`` dimensions.
+
+    INPUT:
+
+    - ``n`` -- the ambient dimension of the Schur cone and its ambient space.
+
+    OUTPUT:
+
+    A rational closed convex Schur cone of dimension ``n``.
+    """
+
+    hs = []
+    for i in range(1,n):
+        h_i = [0]*n
+        h_i[i-1] = QQ(1)
+        h_i[i] = -QQ(1)
+        hs.append(vector(QQ,n,h_i))
+
+    return Cone(hs)