Here you can find the source of sumSq(double[] a)
Parameter | Description |
---|---|
a | the array. |
public static double sumSq(double[] a)
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w . j a v a 2 s. c om*/ * Returns the sum of squares. * * @param a the array. * @return the sum of squares. */ public static double sumSq(double[] a) { return sumSq(a, 0, a.length); } /** * Returns the sum of squares within a specific range. * * @param a the array. * @param fromIndex the index of the first element (inclusive). * @param toIndex the index of the last element (exclusive). * @return the sum of squares. */ public static double sumSq(double[] a, int fromIndex, int toIndex) { double sq = 0.0; for (int i = fromIndex; i < toIndex; i++) { sq += a[i] * a[i]; } return sq; } }