computing pNorm and cosine distance