use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class LongDoubleVector method std.
public double std() {
LongDoubleVectorStorage dstorage = (LongDoubleVectorStorage) storage;
if (dstorage.size() == 0)
return 0;
double sumval = 0.0;
double sumval2 = 0.0;
if (dstorage.isSparse()) {
DoubleIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
double val = iter.nextDouble();
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);
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class DoubleVector method sum.
@Override
public double sum() {
DoubleVectorStorage dstorage = (DoubleVectorStorage) storage;
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;
}
}
return sumval;
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class DoubleVector method norm.
@Override
public double norm() {
DoubleVectorStorage dstorage = (DoubleVectorStorage) storage;
double sumval2 = 0.0;
if (dstorage.isSparse()) {
DoubleIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
double val = iter.nextDouble();
sumval2 += val * val;
}
} else {
for (double val : dstorage.getValues()) {
sumval2 += val * val;
}
}
return Math.sqrt(sumval2);
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class IntDoubleVector method std.
public double std() {
IntDoubleVectorStorage dstorage = (IntDoubleVectorStorage) storage;
if (dstorage.size() == 0)
return 0;
double sumval = 0.0;
double sumval2 = 0.0;
if (dstorage.isSparse()) {
DoubleIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
double val = iter.nextDouble();
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);
}
use of it.unimi.dsi.fastutil.doubles.DoubleIterator in project angel by Tencent.
the class IntDoubleVector method average.
public double average() {
IntDoubleVectorStorage dstorage = (IntDoubleVectorStorage) 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;
}
Aggregations