Covariance-based Clustering in Multivariate and Functional Data Analysis