diff dist calc, ted kim matrix class