@Override public double calculate_K(int[] x_index,double[] x_att,int[] y_index,double[] y_att){
  double result=0;
  double tmp;
  int xpos=x_index.length - 1;
  int ypos=y_index.length - 1;
  int zeros=dim;
  while ((xpos >= 0) && (ypos >= 0)) {
    if (x_index[xpos] == y_index[ypos]) {
      tmp=x_att[xpos] - y_att[ypos];
      result+=Math.exp(-sigma * tmp * tmp);
      xpos--;
      ypos--;
    }
 else     if (x_index[xpos] > y_index[ypos]) {
      tmp=x_att[xpos];
      result+=Math.exp(-sigma * tmp * tmp);
      xpos--;
    }
 else {
      tmp=y_att[ypos];
      result+=Math.exp(-sigma * tmp * tmp);
      ypos--;
    }
    zeros--;
  }
  while (xpos >= 0) {
    tmp=x_att[xpos];
    result+=Math.exp(-sigma * tmp * tmp);
    xpos--;
    zeros--;
  }
  while (ypos >= 0) {
    tmp=y_att[ypos];
    result+=Math.exp(-sigma * tmp * tmp);
    ypos--;
    zeros--;
  }
  result+=zeros;
  return Math.pow(result,degree);
}

@ Override public double calculate_K ( int [ ] x_index , double [ ] x_att , int [ ] y_index , double [ ] y_att ) { double result = 0 ; double tmp ; int xpos = x_index . length - 1 ; int ypos = y_index . length - 1 ; int zeros = dim ; while ( ( xpos >= 0 ) && ( ypos >= 0 ) ) { if ( x_index [ xpos ] == y_index [ ypos ] ) { tmp = x_att [ xpos ] - y_att [ ypos ] ; result += Math . exp ( - sigma * tmp * tmp ) ; xpos -- ; ypos -- ; } else if ( x_index [ xpos ] > y_index [ ypos ] ) { tmp = x_att [ xpos ] ; result += Math . exp ( - sigma * tmp * tmp ) ; xpos -- ; } else { tmp = y_att [ ypos ] ; result += Math . exp ( - sigma * tmp * tmp ) ; ypos -- ; } zeros -- ; } while ( xpos >= 0 ) { tmp = x_att [ xpos ] ; result += Math . exp ( - sigma * tmp * tmp ) ; xpos -- ; zeros -- ; } while ( ypos >= 0 ) { tmp = y_att [ ypos ] ; result += Math . exp ( - sigma * tmp * tmp ) ; ypos -- ; zeros -- ; } result += zeros ; return Math . pow ( result , degree ) ; }
calculates kernel value of vectors x and y .
