use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class IntFloatVector method numZeros.
public int numZeros() {
IntFloatVectorStorage dstorage = (IntFloatVectorStorage) storage;
if (dstorage.size() == 0)
return (int) dim;
int 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 (int) getDim() - numZero;
}
use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class IntFloatVector method max.
public float max() {
IntFloatVectorStorage idstorage = (IntFloatVectorStorage) storage;
if (idstorage.size() == 0)
return 0;
float maxval = Float.MIN_VALUE;
if (idstorage.isSparse()) {
FloatIterator iter = idstorage.valueIterator();
while (iter.hasNext()) {
float val = iter.nextFloat();
if (val > maxval) {
maxval = val;
}
}
} else {
for (float val : idstorage.getValues()) {
if (val > maxval) {
maxval = val;
}
}
}
return maxval;
}
use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class IntFloatVector method average.
public double average() {
IntFloatVectorStorage dstorage = (IntFloatVectorStorage) 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 LongFloatVector method max.
public float max() {
LongFloatVectorStorage idstorage = (LongFloatVectorStorage) storage;
if (idstorage.size() == 0)
return 0;
float maxval = Float.MIN_VALUE;
if (idstorage.isSparse()) {
FloatIterator iter = idstorage.valueIterator();
while (iter.hasNext()) {
float val = iter.nextFloat();
if (val > maxval) {
maxval = val;
}
}
} else {
for (float val : idstorage.getValues()) {
if (val > maxval) {
maxval = val;
}
}
}
return maxval;
}
use of it.unimi.dsi.fastutil.floats.FloatIterator in project angel by Tencent.
the class LongFloatVector method std.
public double std() {
LongFloatVectorStorage dstorage = (LongFloatVectorStorage) 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