# How to enter matrices in block matrix format?

Example: I have a matrix $R = \left( \begin{array}{cc} A & \mathbf{t} \\ 0 & 1 \end{array} \right)$ where $A$ is 3-by-3 and $\mathbf{t}$ is 3 by 1. Or in Mathematica

 A={{1,0,0},{0,0,1},{0,-1,0}};
t={1,1,1}


I would like to be able to use a form of block matrix notation / entry and subsequently find the inverse of R.

Question: Is this possible?

You're looking for ArrayFlatten. For your example matrices,

 R = ArrayFlatten[ {{A, {t}\[Transpose]},{0, 1}} ]
(*
=> {{1, 0, 0, 1}, {0, 0, 1, 1}, {0, -1, 0, 1}, {0, 0, 0, 1}}
*)


The construct {t}\[Transpose] is necessary for ArrayFlatten to treat t as a column matrix.

Then to find $\boldsymbol{R}^{-1}$, you run

Inverse[R]
(*
=> {{1, 0, 0, -1}, {0, 0, -1, 1}, {0, 1, 0, -1}, {0, 0, 0, 1}}
*)

• beat me by 5s... – acl Jan 26 '12 at 16:25
• He was also asking for the inverse - could add this for completeness. – Vitaliy Kaurov Jan 26 '12 at 16:31
• @VitaliyKaurov, done! – rcollyer Jan 26 '12 at 16:36
• @acl, it's a testament to how much we've been waiting for these types of questions when 3 of the top users jump on it within seconds of each other. – rcollyer Jan 26 '12 at 16:38
• This point about {t}\[Transpose] being necessary is important and subtle: Mathematica (to its credit) does NOT finesse the fact that vectors must be either 1 x n or n x 1 matrices, that is, explicitly either row or column vectors. Pretty much everything else (including my beloved Golub & VanLoan) does (tho G&VL have the grace at least to say they do). I find the conceptual hygiene forced by Mathematica to be refreshing and helpful. – Reb.Cabin Jul 27 '14 at 17:32

The keyboard commands Ctrl+Enter, Ctrl+, and Tab can be used to enter this format.

You can also use the menu Insert > Table/Matrix to create a table of specified size with placeholders.

Depending on the meaning of the question, this may have some bearing:

• beat you to it. :P – rcollyer Jan 26 '12 at 16:23
• LOL at the pity vote. – Mr.Wizard Jan 26 '12 at 16:27
• I meant, I beat you to posting the "correct" answer. Although, I posted the result he wanted, and you posted the entry method. Win for both of us. – rcollyer Jan 26 '12 at 16:28
• Not a pity vote. If you don't post this, I would have edited it into @rcollyer's answer. It's much more convenient to enter matrices like this (see my screenshot). – Szabolcs Jan 26 '12 at 16:29
• @rcollyer Recently I saw someone give input to NDSolve that way, and I really liked it --> i.stack.imgur.com/bgWJ3.png – Szabolcs Jan 26 '12 at 16:47