Search in sources :

Example 6 with GetFunc

use of com.tencent.angel.ml.matrix.psf.get.base.GetFunc in project angel by Tencent.

the class AggrFuncTest method testNnz.

@Test
public void testNnz() throws InvalidParameterException, InterruptedException, ExecutionException {
    GetFunc func = new Nnz(w2Client.getMatrixId(), 1);
    double result = ((ScalarAggrResult) w2Client.get(func)).getResult();
    int count = 0;
    for (double x : localArray1) {
        if (Math.abs(x - 0.0) > delta)
            count++;
    }
    Assert.assertEquals((int) result, count);
}
Also used : GetFunc(com.tencent.angel.ml.matrix.psf.get.base.GetFunc) ScalarAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)

Example 7 with GetFunc

use of com.tencent.angel.ml.matrix.psf.get.base.GetFunc in project angel by Tencent.

the class AggrFuncTest method testMin.

@Test
public void testMin() throws InvalidParameterException, InterruptedException, ExecutionException {
    GetFunc func = new Min(w2Client.getMatrixId(), 1);
    double result = ((ScalarAggrResult) w2Client.get(func)).getResult();
    double min = Double.MAX_VALUE;
    for (double x : localArray1) {
        if (min > x)
            min = x;
    }
    Assert.assertEquals(result, min, delta);
}
Also used : GetFunc(com.tencent.angel.ml.matrix.psf.get.base.GetFunc) ScalarAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)

Example 8 with GetFunc

use of com.tencent.angel.ml.matrix.psf.get.base.GetFunc in project angel by Tencent.

the class AggrFuncTest method testNrm2.

@Test
public void testNrm2() throws InvalidParameterException, InterruptedException, ExecutionException {
    GetFunc func = new Nrm2(w2Client.getMatrixId(), 1);
    double result = ((ScalarAggrResult) w2Client.get(func)).getResult();
    double nrm2 = 0;
    for (double x : localArray1) {
        nrm2 += x * x;
    }
    nrm2 = Math.sqrt(nrm2);
    Assert.assertEquals(result, nrm2, delta);
}
Also used : GetFunc(com.tencent.angel.ml.matrix.psf.get.base.GetFunc) ScalarAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)

Example 9 with GetFunc

use of com.tencent.angel.ml.matrix.psf.get.base.GetFunc in project angel by Tencent.

the class AggrFuncTest method testAmin.

@Test
public void testAmin() throws InvalidParameterException, InterruptedException, ExecutionException {
    GetFunc func = new Amin(w2Client.getMatrixId(), 1);
    double result = ((ScalarAggrResult) w2Client.get(func)).getResult();
    double min = Double.MAX_VALUE;
    for (double x : localArray1) {
        if (min > Math.abs(x))
            min = Math.abs(x);
    }
    Assert.assertEquals(result, min, delta);
}
Also used : GetFunc(com.tencent.angel.ml.matrix.psf.get.base.GetFunc) ScalarAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)

Example 10 with GetFunc

use of com.tencent.angel.ml.matrix.psf.get.base.GetFunc in project angel by Tencent.

the class AggrFuncTest method testAsum.

@Test
public void testAsum() throws InvalidParameterException, InterruptedException, ExecutionException {
    GetFunc func = new Asum(w2Client.getMatrixId(), 1);
    double result = ((ScalarAggrResult) w2Client.get(func)).getResult();
    double sum = 0.0;
    for (double x : localArray1) {
        sum += Math.abs(x);
    }
    Assert.assertEquals(result, sum, delta);
}
Also used : GetFunc(com.tencent.angel.ml.matrix.psf.get.base.GetFunc) ScalarAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)

Aggregations

GetFunc (com.tencent.angel.ml.matrix.psf.get.base.GetFunc)11 ScalarAggrResult (com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)9 DenseDoubleVector (com.tencent.angel.ml.math.vector.DenseDoubleVector)1 Pull (com.tencent.angel.ml.matrix.psf.aggr.Pull)1 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)1 GetRowResult (com.tencent.angel.ml.matrix.psf.get.single.GetRowResult)1 ByteBuf (io.netty.buffer.ByteBuf)1