From c7572b7c827ee6ee604236c38a328ac69a3a7a2a Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 11 Nov 2018 19:09:25 -0500 Subject: [PATCH] cone/schur.py: add "lattice" argument. --- mjo/cone/schur.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/mjo/cone/schur.py b/mjo/cone/schur.py index 53607a9..88b7d82 100644 --- a/mjo/cone/schur.py +++ b/mjo/cone/schur.py @@ -5,17 +5,25 @@ Iusem, Seeger, and Sossa. It defines the Schur ordering on `R^{n}`. from sage.all import * -def schur_cone(n): +def schur_cone(n, lattice=None): r""" Return the Schur cone in ``n`` dimensions. INPUT: - - ``n`` -- the dimension the ambient space. + - ``n`` -- the dimension the ambient space. + + - ``lattice`` -- (default: ``None``) an ambient lattice of rank ``n`` + to be passed to the :func:`Cone` constructor. OUTPUT: - A rational closed convex Schur cone of dimension ``n``. + A rational closed convex Schur cone of dimension ``n``. Each + generating ray will have the integer ring as its base ring. + + If a ``lattice`` was specified, then the resulting cone will live in + that lattice unless its rank is incompatible with the dimension + ``n`` (in which case a ``ValueError`` is raised). REFERENCES: @@ -87,7 +95,28 @@ def schur_cone(n): sage: majorized_by(x,y) == ( (y-x) in S ) True + If a ``lattice`` was given, it is actually used:: + + sage: L = ToricLattice(3, 'M') + sage: schur_cone(3, lattice=L) + 2-d cone in 3-d lattice M + + Unless the rank of the lattice disagrees with ``n``:: + + sage: L = ToricLattice(1, 'M') + sage: schur_cone(3, lattice=L) + Traceback (most recent call last): + ... + ValueError: lattice rank=1 and dimension n=3 are incompatible + """ + if lattice is None: + lattice = ToricLattice(n) + + if lattice.rank() != n: + raise ValueError('lattice rank=%d and dimension n=%d are incompatible' + % + (lattice.rank(), n)) def _f(i,j): if i == j: @@ -100,5 +129,4 @@ def schur_cone(n): # The "max" below catches the trivial case where n == 0. S = matrix(ZZ, max(0,n-1), n, _f) - # Likewise, when n == 0, we need to specify the lattice. - return Cone(S.rows(), ToricLattice(n)) + return Cone(S.rows(), lattice) -- 2.43.2