Search in sources :

Example 11 with DoubleIterator

use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.

the class IntDoubleVector method max.

public double max() {
    IntDoubleVectorStorage idstorage = (IntDoubleVectorStorage) storage;
    if (idstorage.size() == 0)
        return 0;
    double maxval = Double.MIN_VALUE;
    if (idstorage.isSparse()) {
        DoubleIterator iter = idstorage.valueIterator();
        while (iter.hasNext()) {
            double val = iter.nextDouble();
            if (val > maxval) {
                maxval = val;
            }
        }
    } else {
        for (double val : idstorage.getValues()) {
            if (val > maxval) {
                maxval = val;
            }
        }
    }
    return maxval;
}
Also used : IntDoubleVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage) DoubleIterator(it.unimi.dsi.fastutil.doubles.DoubleIterator)

Example 12 with DoubleIterator

use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.

the class IntDoubleVector method min.

public double min() {
    IntDoubleVectorStorage idstorage = (IntDoubleVectorStorage) storage;
    if (idstorage.size() == 0)
        return 0;
    double minval = Double.MAX_VALUE;
    if (idstorage.isSparse()) {
        DoubleIterator iter = idstorage.valueIterator();
        while (iter.hasNext()) {
            double val = iter.nextDouble();
            if (val < minval) {
                minval = val;
            }
        }
    } else {
        for (double val : idstorage.getValues()) {
            if (val < minval) {
                minval = val;
            }
        }
    }
    return minval;
}
Also used : IntDoubleVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage) DoubleIterator(it.unimi.dsi.fastutil.doubles.DoubleIterator)

Aggregations

DoubleIterator (it.unimi.dsi.fastutil.doubles.DoubleIterator)12 IntDoubleVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage)5 LongDoubleVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleVectorStorage)5 DoubleVectorStorage (com.tencent.angel.ml.math2.storage.DoubleVectorStorage)2