/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(ByteFV h, ByteFVComparison method) { return method.compare(this, h); }
@Override public boolean isDistance() { return dst.isDistance(); } };
@SuppressWarnings("unchecked") protected <T extends FeatureVector> FVComparator<T> getComp(T fv, FeatureComparison type) { if (fv instanceof ByteFV) return (FVComparator<T>) ByteFVComparison.valueOf(type.name()); if (fv instanceof ShortFV) return (FVComparator<T>) ShortFVComparison.valueOf(type.name()); if (fv instanceof IntFV) return (FVComparator<T>) IntFVComparison.valueOf(type.name()); if (fv instanceof FloatFV) return (FVComparator<T>) FloatFVComparison.valueOf(type.name()); if (fv instanceof DoubleFV) return (FVComparator<T>) DoubleFVComparison.valueOf(type.name()); return null; }
@SuppressWarnings("unchecked") protected <T extends FeatureVector> FVComparator<T> getComp(T fv, FeatureComparison type) { if (fv instanceof ByteFV) return (FVComparator<T>) ByteFVComparison.valueOf(type.name()); if (fv instanceof ShortFV) return (FVComparator<T>) ShortFVComparison.valueOf(type.name()); if (fv instanceof IntFV) return (FVComparator<T>) IntFVComparison.valueOf(type.name()); if (fv instanceof FloatFV) return (FVComparator<T>) FloatFVComparison.valueOf(type.name()); if (fv instanceof DoubleFV) return (FVComparator<T>) DoubleFVComparison.valueOf(type.name()); return null; }
/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(ByteFV h, ByteFVComparison method) { return method.compare(this, h); }
@SuppressWarnings("unchecked") protected <T extends FeatureVector> FVComparator<T> getComp(T fv, FeatureComparison type) { if (fv instanceof ByteFV) return (FVComparator<T>) ByteFVComparison.valueOf(type.name()); if (fv instanceof ShortFV) return (FVComparator<T>) ShortFVComparison.valueOf(type.name()); if (fv instanceof IntFV) return (FVComparator<T>) IntFVComparison.valueOf(type.name()); if (fv instanceof FloatFV) return (FVComparator<T>) FloatFVComparison.valueOf(type.name()); if (fv instanceof DoubleFV) return (FVComparator<T>) DoubleFVComparison.valueOf(type.name()); return null; }
@Override public boolean isDistance() { return dst.isDistance(); } };
/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(MultidimensionalByteFV h, ByteFVComparison method) { return method.compare(this, h); }
@SuppressWarnings("unchecked") protected <T extends FeatureVector> FVComparator<T> getComp(T fv, FeatureComparison type) { if (fv instanceof ByteFV) return (FVComparator<T>) ByteFVComparison.valueOf(type.name()); if (fv instanceof ShortFV) return (FVComparator<T>) ShortFVComparison.valueOf(type.name()); if (fv instanceof IntFV) return (FVComparator<T>) IntFVComparison.valueOf(type.name()); if (fv instanceof FloatFV) return (FVComparator<T>) FloatFVComparison.valueOf(type.name()); if (fv instanceof DoubleFV) return (FVComparator<T>) DoubleFVComparison.valueOf(type.name()); return null; }
@Override public double compare(final byte[] h1, final byte[] h2) { return -1 * COSINE_SIM.compare(h1, h2); } },
/** * Get a feature comparison class for the given feature and metric. * @param fv The feature vector * @param type The feature comparison type * @return A comparable class */ @SuppressWarnings("unchecked") protected <T extends FeatureVector> FVComparator<T> getComp( T fv, FeatureComparison type ) { if (fv instanceof ByteFV) return (FVComparator<T>) ByteFVComparison.valueOf(type.name()); if (fv instanceof ShortFV) return (FVComparator<T>) ShortFVComparison.valueOf(type.name()); if (fv instanceof IntFV) return (FVComparator<T>) IntFVComparison.valueOf(type.name()); if (fv instanceof FloatFV) return (FVComparator<T>) FloatFVComparison.valueOf(type.name()); if (fv instanceof DoubleFV) return (FVComparator<T>) DoubleFVComparison.valueOf(type.name()); return null; }
/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(MultidimensionalByteFV h, ByteFVComparison method) { return method.compare(this, h); }
/** * Get a feature comparison class for the given feature and metric. * @param fv The feature vector * @param type The feature comparison type * @return A comparable class */ @SuppressWarnings("unchecked") protected <T extends FeatureVector> FVComparator<T> getComp( T fv, FeatureComparison type ) { if (fv instanceof ByteFV) return (FVComparator<T>) ByteFVComparison.valueOf(type.name()); if (fv instanceof ShortFV) return (FVComparator<T>) ShortFVComparison.valueOf(type.name()); if (fv instanceof IntFV) return (FVComparator<T>) IntFVComparison.valueOf(type.name()); if (fv instanceof FloatFV) return (FVComparator<T>) FloatFVComparison.valueOf(type.name()); if (fv instanceof DoubleFV) return (FVComparator<T>) DoubleFVComparison.valueOf(type.name()); return null; }
@Override public double compare(final byte[] h1, final byte[] h2) { return -1 * COSINE_SIM.compare(h1, h2); } },
@Override public double compare(byte[] o1, byte[] o2) { return dst.compare(o1, o2); }
@Override public double compare(ByteFV h1, ByteFV h2) { return compare(h1.values, h2.values); }
@Override public double compare(ByteFV h1, ByteFV h2) { return compare(h1.values, h2.values); }
@Override public double compare(byte[] o1, byte[] o2) { return dst.compare(o1, o2); }
@Override public double compare(final byte[] h1, final byte[] h2) { return Math.acos( COSINE_SIM.compare(h1, h2) ); } },
@Override public double compare(final byte[] h1, final byte[] h2) { return Math.acos( COSINE_SIM.compare(h1, h2) ); } },