From 263ce239a456e5e073a9a8835cdf6cf7e0dfaa98 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 5 Jan 2016 22:32:22 -0500 Subject: [PATCH] More minor cleanup of motzkin_decomposition(). --- mjo/cone/cone.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mjo/cone/cone.py b/mjo/cone/cone.py index 84c3adb..eb53163 100644 --- a/mjo/cone/cone.py +++ b/mjo/cone/cone.py @@ -83,7 +83,7 @@ def motzkin_decomposition(K): REFERENCES: .. [Stoer-Witzgall] J. Stoer and C. Witzgall. Convexity and - Optimization in Finite Dimensions I. Springer-Verlag, New + Optimization in Finite Dimensions I. Springer-Verlag, New York, 1970. EXAMPLES: @@ -152,18 +152,17 @@ def motzkin_decomposition(K): sage: S.is_equivalent(expected_S) True """ - linspace_gens = [ copy(b) for b in K.linear_subspace().basis() ] - linspace_gens += [ -b for b in linspace_gens ] + # The lines() method only gives us one generator for each line, + # so we negate the result and combine everything for the full set. + S = Cone([p*l for p in [1,-1] for l in K.lines()], K.lattice()) - S = Cone(linspace_gens, K.lattice()) - - # Since ``S`` is a subspace, its dual is its orthogonal complement - # (albeit in the wrong lattice). - S_perp = Cone(S.dual(), K.lattice()) - P = K.intersection(S_perp) + # Since ``S`` is a subspace, the rays of its dual generate its + # orthogonal complement. + P = K.intersection( Cone(S.dual(), K.lattice()) ) return (P,S) + def positive_operator_gens(K): r""" Compute generators of the cone of positive operators on this cone. -- 2.44.2