Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Matrix multiplication of sparse matrix with matrix over polynomial ring

Hi all,

I would like to know how to multiply the following matrices I have constructed in Sage. Here is my code for a toy example:

from scipy.sparse import csr_matrix
row = [0,0,1]
col = [0,1,1]
data = [1,-1,1]
A = csr_matrix((data,(row,col)),shape=(4,4))


R.<x,y> = PolynomialRing(QQ,2)
B = matrix(R,2,2,[1,x,1,y])

When I try to multiply the matrices using A.dot(B), I end up with the error: "No supported conversion for types: (dtype('int64'), dtype('O'))"

Is there a way I can multiply these matrices and yield an output that is a csr_matrix? (I suspect I would want to convert the entries of my A matrix to be the same data type, but I am unaware of how to do this)

Thank you for your time!