# Determinant of specially structured block matrix

How do you compute the determinant of the following $$nd \times nd$$ block matrix?

$$M = \begin{bmatrix}A+B & A & A & \dots & A & A\\ A & A+B & A & \dots & A & A\\ A & A & A+B & \dots & A & A\\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots\\ A & A & A & \dots & A+B & A\\ A & A & A & \dots & A & A+B\end{bmatrix}$$

where $$A$$ and $$B$$ are $$d \times d$$ matrices.

It has the same determinant as the matrix $$\begin{pmatrix} B & 0 & \cdots & -B \\ 0 & B & \cdots & -B \\ \vdots & \vdots & \ddots & \vdots\\ A & A & \cdots & A+B \end{pmatrix},$$ which has the same determinant as $$\begin{pmatrix} B & 0 & \cdots & 0 \\ 0 & B & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots\\ A & A & \cdots & nA+B \end{pmatrix},$$ which is easy to compute.
Let us assume that $$B$$ is invertible. Write
$$\begin{array}{rl} M &= \begin{bmatrix} A + B & A & \ldots & A\\ A & A + B & \ldots & A\\ \vdots & \vdots & \ddots & \vdots\\A & A & \ldots & A + B \end{bmatrix}\\\\ &= \begin{bmatrix} B & O_d & \ldots & O_d\\ O_d & B & \ldots & O_d\\ \vdots & \vdots & \ddots & \vdots\\ O_d & O_d & \ldots & B \end{bmatrix} + \begin{bmatrix} A \\ A\\ \vdots \\ A\end{bmatrix} \begin{bmatrix} I_d \\ I_d\\ \vdots \\ I_d\end{bmatrix}^T\\\\ &= (I_n \otimes B) + (1_n \otimes A) (1_n \otimes I_d)^T\\\\ &= (I_n \otimes B) \left(I_{nd} + (I_n \otimes B^{-1}) (1_n \otimes A) (1_n \otimes I_d)^T\right)\end{array}$$
$$\begin{array}{rl} \det (M) &= \det\left((I_n \otimes B) \left(I_{nd} + (I_n \otimes B^{-1}) (1_n \otimes A) (1_n \otimes I_d)^T\right)\right)\\\\ &= \det(I_n \otimes B) \cdot \det \left( I_{nd} + (I_n \otimes B^{-1}) (1_n \otimes A) (1_n \otimes I_d)^T\right)\\\\ &= \det(I_n \otimes B) \cdot \det \left( I_{d} + (1_n \otimes I_d)^T (I_n \otimes B^{-1}) (1_n \otimes A) \right)\\\\ &= \left(\det(B)\right)^n \cdot \det \left( I_{d} + n B^{-1} A \right)\\\\ &= \det(B^n) \cdot \det \left( I_{d} + n B^{-1} A \right)\\\\ &= \det \left( B^n + n B^{n-1} A \right)\end{array}$$