distribute_matrix_across_clusters function

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