]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/basis_repr.py: don't import from sage.all
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 22 Nov 2024 19:54:46 +0000 (14:54 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 22 Nov 2024 19:54:46 +0000 (14:54 -0500)
mjo/basis_repr.py

index b0b6083951b4589e3d5b53d6fcad9bef6ac3a425..5e5a3bae0040be402e486804d05300260fed5ecd 100644 (file)
@@ -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()