Ask Your Question

# creating a matrix from blocks

I am new to SAGE. I need to create a matrix by using matrices of different sizes. For example:

Abar= [(A + B), C]
[  D ,    E]

where A and B are 2x2's, C is a 2x1, D is a 1x2, and E is a 1x1. I do not need Abar to be a partitioned matrix. Thanks much.

edit retag close merge delete

## 2 Answers

Sort by ยป oldest newest most voted

Here is a way of getting Abar

sage: Abar=block_matrix([[(A+B),C],[D,E]])

Update: Using @calc314's suggestion for no subdivisions:

sage: Abar=block_matrix([[(A+B),C],[D,E]], subdivide=False)
more

## Comments

1

If you don't want the subdivisions, you can use: block_matrix([[a+b,c],[d,e]],subdivide=False)

( 2012-11-29 20:36:29 +0100 )edit

Nice! I'll update the answer above.

( 2012-11-29 20:40:11 +0100 )edit

Thanks much, but I still get a syntax error. I have double checked the matrices A,B,C,D, and E by using print and dimensions are correct. The matrices do contain symbolic variables that have been defined using var. Any suggestions? Thanks.

( 2012-12-01 00:39:31 +0100 )edit

Thanks much, but I still get a syntax error. I have double checked the matrices A,B,C,D, and E by using print and dimensions are correct. The matrices do contain symbolic variables that have been defined using var. Any suggestions? Thanks.

more

## Comments

1

Please post all of your code or a simplified example so we can take a look at the situation.

( 2012-12-01 07:22:03 +0100 )edit

## Your Answer

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

Add Answer

## Stats

Asked: 2012-11-29 19:30:58 +0100

Seen: 2,077 times

Last updated: Nov 30 '12