use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class LongFloatVector method numZeros.
public long numZeros() {
LongFloatVectorStorage dstorage = (LongFloatVectorStorage) storage;
if (dstorage.size() == 0)
return (long) dim;
long numZero = 0;
if (dstorage.isSparse()) {
FloatIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
if (iter.nextFloat() != 0) {
numZero += 1;
}
}
} else {
for (float val : dstorage.getValues()) {
if (val != 0) {
numZero += 1;
}
}
}
return (long) getDim() - numZero;
}
use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class LongFloatVector method min.
public float min() {
LongFloatVectorStorage idstorage = (LongFloatVectorStorage) storage;
if (idstorage.size() == 0)
return 0;
float minval = Float.MAX_VALUE;
if (idstorage.isSparse()) {
FloatIterator iter = idstorage.valueIterator();
while (iter.hasNext()) {
float val = iter.nextFloat();
if (val < minval) {
minval = val;
}
}
} else {
for (float val : idstorage.getValues()) {
if (val < minval) {
minval = val;
}
}
}
return minval;
}
use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class LongFloatVector method average.
public double average() {
LongFloatVectorStorage dstorage = (LongFloatVectorStorage) storage;
if (dstorage.size() == 0)
return 0;
double sumval = 0.0;
if (dstorage.isSparse()) {
FloatIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
sumval += iter.nextFloat();
}
} else {
for (double val : dstorage.getValues()) {
sumval += val;
}
}
sumval /= getDim();
return sumval;
}
use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class IntFloatVector method min.
public float min() {
IntFloatVectorStorage idstorage = (IntFloatVectorStorage) storage;
if (idstorage.size() == 0)
return 0;
float minval = Float.MAX_VALUE;
if (idstorage.isSparse()) {
FloatIterator iter = idstorage.valueIterator();
while (iter.hasNext()) {
float val = iter.nextFloat();
if (val < minval) {
minval = val;
}
}
} else {
for (float val : idstorage.getValues()) {
if (val < minval) {
minval = val;
}
}
}
return minval;
}
use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class IntFloatVector method std.
public double std() {
IntFloatVectorStorage dstorage = (IntFloatVectorStorage) storage;
if (dstorage.size() == 0)
return 0;
double sumval = 0.0;
double sumval2 = 0.0;
if (dstorage.isSparse()) {
FloatIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
double val = iter.nextFloat();
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);
}
Aggregations