]>
gitweb.michael.orlitzky.com - sage.d.git/blob - cone/schur.py
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}`.
8 def schur_cone(n
, lattice
=None):
10 Return the Schur cone in ``n`` dimensions that induces the
11 majorization ordering.
15 - ``n`` -- the dimension the ambient space.
17 - ``lattice`` -- (default: ``None``) an ambient lattice of rank ``n``
18 to be passed to the :func:`Cone` constructor.
22 A rational closed convex Schur cone of dimension ``n``. Each
23 generating ray will have the integer ring as its base ring.
25 If a ``lattice`` was specified, then the resulting cone will live in
26 that lattice unless its rank is incompatible with the dimension
27 ``n`` (in which case a ``ValueError`` is raised).
31 .. [GourionSeeger] Daniel Gourion and Alberto Seeger.
32 Critical angles in polyhedral convex cones: numerical and
33 statistical considerations. Mathematical Programming, 123:173-198,
34 2010, doi:10.1007/s10107-009-0317-2.
36 .. [IusemSeegerOnPairs] Alfredo Iusem and Alberto Seeger.
37 On pairs of vectors achieving the maximal angle of a convex cone.
38 Mathematical Programming, 104(2-3):501-523, 2005,
39 doi:10.1007/s10107-005-0626-z.
41 .. [SeegerSossaI] Alberto Seeger and David Sossa.
42 Critical angles between two convex cones I. General theory.
43 TOP, 24(1):44-65, 2016, doi:10.1007/s11750-015-0375-y.
47 sage: from mjo.cone.nonnegative_orthant import nonnegative_orthant
48 sage: from mjo.cone.schur import schur_cone
52 Verify the claim that the maximal angle between any two generators
53 of the Schur cone and the nonnegative quintant is ``3*pi/4``::
55 sage: P = schur_cone(5)
56 sage: Q = nonnegative_orthant(5)
57 sage: G = ( g.change_ring(QQbar).normalized() for g in P )
58 sage: H = ( h.change_ring(QQbar).normalized() for h in Q )
59 sage: actual = max(arccos(u.inner_product(v)) for u in G for v in H)
60 sage: expected = 3*pi/4
61 sage: abs(actual - expected).n() < 1e-12
64 The dual of the Schur cone is the "downward monotonic cone"
65 [GourionSeeger]_, whose elements' entries are in non-increasing
68 sage: n = ZZ.random_element(10)
69 sage: K = schur_cone(n).dual()
70 sage: x = K.random_element()
71 sage: all( x[i] >= x[i+1] for i in range(n-1) )
76 We get the trivial cone when ``n`` is zero::
78 sage: schur_cone(0).is_trivial()
81 The Schur cone induces the majorization ordering::
83 sage: def majorized_by(x,y):
84 ....: return (all(sum(x[0:i]) <= sum(y[0:i])
85 ....: for i in range(x.degree()-1))
86 ....: and sum(x) == sum(y))
87 sage: n = ZZ.random_element(10)
88 sage: V = VectorSpace(QQ, n)
89 sage: S = schur_cone(n)
90 sage: majorized_by(V.zero(), S.random_element())
92 sage: x = V.random_element()
93 sage: y = V.random_element()
94 sage: majorized_by(x,y) == ( (y-x) in S )
97 If a ``lattice`` was given, it is actually used::
99 sage: L = ToricLattice(3, 'M')
100 sage: schur_cone(3, lattice=L)
101 2-d cone in 3-d lattice M
103 Unless the rank of the lattice disagrees with ``n``::
105 sage: L = ToricLattice(1, 'M')
106 sage: schur_cone(3, lattice=L)
107 Traceback (most recent call last):
109 ValueError: lattice rank=1 and dimension n=3 are incompatible
113 lattice
= ToricLattice(n
)
115 if lattice
.rank() != n
:
116 raise ValueError('lattice rank=%d and dimension n=%d are incompatible'
128 # The "max" below catches the trivial case where n == 0.
129 S
= matrix(ZZ
, max(0,n
-1), n
, _f
)
131 return Cone(S
.rows(), lattice
)