Package de.lmu.ifi.dbs.elki.distance.distancevalue

Examples of de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance


      for(int i = 0; i < node.getNumEntries(); i++) {
        SpatialEntry p = node.getEntry(i);
        for(Entry<DBID, KNNHeap<DoubleDistance>> ent : knnLists.entrySet()) {
          final DBID q = ent.getKey();
          final KNNHeap<DoubleDistance> knns_q = ent.getValue();
          DoubleDistance knn_q_maxDist = knns_q.getKNNDistance();

          DBID pid = ((LeafEntry) p).getDBID();
          // FIXME: objects are NOT accessible by DBID in a plain rtree context!
          DoubleDistance dist_pq = distanceFunction.distance(relation.get(pid), relation.get(q));
          tree.distanceCalcs++;
          if(dist_pq.compareTo(knn_q_maxDist) <= 0) {
            knns_q.add(dist_pq, pid);
          }
        }
      }
    }
View Full Code Here


    return Math.sqrt(sqrDist);
  }

  @Override
  public DoubleDistance minDist(SpatialComparable mbr1, SpatialComparable mbr2) {
    return new DoubleDistance(doubleMinDist(mbr1, mbr2));
  }
View Full Code Here

    return min;
  }

  @Override
  public DoubleDistance minDist(SpatialComparable mbr1, SpatialComparable mbr2) {
    return new DoubleDistance(doubleMinDist(mbr1, mbr2));
  }
View Full Code Here

    public DoubleDistance distance(DBID id1, DBID id2) {
      Matrix m1 = index.getLocalProjection(id1).similarityMatrix();
      Matrix m2 = index.getLocalProjection(id2).similarityMatrix();

      if(m1 == null || m2 == null) {
        return new DoubleDistance(Double.POSITIVE_INFINITY);
      }

      V v1 = relation.get(id1);
      V v2 = relation.get(id2);
      Vector v1Mv2 = v1.getColumnVector().minusEquals(v2.getColumnVector());
      Vector v2Mv1 = v2.getColumnVector().minusEquals(v1.getColumnVector());

      double dist1 = v1Mv2.transposeTimesTimes(m1, v1Mv2);
      double dist2 = v2Mv1.transposeTimesTimes(m2, v2Mv1);

      if(dist1 < 0) {
        if(-dist1 < 0.000000000001) {
          dist1 = 0;
        }
        else {
          throw new IllegalArgumentException("dist1 " + dist1 + "  < 0!");
        }
      }
      if(dist2 < 0) {
        if(-dist2 < 0.000000000001) {
          dist2 = 0;
        }
        else {
          throw new IllegalArgumentException("dist2 " + dist2 + "  < 0!");
        }
      }

      return new DoubleDistance(Math.max(Math.sqrt(dist1), Math.sqrt(dist2)));
    }
View Full Code Here

    return sqrDist;
  }

  @Override
  public DoubleDistance minDist(SpatialComparable mbr1, SpatialComparable mbr2) {
    return new DoubleDistance(doubleMinDist(mbr1, mbr2));
  }
View Full Code Here

    }
    double sim = 0;
    for(int i = 1; i <= o1.getDimensionality(); i++) {
      sim += o1.doubleValue(i) * o2.doubleValue(i);
    }
    return new DoubleDistance(sim);
  }
View Full Code Here

    return new DoubleDistance(sim);
  }

  @Override
  public DoubleDistance distance(final O fv1, final O fv2) {
    return new DoubleDistance(Math.sqrt(similarity(fv1, fv1).doubleValue() + similarity(fv2, fv2).doubleValue() - 2 * similarity(fv1, fv2).doubleValue()));
  }
View Full Code Here

    @Override
    public DoubleDistance similarity(DBID id1, DBID id2) {
      DBIDs neighbors1 = index.getNearestNeighborSet(id1);
      DBIDs neighbors2 = index.getNearestNeighborSet(id2);
      int intersection = countSharedNeighbors(neighbors1, neighbors2);
      return new DoubleDistance((double) intersection / index.getNumberOfNeighbors());
    }
View Full Code Here

  }

  @Override
  public DoubleDistance similarity(O o1, O o2) {
    double dist = distanceFunction.distance(o1, o2).doubleValue();
    return new DoubleDistance(1. / dist);
  }
View Full Code Here

    double sim = 0.0;
    // iterate over differently powered dimensions
    for(int degree = 1; degree <= max_degree; degree++) {
      sim += Math.pow(o1.doubleValue(degree) * o2.doubleValue(degree), degree);
    }
    return new DoubleDistance(sim);
  }
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.