From e4c0c9872cc60485c06decd5443b1e20f782a942 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 12 Nov 2018 01:09:50 -0500 Subject: [PATCH] cone/trivial_cone.py: add the trivial_cone() function. --- mjo/cone/all.py | 1 + mjo/cone/trivial_cone.py | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 mjo/cone/trivial_cone.py diff --git a/mjo/cone/all.py b/mjo/cone/all.py index 80d5b0b..d6a6dd6 100644 --- a/mjo/cone/all.py +++ b/mjo/cone/all.py @@ -11,3 +11,4 @@ from mjo.cone.permutation_invariant import * from mjo.cone.rearrangement import * from mjo.cone.schur import * from mjo.cone.symmetric_psd import * +from mjo.cone.trivial_cone import * diff --git a/mjo/cone/trivial_cone.py b/mjo/cone/trivial_cone.py new file mode 100644 index 0000000..17c6835 --- /dev/null +++ b/mjo/cone/trivial_cone.py @@ -0,0 +1,64 @@ +from sage.all import * + +def trivial_cone(n, lattice=None): + r""" + The trivial cone with no generators in ``n`` dimensions. + + INPUT: + + - ``n`` -- the dimension of the ambient space. + + - ``lattice`` -- (default: ``None``) an ambient lattice of rank ``n`` + to be passed to the :func:`Cone` constructor. + + OUTPUT: + + The trivial cone with no generators. + + 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). + + SETUP:: + + sage: from mjo.cone.trivial_cone import trivial_cone + + EXAMPLES:: + + We can construct the trivial cone as the nonnegative orthant in a + trivial ambient space:: + + sage: trivial_cone(0) + 0-d cone in 0-d lattice N + + Or in a nontrivial ambient space:: + + sage: trivial_cone(3) + 0-d cone in 3-d lattice N + + If a ``lattice`` is given, the trivial cone will live in that lattice:: + + sage: L = ToricLattice(3, 'M') + sage: trivial_cone(3, lattice=L) + 0-d cone in 3-d lattice M + + TESTS: + + An error is raised if the rank of the lattice disagrees with ``n``:: + + sage: L = ToricLattice(1, 'M') + sage: trivial_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)) + + return Cone([], lattice) -- 2.44.2