]>
gitweb.michael.orlitzky.com - sage.d.git/blob - schur.py
88b7d82722956f73a54ac429641c7143df99b749
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.
14 - ``n`` -- the dimension the ambient space.
16 - ``lattice`` -- (default: ``None``) an ambient lattice of rank ``n``
17 to be passed to the :func:`Cone` constructor.
21 A rational closed convex Schur cone of dimension ``n``. Each
22 generating ray will have the integer ring as its base ring.
24 If a ``lattice`` was specified, then the resulting cone will live in
25 that lattice unless its rank is incompatible with the dimension
26 ``n`` (in which case a ``ValueError`` is raised).
30 .. [GourionSeeger] Daniel Gourion and Alberto Seeger.
31 Critical angles in polyhedral convex cones: numerical and
32 statistical considerations. Mathematical Programming, 123:173-198,
33 2010, doi:10.1007/s10107-009-0317-2.
35 .. [IusemSeegerOnPairs] Alfredo Iusem and Alberto Seeger.
36 On pairs of vectors achieving the maximal angle of a convex cone.
37 Mathematical Programming, 104(2-3):501-523, 2005,
38 doi:10.1007/s10107-005-0626-z.
40 .. [SeegerSossaI] Alberto Seeger and David Sossa.
41 Critical angles between two convex cones I. General theory.
42 TOP, 24(1):44-65, 2016, doi:10.1007/s11750-015-0375-y.
46 sage: from mjo.cone.nonnegative_orthant import nonnegative_orthant
47 sage: from mjo.cone.schur import schur_cone
51 Verify the claim that the maximal angle between any two generators
52 of the Schur cone and the nonnegative quintant is ``3*pi/4``::
54 sage: P = schur_cone(5)
55 sage: Q = nonnegative_orthant(5)
56 sage: G = ( g.change_ring(QQbar).normalized() for g in P )
57 sage: H = ( h.change_ring(QQbar).normalized() for h in Q )
58 sage: actual = max(arccos(u.inner_product(v)) for u in G for v in H)
59 sage: expected = 3*pi/4
60 sage: abs(actual - expected).n() < 1e-12
63 The dual of the Schur cone is the "downward monotonic cone"
64 [GourionSeeger]_, whose elements' entries are in non-increasing
67 sage: set_random_seed()
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 xrange(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: set_random_seed()
84 sage: def majorized_by(x,y):
85 ....: return (all(sum(x[0:i]) <= sum(y[0:i])
86 ....: for i in xrange(x.degree()-1))
87 ....: and sum(x) == sum(y))
88 sage: n = ZZ.random_element(10)
89 sage: V = VectorSpace(QQ, n)
90 sage: S = schur_cone(n)
91 sage: majorized_by(V.zero(), S.random_element())
93 sage: x = V.random_element()
94 sage: y = V.random_element()
95 sage: majorized_by(x,y) == ( (y-x) in S )
98 If a ``lattice`` was given, it is actually used::
100 sage: L = ToricLattice(3, 'M')
101 sage: schur_cone(3, lattice=L)
102 2-d cone in 3-d lattice M
104 Unless the rank of the lattice disagrees with ``n``::
106 sage: L = ToricLattice(1, 'M')
107 sage: schur_cone(3, lattice=L)
108 Traceback (most recent call last):
110 ValueError: lattice rank=1 and dimension n=3 are incompatible
114 lattice
= ToricLattice(n
)
116 if lattice
.rank() != n
:
117 raise ValueError('lattice rank=%d and dimension n=%d are incompatible'
129 # The "max" below catches the trivial case where n == 0.
130 S
= matrix(ZZ
, max(0,n
-1), n
, _f
)
132 return Cone(S
.rows(), lattice
)