I would like to construct a diagonal matrix that is defined as a function and put it multiple times in a block-diagonal matrix each block evaluated at a consecutive integer.
Let's say my matrix looks like this:
$$\mathtt{mat}[x\_]=\begin{pmatrix} x & 1 \\ 1 & x^2 \end{pmatrix}$$
and I would like to stack it up such that it looks something like this:
$$\mathtt{matnew}[x\_]=\begin{pmatrix} x|_1 & 1 & 0& 0&0\\ 1 & x^2|_1 & 0& 0&0\\ 0& 0&x|_2 & 1 &0\\ 0& 0&1 & x^2|_2 &0\\ 0& 0&0 & 0&\ddots\\ \end{pmatrix}$$
where each block in this block-diagonal matrix is evaluated at a different consecutive number. An interesting approach came up here. Particularly, the function
mats[p_, n_] := ArrayFlatten[DiagonalMatrix[Array[1 &, n]] /. {1 -> p, 0 -> 0 p}];
seems to be very helpful, but unfortunately each block will not be evaluated at different x. How should I change the function Array[]
in this definition to get the above matrix matnew[x_]
with x = 1, x = 2
, ...?