RE: RE: making a block diagonal matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg37617] RE: [mg37577] RE: [mg37548] making a block diagonal matrix
- From: "DrBob" <drbob at bigfoot.com>
- Date: Wed, 6 Nov 2002 06:57:44 -0500 (EST)
- Reply-to: <drbob at bigfoot.com>
- Sender: owner-wri-mathgroup at wolfram.com
Better yet:
<< LinearAlgebra`MatrixManipulation`
MatrixForm[blocks = #IdentityMatrix[#] - 2 & /@ {2, 3, 1}]
glue1 = BlockMatrix@{{#1, ZeroMatrix[Length@#1, Length@#2]},
{ZeroMatrix[
Length@#2, Length@#1], #2}} &;
glueAll = Fold[glue1, First@#, Rest@#] &;
MatrixForm[glueAll@blocks]
The determinant is:
Times@@(Det/@blocks)
The inverse is:
MatrixForm[glueAll[Inverse /@ blocks]]
There's probably no good reason ever to actually form these sparse
matrices, by the way; it's enough that you know what they are.
DrBob
-----Original Message-----
From: DrBob [mailto:drbob at bigfoot.com]
To: mathgroup at smc.vnet.net
Subject: [mg37617] [mg37577] RE: [mg37548] making a block diagonal matrix
Here's an example.
<< LinearAlgebra`MatrixManipulation`
MatrixForm[blocks = #IdentityMatrix[#] - 2 & /@ {2, 3, 1}]
glue1 = BlockMatrix@{{#1, Table[0, {Length@#1}, {Length@#2}]}, {Table[0,
{
Length@#2}, {Length@#1}], #2}} &;
MatrixForm[glueAll = Fold[glue1, First@blocks, Rest@blocks]]
DrBob
-----Original Message-----
From: David E. Burmaster [mailto:deb at alceon.com]
To: mathgroup at smc.vnet.net
Subject: [mg37617] [mg37577] [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
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++