Calculates the scalar multiplication of a vector.