Пример #1
0
///figure out set of funcs/services to remove when transitioning from set a to set b
static uint16_t
get_funcs_to_remove (uint16_t ** f_rmv_ret, uint16_t ** p_rmv_ret,
                     uint16_t * funcs_a, uint16_t * pnrs_a,
                     uint16_t n_funcs_a, uint16_t * funcs_b,
                     uint16_t * pnrs_b, uint16_t n_funcs_b)
{
  uint16_t n_rmv = 0;
  uint16_t *f_rmv = NULL;
  uint16_t *p_rmv = NULL;
  unsigned i;
  /*
     those pnrs that disappear completely,
     get removed with those func bits set in the a set(not necesarily all)

     those pnrs that stay but change func bits get removed when bits set in a set and cleared in b set.
     func[i]=funcs_a&(~funcs_b);

     perhaps flatten the whole function list, so it's easier to do?
     __________
     |pnr|func|
     ----------
     instead of func bitfield, func idx combined with pnr in 1 word...
     so each element in array corresponds to exactly 1 func?
     the pnr is a full 16 bits, so would have up word size.
     would it break stuff somewhere else? would not be able to use
     pidbuf funcs...

     naaahhh
   */

  //start out with complete removals
  p_rmv = pidbufDifference (pnrs_a, n_funcs_a, pnrs_b, n_funcs_b, &n_rmv);
  //got the pnrs, now find the funcs they had..
  f_rmv = utlCalloc (n_rmv, sizeof (uint16_t));
  for (i = 0; i < n_rmv; i++)
  {
    int j = get_idx (pnrs_a, n_funcs_a, p_rmv[i]);      //lookup pnrs index in a array
    f_rmv[i] = funcs_a[j];      //copy func bits (they all get removed)
  }

  //now those pnrs that are in both arrays
  for (i = 0; i < n_funcs_a; i++)
  {                             //iterate over a array and see if it's in b, too
    if (pidbufContains (pnrs_a[i], pnrs_b, n_funcs_b))
    {                           //yes it is
      int j = get_idx (pnrs_b, n_funcs_b, pnrs_a[i]);
      uint16_t tmp;
      if ((tmp = (funcs_a[i] & (~funcs_b[j]))))
      {                         //function bits got unset
        pidbufAddPid (pnrs_a[i], &p_rmv, &n_rmv);
        n_rmv--;                //'cause it got incremented above.. needs to get less ugly...
        pidbufAddPid (tmp, &f_rmv, &n_rmv);
      }
      //otherwise something got added
    }
  }
  *f_rmv_ret = f_rmv;
  *p_rmv_ret = p_rmv;
  return n_rmv;
}
Пример #2
0
void setparams()
{
    input = getparam("in");
    otimes = getparam("times");
    if (strcmp(otimes,"all")==0) {
        trange[0] = -HUGE;
        trange[1] =  HUGE;
    } else
    	setrange(trange, otimes);

    nplot=getiparam("nplot");    

    xvar = getparam("xvar");
    xvar_idx = get_idx(xvar);
    if (hasvalue("xlabel"))
        xlabel = getparam("xlabel");
    else
        xlabel = xvar;
    setrange(xrange, getparam("xrange"));

    yvar = getparam("yvar");
    yvar_idx = get_idx(yvar);
    if (hasvalue("ylabel"))
        ylabel = getparam("ylabel");
    else
        ylabel = yvar;
    setrange(yrange, getparam("yrange"));

    visib = getparam("visib");
    psize = getparam("psize");
#ifdef COLOR
    color = getparam("color");
#endif
    maxsteps = getiparam("maxsteps");
}
Пример #3
0
void goal::elim_redundancies() {
    if (inconsistent())
        return;
    expr_ref_fast_mark1 neg_lits(m());
    expr_ref_fast_mark2 pos_lits(m());
    unsigned sz = size();
    unsigned j  = 0;
    for (unsigned i = 0; i < sz; i++) {
        expr * f = form(i);
        if (m().is_true(f))
            continue;
        if (m().is_not(f)) {
            expr * atom = to_app(f)->get_arg(0);
            if (neg_lits.is_marked(atom))
                continue;
            if (pos_lits.is_marked(atom)) {
                proof * p = 0;
                if (proofs_enabled()) {
                    proof * prs[2] = { pr(get_idx(atom)), pr(i) };
                    p = m().mk_unit_resolution(2, prs);
                }
                expr_dependency_ref d(m());
                if (unsat_core_enabled())
                    d = m().mk_join(dep(get_idx(atom)), dep(i));
                push_back(m().mk_false(), p, d);                    
                return;
            }
            neg_lits.mark(atom);
        }
        else {
            if (pos_lits.is_marked(f))
                continue;
            if (neg_lits.is_marked(f)) {
                proof * p = 0;
                if (proofs_enabled()) {
                    proof * prs[2] = { pr(get_not_idx(f)), pr(i) };
                    p = m().mk_unit_resolution(2, prs);
                }
                expr_dependency_ref d(m());
                if (unsat_core_enabled())
                    d = m().mk_join(dep(get_not_idx(f)), dep(i));
                push_back(m().mk_false(), p, d);
                return;
            }
            pos_lits.mark(f);
        }
        if (i == j) {
            j++;
            continue;
        }
        m().set(m_forms, j, f);
        if (proofs_enabled())
            m().set(m_proofs, j, pr(i));
        if (unsat_core_enabled())
            m().set(m_dependencies, j, dep(i));
        j++;
    }
    shrink(j);
}
Пример #4
0
void process_event_record(uint8_t *event_data, size_t bytes)
{
	struct record *rec = (struct record *)event_data;

	printf("\n\n%s", sts_str[get_idx(hab_statuses, rec->contents[0])]);
	printf("%s", rsn_str[get_idx(hab_reasons, rec->contents[1])]);
	printf("%s", ctx_str[get_idx(hab_contexts, rec->contents[2])]);
	printf("%s", eng_str[get_idx(hab_engines, rec->contents[3])]);
}
Пример #5
0
// first monte carlo solver, mildly constraint
void oku_mcsol(oku_sod* sod, double temp){
	int i,j,num,size = sod->size;
	int cnt[size+1];
	int fit1, fit2, idx1, idx2,tmp,tmp2;

	//refresh list of unknowns in sod
	unk_find(sod);

	//fill sudoku with missing symbols
	for(i=1;i<size+1;i++) cnt[i] = size;

	for(i=0;i<size*size;i++)
		cnt[get_idx(sod,i)]--;

	j=1;
	for(i=0;i<get_numunk(sod);i++){
		while(cnt[j] < 1 && j <= size+1) j++;
		cnt[j]--;
		set_idx(sod,get_unkidx(sod,i),j);
	}

	fit1 = fitness(sod);
	num=0;

	while(fit1 && num < 200000){
		//choose 2 indices
		idx1 = get_unkidx(sod,rndi() % get_numunk(sod));
		idx2 = get_unkidx(sod,rndi() % get_numunk(sod));

		//swap
		tmp = get_idx(sod,idx1);
		if(tmp == (tmp2 = get_idx(sod,idx2))) continue;
		set_idx(sod,idx1,tmp2);
		set_idx(sod,idx2,tmp);

		fit2 = fitness(sod);

		if(fit2 > fit1 && exp((fit1 - fit2)/temp) < rndf()){
			//swap back
			tmp = get_idx(sod,idx1);
			set_idx(sod,idx1,get_idx(sod,idx2));
			set_idx(sod,idx2,tmp);
		} else fit1 = fit2;
		num++;
			
	}
	printf("Solution found after %d MC Steps\n",num);

};
Пример #6
0
int match_kmp(circular_buffer *text, const char *target) {
    int m = strlen(target);
    int *jumps = kmp_jump_table(target, m);
    int target_idx = 0;
    int text_idx = 0;
    char text_char = 0;

    while ((text_char = buf_get(text, text_idx)) != -1)
    {
        if (target_idx >= m) /* match condition */
        {
            return 1;
        }

        if (!is_legal(text_char))
        {
            target_idx = 0;
        }
        else
        {
            target_idx = jumps[get_idx(target_idx, text_char)];
        }
        text_idx++;
    }

    free(jumps);
    return target_idx >= m;
}
Пример #7
0
static struct image_extent
get_test_extent(const struct image_target_info *target, unsigned d)
{
        const struct image_extent ls = image_target_limits(target);
        const unsigned high = ~0, low = 8;
        struct image_extent ext;
        int i;

        for (i = 0; i < 4; ++i)
                set_idx(ext, i, MIN2(get_idx(ls, i), (i == d ? high : low)));

        if (target->target == GL_TEXTURE_CUBE_MAP ||
            target->target == GL_TEXTURE_CUBE_MAP_ARRAY) {
                /* Cube maps have to be square and the number of faces
                 * should be a multiple of six. */
                ext.y = ext.x;
                ext.z = 6 * MAX2(ext.z / 6, 1);

        } else if (image_target_samples(target) > 1) {
                /* Use the maximum number of samples to keep things
                 * interesting. */
                ext.x = image_target_samples(target);
        }

        return ext;
}
Пример #8
0
int main() {
    int n;
    scanf("%d", &n);

    list mylist;
    init_list(&mylist);
    while(n--) {
        char command[10];
        scanf("%s", command);

        // push, get, size, count, clear
        if(command[0] == 'p') {
            int value;
            scanf("%d", &value);
            push_back(&mylist, value);
        } else if(command[0] == 'g') {
            int idx;
            scanf("%d", &idx);
            printf("%d\n", get_idx(&mylist, idx));
        } else if(command[0] == 's') {
            printf("%d\n", mylist.size);
        } else if(command[1] == 'o') {
            int target;
            scanf("%d", &target);
            printf("%d\n", count_target(&mylist, target));
        } else {
            clear_list(&mylist);
        }
    }

    return 0;
}
Пример #9
0
//gets the posth element of the blkth block
int get_blk(oku_sod* sod, int blk, int pos){
	if(blk < sod->size && pos < sod->size){
		return get_idx(sod,sod->blkidx[blk][pos]);
	} else printf("Error! Invalid Input in get_blk. blk=%d, pos=%d\n",blk,pos);

	return 0;
}
Пример #10
0
static void DOCX_Circle(double x, double y, double r, const pGEcontext gc,
		pDevDesc dev) {
	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	int idx = get_idx(dev);

	fprintf(pd->dmlFilePointer, docx_elt_tag_start);
	if( pd->editable > 0 )
		fprintf(pd->dmlFilePointer,	"<wps:cNvPr id=\"%d\" name=\"Point %d\" />%s", idx,	idx, docx_unlock_properties);
	else fprintf(pd->dmlFilePointer,	"<wps:cNvPr id=\"%d\" name=\"Point %d\" />%s", idx,	idx, docx_lock_properties);
	fprintf(pd->dmlFilePointer, "<wps:spPr>");
	fprintf(pd->dmlFilePointer, "<a:xfrm>");
	fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>",
			p2e_(pd->offx + x - r), p2e_(pd->offy + y - r));
	fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>", p2e_(r * 2),
			p2e_(r * 2));
	fprintf(pd->dmlFilePointer, "</a:xfrm>");
	fprintf(pd->dmlFilePointer,
			"<a:prstGeom prst=\"ellipse\"><a:avLst /></a:prstGeom>");
	SetFillColor(dev, gc);
	SetLineSpec(dev, gc);
	fprintf(pd->dmlFilePointer, "</wps:spPr>");

	fprintf(pd->dmlFilePointer, "<wps:bodyPr />");
	fprintf(pd->dmlFilePointer, docx_elt_tag_end);
	fprintf(pd->dmlFilePointer, "\n");
	fflush(pd->dmlFilePointer);
}
Пример #11
0
int main(int argc,char** argv)
{
    char* ifo_name="../dict/stardict-langdao-ec-gb-2.4.2/langdao-ec-gb.ifo";
    char* idx_name="../dict/stardict-langdao-ec-gb-2.4.2/langdao-ec-gb.idx";
    char* dict_name="../dict/stardict-langdao-ec-gb-2.4.2/langdao-ec-gb.dict";
    DICT_INFO* dict_info;
    dict_info=get_dict_info(ifo_name);
    WORD_IDX* idx=(WORD_IDX*)malloc(sizeof(WORD_IDX)*dict_info->word_count);

    get_words(idx_name,dict_info,idx);

    WORD_IDX* word=get_idx(argv[1],idx,dict_info);
    if(word==NULL){
        printf("<NULL>\n");
        exit(0);
    }
    printf("%s,%d,%d\n",word->word,word->offset,word->length);
    FILE* dict=fopen(dict_name,"r");
    if(NULL==dict)
    {
        printf("dict error!\n");
        return EXIT_FAILURE;
    }
    if(0!=fseek(dict,word->offset,SEEK_SET))
    {
        printf("seek error\n");
        return EXIT_FAILURE;
    }
    char explain[word->length+1];
    memset(explain,'\0',word->length+1);
    fread(explain,word->length,1,dict);
    printf("%s\n",explain);
    free(idx);
    return EXIT_SUCCESS;
}
Пример #12
0
int *kmp_jump_table(const char *target, int m)
{
    /**
     * precompute kmp jump table. This is a map saying "if I'm at index i of
     * target and reading character c from text, what is the next index of
     * target I look at?"
     *
     * more precisely for each substr_len prefix of target, does a prefix of
     * length prefix_len - 1 match a suffix of (prefix_len - 1)? If so, compute
     * the next index of target to compare
     *
     *      jumps[current index of substr (substr_len)]
     *          [next character (target[prefix_len]] =
     *          next index to examine (prefix_len + 1)
     *
     * Return: user-free (strlen(target) * PRINT_RANGE * sizeof(int))
     *      containing jump table
     */
    /* we use calloc to zero the memory */
    int *jumps = (int *) calloc(m * PRINT_RANGE, sizeof(int));
    int substr_len, prefix_len, i;

    for (substr_len = 0; substr_len < m; substr_len++)
    {
        for (prefix_len = 1; prefix_len < substr_len; prefix_len++)
        {
            /* compare prefix_len - 1 prefix and suffix of substr_len */
            for (i = 0; i < prefix_len; i++)
            {
                if (*(target + i) !=
                    *(target + substr_len - (prefix_len - 1) + i))
                {
                    break;
                }
            }
            if (i == prefix_len - 1)
            {
                /* match */
                jumps[get_idx(substr_len, target[prefix_len])] = prefix_len + 1;
            }
        }
        /* special case since we don't need string comparison here */
        jumps[get_idx(substr_len, target[substr_len])] = substr_len + 1;
    }
    return jumps;
}
Пример #13
0
void unk_find(oku_sod* sod){
	int i,size = sod->size;

	sod->numunk = 0;

	for(i=0;i<size*size;i++)
		if(get_idx(sod,i) == 0)
			sod->unkidx[sod->numunk++] = i;
}
Пример #14
0
//deepcopy of sod
void oku_sod_copy(oku_sod* dst,oku_sod* src){
	int i,size = src->size;
	if(dst->size != src->size){
		oku_sod_destroy(dst);
		oku_sod_init(&dst,src->size);
	}

	//sudoku dimendion is size*size
	for(i=0;i<size*size;i++)
		set_idx(dst,i,get_idx(src,i));
};
Пример #15
0
struct list *
search(py_tree *tree, const char *s)
{
    for (int i = 0, len = strlen(s); i < len; i++) {
	if (tree == NULL)
	    return NULL;
	tree = tree->next[get_idx(s[i])];
    }

    struct list *ret;
    return NULL;
}
Пример #16
0
static bool
should_test_dimension(const struct image_target_info *target, int d)
{
        const struct image_extent ls = image_target_limits(target);

        return get_idx(ls, d) > 1 &&
                /* Skip second cube map dimension as faces have to be
                 * square. */
                !(target->target == GL_TEXTURE_CUBE_MAP && d >= 1) &&
                !(target->target == GL_TEXTURE_CUBE_MAP_ARRAY && d == 1) &&
                /* Skip sample dimension. */
                !(image_target_samples(target) > 1 && d == 0);
}
Пример #17
0
char *query(const char *word)
{
    idx *x;
    char *info;

    x = get_idx(word);
    if(x == NULL) 
        return NULL;
    //printf("%s offset=%d, len=%d\n", x->word, x->offset, x->length);
    info = get_info(x);

    return info;
}
Пример #18
0
///figure out set of funcs/services to add when transitioning from set a to set b
static uint16_t
get_funcs_to_add (uint16_t ** f_add_ret, uint16_t ** p_add_ret,
                  uint16_t * funcs_a, uint16_t * pnrs_a, uint16_t n_funcs_a,
                  uint16_t * funcs_b, uint16_t * pnrs_b, uint16_t n_funcs_b)
{
  uint16_t n_add = 0;
  uint16_t *f_add = NULL;
  uint16_t *p_add = NULL;
  unsigned i;
  //start out with newly added pnrs
  p_add = pidbufDifference (pnrs_b, n_funcs_b, pnrs_a, n_funcs_a, &n_add);
  //got the pnrs, now find the funcs they will have..
  f_add = utlCalloc (n_add, sizeof (uint16_t));
  for (i = 0; i < n_add; i++)
  {
    int j = get_idx (pnrs_b, n_funcs_b, p_add[i]);      //lookup pnrs index in b array
    f_add[i] = funcs_b[j];      //copy func bits (they all get added)
  }

  //now those pnrs that are in both arrays
  for (i = 0; i < n_funcs_a; i++)
  {                             //iterate over a array and see if it's in b, too
    if (pidbufContains (pnrs_a[i], pnrs_b, n_funcs_b))
    {                           //yes it is
      int j = get_idx (pnrs_b, n_funcs_b, pnrs_a[i]);
      uint16_t tmp;
      if ((tmp = ((~funcs_a[i]) & funcs_b[j])))
      {                         //function bits got set
        pidbufAddPid (pnrs_a[i], &p_add, &n_add);
        n_add--;                //'cause it got incremented above.. needs to get less ugly...
        pidbufAddPid (tmp, &f_add, &n_add);
      }
    }
  }
  *f_add_ret = f_add;
  *p_add_ret = p_add;
  return n_add;
}
Пример #19
0
int main()
{
    bool first = true;
    while (true) {
        if (scanf("%d", &n) != 1) break;
        for (int i = 0; i < n; ++i)
            scanf("%s", names[i]);

        Zero(gifts);

        for (int i = 0; i < n; ++i) {
            scanf("%s", name);
            int idx = get_idx(name);

            int friends;
            scanf("%d%d", &money[idx], &friends);
            if (friends == 0) continue;

            int spend = money[idx] / friends;

            for (int j = 0; j < friends; ++j) {
                scanf("%s", name);
                int f = get_idx(name);

                gifts[idx] -= spend;
                gifts[f]   += spend;
            }
        }

        if (first) first = false;
        else       putchar('\n');

        for (int i = 0; i < n; ++i)
            printf("%s %d\n", names[i], gifts[i]);
    }

    return 0;
}
Пример #20
0
PIGLIT_GL_TEST_CONFIG_END

