use of it.unimi.dsi.fastutil.longs.LongArrayList in project angel by Tencent.
the class CooLongDoubleMatrix method getCol.
@Override
public Vector getCol(int idx) {
LongArrayList cols = new LongArrayList();
DoubleArrayList data = new DoubleArrayList();
for (int i = 0; i < colIndices.length; i++) {
if (colIndices[i] == idx) {
cols.add(rowIndices[i]);
data.add(values[i]);
}
}
LongDoubleSparseVectorStorage storage = new LongDoubleSparseVectorStorage(shape[0], cols.toLongArray(), data.toDoubleArray());
return new LongDoubleVector(getMatrixId(), 0, getClock(), shape[0], storage);
}
use of it.unimi.dsi.fastutil.longs.LongArrayList in project angel by Tencent.
the class GetNodes method gatherNodes.
private long[] gatherNodes(IntFloatVector ranks, long offset) {
if (ranks.getStorage().isSparse()) {
ObjectIterator<Int2FloatMap.Entry> it = ranks.getStorage().entryIterator();
LongArrayList ret = new LongArrayList();
while (it.hasNext()) {
Int2FloatMap.Entry entry = it.next();
int key = entry.getIntKey();
ret.add(key + offset);
}
return ret.toLongArray();
} else {
float[] vals = ranks.getStorage().getValues();
LongArrayList ret = new LongArrayList();
for (int i = 0; i < vals.length; i++) if (vals[i] != 0.0)
ret.add(i + offset);
return ret.toLongArray();
}
}
Aggregations