本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2FloatMap类的典型用法代码示例。如果您正苦于以下问题:Java Int2FloatMap类的具体用法?Java Int2FloatMap怎么用?Java Int2FloatMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Int2FloatMap类属于it.unimi.dsi.fastutil.ints包,在下文中一共展示了Int2FloatMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: filter
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Override
public TFloatVector filter(float x) {
SparseFloatVector vector = new SparseFloatVector(dim);
vector.setMatrixId(matrixId).setRowId(rowId).setClock(clock);
ObjectIterator<Int2FloatMap.Entry> iter = hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
float value = entry.getFloatValue();
if (Math.abs(value) > x) {
vector.set(entry.getIntKey(), value);
}
}
return vector;
}
开发者ID:Tencent,项目名称:angel,代码行数:17,代码来源:SparseFloatVector.java
示例2: writeTo
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Override public void writeTo(DataOutputStream output) throws IOException {
try {
lock.readLock().lock();
super.writeTo(output);
output.writeInt(hashMap.size());
ObjectIterator<Int2FloatMap.Entry> iter = hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
output.writeInt(entry.getIntKey());
output.writeFloat(entry.getFloatValue());
}
} finally {
lock.readLock().unlock();
}
}
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:ServerSparseFloatRow.java
示例3: serialize
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Override public void serialize(ByteBuf buf) {
try {
lock.readLock().lock();
super.serialize(buf);
buf.writeInt(hashMap.size());
ObjectIterator<Int2FloatMap.Entry> iter = hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
buf.writeInt(entry.getIntKey());
buf.writeFloat(entry.getFloatValue());
}
} finally {
lock.readLock().unlock();
}
}
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:ServerSparseFloatRow.java
示例4: mergeTo
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
/**
* Merge this sparse float vector split to a index/value array
* @param indexes index array
* @param values value array
* @param startPos write start position of the index/value array
* @param len write length
*/
public void mergeTo(int[] indexes, float[] values, int startPos, int len) {
try {
lock.readLock().lock();
int writeLen = len < hashMap.size() ? len : hashMap.size();
if (writeLen == 0) {
return;
}
int index = 0;
for (Int2FloatMap.Entry entry : hashMap.int2FloatEntrySet()) {
indexes[startPos + index] = entry.getIntKey();
values[startPos + index] = entry.getFloatValue();
index++;
if (index == writeLen) {
return;
}
}
} finally {
lock.readLock().unlock();
}
}
开发者ID:Tencent,项目名称:angel,代码行数:29,代码来源:ServerSparseFloatRow.java
示例5: predict
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private static double predict(final int user, final int itemI,
@Nonnull final Int2ObjectMap<Int2FloatMap> knnItems, final int excludeIndex,
@Nonnull final FloatMatrix weightMatrix) {
final Int2FloatMap kNNu = knnItems.get(user);
if (kNNu == null) {
return 0.d;
}
double pred = 0.d;
for (Int2FloatMap.Entry e : Fastutil.fastIterable(kNNu)) {
final int itemK = e.getIntKey();
if (itemK == excludeIndex) {
continue;
}
float ruk = e.getFloatValue();
pred += ruk * weightMatrix.get(itemI, itemK, 0.d);
}
return pred;
}
开发者ID:apache,项目名称:incubator-hivemall,代码行数:20,代码来源:SlimUDTF.java
示例6: replayTrain
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private void replayTrain(@Nonnull final ByteBuffer buf) {
final int itemI = buf.getInt();
final int knnSize = buf.getInt();
final Int2ObjectMap<Int2FloatMap> knnItems = new Int2ObjectOpenHashMap<>(1024);
final IntSet pairItems = new IntOpenHashSet();
for (int i = 0; i < knnSize; i++) {
int user = buf.getInt();
int ruSize = buf.getInt();
Int2FloatMap ru = new Int2FloatOpenHashMap(ruSize);
ru.defaultReturnValue(0.f);
for (int j = 0; j < ruSize; j++) {
int itemK = buf.getInt();
pairItems.add(itemK);
float ruk = buf.getFloat();
ru.put(itemK, ruk);
}
knnItems.put(user, ru);
}
for (int itemJ : pairItems) {
train(itemI, knnItems, itemJ);
}
}
开发者ID:apache,项目名称:incubator-hivemall,代码行数:26,代码来源:SlimUDTF.java
示例7: kNNentries
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Nonnull
private static Int2ObjectMap<Int2FloatMap> kNNentries(@Nonnull final Object kNNiObj,
@Nonnull final MapObjectInspector knnItemsOI,
@Nonnull final PrimitiveObjectInspector knnItemsKeyOI,
@Nonnull final MapObjectInspector knnItemsValueOI,
@Nonnull final PrimitiveObjectInspector knnItemsValueKeyOI,
@Nonnull final PrimitiveObjectInspector knnItemsValueValueOI,
@Nullable Int2ObjectMap<Int2FloatMap> knnItems, @Nonnull final MutableInt nnzKNNi) {
if (knnItems == null) {
knnItems = new Int2ObjectOpenHashMap<>(1024);
} else {
knnItems.clear();
}
int numElementOfKNNItems = 0;
for (Map.Entry<?, ?> entry : knnItemsOI.getMap(kNNiObj).entrySet()) {
int user = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), knnItemsKeyOI);
Int2FloatMap ru = int2floatMap(knnItemsValueOI.getMap(entry.getValue()),
knnItemsValueKeyOI, knnItemsValueValueOI);
knnItems.put(user, ru);
numElementOfKNNItems += ru.size();
}
nnzKNNi.setValue(numElementOfKNNItems);
return knnItems;
}
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:SlimUDTF.java
示例8: int2floatMap
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Nonnull
private static Int2FloatMap int2floatMap(@Nonnull final Map<?, ?> map,
@Nonnull final PrimitiveObjectInspector keyOI,
@Nonnull final PrimitiveObjectInspector valueOI) {
final Int2FloatMap result = new Int2FloatOpenHashMap(map.size());
result.defaultReturnValue(0.f);
for (Map.Entry<?, ?> entry : map.entrySet()) {
float v = PrimitiveObjectInspectorUtils.getFloat(entry.getValue(), valueOI);
if (v == 0.f) {
continue;
}
int k = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), keyOI);
result.put(k, v);
}
return result;
}
开发者ID:apache,项目名称:incubator-hivemall,代码行数:19,代码来源:SlimUDTF.java
示例9: nonZeroNumber
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Override
public long nonZeroNumber() {
long ret = 0;
if (hashMap != null) {
ObjectIterator<Int2FloatMap.Entry> iter = this.hashMap.int2FloatEntrySet().fastIterator();
while (iter.hasNext()) {
if (iter.next().getFloatValue() != 0)
ret++;
}
}
return ret;
}
开发者ID:Tencent,项目名称:angel,代码行数:14,代码来源:SparseFloatVector.java
示例10: plus
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private TVector plus(DenseFloatVector other) {
DenseFloatVector vec = new DenseFloatVector(other);
ObjectIterator<Int2FloatMap.Entry> iter = this.hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
vec.plusBy(entry.getIntKey(), entry.getFloatValue());
}
return vec;
}
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:SparseFloatVector.java
示例11: plusBy
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private TVector plusBy(SparseFloatVector other) {
ObjectIterator<Int2FloatMap.Entry> iter = other.hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
this.hashMap.addTo(entry.getIntKey(), entry.getFloatValue());
}
return this;
}
开发者ID:Tencent,项目名称:angel,代码行数:10,代码来源:SparseFloatVector.java
示例12: squaredNorm
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Override
public double squaredNorm() {
ObjectIterator<Int2FloatMap.Entry> iter = hashMap.int2FloatEntrySet().iterator();
double sum = 0;
while (iter.hasNext()) {
float v = iter.next().getFloatValue();
sum += v * v;
}
return sum;
}
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:SparseFloatVector.java
示例13: times
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Override
public TFloatVector times(float x) {
SparseFloatVector vector = new SparseFloatVector(this.dim);
ObjectIterator<Int2FloatMap.Entry> iter = this.hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
vector.hashMap.put(entry.getIntKey(), x * entry.getFloatValue());
}
return vector;
}
开发者ID:Tencent,项目名称:angel,代码行数:14,代码来源:SparseFloatVector.java
示例14: timesBy
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
@Override
public TFloatVector timesBy(float x) {
ObjectIterator<Int2FloatMap.Entry> iter = this.hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
this.hashMap.put(entry.getIntKey(), x * entry.getFloatValue());
}
return this;
}
开发者ID:Tencent,项目名称:angel,代码行数:12,代码来源:SparseFloatVector.java
示例15: dot
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private double dot(SparseFloatVector other) {
double ret = 0.0;
ObjectIterator<Int2FloatMap.Entry> iter = other.hashMap.int2FloatEntrySet().fastIterator();
while (iter.hasNext()) {
Int2FloatMap.Entry entry = iter.next();
ret += values[entry.getIntKey()] * entry.getFloatValue();
}
return ret;
}
开发者ID:Tencent,项目名称:angel,代码行数:10,代码来源:DenseFloatVector.java
示例16: plus
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private TFloatVector plus(SparseFloatVector other) {
DenseFloatVector vector = new DenseFloatVector(this);
ObjectIterator<Int2FloatMap.Entry> iter = other.hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
vector.values[entry.getIntKey()] += entry.getFloatValue();
}
return vector;
}
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:DenseFloatVector.java
示例17: plusBy
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private TFloatVector plusBy(SparseFloatVector other) {
ObjectIterator<Int2FloatMap.Entry> iter = other.hashMap.int2FloatEntrySet().fastIterator();
while (iter.hasNext()) {
Int2FloatMap.Entry entry = iter.next();
values[entry.getIntKey()] += entry.getFloatValue();
}
return this;
}
开发者ID:Tencent,项目名称:angel,代码行数:10,代码来源:DenseFloatVector.java
示例18: plus
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private TIntDoubleVector plus(SparseFloatVector other, double x) {
DenseDoubleVector vector = this.clone();
ObjectIterator<Int2FloatMap.Entry> iter = other.hashMap.int2FloatEntrySet().iterator();
Int2FloatMap.Entry entry = null;
while(iter.hasNext()) {
entry = iter.next();
vector.values[entry.getIntKey()] += entry.getFloatValue() * x;
}
return vector;
}
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:DenseDoubleVector.java
示例19: plusBy
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private TIntDoubleVector plusBy(SparseFloatVector other, double x) {
ObjectIterator<Int2FloatMap.Entry> iter = other.hashMap.int2FloatEntrySet().fastIterator();
while (iter.hasNext()) {
Int2FloatMap.Entry entry = iter.next();
values[entry.getIntKey()] += entry.getFloatValue() * x;
}
return this;
}
开发者ID:Tencent,项目名称:angel,代码行数:9,代码来源:DenseDoubleVector.java
示例20: plus
import it.unimi.dsi.fastutil.ints.Int2FloatMap; //导入依赖的package包/类
private SparseDoubleVector plus(SparseFloatVector other, double x) {
SparseDoubleVector vector = (SparseDoubleVector) this.clone();
ObjectIterator<Int2FloatMap.Entry> iter = other.hashMap.int2FloatEntrySet().fastIterator();
Int2FloatMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
vector.hashMap.addTo(entry.getIntKey(), entry.getFloatValue() * x);
}
return vector;
}
开发者ID:Tencent,项目名称:angel,代码行数:12,代码来源:SparseDoubleVector.java
注:本文中的it.unimi.dsi.fastutil.ints.Int2FloatMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论