# Construct an infinite matrix with finite sub-matrices

How can I construct an infinite matrix with finite sub-matrices of the form

A = (B0,  0, B1
0, B2,  0
0,  0, B3)


where each Bi is a rectangular or a square matrix?

• You can't really build an "infinite" matrix, but you can build any size you want... there are some nice examples here reference.wolfram.com/mathematica/guide/… Jul 31, 2013 at 2:54
• Jul 31, 2013 at 7:12
• Jul 31, 2013 at 7:42
• It would be interesting to know what the underlying problem is. Are you trying to solve an eigenvalues problem? Jul 31, 2013 at 8:10

Mathematica is very flexible when it comes to constructing matrices.

This below shows how to create as many tiling of matrices as you want. The tools to use are Band and SparseArray and ConstantArray

Starting with the 4 basic matrices b0,b1,b2,b3. To make the display small, small sizes will be used.

b0 = N@{{1, 2}, {3, 4}};
b1 = N@{{5, 6}, {7, 8}};
b2 = N@{{9, 10}, {11, 12}};
b3 = N@{{13, 14}, {15, 16}};


Now the first iteration is build

s = SparseArray[{Band[{1, 1}] -> ConstantArray[b0, 1],
Band[{3, 3}] -> ConstantArray[b2, 1],
Band[{5, 5}] -> ConstantArray[b3, 1],
Band[{1, 5}] -> ConstantArray[b1, 1]}];
MatrixForm[s]


Now using the above, it is in turn is used to build another iteration. Here it is used on the diagonal only, but using Band you can put it in any other location

s2 = SparseArray[Band[{1, 1}] -> ConstantArray[s, 3]];
MatrixForm[s2]


The processes can continue as much as you need

• you could also use ArrayFlatten like in ArrayFlatten[{{b0, 0, b1} , {0, b2, 0}, {0, 0, b3}}] // MatrixForm
– user21
Jul 31, 2013 at 7:53
• ...and following up on user21's suggestion, use KroneckerProduct[] to construct the larger matrix: KroneckerProduct[IdentityMatrix[3], ArrayFlatten[{{b0, 0, b1}, {0, b2, 0}, {0, 0, b3}}]] Jul 30, 2017 at 14:57