Esempio n. 1
0
File: hs.c Progetto: NetSys/sts
static void
vec_isect (struct hs_vec *a, const struct hs_vec *b, int len)
{
  struct hs_vec v = vec_isect_a (a, b, len);
  vec_destroy (a);
  *a = v;
}
Esempio n. 2
0
File: vec.c Progetto: FredFoonly/poe
void vec_copy(struct vec_t* dst, const struct vec_t* src)
{
  TRACE_ENTER;
  vec_destroy(dst);
  vec_initfrom(dst, src);
  TRACE_EXIT;
}
Esempio n. 3
0
File: vec.c Progetto: FredFoonly/poe
void vec_free(struct vec_t* v)
{
  TRACE_ENTER;
  vec_destroy(v);
  free(v);
  TRACE_EXIT;
}
Esempio n. 4
0
void
rism_rdf (State *dom, Vec g,
          const real a[3],        /* center */
          int n, const real r[n], /* radial mesh */
          int m,                  /* quadrature order */
          real rdf[n])            /* out */
{
  const ProblemData *PD = dom->PD;

  /* Prepare Fourier coefficients.  Only needed for trigonometric
     interpolation: */
  local Vec g_fft = NULL;
  if (!trilinear)
    {
      g_fft = vec_create (dom->dc);

      MatMult (dom->fft_mat, g, g_fft);
      /* Do not VecScale (g_fft, volume_element (PD)), the
         interpolation code assumes that ... */
    }

  /* Coordinates  and weights of  spherical quadrature.  Only mm  <= m
     points are valid: */
  real x[m][3], w[m];

  const int mm = genpts (m, x, w);

  /* (Real) grid coordinates and interpolated values: */
  real y[mm][3], gr[mm];

  /* Over radial layers: */
  for (int j = 0; j < n; j++)
    {
      /* Translate quadrature  coordinates into real  grid coordinates
         where integer values correspond to the grid nodes: */
      for (int i = 0; i < mm; i++)
        FOR_DIM
          y[i][dim] = (a[dim] + r[j] * x[i][dim] + PD->L[dim] / 2) / PD->h[dim];

      /* NOTE:  trigonometric  interpolation   is  O(N^3)  per  point,
         trilinear is O(1): */
      if (trilinear)
        bgy3d_interp (dom->da, g, mm, y, gr);
      else
        bgy3d_fft_interp (dom->fft_mat, g_fft, mm, y, gr);

      /* Scale by integration weights: */
      for (int i = 0; i < mm; i++)
        gr[i] *= w[i];

      /* Integrate over sphere: */
      rdf[j] = sum (mm, gr);
    }

  if (!trilinear)
    vec_destroy (&g_fft);
}
Esempio n. 5
0
File: hs.c Progetto: NetSys/sts
/* Free elem I of V, replacing it with last elem. */
static void
vec_elem_free (struct hs_vec *v, int i)
{
  free (v->elems[i]);
  v->elems[i] = v->elems[--v->used];
  if (v->diff) {
    vec_destroy (&v->diff[i]);
    v->diff[i] = v->diff[v->used];
  }
}
Esempio n. 6
0
File: hs.c Progetto: NetSys/sts
static void
vec_destroy (struct hs_vec *v)
{
  for (int i = 0; i < v->used; i++) {
    free (v->elems[i]);
    if (v->diff) vec_destroy (&v->diff[i]);
  }
  free (v->elems);
  free (v->diff);
}
Esempio n. 7
0
File: state.c Progetto: ysm001/slim
void transition_free(Transition t)
{
#ifdef PROFILE
  if (lmn_env.profile_level >= 3) {
    profile_remove_space(PROFILE_SPACE__TRANS_OBJECT, transition_space(t));
  }
#endif
  vec_destroy(&t->rule_names);
  LMN_FREE(t);
}
Esempio n. 8
0
File: hs.c Progetto: NetSys/sts
void
hs_cmpl (struct hs *hs)
{
  if (!hs->list.used) {
    hs_add (hs, array_create (hs->len, BIT_X));
    return;
  }

  struct hs_vec *v = &hs->list, new_list = {0};
  for (int i = 0; i < v->used; i++) {
    struct hs_vec tmp = {0};
    tmp.elems = array_cmpl_a (v->elems[i], hs->len, &tmp.used);
    tmp.alloc = tmp.used;

    /* If complement is empty, result will be empty. */
    if (!tmp.elems) {
      vec_destroy (&new_list);
      vec_destroy (&hs->list);
      memset (&hs->list, 0, sizeof hs->list);
      return;
    }

    tmp.diff = xcalloc (tmp.alloc, sizeof *tmp.diff);
    if (v->diff) { /* NULL if called from comp_diff */
      struct hs_vec *d = &v->diff[i];
      for (int j = 0; j < d->used; j++)
        vec_append (&tmp, d->elems[j], false);
    }

    if (!new_list.used) new_list = tmp;
    else {
      vec_isect (&new_list, &tmp, hs->len);
      vec_destroy (&tmp);
    }
  }

  vec_destroy (v);
  hs->list = new_list;
}
Esempio n. 9
0
File: hs.c Progetto: MurphyMc/sts
static void
vec_isect (struct hs_vec *a, const struct hs_vec *b, int len)
{
  struct hs_vec new_list = {0};

  for (int i = 0; i < a->used; i++) {
    for (int j = 0; j < b->used; j++) {
      array_t *isect = array_isect_a (a->elems[i], b->elems[j], len);
      if (!isect) continue;

      vec_append (&new_list, isect, false);
      int idx = new_list.used;
      struct hs_vec *d = &new_list.diff[idx];
      vec_diff (d, isect, &a->diff[i], len);
      vec_diff (d, isect, &b->diff[j], len);
    }
  }
  vec_destroy (a);
  *a = new_list;
}
Esempio n. 10
0
static void ext_iup_vbox(script_t* script, vector_t* args)
{
	vector_t* array = &script_get_arg(args, 0)->array;
	vector_t handle_array;
	
	vec_init(&handle_array, sizeof(Ihandle*));
	vec_reserve(&handle_array, array->length + 1);
	
	for(int i = 0; i < array->length; ++i)
	{
		script_value_t* val = vec_get_value(array, i, script_value_t*);
		vec_push_back(&handle_array, &val->nat.value);
	}
	Ihandle* null_handle = NULL;
	vec_push_back(&handle_array, &null_handle); 
	
	Ihandle* vbox = IupVboxv((Ihandle**)handle_array.data);
	vec_destroy(&handle_array);
	
	script_push_native(script, vbox, NULL, iup_handle_free);
	script_return_top(script);
}
Esempio n. 11
0
File: hs.c Progetto: NetSys/sts
void
hs_comp_diff (struct hs *hs)
{
  struct hs_vec *v = &hs->list, new_list = {0};
  for (int i = 0; i < v->used; i++) {
    struct hs tmp = {hs->len}, tmp2 = {hs->len};
    vec_append (&tmp.list, v->elems[i], false);
    v->elems[i] = NULL;
    tmp2.list = v->diff[i];
    hs_minus (&tmp, &tmp2);

    if (!new_list.used) new_list = tmp.list;
    else {
      for (int j = 0; j < tmp.list.used; j++) {
        vec_append (&new_list, tmp.list.elems[j], false);
        tmp.list.elems[j] = NULL;
      }
      hs_destroy (&tmp);
    }
  }
  vec_destroy (v);
  hs->list = new_list;
}
Esempio n. 12
0
int main(int argc, char *argv[])
{
    struct vector v;
    int i = 0;
    int *p;

    vec_init(&v, sizeof(int), 0, realloc);

    vec_push(&v, &i);
    i = 1;
    vec_push(&v, &i);

    vec_shrink(&v);
    vec_swap(&v, 0, 1);

    p = vec_get(&v, 0);
    assert(*p == 1);
    p = vec_get(&v, 1);
    assert(*p == 0);

    vec_destroy(&v);

    return 0;
}
Esempio n. 13
0
File: hs.c Progetto: NetSys/sts
void
hs_destroy (struct hs *hs)
{ vec_destroy (&hs->list); }
Esempio n. 14
0
void map_destroy(hashmap_t* map)
{
	map_clear(map);
	vec_destroy(&map->active_buckets);
}
Esempio n. 15
0
static void ext_iup_close(script_t* script, vector_t* args)
{
	IupClose();
	vec_destroy(&g_all_cb_data);
}