Here you can find the source of sum(double[] data, int i_, int n_)
public static double sum(double[] data, int i_, int n_)
//package com.java2s; //License from project: Open Source License public class Main { /** Calculates sum of n items up to position i in the array */ public static double sum(double[] data, int i_, int n_) { double total = 0; for (int i = i_, n = 0; n < n_; i = i > 0 ? i - 1 : data.length - 1, n++) { total += data[i];/* www. j a va 2s.c o m*/ } //System.out.println("i_=" + i_ + ", n_=" + n_ + ", Total of:\n" + Utils.arrayString(data) + " \n =" + total); return total; } /** Calculates the sum of all items in the array */ public static double sum(double[] data) { return sum(data, 0, data.length); } /** Calculates the sum of all items in the array */ public static double sum(double[][] data) { double total = 0; for (int i = 0; i < data.length; i++) { total += sum(data[i]); } return total; } /** Calculates the sum of all items in the array */ public static int sum(int[] data) { int total = 0; for (int i = 0; i < data.length; i++) { total += data[i]; } return total; } /** Calculates the sum of all items in the array */ public static int sum(int[][] data) { int total = 0; for (int i = 0; i < data.length; i++) { total += sum(data[i]); } return total; } }