Exemplo n.º 1
0
int
hitlist_init(void)
{
	var_t *hitlist;
	ht_t *config;
	ht_pos_t pos;
	var_t *v;

	hitlist = cf_get(VT_TABLE, HITLIST_NAME, NULL);
	if (hitlist == NULL)
	{
		log_notice("hitlist_init: no lists configured");
		return 0;
	}

	hitlists = sht_create(BUCKETS, free);
	if (hitlists == NULL)
	{
		log_die(EX_SOFTWARE, "hitlist_init: sht_create failed");
	}

	config = hitlist->v_data;
	ht_start(config, &pos);
	while ((v = ht_next(config, &pos)))
	{
		if (hitlist_register(v->v_name))
		{
			log_error("hitlist_init: hitlist_register failed");
			return -1;
		}
		
	}

	return 0;
}
Exemplo n.º 2
0
Arquivo: cf_test.c Projeto: blynn/frac
int main() {
  mpz_t z, z1;
  mpz_init(z);
  mpz_init(z1);
  cf_t a, b;
  a = cf_new_const(count_fn);
  b = cf_new_const(count_int_fn);
  for (int i = 0; i < 100; i++) {
    cf_get(z, a);
    EXPECT(!mpz_cmp_ui(z, i));
    cf_get(z, b);
    EXPECT(!mpz_cmp_ui(z, i));
  }
  cf_free(a);
  cf_free(b);
  mpz_clear(z);
  mpz_clear(z1);
  return 0;
}
Exemplo n.º 3
0
Arquivo: newton.c Projeto: blynn/frac
// Finds smallest root greater than given lower bound.
// Assumes there exists exactly one root with this property.
// (Impossible to solve equations if roots have same integer part at
// the moment. Don't do that.)
// TODO: Rewrite so you choose if you want smaller or greater root.
// or so it returns both solutions in an array.
static void *newton(cf_t cf) {
  newton_data_ptr nd = cf_data(cf);
  abc_t p;
  abc_init(p);
  abc_set_coeff(p, nd->a);
  cf_t x = nd->x;
  mpz_t z, z0, z1, one, pow2, t0, t1, t2;
  mpz_init(z); mpz_init(z0); mpz_init(z1); mpz_init(pow2);
  mpz_init(t0); mpz_init(t1); mpz_init(t2);
  mpz_init(one);
  mpz_set_ui(one, 1);

  void move_right() {
    cf_get(z, x);
    mpz_mul(t0, z, p->b1);
    mpz_add(t0, t0, p->b0);
    mpz_set(p->b0, p->b1);
    mpz_set(p->b1, t0);

    mpz_mul(t0, z, p->a1);  mpz_mul(t1, z, p->c1);
    mpz_add(t0, t0, p->a0); mpz_add(t1, t1, p->c0);
    mpz_set(p->a0, p->a1);  mpz_set(p->c0, p->c1);
    mpz_set(p->a1, t0);     mpz_set(p->c1, t1);
  }