Java Array Dot Product dotProduct(double[] fv1, double[] fv2)

Here you can find the source of dotProduct(double[] fv1, double[] fv2)

Description

Compute the dot product between two feature vectors represented as double arrays

License

Open Source License

Parameter

Parameter Description
fv1 a parameter
fv2 a parameter

Return

the dot product between fv1 and fv2

Declaration

public static double dotProduct(double[] fv1, double[] fv2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  www. j a  v a 2s.  c o  m*/
     * Compute the dot product between two feature vectors represented as double arrays
     * 
     * @param fv1
     * @param fv2
     * @return the dot product between fv1 and fv2
     */
    public static double dotProduct(double[] fv1, double[] fv2) {
        double sum = 0.0;
        for (int i = 0; i < fv1.length && i < fv2.length; i++) {
            //sum += (fv1[i] != 0 && fv2[i] != 0) ? fv1[i] * fv2[i]: 0;
            sum += fv1[i] * fv2[i];
        }
        return sum;
    }
}

Related

  1. dotProduct(double[] a, double[] b)
  2. dotProduct(double[] a, double[] b)
  3. dotProduct(double[] a, double[] b)
  4. dotProduct(Double[] a, Double[] b)
  5. dotProduct(double[] array, int[] indices, double[] values)
  6. dotProduct(double[] thisVector, double[] thatVector)
  7. dotProduct(double[] v, double[] u)
  8. dotProduct(double[] vector1, double[] vector2)
  9. dotProduct(double[] x, double[] y)