Search in sources :

Example 6 with LongIterator

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

the class LongVector method norm.

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

Example 7 with LongIterator

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

the class IntLongVector method average.

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

Example 8 with LongIterator

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

the class IntLongVector method std.

public double std() {
    IntLongVectorStorage dstorage = (IntLongVectorStorage) 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 : IntLongVectorStorage(com.tencent.angel.ml.math2.storage.IntLongVectorStorage) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Example 9 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project SpongeCommon by SpongePowered.

the class SpongeWorldManager method updateForcedChunks.

private void updateForcedChunks(final ServerLevel world, final ServerChunkCache serverChunkProvider) {
    final ForcedChunksSavedData forcedChunksSaveData = world.getDataStorage().get(ForcedChunksSavedData::new, "chunks");
    if (forcedChunksSaveData != null) {
        final LongIterator longIterator = forcedChunksSaveData.getChunks().iterator();
        while (longIterator.hasNext()) {
            final long i = longIterator.nextLong();
            final ChunkPos forceChunkPos = new ChunkPos(i);
            serverChunkProvider.updateChunkForced(forceChunkPos, true);
        }
    }
}
Also used : ForcedChunksSavedData(net.minecraft.world.level.ForcedChunksSavedData) ChunkPos(net.minecraft.world.level.ChunkPos) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Example 10 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project geode by apache.

the class DiskInitFile method saveDrfIds.

private void saveDrfIds() {
    for (LongIterator i = this.drfIds.iterator(); i.hasNext(); ) {
        writeIFRecord(IFREC_DRF_CREATE, i.next());
        this.ifLiveRecordCount++;
        this.ifTotalRecordCount++;
    }
}
Also used : 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