Let $F/\mathbb{Q}_p$ be a finite extension, and let $\mathcal{O}_F$ be its ring of integers. Now for $ 0< i,j \le r$ let $B_{i,j} \in \mathit{Mat}_{n \times n}(\mathcal{O}_F)$ be some matrices and let $M$ be the block matrix, whose $i,j$ block is given by $B_{i,j}$ and let $D$ be the block diagonal matrix with blocks $B_{i,i}$ along the diagonal (so both $M,D$ have the same size). I would like to know when it is possible to find a matrix $X$ (in $\mathit{Mat}_{rn \times rn}(\mathcal{O}_F)$ ) such that $M=XD$.
In general I wouldn't like to have to assume that $D$ is invertible.
thank you.