当前位置: 首页>>代码示例>>Java>>正文


Java PhDistanceF类代码示例

本文整理汇总了Java中ch.ethz.globis.phtree.PhDistanceF的典型用法代码示例。如果您正苦于以下问题:Java PhDistanceF类的具体用法?Java PhDistanceF怎么用?Java PhDistanceF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PhDistanceF类属于ch.ethz.globis.phtree包,在下文中一共展示了PhDistanceF类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: knnQuery

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
@Override
public double knnQuery(int k, double[] center) {
	f2l(center, knnCenter);
	knnQuery.reset(k, PhDistanceF.THIS, knnCenter);
	double ret = 0;
	double[] v2 = new double[dims];
	int n = 0;
	while (knnQuery.hasNext() && n++ < k) {
		long[] v = knnQuery.nextEntryReuse().getKey();
		l2f(v, v2);
		ret += dist(center, v2);
	}
	if (n < k) {
		throw new IllegalStateException("n/k=" + n + "/" + k);
	}
	return ret;
}
 
开发者ID:tzaeschke,项目名称:TinSpin,代码行数:18,代码来源:PointPHC2.java

示例2: knnQuery

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
@Override
public double knnQuery(int k, double[] center) {
	f2l(center, knnCenter);
	if (knnQuery == null) {
		knnQuery = phc.nearestNeighbour(k, PhDistanceF.THIS, null, knnCenter);
	} else {
		knnQuery.reset(k, PhDistanceF.THIS, knnCenter);
	}
	double ret = 0;
	double[] v2 = new double[dims];
	int n = 0;
	while (knnQuery.hasNext() && n++ < k) {
		long[] v = knnQuery.nextEntryReuse().getKey();
		l2f(v, v2);
		ret += dist(center, v2);
	}
	if (n < k) {
		throw new IllegalStateException("n/k=" + n + "/" + k);
	}
	return ret;
}
 
开发者ID:tzaeschke,项目名称:TinSpin,代码行数:22,代码来源:PointPHC.java

