Ask Your Question
0

block_matrix confusion (matrix constructor rewrite in new versions of Sage)

asked 2011-04-02 04:56:08 -0500

David Ferrone gravatar image

updated 2011-04-02 07:54:23 -0500

Solved - My mistake - I was running an older version of Sage

I'm having trouble making use of the block_matrix function. I can't even recreate simple examples from the block_matrix documentation, for example

sage: A = matrix(QQ, 2, 2, [3,9,6,10])
sage: X=block_matrix([ [A, -A], [~A, 100*A] ])

I receive the error "Must specify rows or cols for non-square block matrix." When I attempt to set those dimensions I continue to get errors.

(My actual application of this is a bit more complicated, but the dimensions all work out. And I have used block_matrix in another program with symbolic entries. I must have gotten lucky.)

I did not import numpy, I did not believe it was necessary. But there's no difference when I do.

Thanks in advance to this magnificent community of sage-masters.

Edit: I have an old version of Sage (4.4). I should have run block_matrix? to read my specific help file rather than the online documentation. It's working fine, I was simply using the wrong syntax for my version.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2011-04-02 05:02:29 -0500

DSM gravatar image

updated 2011-04-02 05:03:19 -0500

This works for me in 4.6.2:

sage: A = matrix(QQ, 2, 2, [3,9,6,10])
sage: block_matrix([ [A, -A], [~A, 100*A] ])
[    3     9|   -3    -9]
[    6    10|   -6   -10]
[-----------+-----------]
[-5/12   3/8|  300   900]
[  1/4  -1/8|  600  1000]

Previously I think you had to write

sage: A = matrix(QQ, 2, 2, [3,9,6,10])
sage: block_matrix([A, -A, ~A, 100*A])
[    3     9|   -3    -9]
[    6    10|   -6   -10]
[-----------+-----------]
[-5/12   3/8|  300   900]
[  1/4  -1/8|  600  1000]

or at least you did back in 4.5.1, and it looks like the constructor was rewritten not so long ago. Check your block_matrix's help.. or upgrade, I guess. :^)

edit flag offensive delete link more

Comments

Oh, silly mistake on my part. Thanks! I've been using 4.4. I'll see about updating.

David Ferrone gravatar imageDavid Ferrone ( 2011-04-02 07:45:52 -0500 )edit

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: 2011-04-02 04:56:08 -0500

Seen: 179 times

Last updated: Apr 02 '11