Created function that returns the D-matrix.