vectorize dmatrix