X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Fcone%2Fcompletely_positive.py;h=3dc66b454dfb8a85a4aa2ba4a4be03978a5b3690;hb=7af2b9d146a6bf2fb8acc3c342983de577b417ce;hp=15be5587cca1e85f50121fd020eb727fda568c36;hpb=3d6ec3f4f138a6278be4f393b491aa1ac2bbffa8;p=sage.d.git diff --git a/mjo/cone/completely_positive.py b/mjo/cone/completely_positive.py index 15be558..3dc66b4 100644 --- a/mjo/cone/completely_positive.py +++ b/mjo/cone/completely_positive.py @@ -1,4 +1,4 @@ -""" +r""" The completely positive cone `$\mathcal{K}$` over `\mathbb{R}^{n}$` is the set of all matrices `$A$`of the form `$\sum uu^{T}$` for `$u \in \mathbb{R}^{n}_{+}$`. Equivalently, `$A = XX{T}$` where all entries of @@ -6,7 +6,7 @@ the set of all matrices `$A$`of the form `$\sum uu^{T}$` for `$u \in """ from sage.all import * -from mjo.cone.symmetric_psd import factor_psd, is_symmetric_psd +from mjo.cone.symmetric_psd import factor_psd from mjo.cone.doubly_nonnegative import (is_doubly_nonnegative, is_extreme_doubly_nonnegative) @@ -89,7 +89,7 @@ def is_completely_positive(A): msg = 'The matrix ``A`` cannot be symbolic.' raise ValueError.new(msg) - if not is_symmetric_psd(A): + if not A.is_positive_semidefinite(): return False n = A.nrows() # Makes sense since ``A`` is symmetric. @@ -176,7 +176,7 @@ def is_extreme_completely_positive(A): msg = 'The matrix ``A`` cannot be symbolic.' raise ValueError(msg) - if not is_symmetric_psd(A): + if not A.is_positive_semidefinite(): return False n = A.nrows() # Makes sense since ``A`` is symmetric. @@ -195,57 +195,3 @@ def is_extreme_completely_positive(A): # factorization into `$XX^{T}$` may not be unique! raise ValueError('Unable to determine extremity of ``A``.') - - -def completely_positive_operators_gens(K): - r""" - Return a list of generators (matrices) for the completely-positive - cone of ``K``. - - INPUT: - - - ``K`` -- a closed convex rational polyhedral cone. - - OUTPUT: - - A list of matrices, the conic hull of which is the - completely-positive cone of ``K``. - - SETUP:: - - sage: from mjo.cone.completely_positive import ( - ....: completely_positive_operators_gens, - ....: is_completely_positive ) - sage: from mjo.cone.nonnegative_orthant import nonnegative_orthant - sage: from mjo.matrix_vector import isomorphism - - EXAMPLES:: - - sage: K = nonnegative_orthant(2) - sage: completely_positive_operators_gens(K) - [ - [1 0] [0 0] - [0 0], [0 1] - ] - sage: all( is_completely_positive(M) - ....: for M in completely_positive_operators_gens(K) ) - True - - TESTS: - - The completely-positive cone of ``K`` is subdual:: - - sage: K = random_cone(max_ambient_dim=8, max_rays=10) - sage: cp_gens = completely_positive_operators_gens(K) - sage: n = K.lattice_dim() - sage: M = MatrixSpace(QQ, n, n) - sage: (p, p_inv) = isomorphism(M) - sage: L = ToricLattice(n**2) - sage: cp_cone = Cone( (p(m) for m in cp_gens), lattice=L ) - sage: copos_cone = Cone(cp_cone.dual().rays(), lattice=L ) - sage: all( x in copos_cone for x in cp_cone ) - True - - """ - return [ x.tensor_product(x) for x in K ] -