compressWeights function

Compress replicate weight matrix