public static int diff(FeatureVector v1,FeatureVector v2){
  int ret=0;
  if (v1.byteValuedDiscreteFeatures.length < v2.byteValuedDiscreteFeatures.length) {
    throw new RuntimeException("v1 and v2 don't have the same number of byte-valued features: [" + v1.byteValuedDiscreteFeatures.length + "] versus ["+ v2.byteValuedDiscreteFeatures.length+ "].");
  }
  for (int i=0; i < v1.byteValuedDiscreteFeatures.length; i++) {
    if (v1.byteValuedDiscreteFeatures[i] == v2.byteValuedDiscreteFeatures[i])     ret++;
  }
  if (v1.shortValuedDiscreteFeatures.length < v2.shortValuedDiscreteFeatures.length) {
    throw new RuntimeException("v1 and v2 don't have the same number of short-valued features: [" + v1.shortValuedDiscreteFeatures.length + "] versus ["+ v2.shortValuedDiscreteFeatures.length+ "].");
  }
  for (int i=0; i < v1.shortValuedDiscreteFeatures.length; i++) {
    if (v1.shortValuedDiscreteFeatures[i] == v2.shortValuedDiscreteFeatures[i])     ret++;
  }
  return (ret);
}

public static int diff ( FeatureVector v1 , FeatureVector v2 ) { int ret = 0 ; if ( v1 . byteValuedDiscreteFeatures . length < v2 . byteValuedDiscreteFeatures . length ) { throw new RuntimeException ( "v1 and v2 don't have the same number of byte-valued features: [" + v1 . byteValuedDiscreteFeatures . length + "] versus [" + v2 . byteValuedDiscreteFeatures . length + "]." ) ; } for ( int i = 0 ; i < v1 . byteValuedDiscreteFeatures . length ; i ++ ) { if ( v1 . byteValuedDiscreteFeatures [ i ] == v2 . byteValuedDiscreteFeatures [ i ] ) ret ++ ; } if ( v1 . shortValuedDiscreteFeatures . length < v2 . shortValuedDiscreteFeatures . length ) { throw new RuntimeException ( "v1 and v2 don't have the same number of short-valued features: [" + v1 . shortValuedDiscreteFeatures . length + "] versus [" + v2 . shortValuedDiscreteFeatures . length + "]." ) ; } for ( int i = 0 ; i < v1 . shortValuedDiscreteFeatures . length ; i ++ ) { if ( v1 . shortValuedDiscreteFeatures [ i ] == v2 . shortValuedDiscreteFeatures [ i ] ) ret ++ ; } return ( ret ) ; }
compares two feature vectors in terms of how many discrete features they have in common . warning : this assumes that the feature vectors are issued from the same featuredefinition ; only the number of features is checked for compatibility .
