AW: making a block diagonal matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg37573] AW: [mg37548] making a block diagonal matrix
- From: Matthias.Bode at oppenheim.de
- Date: Tue, 5 Nov 2002 05:01:12 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hello David, the following produces your block diagonal matrix: Needs["LinearAlgebra`MatrixManipulation`"] Clear[a, b, c, d, e, f, g, h, i, j, k, l, m] m1 = {{a, b}, {c, d}} // MatrixForm; m2 = {{e, f, g}, {h, i, j}, {k, l, m}} // MatrixForm; z1 = ZeroMatrix[2, 3] // MatrixForm; z2 = ZeroMatrix[3, 2] // MatrixForm; MatrixForm[AppendColumns[AppendRows[MatrixForm[{{a, b}, {c, d}}], MatrixForm[{{0, 0, 0}, {0, 0, 0}}]], AppendRows[MatrixForm[{{0, 0}, {0, 0}, {0, 0}}], MatrixForm[{{e, f, g}, {h, i, j}, {k, l, m}}]]]] Out1: MatrixForm[{{a, b, 0, 0, 0}, {c, d, 0, 0, 0}, {0, 0, e, f, g}, {0, 0, h, i, j}, {0, 0, k, l, m}}] BTW: Trying to use BlockMatrix[] directly failed; I got the last command above (the Appends) as output, which upon evaluation - after making it an *identical* input - yielded the Out1 shown above. Best regards, Matthias Bode Sal. Oppenheim jr. & Cie. KGaA Koenigsberger Strasse 29 D-60487 Frankfurt am Main GERMANY Tel.: +49(0)69 71 34 53 80 Mobile: +49(0)172 6 74 95 77 Fax: +49(0)69 71 34 95 380 E-mail: matthias.bode at oppenheim.de Internet: http://www.oppenheim.de -----Ursprüngliche Nachricht----- Von: David E. Burmaster [mailto:deb at alceon.com] Gesendet: Montag, 4. November 2002 08:45 An: mathgroup at smc.vnet.net Betreff: [mg37548] making a block diagonal matrix Dear MathGroup Can anyone please suggest an efficient way to convert a list of square matrices (of different dimensions) into a block diagonal matrix?? The elements of each matrix are all real numbers here is an example with a list of two square matrices -- matrix1 = a b c d matrix2 = e f g h i j k l m output = a b 0 0 0 c d 0 0 0 0 0 e f g 0 0 h i j 0 0 k l m =-= many thanks dave +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ David E. Burmaster, Ph.D. Alceon Corporation POBox 382069 (new Box number effective 1 Sep 2001) Harvard Square Station Cambridge, MA 02238-2069 (new ZIP code effective 1 Sep 2001) Voice 617-864-4300 Web http://www.Alceon.com Email deb at Alceon.com +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++