Changed Dmat to Dvec for memory efficiency