Android Matrix Product dotProd(double[] a, double[] b)

Here you can find the source of dotProd(double[] a, double[] b)

Description

dot Prod

Declaration

public static double dotProd(double[] a, double[] b) 

Method Source Code

//package com.java2s;

public class Main {
    public static double dotProd(double[] a, double[] b) {
        if (a.length != b.length) {
            throw new IllegalArgumentException(
                    "The dimensions have to be equal!");
        }//from w ww.j  ava  2 s . c  om
        double sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i] * b[i];
        }
        return sum;
    }
}