vectorized computation of features involving cosine similarity in order to speed up computation