From: Michael Orlitzky Date: Fri, 2 Nov 2018 14:00:44 +0000 (-0400) Subject: mjo/cone: add the nonnegative_orthant module. X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=785d079a2f5faa5126685aea96d584c3fa9c3007;p=sage.d.git mjo/cone: add the nonnegative_orthant module. --- diff --git a/mjo/cone/all.py b/mjo/cone/all.py index bda0d03..e7d3bff 100644 --- a/mjo/cone/all.py +++ b/mjo/cone/all.py @@ -6,6 +6,7 @@ from mjo.cone.cone import * from mjo.cone.completely_positive import * from mjo.cone.doubly_nonnegative import * from mjo.cone.faces import * +from mjo.cone.nonnegative_orthant import * from mjo.cone.permutation_invariant import * from mjo.cone.rearrangement import * from mjo.cone.symmetric_psd import * diff --git a/mjo/cone/nonnegative_orthant.py b/mjo/cone/nonnegative_orthant.py new file mode 100644 index 0000000..c116330 --- /dev/null +++ b/mjo/cone/nonnegative_orthant.py @@ -0,0 +1,53 @@ +""" +The nonnegative orthant in `\mathbb{Z}^{n}`. I'm sick and tired of +typing it. +""" + +from sage.all import * + +def nonnegative_orthant(n): + r""" + The nonnegative orthant in ``n`` dimensions. + + INPUT: + + - ``n`` -- the dimension of the ambient space. + + OUTPUT: + + The convex cone having ``n`` standard basis vectors as its + generators. Each generating ray will have the integer ring as its + base ring. + + SETUP:: + + sage: from mjo.cone.nonnegative_orthant import nonnegative_orthant + + EXAMPLES:: + + sage: nonnegative_orthant(3).rays() + N(1, 0, 0), + N(0, 1, 0), + N(0, 0, 1) + in 3-d lattice N + + TESTS: + + We can construct the trivial cone as the nonnegative orthant in a + trivial vector space:: + + sage: nonnegative_orthant(0) + 0-d cone in 0-d lattice N + + The nonnegative orthant is a proper cone:: + + sage: set_random_seed() + sage: n = ZZ.random_element(10) + sage: K = nonnegative_orthant(n) + sage: K.is_proper() + True + + """ + I = identity_matrix(ZZ,n) + lattice = ToricLattice(n) + return Cone(I.rows(), lattice)