use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class IntDoubleVector method numZeros.
public int numZeros() {
IntDoubleVectorStorage dstorage = (IntDoubleVectorStorage) storage;
if (dstorage.size() == 0)
return (int) dim;
int numZero = 0;
if (dstorage.isSparse()) {
DoubleIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
if (iter.nextDouble() != 0) {
numZero += 1;
}
}
} else {
for (double val : dstorage.getValues()) {
if (val != 0) {
numZero += 1;
}
}
}
return (int) getDim() - numZero;
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class LongDoubleVector method average.
public double average() {
LongDoubleVectorStorage dstorage = (LongDoubleVectorStorage) storage;
if (dstorage.size() == 0)
return 0;
double sumval = 0.0;
if (dstorage.isSparse()) {
DoubleIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
sumval += iter.nextDouble();
}
} else {
for (double val : dstorage.getValues()) {
sumval += val;
}
}
sumval /= getDim();
return sumval;
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class LongDoubleVector method max.
public double max() {
LongDoubleVectorStorage idstorage = (LongDoubleVectorStorage) 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;
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class LongDoubleVector method numZeros.
public long numZeros() {
LongDoubleVectorStorage dstorage = (LongDoubleVectorStorage) storage;
if (dstorage.size() == 0)
return (long) dim;
long numZero = 0;
if (dstorage.isSparse()) {
DoubleIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
if (iter.nextDouble() != 0) {
numZero += 1;
}
}
} else {
for (double val : dstorage.getValues()) {
if (val != 0) {
numZero += 1;
}
}
}
return (long) getDim() - numZero;
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class LongDoubleVector method min.
public double min() {
LongDoubleVectorStorage idstorage = (LongDoubleVectorStorage) 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;
}
Aggregations