# 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

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

1

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

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.

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

1

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