use of com.tencent.angel.ml.math.vector.SparseDoubleVector in project angel by Tencent.
the class DenseDoubleMatrixTest method plusBy3.
@Test
public void plusBy3() throws Exception {
double[][] value = { { 1.0, 2.0 }, { 3.0, 4.0 } };
DenseDoubleMatrix mat = new DenseDoubleMatrix(2, 2, value);
SparseDoubleVector vec = new SparseDoubleVector(2);
vec.setRowId(0);
vec.set(0, 1.0);
SparseDoubleVector vec_1 = new SparseDoubleVector(2);
vec_1.setRowId(1);
vec_1.set(1, 1.0);
mat.plusBy(vec);
mat.plusBy(vec_1);
assertEquals(2.0, mat.get(0, 0));
assertEquals(2.0, mat.get(0, 1));
assertEquals(3.0, mat.get(1, 0));
assertEquals(5.0, mat.get(1, 1));
}
Aggregations