r""" The symmetric positive definite cone `$S^{n}_{++}$` is the cone consisting of all symmetric positive-definite matrices (as a subset of $\mathbb{R}^{n \times n}$`. It is the interior of the symmetric positive SEMI-definite cone. """ from sage.all import * from mjo.cone.symmetric_psd import random_symmetric_psd def random_symmetric_pd(V): r""" Generate a random symmetric positive-definite matrix over the vector space ``V``. That is, the returned matrix will be a linear transformation on ``V``, with the same base ring as ``V``. (We take a very loose interpretation of "random," here.) INPUT: - ``V`` -- The vector space on which the returned matrix will act. OUTPUT: A random symmetric positive-definite matrix, i.e. a linear transformation from ``V`` to itself. ALGORITHM: We request a full-rank positive-semidefinite matrix from the :func:`mjo.cone.symmetric_psd.random_symmetric_psd` function. SETUP:: sage: from mjo.cone.symmetric_pd import random_symmetric_pd EXAMPLES: Well, it doesn't crash at least:: sage: set_random_seed() sage: V = VectorSpace(QQ, 2) sage: A = random_symmetric_pd(V) sage: A.matrix_space() Full MatrixSpace of 2 by 2 dense matrices over Rational Field """ # We accept_zero because the trivial matrix is (trivially) # symmetric and positive-definite, but it's also "zero." The rank # condition ensures that we don't get the zero matrix in a # nontrivial space. return random_symmetric_psd(V, rank=V.dimension())