comefrom: <awangdev>Cosine Similarity_1.java
code: public double cosineSimilarity(int[] A, int[] B) {
      	if (A == null || B == null || A.length == 0 || B.length == 0 || A.length != B.length) {
      		return 2;
      	}
  
      	double sumProduct = 0;
      	double sumASq = 0;
      	double sumBSq = 0;
      	for (int i = 0; i < A.length; i++) {
      		sumProduct += A[i]*B[i];
      		sumASq += A[i] * A[i];
      		sumBSq += B[i] * B[i];
      	}
      	if (sumASq == 0 && sumBSq == 0) {
      		return 2.0;
      	}
      	return sumProduct / (Math.sqrt(sumASq) * Math.sqrt(sumBSq));
      }
masked: public double sample_funcname ( int [ ] var_0 , int [ ] var_1 ) {
    if ( var_0 == null || var_1 == null || var_0 . length == 0 || var_1 . length == 0 || var_0 . length != var_1 . length ) {
      return 2 ;
    }
    double var_6 = 0 ;
    double var_7 = 0 ;
    double var_8 = 0 ;
    for ( int var_9 = 0 ;
    var_9 < var_0 . length ;
    var_9 ++ ) {
      var_6 += var_0 [ var_9 ] * var_1 [ var_9 ] ;
      var_7 += var_0 [ var_9 ] * var_0 [ var_9 ] ;
      var_8 += var_1 [ var_9 ] * var_1 [ var_9 ] ;
    }
    if ( var_7 == 0 && var_8 == 0 ) {
      return 2.0 ;
    }
    return var_6 / ( Math . sqrt ( var_7 ) * Math . sqrt ( var_8 ) ) ;
  }
  