use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class LongLongVector method min.
public long min() {
LongLongVectorStorage idstorage = (LongLongVectorStorage) 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 com.tencent.angel.ml.math2.storage.Storage 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);
}
use of com.tencent.angel.ml.math2.storage.Storage 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 com.tencent.angel.ml.math2.storage.Storage 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 com.tencent.angel.ml.math2.storage.Storage 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);
}
Aggregations