Code to calculate rms error of similarity matrices