- if l is None and u is None:
- # They're both random, just return a random nonnegative
- # integer.
- return ZZ.random_element().abs()
-
- if l is not None and u is not None:
- # Both were specified. Again, just make up a number and
- # return it. If the user wants to give us u < l then he
- # can have an exception.
- return ZZ.random_element(l,u)
-
- if l is not None and u is None:
- # In this case, we're generating the upper bound randomly
- # GIVEN A LOWER BOUND. So we add a random nonnegative
- # integer to the given lower bound.
- u = l + ZZ.random_element().abs()
- return ZZ.random_element(l,u)
-
- # Here we must be in the only remaining case, where we are
- # given an upper bound but no lower bound. We might as well
- # use zero.
- return ZZ.random_element(0,u)
+ if u is None:
+ # The upper bound is unspecified; return a random integer
+ # in [l,infinity).
+ return l + ZZ.random_element().abs()
+ else:
+ # We have an upper bound, and it's greater than or equal
+ # to our lower bound. So we generate a random integer in
+ # [0,u-l], and then add it to l to get something in
+ # [l,u]. To understand the "+1", check the
+ # ZZ.random_element() docs.
+ return l + ZZ.random_element(u - l + 1)
+
+ def is_full_space(K):
+ r"""
+ Is this cone equivalent to the full ambient vector space?
+ """
+ return K.lines().dim() == K.lattice_dim()