From 344df04250bdc5982eab521276fc08b509fd239f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 12 Feb 2017 16:38:44 -0500 Subject: [PATCH] Fix the is_positive_on test and give better examples. --- mjo/cone/cone.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/mjo/cone/cone.py b/mjo/cone/cone.py index a7c16a5..01ef5f9 100644 --- a/mjo/cone/cone.py +++ b/mjo/cone/cone.py @@ -30,6 +30,16 @@ def is_positive_on(L,K): EXAMPLES: + Positive operators on the nonnegative orthant are nonnegative + matrices:: + + sage: K = Cone([(1,0,0),(0,1,0),(0,0,1)]) + sage: L = random_matrix(QQ,3).apply_map(abs) + sage: is_positive_on(L,K) + True + + TESTS: + The identity is always positive in a nontrivial space:: sage: set_random_seed() @@ -46,8 +56,6 @@ def is_positive_on(L,K): sage: is_positive_on(L,K) True - TESTS: - Everything in ``K.positive_operators_gens()`` should be positive on ``K``:: @@ -66,7 +74,7 @@ def is_positive_on(L,K): elif L.base_ring() is SR: # Fall back to inequality-checking when the entries of ``L`` # might be symbolic. - return all([ s*(L*x) >= 0 for x in K for s in K ]) + return all([ s*(L*x) >= 0 for x in K for s in K.dual() ]) else: # The only inexact ring that we're willing to work with is SR, # since it can still be exact when working with symbolic @@ -246,6 +254,16 @@ def is_lyapunov_like_on(L,K): EXAMPLES: + Lyapunov-like operators on the nonnegative orthant are diagonal + matrices:: + + sage: K = Cone([(1,0,0),(0,1,0),(0,0,1)]) + sage: L = diagonal_matrix(random_vector(QQ,3)) + sage: is_lyapunov_like_on(L,K) + True + + TESTS: + The identity is always Lyapunov-like in a nontrivial space:: sage: set_random_seed() @@ -262,8 +280,6 @@ def is_lyapunov_like_on(L,K): sage: is_lyapunov_like_on(L,K) True - TESTS: - Everything in ``K.lyapunov_like_basis()`` should be Lyapunov-like on ``K``:: -- 2.43.2