Search in sources :

Example 16 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.

the class IntLongVector method min.

public long min() {
    IntLongVectorStorage idstorage = (IntLongVectorStorage) storage;
    if (idstorage.size() == 0)
        return 0;
    long minval = Long.MAX_VALUE;
    if (idstorage.isSparse()) {
        LongIterator iter = idstorage.valueIterator();
        while (iter.hasNext()) {
            long val = iter.nextLong();
            if (val < minval) {
                minval = val;
            }
        }
    } else {
        for (long val : idstorage.getValues()) {
            if (val < minval) {
                minval = val;
            }
        }
    }
    return minval;
}
Also used : IntLongVectorStorage(com.tencent.angel.ml.math2.storage.IntLongVectorStorage) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Example 17 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.

the class IntLongVector method numZeros.

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

Example 18 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.

the class LongLongVector method numZeros.

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

Example 19 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.

the class LongLongVector method std.

public double std() {
    LongLongVectorStorage dstorage = (LongLongVectorStorage) storage;
    if (dstorage.size() == 0)
        return 0;
    double sumval = 0.0;
    double sumval2 = 0.0;
    if (dstorage.isSparse()) {
        LongIterator iter = dstorage.valueIterator();
        while (iter.hasNext()) {
            double val = iter.nextLong();
            sumval += val;
            sumval2 += val * val;
        }
    } else {
        for (double val : dstorage.getValues()) {
            sumval += val;
            sumval2 += val * val;
        }
    }
    sumval /= getDim();
    sumval2 /= getDim();
    return Math.sqrt(sumval2 - sumval * sumval);
}
Also used : LongLongVectorStorage(com.tencent.angel.ml.math2.storage.LongLongVectorStorage) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Example 20 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.

the class LongVector method sum.

@Override
public double sum() {
    LongVectorStorage lstorage = (LongVectorStorage) storage;
    double sumval = 0.0;
    if (lstorage.isSparse()) {
        LongIterator iter = lstorage.valueIterator();
        while (iter.hasNext()) {
            sumval += iter.nextLong();
        }
    } else {
        for (double val : lstorage.getValues()) {
            sumval += val;
        }
    }
    return sumval;
}
Also used : LongVectorStorage(com.tencent.angel.ml.math2.storage.LongVectorStorage) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Aggregations

LongIterator (it.unimi.dsi.fastutil.longs.LongIterator)20 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)5 LongLongVectorStorage (com.tencent.angel.ml.math2.storage.LongLongVectorStorage)5 LongVectorStorage (com.tencent.angel.ml.math2.storage.LongVectorStorage)2 HyperLogLog (com.facebook.airlift.stats.cardinality.HyperLogLog)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1 LongRBTreeSet (it.unimi.dsi.fastutil.longs.LongRBTreeSet)1 LongSortedSet (it.unimi.dsi.fastutil.longs.LongSortedSet)1 ChunkPos (net.minecraft.world.level.ChunkPos)1 ForcedChunksSavedData (net.minecraft.world.level.ForcedChunksSavedData)1