Helper function to turn a cluster-level matrix into an element-level matrix by duplicating rows or columns of the matrix
Useful links