use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.
the class IntLongVector method min.
public long min() {
IntLongVectorStorage idstorage = (IntLongVectorStorage) storage;
if (idstorage.size() == 0)
return 0;
long minval = Long.MAX_VALUE;
if (idstorage.isSparse()) {
LongIterator iter = idstorage.valueIterator();
while (iter.hasNext()) {
long val = iter.nextLong();
if (val < minval) {
minval = val;
}
}
} else {
for (long val : idstorage.getValues()) {
if (val < minval) {
minval = val;
}
}
}
return minval;
}
use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.
the class IntLongVector method numZeros.
public int numZeros() {
IntLongVectorStorage dstorage = (IntLongVectorStorage) storage;
if (dstorage.size() == 0)
return (int) dim;
int numZero = 0;
if (dstorage.isSparse()) {
LongIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
if (iter.nextLong() != 0) {
numZero += 1;
}
}
} else {
for (long val : dstorage.getValues()) {
if (val != 0) {
numZero += 1;
}
}
}
return (int) getDim() - numZero;
}
use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.
the class LongLongVector method numZeros.
public long numZeros() {
LongLongVectorStorage dstorage = (LongLongVectorStorage) storage;
if (dstorage.size() == 0)
return (long) dim;
long numZero = 0;
if (dstorage.isSparse()) {
LongIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
if (iter.nextLong() != 0) {
numZero += 1;
}
}
} else {
for (long val : dstorage.getValues()) {
if (val != 0) {
numZero += 1;
}
}
}
return (long) getDim() - numZero;
}
use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.
the class LongLongVector method std.
public double std() {
LongLongVectorStorage dstorage = (LongLongVectorStorage) storage;
if (dstorage.size() == 0)
return 0;
double sumval = 0.0;
double sumval2 = 0.0;
if (dstorage.isSparse()) {
LongIterator iter = dstorage.valueIterator();
while (iter.hasNext()) {
double val = iter.nextLong();
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.longs.LongIterator in project angel by Tencent.
the class LongVector method sum.
@Override
public double sum() {
LongVectorStorage lstorage = (LongVectorStorage) storage;
double sumval = 0.0;
if (lstorage.isSparse()) {
LongIterator iter = lstorage.valueIterator();
while (iter.hasNext()) {
sumval += iter.nextLong();
}
} else {
for (double val : lstorage.getValues()) {
sumval += val;
}
}
return sumval;
}
Aggregations