/** * Subtract the values in the given vector from * this array and return this * @param vector the vector to add * @return this */ public SparseIntArray subtractInplace(SparseIntArray vector) { for (Entry e : vector.entries()) { increment(e.index, (int)(-e.value)); } return this; }
/** * Add the values in the given vector to * this vector and return this * @param vector the vector to add * @return this */ public SparseIntArray addInplace(SparseIntArray vector) { for (Entry e : vector.entries()) { increment(e.index, e.value); } return this; }
/** * Utility method to quickly convert a collection of quantised local * features to a histogram of their corresponding visual word identifiers. * * @param qfeatures * the quantised features. * @param nfeatures * the number of visual words. * @return a histogram of the occurrences of the visual words */ public static <L extends Location> SparseIntFV extractFeatureFromQuantised(Collection<? extends QuantisedLocalFeature<L>> qfeatures, final int nfeatures) { final SparseIntFV fv = new SparseIntFV(nfeatures); for (final QuantisedLocalFeature<L> qf : qfeatures) { fv.values.increment(qf.id, 1); } return fv; }
/** * Utility method to quickly convert a collection of quantised local * features to a histogram of their corresponding visual word identifiers. * * @param qfeatures * the quantised features. * @param nfeatures * the number of visual words. * @return a histogram of the occurrences of the visual words */ public static <L extends Location> SparseIntFV extractFeatureFromQuantised(Collection<? extends QuantisedLocalFeature<L>> qfeatures, final int nfeatures) { final SparseIntFV fv = new SparseIntFV(nfeatures); for (final QuantisedLocalFeature<L> qf : qfeatures) { fv.values.increment(qf.id, 1); } return fv; }
@Override public SparseIntFV aggregateVectors(List<? extends ArrayFeatureVector<T>> features) { final SparseIntFV fv = new SparseIntFV(this.assigner.size()); for (final ArrayFeatureVector<T> f : features) { final int idx = assigner.assign(f.values); fv.values.increment(idx, 1); } return fv; }
@Override public SparseIntFV aggregateVectors(List<? extends ArrayFeatureVector<T>> features) { final SparseIntFV fv = new SparseIntFV(this.assigner.size()); for (final ArrayFeatureVector<T> f : features) { final int idx = assigner.assign(f.values); fv.values.increment(idx, 1); } return fv; }
/** * Aggregate the given features into a vector. * * @param features * the features to aggregate * @return the aggregated vector */ public SparseIntFV aggregateVectorsRaw(List<T> features) { final SparseIntFV fv = new SparseIntFV(this.assigner.size()); for (final T f : features) { final int idx = assigner.assign(f); fv.values.increment(idx, 1); } return fv; } }
/** * Aggregate the given features into a vector. * * @param features * the features to aggregate * @return the aggregated vector */ public SparseIntFV aggregateVectorsRaw(List<T> features) { final SparseIntFV fv = new SparseIntFV(this.assigner.size()); for (final T f : features) { final int idx = assigner.assign(f); fv.values.increment(idx, 1); } return fv; } }
@Override public SparseIntFV aggregate(List<? extends LocalFeature<?, ? extends ArrayFeatureVector<T>>> features) { final SparseIntFV fv = new SparseIntFV(this.assigner.size()); for (final LocalFeature<?, ? extends ArrayFeatureVector<T>> f : features) { final int idx = assigner.assign(f.getFeatureVector().values); fv.values.increment(idx, 1); } return fv; }
@Override public SparseIntFV aggregate(List<? extends LocalFeature<?, ? extends ArrayFeatureVector<T>>> features) { final SparseIntFV fv = new SparseIntFV(this.assigner.size()); for (final LocalFeature<?, ? extends ArrayFeatureVector<T>> f : features) { final int idx = assigner.assign(f.getFeatureVector().values); fv.values.increment(idx, 1); } return fv; }