本文整理汇总了Java中it.unimi.dsi.fastutil.longs.Long2DoubleMap.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java Long2DoubleMap.Entry方法的具体用法?Java Long2DoubleMap.Entry怎么用?Java Long2DoubleMap.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.longs.Long2DoubleMap
的用法示例。
在下文中一共展示了Long2DoubleMap.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: plusBy
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private SparseLongKeyDoubleVector plusBy(SparseLongKeyDoubleVector other, double x) {
assert (dim == -1 || dim == other.getLongDim());
if(this.indexToValueMap.isEmpty()) {
this.indexToValueMap.putAll(other.getIndexToValueMap());
} else {
resize(other.size());
ObjectIterator<Long2DoubleMap.Entry> iter =
other.indexToValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
indexToValueMap.addTo(entry.getLongKey(), entry.getDoubleValue() * x);
}
}
return this;
}
示例2: plus
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private SparseLongKeyDoubleVector plus(SparseLongKeyDoubleVector other, double x) {
assert (dim == -1 || dim == other.getLongDim());
SparseLongKeyDoubleVector baseVector = null;
SparseLongKeyDoubleVector streamVector = null;
if (size() < other.size()) {
baseVector = new SparseLongKeyDoubleVector(other);
streamVector = this;
} else {
baseVector = new SparseLongKeyDoubleVector(this);
streamVector = other;
}
ObjectIterator<Long2DoubleMap.Entry> iter =
streamVector.indexToValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
baseVector.indexToValueMap.addTo(entry.getLongKey(), entry.getDoubleValue() * x);
}
return baseVector;
}
示例3: dot
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private double dot(SparseLongKeyDoubleVector other) {
assert (dim == -1 || dim == other.getLongDim());
double ret = 0.0;
if (size() <= other.size()) {
ObjectIterator<Long2DoubleMap.Entry> iter =
indexToValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
ret += other.get(entry.getLongKey()) * entry.getDoubleValue();
}
return ret;
} else {
return other.dot(this);
}
}
示例4: filter
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
@Override public TVector filter(double x) {
SparseLongKeyDoubleVector vector = new SparseLongKeyDoubleVector(this.dim);
ObjectIterator<Long2DoubleMap.Entry> iter =
indexToValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
double value = entry.getDoubleValue();
if (Math.abs(value) > x) {
vector.set(entry.getLongKey(), value);
}
}
vector.setRowId(rowId).setMatrixId(matrixId).setClock(clock);
return vector;
}
示例5: serialize
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
try {
lock.readLock().lock();
super.serialize(buf);
buf.writeInt(index2ValueMap.size());
ObjectIterator<Long2DoubleMap.Entry> iter = index2ValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
buf.writeLong(entry.getLongKey());
buf.writeDouble(entry.getDoubleValue());
}
} finally {
lock.readLock().unlock();
}
}
示例6: mergeTo
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
/**
* Put the elements in this vector partition to the given index and value arrays
* @param indexes index array
* @param values value array
* @param startPos the start position for the elements of this vector partition
* @param len the reserved length for this vector partition
*/
public void mergeTo(long[] indexes, double[] values, int startPos, int len) {
try {
lock.readLock().lock();
int writeLen = len < index2ValueMap.size() ? len : index2ValueMap.size();
if (writeLen == 0) {
return;
}
int index = 0;
ObjectIterator<Long2DoubleMap.Entry> iter = index2ValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
indexes[startPos + index] = entry.getLongKey();
values[startPos + index] = entry.getDoubleValue();
index++;
if (index == writeLen) {
return;
}
}
} finally {
lock.readLock().unlock();
}
}
示例7: constructAliasTableArray
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
/**
* Construct a index array and an alias table given the LHS seed nodes with weights.
* The probability for a LHS seed node u to be sampled should be proportional to
* degree(u) * Weight(u)
*
* @param seedsWithWeights the LHS seed nodes with weights
* @param indexArray the index array for the seeds
* @param aliasTableArray the alias table used for sampling from the seeds
*/
private void constructAliasTableArray(
Long2DoubleMap seedsWithWeights,
long[] indexArray,
int[] aliasTableArray) {
int index = 0;
int averageWeight = 0;
for (Long2DoubleMap.Entry entry: seedsWithWeights.long2DoubleEntrySet()) {
long seed = entry.getLongKey();
double seedWeight = entry.getDoubleValue();
indexArray[index] = seed;
int finalWeight = (int) (Math.round(MULTIPER_FOR_ALIASTABLE * seedWeight
* bipartiteGraph.getLeftNodeDegree(seed)));
IntArrayAliasTable.setEntry(aliasTableArray, index, index);
IntArrayAliasTable.setWeight(aliasTableArray, index, finalWeight);
averageWeight += finalWeight;
index++;
}
// finally set the size and weight
IntArrayAliasTable.setAliasTableSize(aliasTableArray, index);
IntArrayAliasTable.setAliasTableAverageWeight(aliasTableArray, averageWeight / index);
// now we can construct the alias table
AliasTableUtil.constructAliasTable(aliasTableArray);
}
示例8: verifyCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private final Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
Long2DoubleOpenHashMap matches = new Long2DoubleOpenHashMap();
for (Long2DoubleMap.Entry e : accumulator.long2DoubleEntrySet()) {
final long candidateID = e.getLongKey();
if (Double.compare(e.getDoubleValue() + ps.get(candidateID), theta) < 0) // A[y] = dot(x, y'')
continue; // l2 pruning
Vector residual = residuals.get(candidateID);
assert (residual != null);
final double ds1 = e.getDoubleValue()
+ Math.min(v.maxValue() * residual.sumValues(), residual.maxValue() * v.sumValues());
if (Double.compare(ds1, theta) < 0)
continue; // dpscore, eq. (5)
final double sz2 = e.getDoubleValue() + Math.min(v.maxValue() * residual.size(), residual.maxValue() * v.size());
if (Double.compare(sz2, theta) < 0)
continue; // dpscore, eq. (9)
final long deltaT = v.timestamp() - candidateID;
double score = e.getDoubleValue() + Vector.similarity(v, residual); // dot(x, y) = A[y] + dot(x, y')
score *= forgettingFactor(lambda, deltaT); // apply forgetting factor
numSimilarities++;
if (Double.compare(score, theta) >= 0) // final check
matches.put(candidateID, score);
}
numMatches += matches.size();
return matches;
}
示例9: verifyCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private final Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
Long2DoubleOpenHashMap matches = new Long2DoubleOpenHashMap();
for (Long2DoubleMap.Entry e : accumulator.long2DoubleEntrySet()) {
final long candidateID = e.getLongKey();
if (Double.compare(e.getDoubleValue() + ps.get(candidateID), theta) < 0) // A[y] = dot(x, y'')
continue; // l2 pruning
final Vector residual = residuals.get(candidateID);
assert (residual != null);
final double ds1 = e.getDoubleValue()
+ Math.min(v.maxValue() * residual.sumValues(), residual.maxValue() * v.sumValues());
if (Double.compare(ds1, theta) < 0)
continue; // dpscore, eq. (5)
final double sz2 = e.getDoubleValue() + Math.min(v.maxValue() * residual.size(), residual.maxValue() * v.size());
if (Double.compare(sz2, theta) < 0)
continue; // dpscore, eq. (9)
final long deltaT = v.timestamp() - candidateID;
double score = e.getDoubleValue() + Vector.similarity(v, residual); // dot(x, y) = A[y] + dot(x, y')
score *= forgettingFactor(lambda, deltaT); // apply forgetting factor
numSimilarities++;
if (Double.compare(score, theta) >= 0) // final check
matches.put(candidateID, score);
}
numMatches += matches.size();
return matches;
}
示例10: verifyCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
Long2DoubleOpenHashMap matches = new Long2DoubleOpenHashMap();
for (Long2DoubleMap.Entry e : accumulator.long2DoubleEntrySet()) {
long candidateID = e.getLongKey();
Vector candidateResidual = residuals.get(candidateID);
assert (candidateResidual != null);
double score = e.getDoubleValue() + Vector.similarity(v, candidateResidual); // A[y] + dot(y',x)
long deltaT = v.timestamp() - candidateID;
score *= Commons.forgettingFactor(lambda, deltaT); // apply forgetting factor
numSimilarities++;
if (Double.compare(score, theta) >= 0) // final check
matches.put(candidateID, score);
}
numMatches += matches.size();
return matches;
}
示例11: iterator
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
@Override
public Iterator<Edge<LongWritable, DoubleWritable>> iterator() {
// Returns an iterator that reuses objects.
return new UnmodifiableIterator<Edge<LongWritable, DoubleWritable>>() {
/** Wrapped map iterator. */
private ObjectIterator<Long2DoubleMap.Entry> mapIterator =
edgeMap.long2DoubleEntrySet().fastIterator();
/** Representative edge object. */
private ReusableEdge<LongWritable, DoubleWritable> representativeEdge =
EdgeFactory.createReusable(new LongWritable(), new DoubleWritable());
@Override
public boolean hasNext() {
return mapIterator.hasNext();
}
@Override
public Edge<LongWritable, DoubleWritable> next() {
Long2DoubleMap.Entry nextEntry = mapIterator.next();
representativeEdge.getTargetVertexId().set(nextEntry.getLongKey());
representativeEdge.getValue().set(nextEntry.getDoubleValue());
return representativeEdge;
}
};
}
示例12: plusBy
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private TVector plusBy(SparseLongKeyDoubleVector other) {
ObjectIterator<Long2DoubleMap.Entry>
iter = other.getIndexToValueMap().long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while(iter.hasNext()) {
entry = iter.next();
plusBy(entry.getLongKey(), entry.getDoubleValue());
}
return this;
}
示例13: dot
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
private double dot(SparseLongKeyDoubleVector other) {
double dotValue = 0.0;
ObjectIterator<Long2DoubleMap.Entry>
iter = other.getIndexToValueMap().long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while(iter.hasNext()) {
entry = iter.next();
dotValue += get(entry.getLongKey()) * entry.getDoubleValue();
}
return dotValue;
}
示例14: times
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
@Override public TVector times(double x) {
SparseLongKeyDoubleVector vector = new SparseLongKeyDoubleVector(dim, indexToValueMap.size());
ObjectIterator<Long2DoubleMap.Entry> iter =
indexToValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
vector.set(entry.getLongKey(), entry.getDoubleValue() * x);
}
return vector;
}
示例15: timesBy
import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入方法依赖的package包/类
@Override public TVector timesBy(double x) {
ObjectIterator<Long2DoubleMap.Entry> iter =
indexToValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
entry.setValue(entry.getDoubleValue() * x);
}
return this;
}