Fix an $n$ and an $m$ positive integers.I have some set of four $n\times n$ matrices $A$,$B$,$Y$,$Z$ (where $Z$ is the zero matrix). I'd like to input the $nm\times nm$ matrix of block matrices given by
ArrayFlatten [{{A,B,Z,...,Z},{Y,A,B,Z,...,Z}{Z,Y,A,B,Z...},...,{Z,...,Z,Y,A}}]
I have tried to do this using SparseArray
using something like
SparseArray[{
{i_, i_} -> A,
{i_, j_} /; i - j == 1 -> B,
{i_, j_} /; j - i == 1 -> Y,
{i_, j_} /; Abs[i - j] > 1 -> Z
}, {m, m}]
SparseArray
does not seem to play nice with matrix inputs, and I do not think it is the right tool. I am told that things are not lists. What is an easy way to build block matrices out of rules (as Sparse Array does for matrices of numbers).