public static double sumOfSquares ( NumberVector v ) { final int dim = v . getDimensionality ( ) ; double sum = 0 ; for ( int d = 0 ; d < dim ; d ++ ) { double x = v . doubleValue ( d ) ; sum += x * x ; } return sum ; }
Compute the sum of squares of a vector .