use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanDistanceRangeQuery method getRangeForObject.
@Override
public DoubleDBIDList getRangeForObject(O obj, double range) {
final DistanceQuery<O> dq = distanceQuery;
ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList();
for (DBIDIter iter = getRelation().getDBIDs().iter(); iter.valid(); iter.advance()) {
final double currentDistance = dq.distance(obj, iter);
if (currentDistance <= range) {
result.add(currentDistance, iter);
}
}
result.sort();
return result;
}
use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanDistanceRangeQuery method getRangeForDBID.
@Override
public DoubleDBIDList getRangeForDBID(DBIDRef id, double range) {
final DistanceQuery<O> dq = distanceQuery;
ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList();
for (DBIDIter iter = getRelation().getDBIDs().iter(); iter.valid(); iter.advance()) {
final double currentDistance = dq.distance(id, iter);
if (currentDistance <= range) {
result.add(currentDistance, iter);
}
}
result.sort();
return result;
}
use of de.lmu.ifi.dbs.elki.database.ids.ModifiableDoubleDBIDList in project elki by elki-project.
the class LinearScanPrimitiveDistanceRangeQuery method getRangeForDBID.
@Override
public DoubleDBIDList getRangeForDBID(DBIDRef id, double range) {
final Relation<? extends O> relation = getRelation();
// 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 LinearScanSimilarityRangeQuery method getRangeForDBID.
@Override
public DoubleDBIDList getRangeForDBID(DBIDRef id, double range) {
ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList();
for (DBIDIter iter = relation.getDBIDs().iter(); iter.valid(); iter.advance()) {
final double currentSim = simQuery.similarity(id, 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 getRKNNForDBID.
@Override
public DoubleDBIDList getRKNNForDBID(DBIDRef id, int k) {
ModifiableDoubleDBIDList rNNList = 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()) {
if (DBIDUtil.equal(n, id)) {
rNNList.add(n.doubleValue(), iter);
}
}
i++;
}
rNNList.sort();
return rNNList;
}
Aggregations