]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/cone/trivial_cone.py
makefile: add --long to the test command.
[sage.d.git] / mjo / cone / trivial_cone.py
1 from sage.all import *
2
3 def trivial_cone(n, lattice=None):
4 r"""
5 The trivial cone with no generators in ``n`` dimensions.
6
7 INPUT:
8
9 - ``n`` -- the dimension of the ambient space.
10
11 - ``lattice`` -- (default: ``None``) an ambient lattice of rank ``n``
12 to be passed to the :func:`Cone` constructor.
13
14 OUTPUT:
15
16 The trivial cone with no generators.
17
18 If a ``lattice`` was specified, then the resulting cone will live in
19 that lattice unless its rank is incompatible with the dimension
20 ``n`` (in which case a ``ValueError`` is raised).
21
22 SETUP::
23
24 sage: from mjo.cone.trivial_cone import trivial_cone
25
26 EXAMPLES::
27
28 We can construct the trivial cone as the nonnegative orthant in a
29 trivial ambient space::
30
31 sage: trivial_cone(0)
32 0-d cone in 0-d lattice N
33
34 Or in a nontrivial ambient space::
35
36 sage: trivial_cone(3)
37 0-d cone in 3-d lattice N
38
39 If a ``lattice`` is given, the trivial cone will live in that lattice::
40
41 sage: L = ToricLattice(3, 'M')
42 sage: trivial_cone(3, lattice=L)
43 0-d cone in 3-d lattice M
44
45 TESTS:
46
47 An error is raised if the rank of the lattice disagrees with ``n``::
48
49 sage: L = ToricLattice(1, 'M')
50 sage: trivial_cone(3, lattice=L)
51 Traceback (most recent call last):
52 ...
53 ValueError: lattice rank=1 and dimension n=3 are incompatible
54
55 """
56 if lattice is None:
57 lattice = ToricLattice(n)
58
59 if lattice.rank() != n:
60 raise ValueError('lattice rank=%d and dimension n=%d are incompatible'
61 %
62 (lattice.rank(), n))
63
64 return Cone([], lattice)