From 8c599e45b2f2d9e1655f05000a259d308b9bf271 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 22 Nov 2024 14:54:46 -0500 Subject: [PATCH] mjo/basis_repr.py: don't import from sage.all --- mjo/basis_repr.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mjo/basis_repr.py b/mjo/basis_repr.py index b0b6083..5e5a3ba 100644 --- a/mjo/basis_repr.py +++ b/mjo/basis_repr.py @@ -10,11 +10,12 @@ a vector space of the same dimension. """ -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): """ @@ -220,10 +221,14 @@ def basis_repr_of_operator(M, L): # 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() -- 2.49.0