Search in sources :

Example 36 with LongArrayList

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);
}
Also used : LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) LongDoubleSparseVectorStorage(com.tencent.angel.ml.math2.storage.LongDoubleSparseVectorStorage) DoubleArrayList(it.unimi.dsi.fastutil.doubles.DoubleArrayList)

Example 37 with LongArrayList

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();
    }
}
Also used : LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Int2FloatMap(it.unimi.dsi.fastutil.ints.Int2FloatMap)

Aggregations

LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)37 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)3 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)3 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)3 LongList (it.unimi.dsi.fastutil.longs.LongList)3 LongOpenHashSet (it.unimi.dsi.fastutil.longs.LongOpenHashSet)3 IOException (java.io.IOException)3 List (java.util.List)3 Block (com.facebook.presto.spi.block.Block)2 Type (com.facebook.presto.spi.type.Type)2 Supplier (com.google.common.base.Supplier)2 LongFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatSparseVectorStorage)2 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)2 FloatArrayList (it.unimi.dsi.fastutil.floats.FloatArrayList)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 BinaryDecoder (co.cask.cdap.common.io.BinaryDecoder)1