use of com.tencent.angel.ml.math.vector.TIntVector in project angel by Tencent.
the class DenseIntMatrixTest method plusBy3.
@Test
public void plusBy3() throws Exception {
int[][] value = { { 1, 2 }, { 3, 4 } };
DenseIntMatrix mat = new DenseIntMatrix(2, 2, value);
TIntVector vec = new DenseIntVector(2, new int[] { 1, 2 });
vec.setRowId(0);
mat.plusBy(vec);
assertEquals(2, mat.get(0, 0));
assertEquals(4, mat.get(0, 1));
assertEquals(3, mat.get(1, 0));
assertEquals(4, mat.get(1, 1));
DenseIntMatrix mat_1 = new DenseIntMatrix(2, 2);
mat_1.plusBy(vec);
assertEquals(1, mat_1.get(0, 0));
assertEquals(2, mat_1.get(0, 1));
assertEquals(0, mat_1.get(1, 0));
assertEquals(0, mat_1.get(1, 1));
}
use of com.tencent.angel.ml.math.vector.TIntVector in project angel by Tencent.
the class DenseIntMatrixTest method getTIntVector.
@Test
public void getTIntVector() throws Exception {
int[][] value = { { 1, 2 }, { 3, 4 } };
DenseIntMatrix mat = new DenseIntMatrix(2, 2, value);
TIntVector vec = (TIntVector) mat.getRow(0);
assertEquals(1, vec.get(0));
assertEquals(2, vec.get(1));
DenseIntMatrix mat_1 = new DenseIntMatrix(2, 2);
mat_1.plusBy(vec);
TIntVector vec_1 = (TIntVector) mat_1.getRow(1);
assertEquals(0, vec_1.get(0));
assertEquals(0, vec_1.get(1));
}
Aggregations