void print_alternating() /* dumps the alternating automaton */ { int i; ATrans *t; fprintf(tl_out, "init :\n"); for(t = transition[0]; t; t = t->nxt) { print_set(t->to, 0); fprintf(tl_out, "\n"); } for(i = node_id - 1; i > 0; i--) { if(!label[i]) continue; fprintf(tl_out, "state %i : ", i); dump(label[i]); fprintf(tl_out, "\n"); for(t = transition[i]; t; t = t->nxt) { if (empty_set(t->pos, 1) && empty_set(t->neg, 1)) fprintf(tl_out, "1"); print_set(t->pos, 1); if (!empty_set(t->pos,1) && !empty_set(t->neg,1)) fprintf(tl_out, " & "); print_set(t->neg, 2); fprintf(tl_out, " -> "); print_set(t->to, 0); fprintf(tl_out, "\n"); } } }
void test_agile_set() { agile_set set1,set2; agile_set_init(&set1,string_match,free); agile_set_init(&set2,string_match,free); char* data1_1 = get_data(1); char* data2_1 = get_data(2); char* data3_1 = get_data(3); agile_set_insert(&set1, data1_1); agile_set_insert(&set1, data2_1); agile_set_insert(&set1, data3_1); print_set(&set1,"1"); char* data1_2 = get_data(1); char* data2_2 = get_data(2); char* data3_2 = get_data(3); agile_set_insert(&set2, data1_2); agile_set_insert(&set2, data2_2); agile_set_insert(&set2, data3_2); print_set(&set2,"2"); printf("equal: %d\n", agile_set_is_equal(&set1,&set2)); printf("12subset: %d\n", agile_set_is_subset(&set1,&set2)); char* data4_1 = get_data(4); agile_set_insert(&set1, data4_1); printf("12subset: %d\n", agile_set_is_subset(&set1,&set2)); printf("21subset: %d\n", agile_set_is_subset(&set2,&set1)); agile_set_destroy(&set1); agile_set_destroy(&set2); }
int main(int argc, char** argv) { set_foo* s = set_foo_create(0); print_set(s); printf("empty: %d (1)\n", set_foo_empty(s)); set_foo_insert(s, 10); set_foo_insert(s, 20); set_foo_insert(s, 30); set_foo_insert(s, 40); set_foo_insert(s, 25); set_foo_insert(s, 5); set_foo_insert(s, 45); print_set(s); printf("empty: %d (0)\n", set_foo_empty(s)); set_foo_insert(s, 45); set_foo_insert(s, 45); print_set(s); set_foo_remove(s, 25); set_foo_remove(s, 5); set_foo_remove(s, 45); print_set(s); printf("empty: %d (0)\n", set_foo_empty(s)); set_foo* o = set_foo_create(0); set_foo_insert(o, 10); set_foo_insert(o, 20); set_foo_insert(o, 30); set_foo_insert(o, 40); printf("equal: %d (1)\n", set_foo_equal(s, s)); printf("equal: %d (1)\n", set_foo_equal(s, o)); set_foo_remove(o, 10); printf("equal: %d (0)\n", set_foo_equal(s, o)); set_foo_insert(o, 1100); printf("equal: %d (0)\n", set_foo_equal(s, o)); set_foo_remove(s, 10); set_foo_remove(s, 20); set_foo_remove(s, 30); set_foo_remove(s, 40); set_foo_remove(s, 25); set_foo_remove(s, 5); set_foo_remove(s, 45); print_set(s); printf("empty: %d (1)\n", set_foo_empty(s)); }
int main(){ struct bitset *mybitset,* myotherbitset; /*Checking mybitset = bitset_new(17); //Make pointer from int without cast. What? myotherbitset = bitset_new(8); bitset_add(mybitset,2); bitset_add(mybitset,1); bitset_add(myotherbitset,4); printf("%d %d\n",mybitset->bits[0],bitset_lookup(mybitset,2)); printf("%d %d\n",mybitset->bits[0],bitset_lookup(mybitset,3)); struct bitset *setunion; setunion = mk_union(mybitset, myotherbitset); print_set(mybitset); print_set(myotherbitset); print_set(setunion); //End checking*/ /*This block creates two sets and reads in two strings It the puts the strings in the set */ struct bitset *one,*two; char input1[MAX],input2[MAX]; printf("First sentace plox: \n"); fgets(input1,MAX,stdin); one = parse_string(input1); printf("Second sentance plox\n"); fgets(input2,MAX,stdin); two = parse_string(input2); printf("Line 1\n\n"); print_set(one); printf("Line 2\n\n"); print_set(two); struct bitset * setunion; setunion = mk_union(one,two); printf("\nUnion:\n"); print_set(setunion); struct bitset * intersection; intersection = intersect(one,two); printf("\nIntersetion:\n"); print_set(intersection); return 0; }
int main(int argc, char **argv) { srand(time(0)); init_synth(argc-1, argv+1); double totalcsd = 0.0, totalbits = 0.0, totalopt = 0.0; for(int n = 0; n < NTESTS; ++n) { create_random_problem(1); if(PRINT_TARGETS) { cout << " /* "; print_set("targets:", TARGETS, 0, cout); cout << " */ " << endl; } totalcsd += csdcost(TARGETS); totalbits += bitscost(TARGETS); if(USE_TABLE) totalopt += optcost(TARGETS); } if_verbose(1) cerr << endl; double mean_csd = totalcsd / NTESTS; double mean_bits = totalbits / NTESTS; double mean_opt = 0; if(USE_TABLE) mean_opt = totalopt / NTESTS; printf("%.2d %6.2f %6.2f %4.2f%%", MAX_SHIFT-1, mean_bits, mean_csd, (mean_bits-mean_csd)/mean_bits*100); if(USE_TABLE) printf(" %6.2f %4.2f%%", mean_opt, (mean_bits-mean_opt)/mean_bits*100); printf("\n"); return 0; }
void efail() { print_set(66); print("[", COLOR_GRAY); print("EPIC FAIL", COLOR_RED); print("]\r\n", COLOR_GRAY); }
void ewrin() { print_set(66); print("[", COLOR_GRAY); print("EPIC WRIN", COLOR_GREEN); print("]\r\n", COLOR_GRAY); }
INT check_arc(INT len, INT *S, void *data, INT verbose_level) { arc_generator *Gen = (arc_generator *) data; INT f_OK; INT f_v = (verbose_level >= 1); if (f_v) { cout << "checking set "; print_set(cout, len, S); cout << endl; } f_OK = Gen->check_arc(S, len, verbose_level - 1); if (f_OK) { if (f_v) { cout << "accepted" << endl; } return TRUE; } else { if (f_v) { cout << "rejected" << endl; } return FALSE; } }
void print_item(string tag) { string type, stag; int *dims; type = get_type(instr, tag); if (streq(type, SetType)) { get_set(instr, tag); print_set(tag); while ((stag = next_item_tag(instr)) != NULL) { print_item(stag); free(stag); } get_tes(instr, tag); print_tes(tag); } else { dims = get_dimensions(instr, tag); print_head(tag, type, dims); print_data(tag, type, dims); endline(); if (dims != NULL) free(dims); } free(type); }
INT placebo_test_function(INT len, INT *S, void *data, INT verbose_level) { //arc_generator *Gen = (arc_generator *) data; INT f_OK; INT f_v = (verbose_level >= 1); if (f_v) { cout << "checking set "; print_set(cout, len, S); cout << endl; } f_OK = TRUE; if (f_OK) { if (f_v) { cout << "accepted" << endl; } return TRUE; } else { if (f_v) { cout << "rejected" << endl; } return FALSE; } }
int main() { int set[] = {1,2,3}; print_set(set); return 0; }
void print_item(string tag) { string type, *tags, *tp; int *dims; type = get_type(instr, tag); if (streq(type, SetType)) { get_set(instr, tag); print_set(tag); tags = list_tags(instr); for (tp = tags; *tp != NULL; tp++) print_item(*tp); get_tes(instr, tag); print_tes(tag); for (tp = tags; *tp != NULL; tp++) free(*tp); free((char *)tags); } else { dims = get_dims(instr, tag); print_header(tag, type, dims); (void) outstr(" "); print_data(tag, type, dims); end_line(); if (dims != NULL) free((char *)dims); } free(type); }
void affinity_set::print_affinity(int id, const char* s) { if (get_affinity() == 0) print_set(id, s); else printf("Error in sched_getaffinity\n"); }
void print_item(bnf_grammar* bnf,cset* items,int index,bool numeric) { slist_elem* isle=items->members->_head; slist_elem* sle=0; slist_elem* sle2=0; bnf_index* cbi=0; bnf_index* cbi2=0; int item_index=-1; while(isle) { ++item_index; if(item_index<index) { isle=isle->_next; continue; } else if(item_index>index) break; printf("item %d.\n",item_index); sle=((cset*)isle->_data)->members->_head;/*this is an existing item*/ while(sle)/*loop through its product indices*/ { cbi=(bnf_index*)sle->_data; if(numeric) { printf("\t%d:%d:%d(",cbi->item,cbi->product,cbi->product_part); print_set(cbi->lookaheads,"%d,"); printf(")\n"); } else { cbi2=new_bnf_index(cbi->item,cbi->product,0,cbi->lookaheads); printf("\t%s->",&bnf->lexicon[bnf->items[cbi2->item][0][0]][1]); for(;PART_SYMBOL(bnf,cbi2)>=0;++cbi2->product_part) if(cbi2->product_part==cbi->product_part) printf(" . %s:",&bnf->lexicon[PART_SYMBOL(bnf,cbi2)][1]); else printf("%s:",&bnf->lexicon[PART_SYMBOL(bnf,cbi2)][1]); printf("("); sle2=cbi->lookaheads->members->_head; while(sle2) { if((int)sle2->_data<bnf->start_of_actions) printf("%s,",&bnf->lexicon[(int)sle2->_data][1]); else if((int)sle2->_data==bnf->start_of_actions) printf("$,"); else printf("#,"); sle2=sle2->_next; } printf(")\n"); } sle=sle->_next; } } }
void print_constants(scp_operand program) { scp_operand arc1, arc2, constants_set; MAKE_DEFAULT_OPERAND_ASSIGN(constants_set); MAKE_DEFAULT_ARC_ASSIGN(arc1); MAKE_DEFAULT_ARC_ASSIGN(arc2); scp_iterator5 *iterator = scp_iterator5_new(s_default_ctx, &program, &arc1, &constants_set, &arc2, &nrel_scp_program_const); if (SCP_RESULT_TRUE == scp_iterator5_next(s_default_ctx, iterator, &program, &arc1, &constants_set, &arc2, &nrel_scp_program_const)) print_set(constants_set); }
INT arc_generator::check_arc(INT *S, INT len, INT verbose_level) { INT f_v = (verbose_level >= 1); //INT f_vv = (verbose_level >= 2); //INT f_vvv = (verbose_level >= 3); INT f_OK = TRUE; if (f_v) { cout << "checking set "; print_set(cout, len, S); } if (!rc.check_rank(len, S, verbose_level - 1)) { return FALSE; } if (f_v) { cout << "checking set "; print_set(cout, len, S); } if (f_v) { cout << endl; //print_integer_matrix(cout, S, 1, len); print_integer_matrix(cout, rc.M1, rc.m, len); if (len > 2) { print_set_in_affine_plane(len - 2, S + 2); } } if (f_OK) { if (f_v) { cout << "accepted" << endl; } return TRUE; } else { if (f_v) { cout << "rejected" << endl; } return FALSE; } }
void print_sets(cfg_t* cfg, FILE *fp) { size_t i; vertex_t* u; for (i = 0; i < cfg->nvertex; ++i) { u = &cfg->vertex[i]; fprintf(fp, "use[%zu] = ", u->index); print_set(u->set[USE], fp); fprintf(fp, "def[%zu] = ", u->index); print_set(u->set[DEF], fp); fputc('\n', fp); fprintf(fp, "in[%zu] = ", u->index); print_set(u->set[IN], fp); fprintf(fp, "out[%zu] = ", u->index); print_set(u->set[OUT], fp); fputc('\n', fp); } }
int main() { IntervalSet s; s.insert(Interval<size_t>(1,10)); s.insert(Interval<size_t>(10,20)); s.insert(Interval<size_t>(20,30)); s.insert(Interval<size_t>(30,40)); print_set(s); printf("Matching intervals:\n"); std::pair<IntervalSet::const_iterator,IntervalSet::const_iterator> ir = intersecting_intervals(s, Interval<size_t>(10,25)); for(IntervalSet::const_iterator i=ir.first; i!=ir.second; ++i) { printf("%i-%i ", (int)i->start, (int)i->end); } printf("\n"); intervalset_merge(s, Interval<size_t>(25, 50)); print_set(s); }
/** * Handles the .p command to print the current available sets * @return Returns nothing **/ void print_sets( ) { psetArray walker = root; int index = 0; while ( walker ) { print_set( walker ); walker = walker->next; if ( walker == root ) { break; } } return; }
void print_dfa(const DFA& dfa) { cout << "start : " << dfa.start() << endl; cout << "last : "; const ::mpl::lexer::detail::States& last = dfa.last(); print_set(last); cout << endl; for (size_t i = 0; i < dfa.size(); i++) { const ::mpl::lexer::detail::DFATran& tran = dfa[i]; for (::mpl::lexer::detail::DFATran::const_iterator it = tran.begin(); it != tran.end(); ++it) { cout << i << "("; if (it->first == ::mpl::lexer::detail::EPSILON) { cout << "\\0"; } else if (it->first == ::mpl::lexer::detail::OTHER) { cout << "-1"; } else { //cout << it->first; cout << "0x" << hex << (int)(it->first & 0xFF) << dec; } cout << ")"; cout << "\t->\t"; cout << it->second; cout << endl; } } for (::mpl::lexer::detail::States::const_iterator it = last.begin(); it != last.end(); ++it) { const ::mpl::lexer::detail::Tag& tag = dfa.tags(*it); cout << *it << ": "; print_set(tag); cout << endl; } }
/* ARGSUSED */ int metaset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { snarf_sets(); if (!(flags & DCMD_ADDRSPEC)) { if (mdb_walk_dcmd("md_sets", "metaset", argc, argv) == -1) { mdb_warn("failed to walk sets"); return (DCMD_ERR); } return (DCMD_OK); } print_set(addr); return (DCMD_OK); }
/* prints the sets in the table that have more than 1 value*/ void print_table(Table_T* table) { int table_len = Table_length(*table); void **table_array = Table_toArray(*table, NULL); int counter = num_fgroups(table); for (int i=1; i<(2*table_len); i += 2) { if(Set_length((Set_T)table_array[i]) > 1) { print_set((Set_T *)&table_array[i]); counter--; if (counter != 0) { printf("\n"); } } Set_free((Set_T *)&table_array[i]); } free(table_array); }
void placebo_early_test_function(INT *S, INT len, INT *candidates, INT nb_candidates, INT *good_candidates, INT &nb_good_candidates, void *data, INT verbose_level) { //arc_generator *Gen = (arc_generator *) data; INT f_v = (verbose_level >= 1); if (f_v) { cout << "placebo_early_test_function for set "; print_set(cout, len, S); cout << endl; } INT_vec_copy(candidates, good_candidates, nb_candidates); nb_good_candidates = nb_candidates; if (f_v) { cout << "placebo_early_test_function done" << endl; } }
void arc_generator_early_test_function(INT *S, INT len, INT *candidates, INT nb_candidates, INT *good_candidates, INT &nb_good_candidates, void *data, INT verbose_level) { arc_generator *Gen = (arc_generator *) data; INT f_v = (verbose_level >= 1); if (f_v) { cout << "arc_generator_early_test_function for set "; print_set(cout, len, S); cout << endl; } Gen->early_test_func(S, len, candidates, nb_candidates, good_candidates, nb_good_candidates, verbose_level - 2); if (f_v) { cout << "arc_generator_early_test_function done" << endl; } }
/* * Update some rows in the specified table * _h: structure representing database connection * _k: key names * _o: operators * _v: values of the keys that must match * _uk: updated columns * _uv: updated values of the columns * _n: number of key=value pairs * _un: number of columns to update */ int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, db_key_t* _uk, db_val_t* _uv, int _n, int _un) { int off, ret; if ((!_h) || (!_uk) || (!_uv) || (!_un)) { LOG(L_ERR, "db_update: Invalid parameter value\n"); return -1; } ret = snprintf(sql_buf, SQL_BUF_LEN, "update %s set ", CON_TABLE(_h)); if (ret < 0 || ret >= SQL_BUF_LEN) goto error; off = ret; ret = print_set(CON_CONNECTION(_h), sql_buf + off, SQL_BUF_LEN - off, _uk, _uv, _un); if (ret < 0) return -1; off += ret; if (_n) { ret = snprintf(sql_buf + off, SQL_BUF_LEN - off, " where "); if (ret < 0 || ret >= (SQL_BUF_LEN - off)) goto error; off += ret; ret = print_where(CON_CONNECTION(_h), sql_buf + off, SQL_BUF_LEN - off, _k, _o, _v, _n); if (ret < 0) return -1; off += ret; *(sql_buf + off) = '\0'; } if (submit_query(_h, sql_buf) < 0) { LOG(L_ERR, "db_update: Error while submitting query\n"); return -2; } return 0; error: LOG(L_ERR, "db_update: Error in snprintf\n"); return -1; }
void settings(){ delay(500); print_set(); //Print "Set" on the screen //Firstly set the time do{ set_hrs_mins(); } while (digitalRead(button_settings_in) == LOW); beep(); print_set_alrarm_1(); //Print "Set" on the screen //Then set Alarm 1 do{ set_alarm_1(); } while (digitalRead(button_settings_in) == LOW); beep(); print_out(); delay(500); }
INT check_klist(INT len, INT *S, void *data, INT verbose_level) { sub_generator *sg = (sub_generator *) data; INT i,j; INT f_OK = TRUE; INT f_v = (verbose_level >= 1); INT k_i,f_goodk; if (f_v) { cout << "checking set "; print_set(cout, len, S); } for (i=0;i<len;i++) { k_i=sg->subs->unrank_k(S[i], verbose_level - 1); f_goodk=FALSE; for (j=0;j<sg->nk;j++) { if(k_i==sg->klist[j]){ f_goodk=TRUE; break; } } if (f_goodk==FALSE) { f_OK=FALSE; break; } } if (f_OK) { if (f_v) { cout << "OK" << endl; } return TRUE; } else { return FALSE; } }
/* * Update some rows in the specified table * _h: structure representing database connection * _k: key names * _o: operators * _v: values of the keys that must match * _uk: updated columns * _uv: updated values of the columns * _n: number of key=value pairs * _un: number of columns to update */ int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, db_key_t* _uk, db_val_t* _uv, int _n, int _un) { int off; off = snprintf(sql_buf, SQL_BUF_LEN, "update %s set ", CON_TABLE(_h)); off += print_set(sql_buf + off, SQL_BUF_LEN - off, _uk, _uv, _un); if (_n) { off += snprintf(sql_buf + off, SQL_BUF_LEN - off, " where "); off += print_where(sql_buf + off, SQL_BUF_LEN - off, _k, _o, _v, _n); *(sql_buf + off) = '\0'; } if(begin_transaction(_h, sql_buf)) return(-1); if (submit_query(_h, sql_buf) < 0) { LOG(L_ERR, "db_update(): Error while updating\n"); return -2; } free_query(_h); commit_transaction(_h); return(0); }
void early_test_function_cocliques(INT *S, INT len, INT *candidates, INT nb_candidates, INT *good_candidates, INT &nb_good_candidates, void *data, INT verbose_level) { colored_graph *CG = (colored_graph *) data; INT f_v = (verbose_level >= 1); if (f_v) { cout << "early_test_function for set "; print_set(cout, len, S); cout << endl; } CG->early_test_func_for_coclique_search(S, len, candidates, nb_candidates, good_candidates, nb_good_candidates, verbose_level - 2); if (f_v) { cout << "early_test_function done" << endl; } }
void arc_generator::early_test_func(INT *S, INT len, INT *candidates, INT nb_candidates, INT *good_candidates, INT &nb_good_candidates, INT verbose_level) { INT f_v = (verbose_level >= 1); INT f_vv = (verbose_level >= 2); INT i, j, rk; INT *Pts; INT *Candidates; INT *Mtx; if (f_v) { cout << "arc_generator::early_test_func checking set "; print_set(cout, len, S); cout << endl; cout << "candidate set of size " << nb_candidates << ":" << endl; INT_vec_print(cout, candidates, nb_candidates); cout << endl; } Pts = Data1; Candidates = Data2; Mtx = Data3; //Pts = NEW_INT(len * 3); //Candidates = NEW_INT(nb_candidates * 3); //Mtx = NEW_INT(3 * 3); for (i = 0; i < len; i++) { point_unrank(Pts + i * 3, S[i]); } #if 0 for (i = 0; i < nb_candidates; i++) { point_unrank(Candidates + i * 3, candidates[i]); } #endif nb_good_candidates = 0; for (j = 0; j < nb_candidates; j++) { point_unrank(Candidates, candidates[j]); for (i = 0; i < len - 1; i++) { INT_vec_copy(Pts + i * 3, Mtx + 0 * 3, 3); INT_vec_copy(Pts + (len - 1) * 3, Mtx + 1 * 3, 3); //INT_vec_copy(Candidates + j * 3, Mtx + 2 * 3, 3); INT_vec_copy(Candidates, Mtx + 2 * 3, 3); rk = F->rank_of_matrix(Mtx, 3, 0); if (rk < 3) { if (f_vv) { cout << "rank is " << rk << " which is bad" << endl; } break; } else { if (f_vv) { cout << "rank is " << rk << " which is OK" << endl; } } } // next i if (i == len - 1) { good_candidates[nb_good_candidates++] = candidates[j]; } } // next j //FREE_INT(Pts); //FREE_INT(Candidates); //FREE_INT(Mtx); }