Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
You can't really build an "infinite" matrix, but you can build any size you want... there are some nice examples here… – bill s Jul 31 '13 at 2:54
It would be interesting to know what the underlying problem is. Are you trying to solve an eigenvalues problem? – sebhofer Jul 31 '13 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}};

Mathematica graphics

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]}];

Mathematica graphics

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]];

Mathematica graphics

The processes can continue as much as you need

share|improve this answer
you could also use ArrayFlatten like in ArrayFlatten[{{b0, 0, b1} , {0, b2, 0}, {0, 0, b3}}] // MatrixForm – user21 Jul 31 '13 at 7:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.