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


Java Int2DoubleOpenHashMap.size方法代码示例

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


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

示例1: dot

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
private double dot(SparseDoubleVector other) {
  double ret = 0.0;

  Int2DoubleOpenHashMap smallMap = this.hashMap;
  Int2DoubleOpenHashMap largeMap = other.hashMap;

  if (smallMap.size() > largeMap.size()) {
    smallMap = other.hashMap;
    largeMap = this.hashMap;
  }

  ObjectIterator<Int2DoubleMap.Entry> iter = smallMap.int2DoubleEntrySet().fastIterator();

  Int2DoubleMap.Entry entry = null;
  while (iter.hasNext()) {
    entry = iter.next();
    if (largeMap.containsKey(entry.getIntKey())) {
      ret += entry.getDoubleValue() * largeMap.get(entry.getIntKey());
    }
  }
  return ret;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:23,代码来源:SparseDoubleVector.java

示例2: newNumberVector

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
@Override
public SparseFloatVector newNumberVector(Int2DoubleOpenHashMap dvalues, int maxdim) {
  int[] indexes = new int[dvalues.size()];
  float[] values = new float[dvalues.size()];
  // Import and sort the indexes
  ObjectIterator<Int2DoubleMap.Entry> iter = dvalues.int2DoubleEntrySet().fastIterator();
  for(int i = 0; iter.hasNext(); i++) {
    indexes[i] = iter.next().getIntKey();
  }
  Arrays.sort(indexes);
  // Import the values accordingly
  for(int i = 0; i < dvalues.size(); i++) {
    values[i] = (float) dvalues.get(indexes[i]);
  }
  return new SparseFloatVector(indexes, values, maxdim);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:17,代码来源:SparseFloatVector.java

示例3: SparseByteVector

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
/**
 * Create a SparseByteVector consisting of double values according to the
 * specified mapping of indices and values.
 *
 * @param values the values to be set as values of the real vector
 * @param dimensionality the dimensionality of this feature vector
 * @throws IllegalArgumentException if the given dimensionality is too small
 *         to cover the given values (i.e., the maximum index of any value not
 *         zero is bigger than the given dimensionality)
 */
public SparseByteVector(Int2DoubleOpenHashMap values, int dimensionality) throws IllegalArgumentException {
  if(values.size() > dimensionality) {
    throw new IllegalArgumentException("values.size() > dimensionality!");
  }

  this.indexes = new int[values.size()];
  this.values = new byte[values.size()];
  // Import and sort the indexes
  {
    ObjectIterator<Int2DoubleMap.Entry> iter = values.int2DoubleEntrySet().fastIterator();
    for(int i = 0; iter.hasNext(); i++) {
      this.indexes[i] = iter.next().getIntKey();
    }
    Arrays.sort(this.indexes);
  }
  // Import the values accordingly
  {
    for(int i = 0; i < values.size(); i++) {
      this.values[i] = (byte) values.get(this.indexes[i]);
    }
  }
  this.dimensionality = dimensionality;
  final int maxdim = getMaxDim();
  if(maxdim > dimensionality) {
    throw new IllegalArgumentException("Given dimensionality " + dimensionality + " is too small w.r.t. the given values (occurring maximum: " + maxdim + ").");
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:38,代码来源:SparseByteVector.java

示例4: SparseShortVector

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
/**
 * Create a SparseShortVector consisting of double values according to the
 * specified mapping of indices and values.
 *
 * @param values the values to be set as values of the real vector
 * @param dimensionality the dimensionality of this feature vector
 * @throws IllegalArgumentException if the given dimensionality is too small
 *         to cover the given values (i.e., the maximum index of any value not
 *         zero is bigger than the given dimensionality)
 */
public SparseShortVector(Int2DoubleOpenHashMap values, int dimensionality) throws IllegalArgumentException {
  if(values.size() > dimensionality) {
    throw new IllegalArgumentException("values.size() > dimensionality!");
  }

  this.indexes = new int[values.size()];
  this.values = new short[values.size()];
  // Import and sort the indexes
  {
    ObjectIterator<Int2DoubleMap.Entry> iter = values.int2DoubleEntrySet().fastIterator();
    for(int i = 0; iter.hasNext(); i++) {
      this.indexes[i] = iter.next().getIntKey();
    }
    Arrays.sort(this.indexes);
  }
  // Import the values accordingly
  {
    for(int i = 0; i < values.size(); i++) {
      this.values[i] = (short) values.get(this.indexes[i]);
    }
  }
  this.dimensionality = dimensionality;
  final int maxdim = getMaxDim();
  if(maxdim > dimensionality) {
    throw new IllegalArgumentException("Given dimensionality " + dimensionality + " is too small w.r.t. the given values (occurring maximum: " + maxdim + ").");
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:38,代码来源:SparseShortVector.java

示例5: SparseIntegerVector

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
/**
 * Create a SparseIntegerVector consisting of double values according to the
 * specified mapping of indices and values.
 *
 * @param values the values to be set as values of the real vector
 * @param dimensionality the dimensionality of this feature vector
 * @throws IllegalArgumentException if the given dimensionality is too small
 *         to cover the given values (i.e., the maximum index of any value not
 *         zero is bigger than the given dimensionality)
 */
public SparseIntegerVector(Int2DoubleOpenHashMap values, int dimensionality) throws IllegalArgumentException {
  if(values.size() > dimensionality) {
    throw new IllegalArgumentException("values.size() > dimensionality!");
  }

  this.indexes = new int[values.size()];
  this.values = new int[values.size()];
  // Import and sort the indexes
  {
    ObjectIterator<Int2DoubleMap.Entry> iter = values.int2DoubleEntrySet().fastIterator();
    for(int i = 0; iter.hasNext(); i++) {
      this.indexes[i] = iter.next().getIntKey();
    }
    Arrays.sort(this.indexes);
  }
  // Import the values accordingly
  {
    for(int i = 0; i < values.size(); i++) {
      this.values[i] = (int) values.get(this.indexes[i]);
    }
  }
  this.dimensionality = dimensionality;
  final int maxdim = getMaxDim();
  if(maxdim > dimensionality) {
    throw new IllegalArgumentException("Given dimensionality " + dimensionality + " is too small w.r.t. the given values (occurring maximum: " + maxdim + ").");
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:38,代码来源:SparseIntegerVector.java

示例6: SparseDoubleVector

import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; //导入方法依赖的package包/类
/**
 * Create a SparseDoubleVector consisting of double values according to the
 * specified mapping of indices and values.
 *
 * @param values the values to be set as values of the real vector
 * @param dimensionality the dimensionality of this feature vector
 * @throws IllegalArgumentException if the given dimensionality is too small
 *         to cover the given values (i.e., the maximum index of any value not
 *         zero is bigger than the given dimensionality)
 */
public SparseDoubleVector(Int2DoubleOpenHashMap values, int dimensionality) throws IllegalArgumentException {
  if(values.size() > dimensionality) {
    throw new IllegalArgumentException("values.size() > dimensionality!");
  }

  this.indexes = new int[values.size()];
  this.values = new double[values.size()];
  // Import and sort the indexes
  {
    ObjectIterator<Int2DoubleMap.Entry> iter = values.int2DoubleEntrySet().fastIterator();
    for(int i = 0; iter.hasNext(); i++) {
      this.indexes[i] = iter.next().getIntKey();
    }
    Arrays.sort(this.indexes);
  }
  // Import the values accordingly
  {
    for(int i = 0; i < values.size(); i++) {
      this.values[i] = values.get(this.indexes[i]);
    }
  }
  this.dimensionality = dimensionality;
  final int maxdim = getMaxDim();
  if(maxdim > dimensionality) {
    throw new IllegalArgumentException("Given dimensionality " + dimensionality + " is too small w.r.t. the given values (occurring maximum: " + maxdim + ").");
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:38,代码来源:SparseDoubleVector.java


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