matrix expansion for D