Search in sources :

Example 36 with IntIntVectorStorage

use of com.tencent.angel.ml.math2.storage.IntIntVectorStorage in project angel by Tencent.

the class IntIntVector method numZeros.

public int numZeros() {
    IntIntVectorStorage dstorage = (IntIntVectorStorage) storage;
    if (dstorage.size() == 0)
        return (int) dim;
    int numZero = 0;
    if (dstorage.isSparse()) {
        IntIterator iter = dstorage.valueIterator();
        while (iter.hasNext()) {
            if (iter.nextInt() != 0) {
                numZero += 1;
            }
        }
    } else {
        for (int val : dstorage.getValues()) {
            if (val != 0) {
                numZero += 1;
            }
        }
    }
    return (int) getDim() - numZero;
}
Also used : IntIntVectorStorage(com.tencent.angel.ml.math2.storage.IntIntVectorStorage) IntIterator(it.unimi.dsi.fastutil.ints.IntIterator)

Aggregations

IntIntVectorStorage (com.tencent.angel.ml.math2.storage.IntIntVectorStorage)34 Int2IntMap (it.unimi.dsi.fastutil.ints.Int2IntMap)24 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)22 IntIntVector (com.tencent.angel.ml.math2.vector.IntIntVector)17 IntDoubleVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage)14 IntFloatVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatVectorStorage)14 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)14 IntIntSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntIntSortedVectorStorage)12 LongDoubleVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleVectorStorage)12 LongFloatVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatVectorStorage)12 LongIntVectorStorage (com.tencent.angel.ml.math2.storage.LongIntVectorStorage)12 LongLongVectorStorage (com.tencent.angel.ml.math2.storage.LongLongVectorStorage)12 Storage (com.tencent.angel.ml.math2.storage.Storage)12 CompIntIntVector (com.tencent.angel.ml.math2.vector.CompIntIntVector)12 AngelException (com.tencent.angel.exception.AngelException)11 IntIntSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntIntSparseVectorStorage)11 IntDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSortedVectorStorage)8 IntDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSparseVectorStorage)8 IntFloatSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSortedVectorStorage)8 IntFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSparseVectorStorage)8