Dimensionality reduction with subgaussian matrices: a unified theory