use of com.tencent.angel.ml.math2.storage.DoubleVectorStorage 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.DoubleVectorStorage 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.DoubleVectorStorage in project angel by Tencent.
the class AggrFuncTest method testPull.
@Test
public void testPull() throws InvalidParameterException, InterruptedException, ExecutionException {
GetFunc func = new Pull(w2Client.getMatrixId(), 1);
double[] result = ((DoubleVectorStorage) (((GetRowResult) w2Client.get(func)).getRow()).getStorage()).getValues();
for (int i = 0; i < dim; i++) {
Assert.assertEquals(result[i], localArray1[i], delta);
}
}
Aggregations