use of it.unimi.dsi.fastutil.floats.FloatArrayList in project angel by Tencent.
the class CooLongFloatMatrix method getCol.
@Override
public Vector getCol(int idx) {
LongArrayList cols = new LongArrayList();
FloatArrayList data = new FloatArrayList();
for (int i = 0; i < colIndices.length; i++) {
if (colIndices[i] == idx) {
cols.add(rowIndices[i]);
data.add(values[i]);
}
}
LongFloatSparseVectorStorage storage = new LongFloatSparseVectorStorage(shape[0], cols.toLongArray(), data.toFloatArray());
return new LongFloatVector(getMatrixId(), 0, getClock(), shape[0], storage);
}
use of it.unimi.dsi.fastutil.floats.FloatArrayList in project angel by Tencent.
the class CsrFloatMatrix method getCol.
@Override
public Vector getCol(int idx) {
IntArrayList cols = new IntArrayList();
FloatArrayList data = new FloatArrayList();
int[] rows = new int[indices.length];
int i = 0;
int j = 0;
while (i < indptr.length - 1 && j < indptr.length - 1) {
int r = indptr[i + 1] - indptr[i];
for (int p = j; p < j + r; p++) {
rows[p] = i;
}
if (r != 0) {
j++;
}
i++;
}
for (int id = 0; id < indices.length; id++) {
if (indices[id] == idx) {
cols.add(rows[id]);
data.add(values[id]);
}
}
IntFloatSparseVectorStorage storage = new IntFloatSparseVectorStorage(shape[0], cols.toIntArray(), data.toFloatArray());
return new IntFloatVector(getMatrixId(), 0, getClock(), shape[0], storage);
}
Aggregations