Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

Concatenate two sparse matrices over a Polynomial Ring

asked 5 years ago

Bark gravatar image

updated 5 years ago

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×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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

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]
Preview: (hide)
link

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: 5 years ago

Seen: 792 times

Last updated: Jul 18 '19