from sage.all import *
-def drop_dependent(vs):
- r"""
- Return the largest linearly-independent subset of ``vs``.
- """
- result = []
- m = matrix(vs).echelon_form()
- for idx in range(0, m.nrows()):
- if not m[idx].is_zero():
- result.append(m[idx])
-
- return result
-
-
def basically_the_same(K1,K2):
r"""
``True`` if ``K1`` and ``K2`` are basically the same, and ``False``
- otherwise.
+ otherwise. This is intended as a lazy way to check whether or not
+ ``K1`` and ``K2`` are linearly isomorphic (i.e. ``A(K1) == K2`` for
+ some invertible linear transformation ``A``).
"""
if K1.lattice_dim() != K2.lattice_dim():
return False
INPUT:
- - ``K2`` -- another cone whose lattice has the same rank as this cone.
+ - ``K2`` -- another cone whose lattice has the same rank as this
+ cone.
OUTPUT:
sage: set_random_seed()
sage: K = random_cone(max_dim = 8, strictly_convex=False, solid=False)
sage: K_S = rho(K)
- sage: P = rho(K_S.dual()).dual()
- sage: P.is_proper()
+ sage: K_SP = rho(K_S.dual()).dual()
+ sage: K_SP.is_proper()
True
- sage: P = rho(K_S, K_S.dual())
- sage: P.is_proper()
+ sage: K_SP = rho(K_S, K_S.dual())
+ sage: K_SP.is_proper()
True
::
sage: set_random_seed()
sage: K = random_cone(max_dim = 8, strictly_convex=True, solid=False)
sage: K_S = rho(K)
- sage: P = rho(K_S.dual()).dual()
- sage: P.is_proper()
+ sage: K_SP = rho(K_S.dual()).dual()
+ sage: K_SP.is_proper()
True
- sage: P = rho(K_S, K_S.dual())
- sage: P.is_proper()
+ sage: K_SP = rho(K_S, K_S.dual())
+ sage: K_SP.is_proper()
True
::
sage: set_random_seed()
sage: K = random_cone(max_dim = 8, strictly_convex=False, solid=True)
sage: K_S = rho(K)
- sage: P = rho(K_S.dual()).dual()
- sage: P.is_proper()
+ sage: K_SP = rho(K_S.dual()).dual()
+ sage: K_SP.is_proper()
True
- sage: P = rho(K_S, K_S.dual())
- sage: P.is_proper()
+ sage: K_SP = rho(K_S, K_S.dual())
+ sage: K_SP.is_proper()
True
::
sage: set_random_seed()
sage: K = random_cone(max_dim = 8, strictly_convex=True, solid=True)
sage: K_S = rho(K)
- sage: P = rho(K_S.dual()).dual()
- sage: P.is_proper()
+ sage: K_SP = rho(K_S.dual()).dual()
+ sage: K_SP.is_proper()
True
- sage: P = rho(K_S, K_S.dual())
- sage: P.is_proper()
+ sage: K_SP = rho(K_S, K_S.dual())
+ sage: K_SP.is_proper()
True
- Test the proposition in our paper concerning the duals, where the
- subspace `W` is the span of `K^{*}`::
+ Test the proposition in our paper concerning the duals and
+ restrictions. Generate a random cone, then create a subcone of
+ it. The operation of dual-taking should then commute with rho::
sage: set_random_seed()
- sage: K = random_cone(max_dim = 8, solid=False, strictly_convex=False)
- sage: K_W = rho(K, K.dual())
- sage: K_star_W_star = rho(K.dual()).dual()
+ sage: J = random_cone(max_dim = 8, solid=False, strictly_convex=False)
+ sage: K = Cone(random_sublist(J.rays(), 0.5), lattice=J.lattice())
+ sage: K_W = rho(K, J)
+ sage: K_star_W_star = rho(K.dual(), J).dual()
sage: basically_the_same(K_W, K_star_W_star)
True
::
sage: set_random_seed()
- sage: K = random_cone(max_dim = 8, solid=True, strictly_convex=False)
- sage: K_W = rho(K, K.dual())
- sage: K_star_W_star = rho(K.dual()).dual()
+ sage: J = random_cone(max_dim = 8, solid=True, strictly_convex=False)
+ sage: K = Cone(random_sublist(J.rays(), 0.5), lattice=J.lattice())
+ sage: K_W = rho(K, J)
+ sage: K_star_W_star = rho(K.dual(), J).dual()
sage: basically_the_same(K_W, K_star_W_star)
True
::
sage: set_random_seed()
- sage: K = random_cone(max_dim = 8, solid=False, strictly_convex=True)
- sage: K_W = rho(K, K.dual())
- sage: K_star_W_star = rho(K.dual()).dual()
+ sage: J = random_cone(max_dim = 8, solid=False, strictly_convex=True)
+ sage: K = Cone(random_sublist(J.rays(), 0.5), lattice=J.lattice())
+ sage: K_W = rho(K, J)
+ sage: K_star_W_star = rho(K.dual(), J).dual()
sage: basically_the_same(K_W, K_star_W_star)
True
::
sage: set_random_seed()
- sage: K = random_cone(max_dim = 8, solid=True, strictly_convex=True)
- sage: K_W = rho(K, K.dual())
- sage: K_star_W_star = rho(K.dual()).dual()
+ sage: J = random_cone(max_dim = 8, solid=True, strictly_convex=True)
+ sage: K = Cone(random_sublist(J.rays(), 0.5), lattice=J.lattice())
+ sage: K_W = rho(K, J)
+ sage: K_star_W_star = rho(K.dual(), J).dual()
sage: basically_the_same(K_W, K_star_W_star)
True
if K2 is None:
K2 = K
- # First we project K onto the span of K2. This can be done with
- # cones (i.e. without converting to vector spaces), but it's
- # annoying to deal with lattice mismatches.
+ # First we project K onto the span of K2. This will explode if the
+ # rank of ``K2.lattice()`` doesn't match ours.
span_K2 = Cone(K2.rays() + (-K2).rays(), lattice=K.lattice())
K = K.intersection(span_K2)
- V = K.lattice().vector_space()
-
- # Create the space W \times W^{\perp} isomorphic to V.
- # First we get an orthogonal (but not normal) basis...
- W_basis = drop_dependent(K2.rays())
- W = V.subspace_with_basis(W_basis)
+ # Cheat a little to get the subspace span(K2). The paper uses the
+ # rays of K2 as a basis, but everything is invariant under linear
+ # isomorphism (i.e. a change of basis), and this is a little
+ # faster.
+ W = span_K2.linear_subspace()
# We've already intersected K with the span of K2, so every
# generator of K should belong to W now.
A list of pairs `(x,s)` such that,
- * `x` is in this cone.
* `x` is a generator of this cone.
- * `s` is in this cone's dual.
* `s` is a generator of this cone's dual.
* `x` and `s` are orthogonal.
sage: K = random_cone(max_dim=8)
sage: actual = lyapunov_rank(K)
sage: K_S = rho(K)
- sage: P = rho(K_S.dual()).dual()
+ sage: K_SP = rho(K_S.dual()).dual()
sage: l = lineality(K)
sage: c = codim(K)
- sage: expected = lyapunov_rank(P) + K.dim()*(l + c) + c**2
+ sage: expected = lyapunov_rank(K_SP) + K.dim()*(l + c) + c**2
sage: actual == expected
True
True
"""
- K_orig = K
beta = 0
m = K.dim()
l = lineality(K)
if m < n:
- # K is not solid, project onto its span.
+ # K is not solid, restrict to its span.
K = rho(K)
# Lemma 2
beta += m*(n - m) + (n - m)**2
if l > 0:
- # K is not pointed, project its dual onto its span.
- # Uses a proposition from our paper, i.e. this is
- # equivalent to K = rho(K.dual()).dual()
+ # K is not pointed, restrict to the span of its dual. Uses a
+ # proposition from our paper, i.e. this is equivalent to K =
+ # rho(K.dual()).dual().
K = rho(K, K.dual())
# Lemma 3