Ask Your Question
1

span of a matrixspace

asked 2018-05-11 07:47:52 +0100

grburrul gravatar image

updated 2018-05-11 19:53:46 +0100

given a matrix subspace of sparse matrices over a ring Q

M=MatrixSpace(Q,1000,1000, sparse=True)

I need a way to define the subspace N of M given a list of matrices of M

I tried to turn matrices into lists and use the VectorSpace category, however my matrices are sparse matrices, and this takes very long

def lista(A):  #converts a matrix into a list
return A.list()

def coor(P): # for the determined base B, it gives the coordinate vector of a matrix P[0]
   A=base(P[1][1])
   k=len(P[1][1])
   V=VectorSpace(Q,2**(2*k), sparse=True) #I would like to work with MatrixSpace instead
   B=[] #this will be my basis
   for i in range(len(A)):
       a=A[i][0]
       B.append(V(lista(a)))
   W=W=V.span_of_basis(B) #I dont know if this function exists in MatrixSpace
   p=W.coordinate_vector(V(lista(P[0])))   
   return p
edit retag flag offensive close merge delete

Comments

1

Could you please provide the code of what you tried, so that we see where the problem is ?

tmonteil gravatar imagetmonteil ( 2018-05-11 11:13:09 +0100 )edit

@tmonteil done!

grburrul gravatar imagegrburrul ( 2018-05-11 19:54:10 +0100 )edit

Could you please provide the constructon of the list of matrices ?

tmonteil gravatar imagetmonteil ( 2018-05-12 10:29:21 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-05-16 20:55:18 +0100

Instead of converting sparse matrices to lists, try converting them to dictionaries.

M = MatrixSpace(QQ,10,10, sparse=True)
L = [M.random_element() for i in range(10)]  # my starting list of matrices
W = VectorSpace(QQ, 100, sparse=True)

LL = [] # will be new list of sparse vectors
for m in L:
    newdict = {}
    mdict = m.dict()
    for (i,j) in mdict:
        # convert matrix dictionary indexed by (i,j) to vector dictionary indexed by 10*i+j
        newdict[10*i+j] = mdict[i,j] 
    LL.append(W(newdict))

W.subspace(LL) # vector subspace of WW

In a perfect world, the following would work:

M = MatrixSpace(QQ,10,10, sparse=True)
L = [M.random_element() for i in range(10)]  # my starting list of matrices
M.submodule(L)

but when I try it, it raises an error.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-05-11 07:47:52 +0100

Seen: 846 times

Last updated: May 16 '18