init D-matrix at the beginning