org.apache.mahout.math.Vector.mergeUpdates()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.mahout.math.Vector.mergeUpdates()方法的一些代码示例,展示了Vector.mergeUpdates()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.mergeUpdates()方法的具体详情如下:
包路径:org.apache.mahout.math.Vector
类名称:Vector
方法名:mergeUpdates

Vector.mergeUpdates介绍

[英]Merge a set of (index, value) pairs into the vector.
[中]将一组(索引、值)对合并到向量中。

代码示例

代码示例来源:origin: apache/mahout

/**
 * Merge a set of (index, value) pairs into the vector.
 *
 * @param updates an ordered mapping of indices to values to be merged in.
 */
@Override
public void mergeUpdates(OrderedIntDoubleMapping updates) {
 delegate.mergeUpdates(updates);
}

代码示例来源:origin: apache/mahout

/**
 * Merge a set of (index, value) pairs into the vector.
 *
 * @param updates an ordered mapping of indices to values to be merged in.
 */
@Override
public void mergeUpdates(OrderedIntDoubleMapping updates) {
 delegate.mergeUpdates(updates);
}

代码示例来源:origin: apache/mahout

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  Iterator<Vector.Element> xi = x.all().iterator();
  Iterator<Vector.Element> yi = y.all().iterator();
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  while (xi.hasNext() && yi.hasNext()) {
   Element xe = xi.next();
   updates.set(xe.index(), f.apply(xe.get(), yi.next().get()));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: apache/mahout

/**
 * Used internally by assign() to update multiple indices and values at once.
 * Only really useful for sparse vectors (especially SequentialAccessSparseVector).
 * <p>
 * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector.
 *
 * @param updates a mapping of indices to values to merge in the vector.
 */
@Override
public void mergeUpdates(OrderedIntDoubleMapping updates) {
 for (int i = 0; i < updates.getNumMappings(); ++i) {
  updates.setIndexAt(i, pivot[updates.indexAt(i)]);
 }
 vector.mergeUpdates(updates);
}

代码示例来源:origin: apache/mahout

/**
  * Used internally by assign() to update multiple indices and values at once.
  * Only really useful for sparse vectors (especially SequentialAccessSparseVector).
  * <p>
  * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector.
  *
  * @param updates a mapping of indices to values to merge in the vector.
  */
 @Override
 public void mergeUpdates(OrderedIntDoubleMapping updates) {
  for (int i = 0; i < updates.getNumMappings(); ++i) {
   updates.setIndexAt(i, updates.indexAt(i) + offset);
  }
  vector.mergeUpdates(updates);
 }
}

代码示例来源:origin: apache/mahout

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (int i = 0; i < x.size(); ++i) {
   updates.set(i, f.apply(x.getQuick(i), y.getQuick(i)));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: apache/mahout

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (Element ye : y.nonZeroes()) {
   updates.set(ye.index(), f.apply(x.getQuick(ye.index()), ye.get()));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: apache/mahout

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (Element xe : x.all()) {
   updates.set(xe.index(), f.apply(xe.get(), y.getQuick(xe.index())));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: apache/mahout

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (Element ye : y.all()) {
   updates.set(ye.index(), f.apply(x.getQuick(ye.index()), ye.get()));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: apache/mahout

x.mergeUpdates(updates);
return x;

代码示例来源:origin: apache/mahout

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OpenIntHashSet visited = new OpenIntHashSet();
  for (Element xe : x.nonZeroes()) {
   xe.set(f.apply(xe.get(), y.getQuick(xe.index())));
   visited.add(xe.index());
  }
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (Element ye : y.nonZeroes()) {
   if (!visited.contains(ye.index())) {
    updates.set(ye.index(), f.apply(x.getQuick(ye.index()), ye.get()));
   }
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: org.apache.mahout/mahout-math

/**
 * Merge a set of (index, value) pairs into the vector.
 *
 * @param updates an ordered mapping of indices to values to be merged in.
 */
@Override
public void mergeUpdates(OrderedIntDoubleMapping updates) {
 delegate.mergeUpdates(updates);
}

代码示例来源:origin: org.apache.mahout/mahout-math

/**
 * Merge a set of (index, value) pairs into the vector.
 *
 * @param updates an ordered mapping of indices to values to be merged in.
 */
@Override
public void mergeUpdates(OrderedIntDoubleMapping updates) {
 delegate.mergeUpdates(updates);
}

代码示例来源:origin: org.apache.mahout/mahout-math

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  Iterator<Vector.Element> xi = x.all().iterator();
  Iterator<Vector.Element> yi = y.all().iterator();
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  while (xi.hasNext() && yi.hasNext()) {
   Element xe = xi.next();
   updates.set(xe.index(), f.apply(xe.get(), yi.next().get()));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: org.apache.mahout/mahout-math

/**
 * Used internally by assign() to update multiple indices and values at once.
 * Only really useful for sparse vectors (especially SequentialAccessSparseVector).
 * <p>
 * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector.
 *
 * @param updates a mapping of indices to values to merge in the vector.
 */
@Override
public void mergeUpdates(OrderedIntDoubleMapping updates) {
 for (int i = 0; i < updates.getNumMappings(); ++i) {
  updates.setIndexAt(i, pivot[updates.indexAt(i)]);
 }
 vector.mergeUpdates(updates);
}

代码示例来源:origin: org.apache.mahout/mahout-math

/**
  * Used internally by assign() to update multiple indices and values at once.
  * Only really useful for sparse vectors (especially SequentialAccessSparseVector).
  * <p>
  * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector.
  *
  * @param updates a mapping of indices to values to merge in the vector.
  */
 @Override
 public void mergeUpdates(OrderedIntDoubleMapping updates) {
  for (int i = 0; i < updates.getNumMappings(); ++i) {
   updates.setIndexAt(i, updates.indexAt(i) + offset);
  }
  vector.mergeUpdates(updates);
 }
}

代码示例来源:origin: org.apache.mahout/mahout-math

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (int i = 0; i < x.size(); ++i) {
   updates.set(i, f.apply(x.getQuick(i), y.getQuick(i)));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: org.apache.mahout/mahout-math

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (Element ye : y.all()) {
   updates.set(ye.index(), f.apply(x.getQuick(ye.index()), ye.get()));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: org.apache.mahout/mahout-math

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (Element ye : y.nonZeroes()) {
   updates.set(ye.index(), f.apply(x.getQuick(ye.index()), ye.get()));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

代码示例来源:origin: org.apache.mahout/mahout-math

@Override
 public Vector assign(Vector x, Vector y, DoubleDoubleFunction f) {
  OrderedIntDoubleMapping updates = new OrderedIntDoubleMapping(false);
  for (Element xe : x.all()) {
   updates.set(xe.index(), f.apply(xe.get(), y.getQuick(xe.index())));
  }
  x.mergeUpdates(updates);
  return x;
 }
}

相关文章