]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/cone/symmetric_pd.py
mjo/cone: drop is_symmetric_p{s,}d() methods.
[sage.d.git] / mjo / cone / symmetric_pd.py
1 r"""
2 The symmetric positive definite cone `$S^{n}_{++}$` is the cone
3 consisting of all symmetric positive-definite matrices (as a subset of
4 $\mathbb{R}^{n \times n}$`. It is the interior of the symmetric positive
5 SEMI-definite cone.
6 """
7
8 from sage.all import *
9 from mjo.cone.symmetric_psd import random_symmetric_psd
10
11 def random_symmetric_pd(V):
12 r"""
13 Generate a random symmetric positive-definite matrix over the
14 vector space ``V``. That is, the returned matrix will be a linear
15 transformation on ``V``, with the same base ring as ``V``.
16
17 (We take a very loose interpretation of "random," here.)
18
19 INPUT:
20
21 - ``V`` -- The vector space on which the returned matrix will act.
22
23 OUTPUT:
24
25 A random symmetric positive-definite matrix, i.e. a linear
26 transformation from ``V`` to itself.
27
28 ALGORITHM:
29
30 We request a full-rank positive-semidefinite matrix from the
31 :func:`mjo.cone.symmetric_psd.random_symmetric_psd` function.
32
33 SETUP::
34
35 sage: from mjo.cone.symmetric_pd import random_symmetric_pd
36
37 EXAMPLES:
38
39 Well, it doesn't crash at least::
40
41 sage: set_random_seed()
42 sage: V = VectorSpace(QQ, 2)
43 sage: A = random_symmetric_pd(V)
44 sage: A.matrix_space()
45 Full MatrixSpace of 2 by 2 dense matrices over Rational Field
46
47 """
48 # We accept_zero because the trivial matrix is (trivially)
49 # symmetric and positive-definite, but it's also "zero." The rank
50 # condition ensures that we don't get the zero matrix in a
51 # nontrivial space.
52 return random_symmetric_psd(V, rank=V.dimension())