• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Long2DoubleMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Long2DoubleMap类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了Long2DoubleMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:SparseLongKeyDoubleVector.java


示例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;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:23,代码来源:SparseLongKeyDoubleVector.java


示例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);
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:17,代码来源:SparseLongKeyDoubleVector.java


示例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;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:17,代码来源:SparseLongKeyDoubleVector.java


示例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();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:ServerSparseDoubleLongKeyRow.java


示例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();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:33,代码来源:ServerSparseDoubleLongKeyRow.java


示例7: TopSecondDegreeByCountRequest

import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入依赖的package包/类
/**
 * @param queryNode                 is the query node for running TopSecondDegreeByCount
 * @param leftSeedNodesWithWeight   is the set of seed nodes and their weights to use for
 *                                  TopSecondDegreeByCount
 * @param toBeFiltered              is the set of RHS nodes to be filtered from the output
 * @param maxSocialProofTypeSize    is the number of social proof types in the graph
 * @param socialProofTypes          Social proof types, masked into a byte array
 * @param maxRightNodeAgeInMillis   Max right node age in millisecond, such as tweet age
 * @param maxEdgeAgeInMillis        Max edge age in millisecond such as reply edge age
 * @param resultFilterChain         Filter chain to be applied after recommendation computation
 */
public TopSecondDegreeByCountRequest(
  long queryNode,
  Long2DoubleMap leftSeedNodesWithWeight,
  LongSet toBeFiltered,
  int maxSocialProofTypeSize,
  byte[] socialProofTypes,
  long maxRightNodeAgeInMillis,
  long maxEdgeAgeInMillis,
  ResultFilterChain resultFilterChain) {
  super(queryNode, toBeFiltered, socialProofTypes);
  this.leftSeedNodesWithWeight = leftSeedNodesWithWeight;
  this.maxSocialProofTypeSize = maxSocialProofTypeSize;
  this.maxRightNodeAgeInMillis = maxRightNodeAgeInMillis;
  this.maxEdgeAgeInMillis = maxEdgeAgeInMillis;
  this.resultFilterChain = resultFilterChain;
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:28,代码来源:TopSecondDegreeByCountRequest.java


示例8: TopSecondDegreeByCountRequestForMoment

import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入依赖的package包/类
/**
 * @param queryNode                 is the query node for running TopSecondDegreeByCountRequestForMoment
 * @param leftSeedNodesWithWeight   is the set of seed nodes and their weights to use for calculation
 * @param toBeFiltered              is the set of RHS nodes to be filtered from the output
 * @param maxNumResults             is the maximum number of recommendations returned in the response
 * @param maxNumSocialProofs        is the maximum number of social proofs per recommendation
 * @param maxSocialProofTypeSize    is the number of social proof types in the graph
 * @param minUserPerSocialProof     for each social proof, require a minimum number of users to be valid
 * @param socialProofTypes          is the list of valid social proofs, (i.e. Create, Like etc)
 * @param maxRightNodeAgeInMillis   Max right node age in millisecond, such as moment age
 * @param maxEdgeAgeInMillis        Max edge age in millisecond such as like edge age
 * @param resultFilterChain         is the chain of filters to be applied
 */
public TopSecondDegreeByCountRequestForMoment(
  long queryNode,
  Long2DoubleMap leftSeedNodesWithWeight,
  LongSet toBeFiltered,
  int maxNumResults,
  int maxNumSocialProofs,
  int maxSocialProofTypeSize,
  Map<Byte, Integer> minUserPerSocialProof,
  byte[] socialProofTypes,
  long maxRightNodeAgeInMillis,
  long maxEdgeAgeInMillis,
  ResultFilterChain resultFilterChain) {
  super(queryNode, leftSeedNodesWithWeight, toBeFiltered, maxSocialProofTypeSize,
      socialProofTypes, maxRightNodeAgeInMillis, maxEdgeAgeInMillis, resultFilterChain);
  this.maxNumResults = maxNumResults;
  this.maxNumSocialProofs = maxNumSocialProofs;
  this.minUserPerSocialProof = minUserPerSocialProof;
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:32,代码来源:TopSecondDegreeByCountRequestForMoment.java


示例9: TopSecondDegreeByCountRequestForUser

import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入依赖的package包/类
/**
 * @param queryNode                 is the query node for running TopSecondDegreeByCountForUser
 * @param leftSeedNodesWithWeight   is the set of seed nodes and their weights to use for calculation
 * @param toBeFiltered              is the list of users to be excluded from recommendations
 * @param maxNumResults             is the maximum number of recommendations returned in the response
 * @param maxNumSocialProofs        is the maximum number of social proofs per recommendation
 * @param maxSocialProofTypeSize    is the number of social proof types in the graph
 * @param minUserPerSocialProof     for each social proof, require a minimum number of users to be valid
 * @param socialProofTypes          is the list of valid social proofs, (i.e, Follow, Mention, Mediatag)
 * @param maxRightNodeAgeInMillis   is the max right node age in millisecond, such as tweet age
 * @param maxEdgeAgeInMillis        is the max edge age in millisecond such as reply edge age
 * @param resultFilterChain         is the chain of filters to be applied
 */
public TopSecondDegreeByCountRequestForUser(
  long queryNode,
  Long2DoubleMap leftSeedNodesWithWeight,
  LongSet toBeFiltered,
  int maxNumResults,
  int maxNumSocialProofs,
  int maxSocialProofTypeSize,
  Map<Byte, Integer> minUserPerSocialProof,
  byte[] socialProofTypes,
  long maxRightNodeAgeInMillis,
  long maxEdgeAgeInMillis,
  ResultFilterChain resultFilterChain) {
  super(queryNode, leftSeedNodesWithWeight, toBeFiltered, maxSocialProofTypeSize,
      socialProofTypes, maxRightNodeAgeInMillis, maxEdgeAgeInMillis, resultFilterChain);
  this.maxNumResults = maxNumResults;
  this.maxNumSocialProofs = maxNumSocialProofs;
  this.minUserPerSocialProof = minUserPerSocialProof;
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:32,代码来源:TopSecondDegreeByCountRequestForUser.java


示例10: 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);
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:33,代码来源:RandomMultiGraphNeighbors.java


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


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


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


示例14: 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;
    }
  };
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:26,代码来源:LongDoubleHashMapEdges.java


示例15: 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;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:CompLongKeyDoubleVector.java


示例16: 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;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:12,代码来源:CompLongKeyDoubleVector.java


示例17: 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;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:12,代码来源:SparseLongKeyDoubleVector.java


示例18: 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;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:SparseLongKeyDoubleVector.java


示例19: nonZeroNumber

import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入依赖的package包/类
@Override public long nonZeroNumber() {
  long counter = 0L;
  ObjectIterator<Long2DoubleMap.Entry> iter =
    indexToValueMap.long2DoubleEntrySet().fastIterator();
  while (iter.hasNext()) {
    if(iter.next().getDoubleValue() > 0)
      counter++;
  }

  return counter;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:12,代码来源:SparseLongKeyDoubleVector.java


示例20: squaredNorm

import it.unimi.dsi.fastutil.longs.Long2DoubleMap; //导入依赖的package包/类
@Override public double squaredNorm() {
  ObjectIterator<Long2DoubleMap.Entry> iter = indexToValueMap.long2DoubleEntrySet().iterator();
  double sum = 0;
  while (iter.hasNext()) {
    double v = iter.next().getDoubleValue();
    sum += v * v;
  }
  return sum;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:10,代码来源:SparseLongKeyDoubleVector.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpellingProblem类代码示例发布时间:2022-05-22
下一篇:
Java AllWindowFunction类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap