]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/cone/schur.py
fd806d93eb6380574c69cabe5471dc938b7aebe6
[sage.d.git] / mjo / cone / schur.py
1 """
2 The Schur cone, as described in the "Critical angles..." papers by
3 Iusem, Seeger, and Sossa. It defines the Schur ordering on `R^{n}`.
4 """
5
6 from sage.all import *
7
8 def schur_cone(n):
9 r"""
10 Return the Schur cone in ``n`` dimensions.
11
12 INPUT:
13
14 - ``n`` -- the dimension the ambient space.
15
16 OUTPUT:
17
18 A rational closed convex Schur cone of dimension ``n``.
19
20 REFERENCES:
21
22 .. [SeegerSossaI] Alberto Seeger and David Sossa.
23 Critical angles between two convex cones I. General theory.
24 TOP, 24(1):44-65, 2016, doi:10.1007/s11750-015-0375-y.
25
26 SETUP::
27
28 sage: from mjo.cone.nonnegative_orthant import nonnegative_orthant
29 sage: from mjo.cone.schur import schur_cone
30
31 EXAMPLES:
32
33 Verify the claim that the maximal angle between any two generators
34 of the Schur cone and the nonnegative quintant is ``3*pi/4``::
35
36 sage: P = schur_cone(5)
37 sage: Q = nonnegative_orthant(5)
38 sage: G = [ g.change_ring(QQbar).normalized() for g in P ]
39 sage: H = [ h.change_ring(QQbar).normalized() for h in Q ]
40 sage: actual = max([arccos(u.inner_product(v)) for u in G for v in H])
41 sage: expected = 3*pi/4
42 sage: abs(actual - expected).n() < 1e-12
43 True
44
45 TESTS:
46
47 We get the trivial cone when ``n`` is zero::
48
49 sage: schur_cone(0).is_trivial()
50 True
51
52 """
53
54 def _f(i,j):
55 if i == j:
56 return 1
57 elif j - i == 1:
58 return -1
59 else:
60 return 0
61
62 # The "max" below catches the trivial case where n == 0.
63 S = matrix(ZZ, max(0,n-1), n, _f)
64
65 # Likewise, when n == 0, we need to specify the lattice.
66 return Cone(S.rows(), ToricLattice(n))