Пример #1
0
static void test_inc_x(size_t i, const double *dx, const size_t *jdx, size_t ndx)
{
	size_t j, k;

	if (jdx) {
		for (k = 0; k < ndx; k++) {
			X[i * P + jdx[k]] += dx[k];
		}
	} else if (ndx) {
		assert(ndx == P);

		for (j = 0; j < P; j++) {
			X[i * P + j] += dx[j];
		}
	}
	recompute();

	mlogit_set_x(&MLOGIT, i, 0, P, X + i * P);
	//print_error("\tx...");
	test_x();
	//print_error("ok\n\tmean...");
	test_mean();
	//print_error("ok\n\tcov...");
	test_cov();
	//print_error("ok\n");
}
int main (void)
{
  test_c ('?');
  test_d_i (0xdeadbeef, 0xdeadbeefL);
  test_x ('?', 0xdead, 0xdeadbeef);

  test_a_double (0.0);
  test_e_double (0.0);
  test_f_double (0.0);
  test_g_double (0.0);

  test_a_long_double ();
  test_e_long_double (0.0);
  test_f_long_double ();
  test_g_long_double ();

  test_s (0);

  test_n ();

  test_percent ();

  if (nfails)
    {
      __builtin_printf ("%u out of %u tests failed\n", nfails, ntests);
      __builtin_abort ();
    }

  return 0;
}
Пример #3
0
int main(){
    std::vector<std::vector<double> >test_x(3);
    test_x[0].push_back(3);test_x[0].push_back(3);
    test_x[1].push_back(4);test_x[1].push_back(3);
    test_x[2].push_back(1);test_x[2].push_back(1);
    std::vector<int> test_y(3);
    test_y[0] = 1;
    test_y[1] = 1;
    test_y[2] = -1;
   
    DualPerception *model = new DualPerception(1, 1.0, 100);
    model->train(test_x,test_y);
    model->printPerceptronModel();
}