use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanPrimitiveDistanceRangeQuery method getRangeForObject.
@Override
public DoubleDBIDList getRangeForObject(O obj, double range) {
final Relation<? extends O> relation = getRelation();
ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList();
linearScan(relation, relation.iterDBIDs(), obj, range, result);
result.sort();
return result;
}
use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanPrimitiveSimilarityRangeQuery method getRangeForDBID.
@Override
public DoubleDBIDList getRangeForDBID(DBIDRef id, double range) {
// Note: subtle optimization. Get "id" only once!
final O obj = relation.get(id);
ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList();
linearScan(relation, relation.iterDBIDs(), obj, range, result);
result.sort();
return result;
}
use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanPrimitiveSimilarityRangeQuery method getRangeForObject.
@Override
public DoubleDBIDList getRangeForObject(O obj, double range) {
ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList();
linearScan(relation, relation.iterDBIDs(), obj, range, result);
result.sort();
return result;
}
use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanSimilarityRangeQuery method getRangeForObject.
@Override
public DoubleDBIDList getRangeForObject(O obj, double range) {
ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList();
for (DBIDIter iter = relation.getDBIDs().iter(); iter.valid(); iter.advance()) {
final double currentSim = simQuery.similarity(obj, iter);
if (currentSim >= range) {
result.add(currentSim, iter);
}
}
result.sort();
return result;
}
use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanRKNNQuery method getRKNNForBulkDBIDs.
@Override
public List<? extends DoubleDBIDList> getRKNNForBulkDBIDs(ArrayDBIDs ids, int k) {
List<ModifiableDoubleDBIDList> rNNList = new ArrayList<>(ids.size());
for (int i = 0; i < ids.size(); i++) {
rNNList.add(DBIDUtil.newDistanceDBIDList());
}
ArrayDBIDs allIDs = DBIDUtil.ensureArray(relation.getDBIDs());
List<? extends KNNList> kNNList = knnQuery.getKNNForBulkDBIDs(allIDs, k);
int i = 0;
for (DBIDIter iter = allIDs.iter(); iter.valid(); iter.advance()) {
KNNList knn = kNNList.get(i);
for (DoubleDBIDListIter n = knn.iter(); n.valid(); n.advance()) {
int j = 0;
for (DBIDIter iter2 = ids.iter(); iter2.valid(); iter2.advance()) {
if (DBIDUtil.equal(n, iter2)) {
ModifiableDoubleDBIDList rNN = rNNList.get(j);
rNN.add(n.doubleValue(), iter);
}
j++;
}
}
i++;
}
for (int j = 0; j < ids.size(); j++) {
rNNList.get(j).sort();
}
return rNNList;
}
Aggregations