示例3: radiusSearch

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
@Override
public <V> PhKnnQuery<V> radiusSearch(String initialHost, long[] key, int k, 
		List<long[]> candidates, PHTreeIndexProxy<V> indexProxy) {
    long[] farthestNeighbor = candidates.get(k - 1);
    long distance = MultidimUtil.computeDistance(key, farthestNeighbor);
    long[] start = MultidimUtil.transpose(key, -distance);
    long[] end = MultidimUtil.transpose(key, distance);
    PhDistance measure = new PhDistanceF();
    double dist = measure.dist(key, farthestNeighbor);

    List<long[]> extendedCandidates = indexProxy.getRange(initialHost, start, end, dist);

    extendedCandidates.addAll(candidates);

    return MultidimUtil.nearestNeighbours(key, k, extendedCandidates);
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:17,代码来源:RangeFilteredKNNRadiusStrategy.java

示例4: knnQuery

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
@Override
public double knnQuery(int k, double[] center) {
	knnQuery.reset(k, PhDistanceF.THIS, center);
	double ret = 0;
	int n = 0;
	while (knnQuery.hasNext() && n++ < k) {
		double[] v = knnQuery.nextEntryReuse().getKey();
		ret += dist(center, v);
	}
	if (n < k) {
		throw new IllegalStateException("n/k=" + n + "/" + k);
	}
	return ret;
}
 
开发者ID:tzaeschke,项目名称:TinSpin,代码行数:15,代码来源:PointPHCF.java

示例5: createList

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
private IndexEntryList<long[], byte[]> createList(PhIterator<byte[]> it, long[] key, double distance) {
    IndexEntryList<long[], byte[]> results = new IndexEntryList<>();
    PhDistance measure = new PhDistanceF();
    while (it.hasNext()) {
        PhEntry<byte[]> entry = it.nextEntry();
        if (distance > measure.dist(key, entry.getKey())) {
            results.add(entry.getKey(), entry.getValue());
        }
    }
    return results;
}
 
开发者ID:tzaeschke,项目名称:distributed-phtree,代码行数:12,代码来源:PhTreeRequestHandler.java

示例6: testQueryND64RandomDistFunc

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
@Test
public void testQueryND64RandomDistFunc() {
	final int DIM = 15;
	final int LOOP = 10;
	final int N = 1000;
	final int NQ = 100;
	final int MAXV = 1000;
	final Random R = new Random(0);
	for (int d = 0; d < LOOP; d++) {
		PhTreeSolidF<Object> ind = newTreeSF(DIM);
		PhKnnQuerySF<Object> q = ind.nearestNeighbour(1, newDistFn(ind), new double[DIM]);
		populate(ind, R, N, DIM, MAXV);
		for (int i = 0; i < NQ; i++) {
			double[] v = new double[DIM];
			for (int j = 0; j < DIM; j++) {
				v[j] = R.nextDouble()*MAXV;
			}
			PhEntrySF<Object> exp = nearestNeighbor1(ind, v);
			//        System.out.println("d="+ d + "   i=" + i + "   minD=" + dist(v, exp));
			//        System.out.println("v="+ Arrays.toString(v));
			//        System.out.println("exp="+ Arrays.toString(exp));
			List<PhEntrySF<Object>> nnList = toList(q.reset(1, PhDistanceF.THIS, v));

			//        System.out.println(ind.toStringPlain());
			//        System.out.println("v  =" + Arrays.toString(v));
			//        System.out.println("exp=" + Arrays.toString(exp));
			assertTrue("i=" + i + " d=" + d, !nnList.isEmpty());
			PhEntrySF<Object> nn = nnList.get(0);
			check(v, exp, nn);
		}
	}
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:33,代码来源:TestNearestNeighbourFS.java

示例7: testQueryND64RandomCenterAway

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
@Test
public void testQueryND64RandomCenterAway() {
	final int DIM = 5;
	final int LOOP = 10;
	final int N = 1000;
	final int NQ = 100;
	final int MAXV = 1000;
	final Random R = new Random(0);
	for (int d = 0; d < LOOP; d++) {
		PhTreeSolidF<Object> ind = newTreeSF(DIM);
		PhKnnQuerySF<Object> q = ind.nearestNeighbour(1, newDistFn(ind), new double[DIM]);
		populate(ind, R, N, DIM, 1);
		for (int i = 0; i < NQ; i++) {
			double[] v = new double[DIM];
			for (int j = 0; j < DIM; j++) {
				v[j] = R.nextDouble()*MAXV;
			}
			PhEntrySF<?> exp = nearestNeighbor1(ind, v);
			//        System.out.println("d="+ d + "   i=" + i + "   minD=" + dist(v, exp));
			//        System.out.println("v="+ Arrays.toString(v));
			//        System.out.println("exp="+ Arrays.toString(exp));
			List<PhEntrySF<Object>> nnList = toList(q.reset(1, PhDistanceF.THIS, v));

			//        System.out.println(ind.toStringPlain());
			//        System.out.println("v  =" + Arrays.toString(v));
			//        System.out.println("exp=" + Arrays.toString(exp));
			assertTrue("i=" + i + " d=" + d, !nnList.isEmpty());
			PhEntrySF<Object> nn = nnList.get(0);
			check(v, exp, nn);
		}
	}
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:33,代码来源:TestNearestNeighbourFS.java

示例8: testQueryND64Random10DistFunc

import ch.ethz.globis.phtree.PhDistanceF; //导入依赖的package包/类
@Test
public void testQueryND64Random10DistFunc() {
	final int DIM = 15;
	final int LOOP = 10;
	final int N = 1000;
	final int NQ = 100;
	final int MAXV = 1;
	final Random R = new Random(0);
	for (int d = 0; d < LOOP; d++) {
		PhTreeSolidF<Object> ind = newTreeSF(DIM);
		PhKnnQuerySF<Object> q = ind.nearestNeighbour(10, newDistFn(ind), new double[DIM]);
		populate(ind, R, N, DIM, MAXV);
		for (int i = 0; i < NQ; i++) {
			double[] v = new double[DIM];
			for (int j = 0; j < DIM; j++) {
				v[j] = R.nextDouble()*MAXV;
			}
			ArrayList<PhEntrySF<Object>> exp = nearestNeighborK(ind, 10, v);
			//        System.out.println("d="+ d + "   i=" + i + "   minD=" + dist(v, exp));
			//        System.out.println("v="+ Arrays.toString(v));
			//        System.out.println("exp="+ Arrays.toString(exp));
			List<PhEntrySF<Object>> nnList = toList(q.reset(10, PhDistanceF.THIS, v));

			//        System.out.println(ind.toStringPlain());
			//        System.out.println("v  =" + Arrays.toString(v));
			//        System.out.println("exp=" + Arrays.toString(exp));
			assertTrue("i=" + i + " d=" + d, !nnList.isEmpty());
			check(v, exp, nnList);
		}
	}
}
 
开发者ID:tzaeschke,项目名称:phtree,代码行数:32,代码来源:TestNearestNeighbourFS.java


注:本文中的ch.ethz.globis.phtree.PhDistanceF类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。