private double innerProduct(Instance i1,Instance i2) throws Exception {
  double result=0;
  int n1=i1.numValues();
  int n2=i2.numValues();
  int classIndex=m_Train.classIndex();
  for (int p1=0, p2=0; p1 < n1 && p2 < n2; ) {
    int ind1=i1.index(p1);
    int ind2=i2.index(p2);
    if (ind1 == ind2) {
      if (ind1 != classIndex) {
        result+=i1.valueSparse(p1) * i2.valueSparse(p2);
      }
      p1++;
      p2++;
    }
 else     if (ind1 > ind2) {
      p2++;
    }
 else {
      p1++;
    }
  }
  result+=1.0;
  if (m_Exponent != 1) {
    return Math.pow(result,m_Exponent);
  }
 else {
    return result;
  }
}

private double innerProduct ( Instance i1 , Instance i2 ) throws Exception { double result = 0 ; int n1 = i1 . numValues ( ) ; int n2 = i2 . numValues ( ) ; int classIndex = m_Train . classIndex ( ) ; for ( int p1 = 0 , p2 = 0 ; p1 < n1 && p2 < n2 ; ) { int ind1 = i1 . index ( p1 ) ; int ind2 = i2 . index ( p2 ) ; if ( ind1 == ind2 ) { if ( ind1 != classIndex ) { result += i1 . valueSparse ( p1 ) * i2 . valueSparse ( p2 ) ; } p1 ++ ; p2 ++ ; } else if ( ind1 > ind2 ) { p2 ++ ; } else { p1 ++ ; } } result += 1.0 ; if ( m_Exponent != 1 ) { return Math . pow ( result , m_Exponent ) ; } else { return result ; } }
computes the inner product of two instances
