from mjo.cone.symmetric_psd import (factor_psd,
is_symmetric_psd,
random_symmetric_psd)
-from mjo.matrix_vector import basis_representation
+from mjo.matrix_vector import basis_repr
def is_doubly_nonnegative(A):
# can't compute the dimension of a set of matrices anyway, so we
# convert them all to vectors and just ask for the dimension of the
# resulting vector space.
- (phi, phi_inverse) = basis_representation(A.matrix_space())
+ (phi, phi_inverse) = basis_repr(A.matrix_space())
vectors = map(phi,spanning_set)
V = span(vectors, A.base_ring())
def _mat2vec(m):
return vector(m.base_ring(), m.list())
-def basis_representation(M):
+def basis_repr(M):
"""
Return the forward (``MatrixSpace`` -> ``VectorSpace``) and
inverse isometries, as a pair, that take elements of the given
SETUP::
- sage: from mjo.matrix_vector import basis_representation
+ sage: from mjo.matrix_vector import basis_repr
EXAMPLES:
sage: E22 = matrix(QQbar,[ [0,0],
....: [0,1] ])
sage: basis = [E11, E12, E22]
- sage: phi, phi_inv = basis_representation(basis)
+ sage: phi, phi_inv = basis_repr(basis)
sage: phi(E11); phi(E12); phi(E22)
(1, 0, 0)
(0, 1, 0)
MatrixSpace arguments work too::
sage: M = MatrixSpace(QQ,2)
- sage: phi, phi_inv = basis_representation(M)
+ sage: phi, phi_inv = basis_repr(M)
sage: X = matrix(QQ, [ [1,2],
....: [3,4] ])
sage: phi(X)
sage: n = ZZ.random_element(10)
sage: M = MatrixSpace(QQ,n)
sage: X = M.random_element()
- sage: (phi, phi_inv) = basis_representation(M)
+ sage: (phi, phi_inv) = basis_repr(M)
sage: phi_inv(phi(X)) == X
True
SETUP::
- sage: from mjo.matrix_vector import (basis_representation,
+ sage: from mjo.matrix_vector import (basis_repr,
....: basis_repr_of_operator)
EXAMPLES:
[0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 0 0 1]
- sage: phi, phi_inv = basis_representation(M)
+ sage: phi, phi_inv = basis_repr(M)
sage: X = M([[1,2,3],[4,5,6],[7,8,9]])
sage: F*phi(X) == phi(f(X))
True
basis_space = M[0].matrix_space()
basis = M
- (phi, phi_inv) = basis_representation(M)
+ (phi, phi_inv) = basis_repr(M)
# Get a basis for the image space. Since phi is an isometry,
# it takes one basis to another.