本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry.getDoubleValue方法的典型用法代码示例。如果您正苦于以下问题:Java Entry.getDoubleValue方法的具体用法?Java Entry.getDoubleValue怎么用?Java Entry.getDoubleValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry
的用法示例。
在下文中一共展示了Entry.getDoubleValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToIndex
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
private Vector addToIndex(final Vector v) {
double pscore = 0;
Vector residual = new Vector(v.timestamp());
for (Entry e : v.int2DoubleEntrySet()) {
int dimension = e.getIntKey();
double weight = e.getDoubleValue();
pscore += weight * maxVector.get(dimension);
if (Double.compare(pscore, theta) >= 0) {
PostingList list;
if ((list = idx.get(dimension)) == null) {
list = new PostingList();
idx.put(dimension, list);
}
list.add(v.timestamp(), weight);
size++;
// v.remove(dimension);
} else {
residual.put(dimension, weight);
}
}
return residual;
}
示例2: testIterationOrder
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
@Test
public void testIterationOrder() {
Vector v = new Vector();
v.put(0, 0);
v.put(1, 1);
v.put(2, 2);
v.put(3, 3);
v.put(4, 4);
BidirectionalIterator<Int2DoubleMap.Entry> it = v.int2DoubleEntrySet().fastIterator(v.int2DoubleEntrySet().last());
// for (int i = 0; i < v.size(); i++) {
int i = 4;
while (it.hasPrevious()) {
Entry e = it.previous();
int lastKey = e.getIntKey();
double lastValue = e.getDoubleValue();
assertEquals(i, lastKey);
assertEquals(i, lastValue, Double.MIN_NORMAL);
i--;
}
assertEquals(5, v.size());
assertEquals(0, v.int2DoubleEntrySet().first().getIntKey());
assertEquals(4, v.int2DoubleEntrySet().last().getIntKey());
}
示例3: generateCandidates
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的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;
}
示例4: generateCandidates
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的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;
}
示例5: addToIndex
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
private final Vector addToIndex(final Vector v) {
double bt = 0, b3 = 0, pscore = 0;
boolean psSaved = false;
Vector residual = new Vector(v.timestamp());
for (Entry e : v.int2DoubleEntrySet()) {
int dimension = e.getIntKey();
double weight = e.getDoubleValue();
pscore = b3;
bt += weight * weight;
b3 = FastMath.sqrt(bt);
if (Double.compare(b3, theta) >= 0) {
if (!psSaved) {
assert (!ps.containsKey(v.timestamp()));
ps.put(v.timestamp(), pscore);
psSaved = true;
}
L2APPostingList list;
if ((list = idx.get(dimension)) == null) {
list = new L2APPostingList();
idx.put(dimension, list);
}
list.add(v.timestamp(), weight, pscore);
size++;
} else {
residual.put(dimension, weight);
}
}
return residual;
}
示例6: generateCandidates
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的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;
}
示例7: addToIndex
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
private final Vector addToIndex(final Vector v) {
double b1 = 0, bt = 0, b3 = 0, pscore = 0;
boolean psSaved = false;
Vector residual = new Vector(v.timestamp());
for (Entry e : v.int2DoubleEntrySet()) {
int dimension = e.getIntKey();
double weight = e.getDoubleValue();
pscore = Math.min(b1, b3);
b1 += weight * maxVectorInWindow.get(dimension);
bt += weight * weight;
b3 = FastMath.sqrt(bt);
if (Double.compare(Math.min(b1, b3), theta) >= 0) {
if (!psSaved) {
assert (!ps.containsKey(v.timestamp()));
ps.put(v.timestamp(), pscore);
psSaved = true;
}
L2APPostingList list;
if ((list = idx.get(dimension)) == null) {
list = new L2APPostingList();
idx.put(dimension, list);
}
list.add(v.timestamp(), weight, pscore);
size++;
} else {
residual.put(dimension, weight);
}
}
maxVectorInIndex.updateMaxByDimension(v);
return residual;
}
示例8: generateCandidates
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的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;
}
示例9: addToIndex
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
private final Vector addToIndex(final Vector v) {
double bt = 0, b3 = 0, pscore = 0;
boolean psSaved = false;
final Vector residual = new Vector(v.timestamp());
for (Entry e : v.int2DoubleEntrySet()) {
final int dimension = e.getIntKey();
final double weight = e.getDoubleValue();
pscore = b3;
bt += weight * weight;
b3 = FastMath.sqrt(bt);
if (Double.compare(b3, theta) >= 0) { // bound larger than threshold, start indexing
if (!psSaved) {
ps.put(v.timestamp(), pscore);
psSaved = true;
}
StreamingL2APPostingList list;
if ((list = idx.get(dimension)) == null) {
list = new StreamingL2APPostingList();
idx.put(dimension, list);
}
list.add(v.timestamp(), weight, pscore);
size++;
} else {
residual.put(dimension, weight);
}
}
return residual;
}
示例10: addToIndex
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
private final Vector addToIndex(final Vector v) {
double b1 = 0, bt = 0, b3 = 0, pscore = 0;
boolean psSaved = false;
final Vector residual = new Vector(v.timestamp());
for (Entry e : v.int2DoubleEntrySet()) {
final int dimension = e.getIntKey();
final double weight = e.getDoubleValue();
pscore = Math.min(b1, b3);
b1 += weight * maxVector.get(dimension);
bt += weight * weight;
b3 = FastMath.sqrt(bt);
if (Double.compare(Math.min(b1, b3), theta) >= 0) { // bound larger than threshold, start indexing
if (!psSaved) {
ps.put(v.timestamp(), pscore);
psSaved = true;
}
StreamingL2APPostingList list;
if ((list = idx.get(dimension)) == null) {
list = new StreamingL2APPostingList();
idx.put(dimension, list);
}
list.add(v.timestamp(), weight, pscore);
size++;
} else {
residual.put(dimension, weight);
}
}
return residual;
}
示例11: generateCandidates
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
private final void generateCandidates(final Vector v) {
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;
StreamingL2APPostingList list;
if ((list = idx.get(dimension)) != null) {
for (StreamingL2APPostingListIterator listIter = list.reverseIterator(); listIter.hasPrevious();) {
final L2APPostingEntry pe = listIter.previous();
final long targetID = pe.id(); // y
// time filtering
final long deltaT = v.timestamp() - targetID;
if (Doubles.compare(deltaT, tau) > 0) {
listIter.next(); // back off one position
size -= listIter.nextIndex(); // update index size before cutting
listIter.cutHead(); // prune the head
break;
}
numPostingEntries++;
final double ff = forgettingFactor(lambda, deltaT);
// forgetting factor applied directly to the l2prefix bound
if (accumulator.containsKey(targetID) || Double.compare(rscore * ff, 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||
// forgetting factor applied directly to the l2sum bound
if (Double.compare(l2bound * ff, 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();
}
示例12: generateCandidates
import it.unimi.dsi.fastutil.ints.Int2DoubleMap.Entry; //导入方法依赖的package包/类
private final void generateCandidates(final Vector v) {
double remscore = maxVectorInIndex.simimarityFF(v); // rs3, enhanced remscore bound with addded forgetting factor per dimension
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
squaredQueryPrefixMagnitude -= queryWeight * queryWeight;
StreamingL2APPostingList list;
if ((list = idx.get(dimension)) != null) {
for (StreamingL2APPostingListIterator listIter = list.iterator(); listIter.hasNext();) {
final L2APPostingEntry pe = listIter.next();
final long targetID = pe.id(); // y
// time filtering
numPostingEntries++;
final long deltaT = v.timestamp() - targetID;
if (Doubles.compare(deltaT, tau) > 0) {
listIter.remove();
size--;
continue;
}
final double ff = forgettingFactor(lambda, deltaT);
// forgetting factor applied directly to the l2prefix bounds
final double rscore = Math.min(remscore, l2remscore * ff);
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||
// forgetting factor applied directly to the l2bound
if (Double.compare(l2bound * ff, theta) < 0)
accumulator.remove(targetID); // prune this candidate (early verification)
}
}
final double dimFF = maxVectorInIndex.dimensionFF(dimension, v.timestamp());
remscore -= queryWeight * maxVectorInIndex.get(dimension) * dimFF; // 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();
}