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


Java Long2DoubleOpenHashMap.addTo方法代码示例

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


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

示例1: doUpdate

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, double[] scalars) {
  double scalar = scalars[0];
  Long2DoubleOpenHashMap from = rows[0].getData();
  Long2DoubleOpenHashMap to = from.clone();
  to.defaultReturnValue(scalar);

  for (Map.Entry<Long, Double> entry: to.long2DoubleEntrySet()) {
    to.addTo(entry.getKey(), scalar);
  }

  rows[1].setIndex2ValueMap(to);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:14,代码来源:AddS.java

示例2: doUpdate

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows) {
  Long2DoubleOpenHashMap from1 = rows[0].getIndex2ValueMap();
  Long2DoubleOpenHashMap from2 = rows[1].getIndex2ValueMap();

  Long2DoubleOpenHashMap to = from1.clone();
  to.defaultReturnValue(from1.defaultReturnValue() + from2.defaultReturnValue());
  for (Map.Entry<Long, Double> entry: from2.long2DoubleEntrySet()) {
    to.addTo(entry.getKey(), entry.getValue());
  }
  rows[2].setIndex2ValueMap(to);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:Add.java

示例3: mergeIndexValueMap

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入方法依赖的package包/类
/**
 * Merge a Long2DoubleOpenHashMap to this vector partition
 * @param index2ValueMap
 */
public void mergeIndexValueMap(Long2DoubleOpenHashMap index2ValueMap) {
  try {
    lock.writeLock().lock();
    for (Map.Entry<Long, Double> entry: index2ValueMap.long2DoubleEntrySet()) {
      index2ValueMap.addTo(entry.getKey(), entry.getValue());
    }
  } finally {
    lock.writeLock().unlock();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:15,代码来源:ServerSparseDoubleLongKeyRow.java

示例4: 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;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:28,代码来源:INVIndex.java

示例5: 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;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:36,代码来源:L2Index.java

示例6: 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;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:38,代码来源:L2APIndex.java

示例7: 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;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:29,代码来源:APIndex.java


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