]>
gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/cone/symmetric_pd.py
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
9 from mjo
.cone
.symmetric_psd
import random_symmetric_psd
11 def random_symmetric_pd(V
):
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``.
17 (We take a very loose interpretation of "random," here.)
21 - ``V`` -- The vector space on which the returned matrix will act.
25 A random symmetric positive-definite matrix, i.e. a linear
26 transformation from ``V`` to itself.
30 We request a full-rank positive-semidefinite matrix from the
31 :func:`mjo.cone.symmetric_psd.random_symmetric_psd` function.
35 sage: from mjo.cone.symmetric_pd import random_symmetric_pd
39 Well, it doesn't crash at least::
41 sage: V = VectorSpace(QQ, 2)
42 sage: A = random_symmetric_pd(V)
43 sage: A.matrix_space()
44 Full MatrixSpace of 2 by 2 dense matrices over Rational Field
47 # We accept_zero because the trivial matrix is (trivially)
48 # symmetric and positive-definite, but it's also "zero." The rank
49 # condition ensures that we don't get the zero matrix in a
51 return random_symmetric_psd(V
, rank
=V
.dimension())