bug fix in Matrix.resample()