Here you can find the source of sumProd(double[] v1, double[] v2, int i_, int n_)
public static double sumProd(double[] v1, double[] v2, int i_, int n_)
//package com.java2s; //License from project: Open Source License public class Main { /** Calculates sum of products of n elements in input arrays, up to position i */ public static double sumProd(double[] v1, double[] v2, int i_, int n_) { //System.out.println("i_=" + i_ + ", n_=" + n_ + ", Multiplying:\n" + Utils.arrayString(v1) + " \nby\n" + Utils.arrayString(v2)); double total = 0; for (int i = i_, n = 0; n < n_; i = i > 0 ? i - 1 : v1.length - 1, n++) { total += v1[i] * v2[i];// w ww . java 2 s . c o m } //System.out.println("answer= " + total); return total; } }