First time here? Check out the FAQ!

Ask Your Question
2

creating a matrix from blocks

asked 12 years ago

Dionysus gravatar image

updated 12 years ago

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.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
4

answered 12 years ago

fidbc gravatar image

updated 12 years ago

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

Comments

1

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

calc314 gravatar imagecalc314 ( 12 years ago )

Nice! I'll update the answer above.

fidbc gravatar imagefidbc ( 12 years ago )

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.

Dionysus gravatar imageDionysus ( 12 years ago )
0

answered 12 years ago

Dionysus gravatar image

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.

Preview: (hide)
link

Comments

1

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

calc314 gravatar imagecalc314 ( 12 years ago )

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

Seen: 3,460 times

Last updated: Nov 30 '12