Java Array Dot Product dotProd(double x[], double y[])

Here you can find the source of dotProd(double x[], double y[])

Description

dot Prod

License

LGPL

Declaration

public static double dotProd(double x[], double y[]) 

Method Source Code

//package com.java2s;

public class Main {
    public static double dotProd(double x[], double y[]) {
        if (x.length != y.length)
            throw new RuntimeException("Arrays must be same size");
        double sum = 0;
        for (int i = 0; i < x.length; i++)
            sum += x[i] * y[i];/*from  w ww.  j  a  va2 s  .c  o m*/
        return sum;
    }
}

Related

  1. dotprod(double[] xlist, double[] ylist)
  2. dotProd(float[] a, float[] b)
  3. dotProduct(double x1, double y1, double x2, double y2)
  4. dotProduct(double x1, double y1, double x2, double y2, double x3, double y3)