Calculates the magnitude squared of a vector.