static bool
init_image_pixels(const struct image_info img, unsigned unit,
                  uint32_t *r_pixels)
{
        const unsigned m = image_num_components(img.format);
        const struct image_datum s = image_format_scale(img.format);
        unsigned i;

        for (i = 0; i < m * N; ++i)
                r_pixels[i] =
                        (unit == 1 ? 0 :
                         encode(img.format, get_idx(s, i % m) * i / (m * N)));

        return true;
}
Пример #21
0
static void DOCX_Rect(double x0, double y0, double x1, double y1,
		const pGEcontext gc, pDevDesc dev) {
	double tmp;
	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	int idx = get_idx(dev);

	if (x0 >= x1) {
		tmp = x0;
		x0 = x1;
		x1 = tmp;
	}

	if (y0 >= y1) {
		tmp = y0;
		y0 = y1;
		y1 = tmp;
	}
//
	fprintf(pd->dmlFilePointer, docx_elt_tag_start);
	if( pd->editable < 1 )
		fprintf(pd->dmlFilePointer,
			"<wps:cNvPr id=\"%d\" name=\"Rectangle %d\" />%s", idx,	idx, docx_lock_properties);
	else fprintf(pd->dmlFilePointer,
			"<wps:cNvPr id=\"%d\" name=\"Rectangle %d\" />%s", idx,	idx, docx_unlock_properties);
	fprintf(pd->dmlFilePointer, "<wps:spPr>");
	fprintf(pd->dmlFilePointer, "<a:xfrm>");
	fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>",
			p2e_(pd->offx + x0), p2e_(pd->offy + y0));
	fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>",
			p2e_(x1 - x0), p2e_(y1 - y0));
	fprintf(pd->dmlFilePointer, "</a:xfrm>");
	fprintf(pd->dmlFilePointer,
			"<a:prstGeom prst=\"rect\"><a:avLst /></a:prstGeom>");
	SetFillColor(dev, gc);
	SetLineSpec(dev, gc);
	fprintf(pd->dmlFilePointer, "</wps:spPr>");

	fprintf(pd->dmlFilePointer, "<wps:bodyPr />");
	fprintf(pd->dmlFilePointer, docx_elt_tag_end);
	fprintf(pd->dmlFilePointer, "\n");
	fflush(pd->dmlFilePointer);

	//return;

}
Пример #22
0
/**
 * qhasharr->remove_by_obj(): Remove an object from this table by key object
 *
 * @param tbl       qhasharr_t container pointer.
 * @param name      key data
 * @param namesize  size of key
 *
 * @return true if successful, otherwise(not found) returns false
 * @retval errno will be set in error condition.
 *  - ENOENT    : No such key found.
 *  - EINVAL    : Invald argument.
 *  - EFAULT    : Unexpected error. Data structure is not constant.
 */
