SPARK-2281 [MLlib] Simplify the duplicate code in Gradient.scala

The Gradient.compute which returns new tuple of (gradient: Vector, loss: Double) can be constructed by in-place version of Gradient.compute. Thus, we don't need to maintain the duplicate code.

`compute` could return a sparse vector but you force it to be a dense vector.