generalized design matrix construction