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


Java DoubleIterator类代码示例

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


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

示例1: truncateTo

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
@Override
public void truncateTo(int minimumNumberOfElementsToKeep) {
	if (m.size() < minimumNumberOfElementsToKeep)
		return;
	
	DoubleHeapPriorityQueue heap = new DoubleHeapPriorityQueue();
	
	DoubleIterator values = values();
	while (values.hasNext()) {
			heap.enqueue(Math.abs(values.nextDouble()));
			if (heap.size() > minimumNumberOfElementsToKeep)
				heap.dequeueDouble();
		}
	
	double threshold = heap.dequeueDouble();
	
	DoubleIterator iterator = m.values().iterator();
	while (iterator.hasNext()) {
		if (Math.abs(iterator.nextDouble()) < threshold)
			iterator.remove();
	}
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:23,代码来源:LongBasedMatrix.java

示例2: values

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
@Override
public DoubleIterator values() {
	return new DoubleIterator() {
		private int i = size - 1, j = size - 1;
		public Double next() { return Double.valueOf(nextDouble()); }
		public int skip(int n) { throw new UnsupportedOperationException(); }
		public void remove() { throw new UnsupportedOperationException(); }
		
		public double nextDouble() {
			i--;
			if (i < 0) {
				i = size - 1;
				j--;
			}
			return m[i][j];
		}
		public boolean hasNext() {
			return i != 0 || j != 0;
		}
		
	};
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:23,代码来源:ArrayMatrix.java

示例3: getProductMap

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
private Int2DoubleMap getProductMap(int uidx) {
    Int2DoubleOpenHashMap productMap = new Int2DoubleOpenHashMap();
    productMap.defaultReturnValue(0.0);

    if (data.useIteratorsPreferentially()) {
        IntIterator iidxs = data.getUidxIidxs(uidx);
        DoubleIterator ivs = data.getUidxVs(uidx);
        while (iidxs.hasNext()) {
            int iidx = iidxs.nextInt();
            double iv = ivs.nextDouble();
            IntIterator vidxs = data.getIidxUidxs(iidx);
            DoubleIterator vvs = data.getIidxVs(iidx);
            while (vidxs.hasNext()) {
                productMap.addTo(vidxs.nextInt(), iv * vvs.nextDouble());
            }
        }
    } else {
        data.getUidxPreferences(uidx)
                .forEach(ip -> data.getIidxPreferences(ip.v1)
                        .forEach(up -> productMap.addTo(up.v1, ip.v2 * up.v2)));
    }

    productMap.remove(uidx);

    return productMap;
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:27,代码来源:VectorSimilarity.java

示例4: getProductArray

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
private double[] getProductArray(int uidx) {
    double[] productArray = new double[data.numUsers()];

    if (data.useIteratorsPreferentially()) {
        IntIterator iidxs = data.getUidxIidxs(uidx);
        DoubleIterator ivs = data.getUidxVs(uidx);
        while (iidxs.hasNext()) {
            int iidx = iidxs.nextInt();
            double iv = ivs.nextDouble();
            IntIterator vidxs = data.getIidxUidxs(iidx);
            DoubleIterator vvs = data.getIidxVs(iidx);
            while (vidxs.hasNext()) {
                productArray[vidxs.nextInt()] += iv * vvs.nextDouble();
            }
        }
    } else {
        data.getUidxPreferences(uidx)
                .forEach(ip -> data.getIidxPreferences(ip.v1)
                        .forEach(up -> productArray[up.v1] += ip.v2 * up.v2));
    }

    productArray[uidx] = 0.0;

    return productArray;
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:26,代码来源:VectorSimilarity.java

示例5: getNorm2

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
private double getNorm2(int uidx) {
    if (data.useIteratorsPreferentially()) {
        DoubleIterator ivs = data.getUidxVs(uidx);
        double sum = 0;
        while (ivs.hasNext()) {
            double iv = ivs.nextDouble();
            sum += iv * iv;
        }
        return sum;
    } else {
        return data.getUidxPreferences(uidx)
                .mapToDouble(IdxPref::v2)
                .map(x -> x * x)
                .sum();
    }
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:17,代码来源:VectorSimilarity.java

示例6: getWeightedRandomReversed

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
@Nullable
public static <T> T getWeightedRandomReversed(Random random, Double2ObjectMap<T> choices)
{
    double i = 0;
    DoubleSet doubles = choices.keySet();
    for (DoubleIterator iterator = doubles.iterator(); iterator.hasNext(); )
    {
        double x = iterator.nextDouble();
        i += x;
    }
    i = getRandomDouble(random, 0, i);
    for (Double2ObjectMap.Entry<T> entry : choices.double2ObjectEntrySet())
    {
        i -= entry.getDoubleKey();
        if (i < 0)
        {
            return entry.getValue();
        }
    }
    return null;
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:22,代码来源:DioriteRandomUtils.java

示例7: getWeightedRandom

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
@Nullable
public static <T> T getWeightedRandom(Random random, Object2DoubleMap<T> choices)
{
    double i = 0;
    DoubleCollection doubles = choices.values();
    for (DoubleIterator iterator = doubles.iterator(); iterator.hasNext(); )
    {
        double x = iterator.nextDouble();
        i += x;
    }
    i = getRandomDouble(random, 0, i);
    for (Object2DoubleMap.Entry<T> entry : choices.object2DoubleEntrySet())
    {
        i -= entry.getDoubleValue();
        if (i < 0)
        {
            return entry.getKey();
        }
    }
    return null;
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:22,代码来源:DioriteRandomUtils.java

示例8: iterator

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
@Override
public Iterator<Edge<LongWritable, DoubleWritable>> iterator() {
  // Returns an iterator that reuses objects.
  return new UnmodifiableIterator<Edge<LongWritable, DoubleWritable>>() {
    /** Wrapped neighbors iterator. */
    private LongIterator neighborsIt = neighbors.iterator();
    /** Wrapped edge values iterator. */
    private DoubleIterator edgeValuesIt = edgeValues.iterator();
    /** Representative edge object. */
    private Edge<LongWritable, DoubleWritable> representativeEdge =
        EdgeFactory.create(new LongWritable(), new DoubleWritable());

    @Override
    public boolean hasNext() {
      return neighborsIt.hasNext();
    }

    @Override
    public Edge<LongWritable, DoubleWritable> next() {
      representativeEdge.getTargetVertexId().set(neighborsIt.nextLong());
      representativeEdge.getValue().set(edgeValuesIt.nextDouble());
      return representativeEdge;
    }
  };
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:26,代码来源:LongDoubleArrayEdges.java

示例9: isBad

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
@Override
public boolean isBad() {
	final DoubleIterator iterator = values.values().iterator();
	while (iterator.hasNext()) {
		final double value = iterator.nextDouble();
		if (Double.isNaN(value) || Double.isInfinite(value)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:clic-lab,项目名称:spf,代码行数:12,代码来源:FastTreeHashVector.java

示例10: cosineProduct

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
private double cosineProduct(Object2DoubleMap<String> vector1, Object2DoubleMap<String> vector2) {
    double aa = 0, bb = 0, ab = 0;
    for(Object2DoubleMap.Entry<String> e : vector1.object2DoubleEntrySet()) {
        aa += e.getDoubleValue() * e.getDoubleValue();
        ab += e.getDoubleValue() * vector2.getDouble(e.getKey());
    }
    DoubleIterator di  = vector2.values().iterator();
    while(di.hasNext()) {
        double d = di.nextDouble();
        bb +=  d * d;
    }
    return ab / Math.sqrt(aa * bb);
}
 
开发者ID:jmccrae,项目名称:naisc,代码行数:14,代码来源:CLESAFeatureExtractor.java

示例11: isEqualTo

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
public Selection isEqualTo(DoubleColumn d) {
    Selection results = new BitmapBackedSelection();
    int i = 0;
    DoubleIterator doubleIterator = d.iterator();
    for (double doubles : data) {
        if (doubles == doubleIterator.nextDouble()) {
            results.add(i);
        }
        i++;
    }
    return results;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:13,代码来源:DoubleColumn.java

示例12: isGreaterThan

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
public Selection isGreaterThan(DoubleColumn d) {
    Selection results = new BitmapBackedSelection();
    int i = 0;
    DoubleIterator doubleIterator = d.iterator();
    for (double doubles : data) {
        if (doubles > doubleIterator.nextDouble()) {
            results.add(i);
        }
        i++;
    }
    return results;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:13,代码来源:DoubleColumn.java

示例13: isLessThan

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
public Selection isLessThan(DoubleColumn d) {
    Selection results = new BitmapBackedSelection();
    int i = 0;
    DoubleIterator doubleIterator = d.iterator();
    for (double doubles : data) {
        if (doubles < doubleIterator.nextDouble()) {
            results.add(i);
        }
        i++;
    }
    return results;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:13,代码来源:DoubleColumn.java

示例14: numberOfNonZeroEntries

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
public int numberOfNonZeroEntries() {
	int n = 0;
	DoubleIterator values = values();
	while (values.hasNext())
		if (values.nextDouble() != 0)
			n++;
	return n;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:9,代码来源:Matrix.java

示例15: maxNorm

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入依赖的package包/类
public double maxNorm() {
	double max = 0;
	DoubleIterator values = values();
	while (values.hasNext())
		max = Math.max(max, Math.abs(values.nextDouble()));
	return max;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:8,代码来源:Matrix.java


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