public void TestSetters() { SparseMatrix m2 = SparseMatrixFactory.CreateMatrix(10, 100); Assert.Equal(m2.RowCount(), 10); Model m = new Model(); m.nr_class = 10; m.nr_feature = 12; Assert.Equal(10, m.nr_class); Assert.Equal(12, m.nr_feature); Parameter p = new Parameter(); p.eps = 0.01e-12; p.nr_weight = 10; p.weight = new double[p.nr_weight]; p.weight_label = new int[p.nr_weight]; p.solver_type = SOLVER_TYPE.L2R_LR_DUAL; p.init_sol = new double[100]; p.init_sol[0] = 130.09229; p.p = 0.123029; p.C = 1.20299; m.param = p; Assert.Equal(p.eps, m.param.eps); Assert.Equal(p.C, m.param.C); Assert.Equal(p.init_sol[0], m.param.init_sol[0]); Assert.Equal(p.p, m.param.p); Assert.Equal(p.nr_weight, m.param.nr_weight); Assert.Equal(p.solver_type, m.param.solver_type); p.eps = 1309; p.init_sol[0] = 999; Assert.NotEqual(p.eps, m.param.eps); Assert.NotEqual(p.init_sol[0], m.param.init_sol[0]); double[] w = { 1.0, 2.0, 3.0 }; m.w = w; Assert.Equal(w[0], m.w[0]); m.w[0] = 5.0; Assert.NotEqual(w[0], m.w[0]); w[0] = 5.0; Assert.Equal(w[0], m.w[0]); int[] labels = { 1, 2, 3, 4, 5, 6 }; m.label = labels; Assert.Equal(labels[1], m.label[1]); m.label[1] = 9; Assert.NotEqual(labels[1], m.label[1]); labels[1] = 9; Assert.Equal(labels[1], m.label[1]); }
public void EmptyMatrixCreationAndCheck() { // CHeck Matrix Factory SparseMatrix mat = SparseMatrixFactory.CreateMatrix(10, 100); Assert.Equal(mat.RowCount(), 10); Assert.Equal(mat.ColCount(), 100); Assert.Equal(mat.At(0, 0), 0.0D); Assert.Throws <ArgumentOutOfRangeException>(() => mat.At(11, 11)); Assert.Throws <ArgumentOutOfRangeException>(() => mat.At(-1, 11)); Assert.Throws <ArgumentOutOfRangeException>(() => mat.At(0, 101)); Assert.Throws <ArgumentOutOfRangeException>(() => mat.At(11, -1)); }