bool qhasharr_remove_by_obj(qhasharr_t *tbl, const void *name, size_t namesize) {
    if (tbl == NULL || name == NULL || namesize == 0) {
        errno = EINVAL;
        return false;
    }

    qhasharr_data_t *tbldata = tbl->data;

    // get hash integer
    uint32_t hash = qhashmurmur3_32(name, namesize) % tbldata->maxslots;
    int idx = get_idx(tbl, name, namesize, hash);
    if (idx < 0) {
        errno = ENOENT;
        return false;
    }

    return qhasharr_remove_by_idx(tbl, idx);
}
Пример #23
0
void init_table_aux(int table[MAX_SKILLS][2], int *idx, int father, int lev,
                    bool full)
{
	int j, i;

	for (j = 1; j < max_s_idx; j++)
	{
		i = get_idx(j);
		if (s_info[i].father != father) continue;
		if (s_info[i].hidden) continue;
		if (!is_known(i)) continue;

		table[*idx][0] = i;
		table[*idx][1] = lev;
		(*idx)++;
		if (s_info[i].dev || full) init_table_aux(table, idx, i, lev + 1, full);
	}
}
Пример #24
0
void init_table_aux(s32b **table, s32b *idx, s32b father, s32b lev,
                    bool full)
{
	s32b j, i;

	for (j = 1; j < max_s_idx; j++)
	{
		i = get_idx(j);

		if (s_info[i].father != father) continue;
		if (s_info[i].hidden) continue;
		if (!is_known(i)) continue;

		table[*idx][0] = i;
		table[*idx][1] = lev;
		(*idx)++;
		if (s_info[i].dev || full) init_table_aux(table, idx, i, lev + 1, full);
	}
}
Пример #25
0
void set_ts_info(uint8_t *p, struct nit *nit)
{
	int i, j, idx;
	uint8_t *q;
	uint8_t ttype_info, ttype_num_service;
	uint16_t service_id;

	nit->ts_info[0].rc_key_id = p[2];
	nit->ts_info[0].name_len = (p[3] & 0xfc) >> 2;
	nit->ts_info[0].num_ttype = p[3] & 0x03;
	q  = p + 4 + nit->ts_info[0].name_len;
	if (nit->ts_info[0].name_len > MAX_TS_NAME)
		nit->ts_info[0].name_len =  MAX_TS_NAME;

	memcpy(nit->ts_info[0].name, p+4, nit->ts_info[0].name_len);

	dprintf("  ts_info name:%.*s\n",
		nit->ts_info[0].name_len, nit->ts_info[0].name);

	for (i=0; i<nit->ts_info[0].num_ttype; i++) {
		ttype_info = q[0];
		ttype_num_service = q[1];
		dprintf("     ttype:%02hhx(%hhu servs) ",
			ttype_info, ttype_num_service);
		q += 2;
		for(j=0; j<ttype_num_service; j++) {
			service_id = q[0] << 8 | q[1];
			dprintf("[%04hx] ", service_id);
			idx = get_idx(service_id, nit);
			if (idx < 0) {
				continue;
			}
			nit->ts_info[0].services[idx].ttype = ttype_info;

			if (!j)
				nit->ts_info[0].services[idx].primary = 1;

			q += 2;
		}
	}
}
Пример #26
0
void set_partial_recv(uint8_t *p, struct nit *nit)
{
	uint8_t *q;
	int i, idx;
	uint16_t service_id;
	uint8_t service_type;

	q = p + 2;
	dprintf("  partial_recv_list ");
	for (i=0; i<p[1]; i+=3) {
		service_id = q[0] << 8 | q[1];
		idx = get_idx(service_id, nit);
		if (idx < 0) {
			dprintf("overflow! ");
			continue;
		}
		nit->ts_info[0].services[idx].partial = 1;
		q += 2;
		dprintf("[%04hx] ", service_id);
	}
	dprintf("\n");
}
Пример #27
0
static bool
check_pixels_vs(const struct image_info img, unsigned stride,
                const uint32_t *pixels, const uint32_t *expect)
{
        const unsigned m = image_num_components(img.format);
        unsigned i, j;

        for (i = 0; i < product(img.size); ++i) {
                const uint32_t *v = &pixels[m * i];
                const uint32_t *u = &expect[stride * m * i];

                for (j = 0; j < m; ++j) {
                        if ((fabs(decode(img.format, v[j]) - decode(img.format, u[j])) >
                             get_idx(img.epsilon, j)) &&
                            isfinite(decode(img.format, u[j]))) {
                                printf("Probe value at (%u, %u, %u, %u)\n",
                                       i % img.size.x,
                                       i / img.size.x % img.size.y,
                                       i / img.size.x / img.size.y % img.size.z,
                                       i / img.size.x / img.size.y / img.size.z);

                                printf("  Expected:");

                                for (j = 0; j < m; ++j)
                                        printf(" %f", decode(img.format, u[j]));

                                printf("\n  Observed:");

                                for (j = 0; j < m; ++j)
                                        printf(" %f", decode(img.format, v[j]));

                                printf("\n");
                                return false;
                        }
                }
        }

        return true;
}
Пример #28
0
void
push2tree(char *py, char *id)
{
    if (strlen(id) != 24) {
        err_ret("bad id");
        return;
    }

    py_tree *itree, *node;
    int py_len = strlen(py);
    for (int i = py_len - 1; i >= 0; i--) {
        itree = tree;
        for (int j = i; j < py_len; j++) {
            int idx = get_idx(py[j]);
            node = itree;
            itree = itree->next[idx];
            if (itree == NULL)
                itree = node->next[idx] = make_node();
        }
        itree->ids = add2list(itree->ids, id);
    }
}
Пример #29
0
void set_service_list(uint8_t *p, struct nit *nit)
{
	uint8_t *q;
	int i, idx;
	uint16_t service_id;
	uint8_t service_type;

	q = p + 2;
	dprintf("  service_list ");
	for (i=0; i<p[1]; i+=3) {
		service_id = q[0] << 8 | q[1];
		service_type = q[2];
		idx = get_idx(service_id, nit);
		if (idx < 0) {
			dprintf("overflow! ");
			continue;
		}
		nit->ts_info[0].services[idx].service_type = service_type;
		q += 3;
		dprintf("[%04hx](typ:%02hhx) ",	service_id, service_type);
	}
	dprintf("\n");
}
Пример #30
0
inline void init_var_locality(void *data,size_t len,size_t offset,size_t *shape,size_t *dshapes,int dims_size,double shift,TYPE type){
   size_t i,j;
   int size=get_type_size(type);
   size_t idx[dims_size];
   double min,max;
   size_t pos;
   double center=1;
   for(i=0;i<len;i++){
       get_idx(idx,i,dshapes,dims_size);
       idx[0]+=offset;
       center=1;
       for(j=0;j<dims_size;j++){
            center*=1.0*(idx[j]+1)/shape[j];
       }
/*       min=1.0*(pow(center,1.0/3)-shift);*/
/*       max=1.0*(pow(center,1.0/3)+shift);*/
/*       pos=0;*/
/*       for(j=0;j<dims_size;j++){*/
/*           pos+=idx[j]+1;*/
/*       }*/
/*       min=1.0*(pos-max_pos*shift)/max_pos;*/
/*       max=1.0*(pos+max_pos*shift)/max_pos;*/
/*       printf("%lf %lf %d\n",min,max,max_pos);*/
/*       if(min<0){*/
/*           min=0;*/
/*       }*/
/*       if(max>1){*/
/*           max=1;*/
/*       }*/
/*       random(((char *)data+i*size),min,max,type);*/
         double val=pow(center,1.0/3);
/*       double val=center;*/
         setval(((char *)data+i*size),val,type);
/*       getval(((char *)data+i*size),i+offset,type);*/
/*       *(double *)data=i;*/
   }
}