]>
gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/cone/nonnegative_orthant.py
2 The nonnegative orthant in `\mathbb{Z}^{n}`. I'm sick and tired of
8 def nonnegative_orthant(n
, lattice
=None):
10 The nonnegative orthant in ``n`` dimensions.
14 - ``n`` -- the dimension of the ambient space.
16 - ``lattice`` -- (default: ``None``) an ambient lattice of rank ``n``
17 to be passed to the :func:`Cone` constructor.
21 The convex cone having ``n`` standard basis vectors as its
22 generators. Each generating ray will have the integer ring as its
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 sage: from mjo.cone.nonnegative_orthant import nonnegative_orthant
35 sage: nonnegative_orthant(3).rays()
43 We can construct the trivial cone as the nonnegative orthant in a
44 trivial vector space::
46 sage: nonnegative_orthant(0)
47 0-d cone in 0-d lattice N
49 The nonnegative orthant is a proper cone::
51 sage: set_random_seed()
52 sage: n = ZZ.random_element(10)
53 sage: K = nonnegative_orthant(n)
57 If a ``lattice`` was given, it is actually used::
59 sage: L = ToricLattice(3, 'M')
60 sage: nonnegative_orthant(3, lattice=L)
61 3-d cone in 3-d lattice M
63 Unless the rank of the lattice disagrees with ``n``::
65 sage: L = ToricLattice(1, 'M')
66 sage: nonnegative_orthant(3, lattice=L)
67 Traceback (most recent call last):
69 ValueError: lattice rank=1 and dimension n=3 are incompatible
73 lattice
= ToricLattice(n
)
75 if lattice
.rank() != n
:
76 raise ValueError('lattice rank=%d and dimension n=%d are incompatible'
80 I
= identity_matrix(ZZ
,n
)
81 return Cone(I
.rows(), lattice
)