"""
-from sage.all import *
+from sage.modules.free_module import VectorSpace
from sage.matrix.matrix_space import MatrixSpace
def _mat2vec(m):
- return vector(m.base_ring(), m.list())
+ V = VectorSpace(m.base_ring(), m.nrows()*m.ncols())
+ return V(m.list())
def basis_repr(M):
"""
# Get a basis for the image space. Since phi is an isometry,
# it takes one basis to another.
- image_basis = [ phi(b) for b in basis ]
+ image_basis = ( phi(b) for b in basis )
# Now construct the image space itself equipped with our custom basis.
- W = VectorSpace(basis_space.base_ring(), len(basis))
+ n = len(basis)
+ W = VectorSpace(basis_space.base_ring(), n)
W = W.span_of_basis(image_basis)
- return matrix.column( W.coordinates(phi(L(b))) for b in basis )
+ # Transpose in the end because we have columns but the matrix
+ # constructor takes rows.
+ N = MatrixSpace(basis_space.base_ring(), n, n)
+ return N( W.coordinates(phi(L(b))) for b in basis ).transpose()