Energy efficient cosine similarity measures according to a convex cost function