Ask Your Question
1

Concatenate two sparse matrices over a Polynomial Ring

asked 2019-07-18 14:00:49 +0100

Bark gravatar image

updated 2019-07-18 17:26:54 +0100

Hi all,

I am wondering if there is a way to concatenate two sparse matrices over a polynomial ring. Here is a toy example that I am testing with:

S.<x,y> = PolynomialRing(QQ,2)

udict = {(0,0):1, (0,1):x, (1,1):y}
vdict = {(0,0):2*x,(1,0):y}

U = matrix(4,4,ud,sparse=True)
V = matrix(4,2,vd,sparse=True)

I would like to make a larger matrix that is $4 \times 6$, that has the block form $[U|V]$. I attempted to use the block_matrix command, but it said that the given number of rows and columns were incompatible with the number of submatrices.

In Python, for a sparse matrix (csr_matrix or coo_matrix), there is the command hstack from scipy.sparse. Is there a similar command where I can concatenate a list of these sparse matrices? This would be ideal for my general problem.

Thank you for your time!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2019-07-18 18:11:57 +0100

FrédéricC gravatar image

Like that

sage: U.augment(V)
[  1   x   0   0 2*x   0]
[  0   y   0   0   y   0]
[  0   0   0   0   0   0]
[  0   0   0   0   0   0]
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

1 follower

Stats

Asked: 2019-07-18 14:00:49 +0100

Seen: 734 times

Last updated: Jul 18 '19