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


Java DoubleIterator.hasNext方法代码示例

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


在下文中一共展示了DoubleIterator.hasNext方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: norm2

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

示例8: norm1

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

示例9: cutBelow

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入方法依赖的package包/类
public void cutBelow(double k) {
    DoubleIterator iter = values().iterator();
    while (iter.hasNext()) {
        if (iter.nextDouble() < k)
            iter.remove();
    }
}
 
开发者ID:htools,项目名称:htools,代码行数:8,代码来源:FHashMapObjectDouble.java

示例10: cutAbove

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入方法依赖的package包/类
public void cutAbove(double k) {
    DoubleIterator iter = values().iterator();
    while (iter.hasNext()) {
        if (iter.nextDouble() > k)
            iter.remove();
    }
}
 
开发者ID:htools,项目名称:htools,代码行数:8,代码来源:FHashMapObjectDouble.java

示例11: cutBelow

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入方法依赖的package包/类
public void cutBelow(double k) {
    DoubleIterator iter = values().iterator();
    while (iter.hasNext()) {
        if (iter.nextDouble() < k) {
            iter.remove();
        }
    }
}
 
开发者ID:htools,项目名称:htools,代码行数:9,代码来源:FHashMapIntDouble.java

示例12: cutAbove

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入方法依赖的package包/类
public void cutAbove(double k) {
    DoubleIterator iter = values().iterator();
    while (iter.hasNext()) {
        if (iter.nextDouble() > k) {
            iter.remove();
        }
    }
}
 
开发者ID:htools,项目名称:htools,代码行数:9,代码来源:FHashMapIntDouble.java

示例13: parseEdges

import it.unimi.dsi.fastutil.doubles.DoubleIterator; //导入方法依赖的package包/类
/**
 * Read edges in format "id1 id2 w3"* or "id1 id2" up to the end of file.
 * Closes buffer reader.
 */
public static IGraph parseEdges(int numNodes, BufferedReader br) throws IOException {
    IntList[] nodes = new IntList[numNodes];
    DoubleList[] weightsList = new DoubleList[numNodes];
    String line = null;
    //Initialization of IntList and weigthsList
    for (int i = 0; i < numNodes; i++) {
        nodes[i] = new IntArrayList();
        weightsList[i] = new DoubleArrayList();
    }

    while ((line = br.readLine()) != null) {
        String[] splitArray = line.replace("\t", " ").split(" ");
        int node1 = Integer.parseInt(splitArray[0]);
        int node2 = Integer.parseInt(splitArray[1]);
        nodes[node1 - 1].add(node2 - 1); // Numeration in matLab file begins from 1, whether in java array from 0
        if (splitArray.length == 2) {
            weightsList[node1 - 1].add(1);
        } else {
            weightsList[node1 - 1].add(Double.parseDouble(splitArray[2]));
        }
    }
    br.close();
    boolean isWeighted = false;
    int[][] matrix = new int[numNodes][];
    double[][] weights = new double[numNodes][];
    for (int i = 0; i < numNodes; i++) {
        matrix[i] = new int[nodes[i].size()];
        weights[i] = new double[weightsList[i].size()];
        IntIterator intIterator = nodes[i].iterator();
        int count = 0;
        while (intIterator.hasNext()) {
            matrix[i][count] = intIterator.next();
            count++;
        }
        count = 0;
        DoubleIterator doubleIterator = weightsList[i].iterator();
        while (doubleIterator.hasNext()) {
            weights[i][count] = doubleIterator.next();
            if (weights[i][count] != 1) {
                isWeighted = true;
            }
            count++;
        }
    }
    return isWeighted ? new MatrixWeightedGraph(matrix, weights): new MatrixGraph(matrix);
}
 
开发者ID:sokolm,项目名称:LGA,代码行数:51,代码来源:LoaderUtils.java


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