本文整理汇总了Java中it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap.size方法的典型用法代码示例。如果您正苦于以下问题:Java Long2DoubleOpenHashMap.size方法的具体用法?Java Long2DoubleOpenHashMap.size怎么用?Java Long2DoubleOpenHashMap.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap
的用法示例。
在下文中一共展示了Long2DoubleOpenHashMap.size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的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;
}
示例2: verifyCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的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;
}
示例3: verifyCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的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;
}
示例4: doProcessRow
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
long entireSize = row.getEndCol() - row.getStartCol();
double qSum = 0.0;
Long2DoubleOpenHashMap data = row.getIndex2ValueMap();
for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
qSum += Math.pow(entry.getValue(), 2);
}
qSum += Math.pow(data.defaultReturnValue(), 2) * (entireSize - data.size());
return qSum;
}
示例5: doProcessRow
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
long entireSize = row.getEndCol() - row.getStartCol();
Long2DoubleOpenHashMap data = row.getData();
double asum = 0.0;
for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
asum += entry.getValue();
}
asum += data.defaultReturnValue() * (entireSize - data.size());
return asum;
}
示例6: doProcessRow
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
long entireSize = row.getEndCol() - row.getStartCol();
Long2DoubleOpenHashMap data = row.getData();
double asum = 0.0;
for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
asum += Math.abs(entry.getValue());
}
asum += Math.abs(data.defaultReturnValue()) * (entireSize - data.size());
return asum;
}
示例7: generateCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
private final Long2DoubleOpenHashMap generateCandidates(final Vector v, final boolean addToIndex) {
final Long2DoubleOpenHashMap accumulator = new Long2DoubleOpenHashMap(size);
for (Entry e : v.int2DoubleEntrySet()) {
final int dimension = e.getIntKey();
final double queryWeight = e.getDoubleValue();
PostingList list;
if ((list = idx.get(dimension)) != null) {
for (PostingEntry pe : list) {
numPostingEntries++;
final long targetID = pe.getID();
final double targetWeight = pe.getWeight();
final double additionalSimilarity = queryWeight * targetWeight;
accumulator.addTo(targetID, additionalSimilarity);
}
}
if (addToIndex) {
if (list == null) {
list = new PostingList();
idx.put(dimension, list);
}
list.add(v.timestamp(), queryWeight);
size++;
}
}
numCandidates += accumulator.size();
return accumulator;
}
示例8: verifyCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
private final Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
numSimilarities = numCandidates;
// add forgetting factor e^(-lambda*delta_T) and filter candidates < theta
for (Iterator<Long2DoubleMap.Entry> it = accumulator.long2DoubleEntrySet().iterator(); it.hasNext();) {
Long2DoubleMap.Entry e = it.next();
final long deltaT = v.timestamp() - e.getLongKey();
e.setValue(e.getDoubleValue() * forgettingFactor(lambda, deltaT));
if (Doubles.compare(e.getDoubleValue(), theta) < 0)
it.remove();
}
numMatches += accumulator.size();
return accumulator;
}
示例9: generateCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
private final Long2DoubleOpenHashMap generateCandidates(final Vector v) {
final Long2DoubleOpenHashMap accumulator = new Long2DoubleOpenHashMap();
double l2remscore = 1, // rs4
rst = 1, squaredQueryPrefixMagnitude = 1;
for (BidirectionalIterator<Entry> vecIter = v.int2DoubleEntrySet().fastIterator(v.int2DoubleEntrySet().last()); vecIter
.hasPrevious();) { // iterate over v in reverse order
final Entry e = vecIter.previous();
final int dimension = e.getIntKey();
final double queryWeight = e.getDoubleValue(); // x_j
final double rscore = l2remscore;
squaredQueryPrefixMagnitude -= queryWeight * queryWeight;
L2APPostingList list;
if ((list = idx.get(dimension)) != null) {
for (L2APPostingEntry pe : list) {
numPostingEntries++;
final long targetID = pe.id(); // y
if (accumulator.containsKey(targetID) || Double.compare(rscore, theta) >= 0) {
final double targetWeight = pe.weight(); // y_j
final double additionalSimilarity = queryWeight * targetWeight; // x_j * y_j
accumulator.addTo(targetID, additionalSimilarity); // A[y] += x_j * y_j
final double l2bound = accumulator.get(targetID) + FastMath.sqrt(squaredQueryPrefixMagnitude)
* pe.magnitude(); // A[y] + ||x'_j|| * ||y'_j||
if (Double.compare(l2bound, theta) < 0)
accumulator.remove(targetID); // prune this candidate (early verification)
}
}
rst -= queryWeight * queryWeight; // rs_t -= x_j^2
l2remscore = FastMath.sqrt(rst); // rs_4 = sqrt(rs_t)
}
}
numCandidates += accumulator.size();
return accumulator;
}
示例10: generateCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
private final Long2DoubleOpenHashMap generateCandidates(final Vector v) {
final Long2DoubleOpenHashMap accumulator = new Long2DoubleOpenHashMap();
double remscore = Vector.similarity(v, maxVectorInIndex); // rs3, enhanced remscore bound
double l2remscore = 1, // rs4
rst = 1, squaredQueryPrefixMagnitude = 1;
for (BidirectionalIterator<Entry> vecIter = v.int2DoubleEntrySet().fastIterator(v.int2DoubleEntrySet().last()); vecIter
.hasPrevious();) { // iterate over v in reverse order
final Entry e = vecIter.previous();
final int dimension = e.getIntKey();
final double queryWeight = e.getDoubleValue(); // x_j
final double rscore = Math.min(remscore, l2remscore);
squaredQueryPrefixMagnitude -= queryWeight * queryWeight;
L2APPostingList list;
if ((list = idx.get(dimension)) != null) {
for (L2APPostingEntry pe : list) {
numPostingEntries++;
final long targetID = pe.id(); // y
if (accumulator.containsKey(targetID) || Double.compare(rscore, theta) >= 0) {
final double targetWeight = pe.weight(); // y_j
final double additionalSimilarity = queryWeight * targetWeight; // x_j * y_j
accumulator.addTo(targetID, additionalSimilarity); // A[y] += x_j * y_j
final double l2bound = accumulator.get(targetID) + FastMath.sqrt(squaredQueryPrefixMagnitude)
* pe.magnitude(); // A[y] + ||x'_j|| * ||y'_j||
if (Double.compare(l2bound, theta) < 0)
accumulator.remove(targetID); // prune this candidate (early verification)
}
}
remscore -= queryWeight * maxVectorInIndex.get(dimension); // rs_3 -= x_j * \hat{c_w}
rst -= queryWeight * queryWeight; // rs_t -= x_j^2
l2remscore = FastMath.sqrt(rst); // rs_4 = sqrt(rs_t)
}
}
numCandidates += accumulator.size();
return accumulator;
}
示例11: generateCandidates
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
private Long2DoubleOpenHashMap generateCandidates(final Vector v) {
Long2DoubleOpenHashMap accumulator = new Long2DoubleOpenHashMap();
double remscore = Vector.similarity(v, maxVector);
/* candidate generation */
for (BidirectionalIterator<Entry> it = v.int2DoubleEntrySet().fastIterator(v.int2DoubleEntrySet().last()); it
.hasPrevious();) { // iterate over v in reverse order
Entry e = it.previous();
int dimension = e.getIntKey();
double queryWeight = e.getDoubleValue(); // x_j
PostingList list;
if ((list = idx.get(dimension)) != null) {
for (PostingEntry pe : list) {
numPostingEntries++;
final long targetID = pe.getID(); // y
if (accumulator.containsKey(targetID) || Double.compare(remscore, theta) >= 0) {
final double targetWeight = pe.getWeight(); // y_j
final double additionalSimilarity = queryWeight * targetWeight; // x_j * y_j
accumulator.addTo(targetID, additionalSimilarity); // A[y] += x_j * y_j
}
}
}
remscore -= queryWeight * maxVector.get(dimension);
}
numCandidates += accumulator.size();
return accumulator;
}