]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/ldlt.py: goodbye, use https://trac.sagemath.org/ticket/10332 instead.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 7 Oct 2020 21:21:59 +0000 (17:21 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 7 Oct 2020 21:21:59 +0000 (17:21 -0400)
mjo/all.py
mjo/ldlt.py [deleted file]

index 3854ac376440cca9c3e6e16222fde8693e1bd7d1..de2212d488360d5ff38edb7a3da775285e4262c2 100644 (file)
@@ -6,7 +6,6 @@ in his script. Instead, he can just `from mjo.all import *`.
 from mjo.basis_repr import *
 from mjo.cone.all import *
 from mjo.eja.all import *
-from mjo.ldlt import *
 from mjo.interpolation import *
 from mjo.misc import *
 from mjo.orthogonal_polynomials import *
diff --git a/mjo/ldlt.py b/mjo/ldlt.py
deleted file mode 100644 (file)
index 1c2663e..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-from sage.all import *
-
-def is_positive_semidefinite_naive(A):
-    r"""
-    A naive positive-semidefinite check that tests the eigenvalues for
-    nonnegativity.  We follow the sage convention that positive
-    (semi)definite matrices must be symmetric or Hermitian.
-
-    SETUP::
-
-        sage: from mjo.ldlt import is_positive_semidefinite_naive
-
-    TESTS:
-
-    The trivial matrix is vaciously positive-semidefinite::
-
-        sage: A = matrix(QQ, 0)
-        sage: A
-        []
-        sage: is_positive_semidefinite_naive(A)
-        True
-
-    """
-    if A.nrows() == 0:
-        return True # vacuously
-    return A.is_hermitian() and all( v >= 0 for v in A.eigenvalues() )
-
-
-def is_positive_semidefinite(A):
-    r"""
-    A fast positive-semidefinite check based on the block-LDLT
-    factorization.
-
-    SETUP::
-
-        sage: from mjo.ldlt import (is_positive_semidefinite,
-        ....:                       is_positive_semidefinite_naive)
-
-    TESTS:
-
-    Check that the naive and fast answers are the same, in general::
-
-        sage: set_random_seed()
-        sage: F = NumberField(x^2 + 1, 'I')
-        sage: from sage.misc.prandom import choice
-        sage: ring = choice([ZZ,QQ,F])
-        sage: A = matrix.random(ring, 10)
-        sage: is_positive_semidefinite(A) == is_positive_semidefinite_naive(A)
-        True
-
-    Check that the naive and fast answers are the same for a Hermitian
-    matrix::
-
-        sage: set_random_seed()
-        sage: F = NumberField(x^2 + 1, 'I')
-        sage: from sage.misc.prandom import choice
-        sage: ring = choice([ZZ,QQ,F])
-        sage: A = matrix.random(ring, 10); A = A + A.conjugate_transpose()
-        sage: is_positive_semidefinite(A) == is_positive_semidefinite_naive(A)
-        True
-
-    """
-    if not A.is_hermitian():
-        return False
-    _,_,d = A._block_ldlt()
-    for d_i in d:
-        if d_i.nrows() == 1:
-            if d_i < 0:
-                return False
-        else:
-            # A 2x2 block indicates that it's indefinite
-            return False
-    return True