int main(int argc,char *argv[]) { int i, j, x, y, count, gene_num, seq_len; //1番目の引数で指定した転写因子の複数の結合部位配列を読み込む gene_num=read_promoter(argv[1]); for(i=0;i<gene_num;i++){ printf(">%s\n%s\n", pro[i].name, pro[i].seq); } printf("------------------\n"); seq_len = strlen(pro[0].seq); count = 0; for(i = 1; i < gene_num; i++){/*make genelogical tree */ /* Compare 0 with others, * it is not good way, but it is easy to implement*/ make_map(seq_len, 0, i); comb[count].x = i; strcpy(comb[count].name, pro[i].name); comb[count].score = dp[seq_len-1][seq_len-1]; count++; } make_tree(count); for(i = 1; i < gene_num; i++){ make_map(seq_len, 1, i); if(i == 1){ strcpy(result[0].name, pro[0].name); } strcpy(result[i].name, pro[i].name); traceback(seq_len-1, seq_len-1, i); } print_result(gene_num); return 0; }
int main(int argc,char *argv[]) { int i, j, k, l, f, x, y, count, gene_num, seq_len; //1番目の引数で指定した転写因子の複数の結合部位配列を読み込む gene_num=read_promoter(argv[1]); printf("%d", gene_num); for(i=0;i<gene_num;i++){ printf(">%s\n%s\n", pro[i].name, pro[i].seq); } printf("------------------\n"); seq_len = strlen(pro[0].seq); count = 0; for(k = 0; k < gene_num-1; k++){ for(i = 0; i < gene_num-1; i++){/*make genelogical tree */ for(j = i+1; j < gene_num; j++){ f = 0; for(l = 0; cluster[l].name[0] != '\0'; l++){ if(strcmp(cluster[l].name, pro[i].name) || strcmp(cluster[l].name, pro[j].name)){ f = 1; break; } } if(f == 0){ if(cluster[0].name[0] == '\0'){ make_map(seq_len, i, j, 0); } else{ make_map(seq_len, i, j, 1); } strcpy(comb[count].x_name, pro[i].name); strcpy(comb[count].y_name, pro[j].name); comb[count].x = i; comb[count].y = j; comb[count].score = dp[seq_len-1][seq_len-1]; count++; } } } make_tree(count); } for(i = 1; i < gene_num; i++){ make_map(seq_len, i, j, 1); if(i == 1){ strcpy(result[0].name, pro[i].name); } strcpy(result[i].name, pro[i].name); traceback(seq_len-1, seq_len-1, i); } print_result(gene_num); return 0; }
int main(int argc, char ** argv) { struct map maps[NUM_MAPS] = {}, maps_compare[NUM_MAPS] = {}; int i, j, k; test_init(argc, argv); k = 0; for (i = 0; i < NUM_MPROTS; i++) for (j = 0; j < NUM_MFLAGS; j++) init_map(maps + k++, i, j); for (i = 0; i < NUM_MAPS; i++) if (make_map(maps + i)) goto err; test_daemon(); test_waitsig(); for (i = 0; i < NUM_MAPS; i++) if ((maps[i].prot_real=check_map(maps + i))<0) goto err; k=0; for (i = 0; i < NUM_MPROTS; i++) for (j = 0; j < NUM_MFLAGS; j++) init_map(maps_compare + k++, i, j); for (i = 0; i < NUM_MAPS; i++) if (make_map(maps_compare+ i)) goto err; for (i = 0; i < NUM_MAPS; i++) if ((maps_compare[i].prot_real=check_map(maps_compare + i))<0) goto err; for (i = 0; i< NUM_MAPS; i++) if (!check_prot(maps[i].prot_real, maps_compare[i].prot_real)){ fail("protection on %i (flag=%d prot=%d) maps has changed (prot=%d(expected %d))", i, maps[i].flag, maps[i].prot, maps[i].prot_real, maps_compare[i].prot_real); goto err; } pass(); for (i = 0; i < NUM_MAPS; i++) { destroy_map(maps + i); destroy_map(maps_compare + i); } return 0; err: return 1; }
int main(int argc, char** argv) { madness::World& world = madness::initialize(argc,argv); std::size_t m = 20; std::size_t n = 10; std::size_t M = 200; std::size_t N = 100; std::shared_ptr<TiledArray::Pmap> blocked_pmap(new TiledArray::detail::BlockedPmap(world, m * n)); std::vector<ProcessID> blocked_map = make_map(m, n, blocked_pmap); std::shared_ptr<TiledArray::Pmap> cyclic_pmap(new TiledArray::detail::CyclicPmap(world, m, n, M, N)); std::vector<ProcessID> cyclic_map = make_map(m, n, cyclic_pmap); std::shared_ptr<TiledArray::Pmap> hash_pmap(new TiledArray::detail::HashPmap(world, m * n)); std::vector<ProcessID> hash_map = make_map(m, n, hash_pmap); if(world.rank() == 0) { std::cout << "Block\n"; print_map(m, n, blocked_map); std::cout << "\n"; } print_local(world, blocked_pmap); world.gop.fence(); if(world.rank() == 0) { std::cout << "\n\nCyclic\n"; print_map(m, n, cyclic_map); std::cout << "\n"; } print_local(world, cyclic_pmap); world.gop.fence(); if(world.rank() == 0) { std::cout << "\n\nHash\n"; print_map(m, n, hash_map); std::cout << "\n"; } print_local(world, hash_pmap); madness::finalize(); return 0; }
void LrDpleToDple::init() { // Initialize the base classes LrDpleInternal::init(); MX As = MX::sym("As", input(LR_DPLE_A).sparsity()); MX Vs = MX::sym("Vs", input(LR_DPLE_V).sparsity()); MX Cs = MX::sym("Cs", input(LR_DPLE_C).sparsity()); MX Hs = MX::sym("Hs", input(LR_DPLE_H).sparsity()); int n_ = A_[0].size1(); // Chop-up the arguments std::vector<MX> As_ = horzsplit(As, n_); std::vector<MX> Vs_ = horzsplit(Vs, V_[0].size2()); std::vector<MX> Cs_ = horzsplit(Cs, V_[0].size2()); std::vector<MX> Hss_ = horzsplit(Hs, Hsi_); std::vector<MX> V_(Vs_.size()); for (int k=0;k<V_.size();++k) { V_[k] = mul(Cs_[k], mul(Vs_[k], Cs_[k].T())); } std::vector<Sparsity> Vsp(Vs_.size()); for (int k=0;k<V_.size();++k) { Vsp[k] = V_[k].sparsity(); } // Solver options Dict options; if (hasSetOption(optionsname())) { options = getOption(optionsname()); } // Create an dplesolver instance std::map<std::string, std::vector<Sparsity> > tmp; tmp["a"] = A_; tmp["v"] = Vsp; solver_ = DpleSolver("solver", getOption(solvername()), tmp, options); MX P = solver_(make_map("a", horzcat(As_), "v", horzcat(V_))).at("p"); std::vector<MX> Ps_ = horzsplit(P, n_); std::vector<MX> HPH(K_); for (int k=0;k<K_;++k) { std::vector<MX> hph = horzsplit(Hss_[k], cumsum0(Hs_[k])); for (int kk=0;kk<hph.size();++kk) { hph[kk] = mul(hph[kk].T(), mul(Ps_[k], hph[kk])); } HPH[k] = diagcat(hph); } f_ = MXFunction(name_, lrdpleIn("a", As, "v", Vs, "c", Cs, "h", Hs), lrdpleOut("y", horzcat(HPH))); Wrapper<LrDpleToDple>::checkDimensions(); }
int main(int argc, char **argv) { int a = -500; int b = 500; int c = 500; int d = -500; if (argc == 1) { printf("using defaults\n"); } else if (argc == 5) { a = atoi(argv[1]); b = atoi(argv[2]); c = atoi(argv[3]); d = atoi(argv[4]); } else { printf("Bad arguments\n"); return 1; } int *turn_arr; struct point map_top_left = {.x=a, .y=b}; struct point map_bot_right = {.x=c, .y=d}; int turn_arr_size = pari_gen_turn_arr(&turn_arr, 1000000); int** map = make_map(turn_arr, turn_arr_size, &map_top_left, &map_bot_right); int is_success = pngtest(map, (map_bot_right.x - map_top_left.x + 1), (map_top_left.y - map_bot_right.y + 1)); return is_success; }
int main(void) { t_size dims; int **tab; dims.size = ask_user(); if (dims.size == 0) { endwin(); ft_putendl("Thanks for playing !"); return (0); } clear(); tab = make_map(dims.size); initscr(); keypad(stdscr, TRUE); curs_set(0); noecho(); if (controllers(tab, dims.size, &dims) == 1) { endwin(); ft_putendl("Error, exiting with style."); return (0); } endwin(); return (0); }
int main () { int res; res = NCDStringIndex_Init(&string_index); ASSERT_FORCE(res) NCDValMem_Init(&mem, &string_index); res = NCDValCons_Init(&cons, &mem); ASSERT_FORCE(res) NCDValRef val1 = complete(list_prepend(list_prepend(list_prepend(make_list(), make_string("hello")), make_string("world")), make_list())); char *str1 = NCDValGenerator_Generate(val1); ASSERT_FORCE(str1) ASSERT_FORCE(!strcmp(str1, "{{}, \"world\", \"hello\"}")) free(str1); NCDValRef val2 = complete(map_insert(map_insert(map_insert(make_map(), make_list(), make_list()), make_string("A"), make_list()), make_string("B"), make_list())); char *str2 = NCDValGenerator_Generate(val2); ASSERT_FORCE(str2) printf("%s\n", str2); ASSERT_FORCE(!strcmp(str2, "[\"A\":{}, \"B\":{}, {}:{}]")) free(str2); NCDValCons_Free(&cons); NCDValMem_Free(&mem); NCDStringIndex_Free(&string_index); return 0; }
void RealtimeAPCSCP::updateM_act() { std::chrono::time_point<std::chrono::system_clock> start, end; std::chrono::duration<double> duration; start = std::chrono::system_clock::now(); std::map<std::string, Matrix<double> > arg = make_map("der_x", x_act, "adj0_g", y_act, "der_g", y_act); std::map<std::string, Matrix<double> > result = dG_fast(arg); // Matrix<double> m_act_fast = result["adj0_x"]; // updateDg_act(); // Matrix<double> m_act_slow = mul(transpose(Dg_act), y_act); // Matrix<double> diff = m_act_slow - m_act_fast; // m_act_fast.print(std::cout << "Fast = ", false); // std::cout << ";" << std::endl; // m_act_slow.print(std::cout << "Slow = ", false); // std::cout << ";" << std::endl; // diff.print(std::cout << "Difference = ", false); // std::cout << ";" << std::endl; // diff = norm_2(diff); // diff.print(std::cout << "Difference Norm = ", false); // std::cout << ";" << std::endl; // m_act = mul(transpose(Dg_act), y_act); // m_act = m_act_fast; m_act = result["adj0_x"] - mul(transpose(A_act), y_act); end = std::chrono::system_clock::now(); duration = end - start; std::cout << "Duration Update M: " << duration.count() << std::endl; }
int main(void) { char c; make_map(); while (1) { if (scanf("%c", &c) != 1) exit(0); printf("%c", map[c]); } }
StabilizedSqicInterface* StabilizedSqicInterface::clone() const { // Return a deep copy StabilizedSqicInterface* node = new StabilizedSqicInterface(make_map("h", st_[QP_SOLVER_H], "a", st_[QP_SOLVER_A])); if (!node->is_init_) node->init(); return node; }
QpToQcqp* QpToQcqp::clone() const { // Return a deep copy QpToQcqp* node = new QpToQcqp(make_map("h", st_[QP_STRUCT_H], "a", st_[QP_STRUCT_A])); if (!node->is_init_) node->init(); return node; }
static void test_map_stack(void) { Map *m1 = make_map(NULL); map_put(m1, "x", (void *)1); map_put(m1, "y", (void *)2); assert_int(1, (int)(intptr_t)map_get(m1, "x")); Map *m2 = make_map(m1); assert_int(1, (int)(intptr_t)map_get(m2, "x")); map_put(m2, "x", (void *)3); assert_int(3, (int)(intptr_t)map_get(m2, "x")); assert_int(1, (int)(intptr_t)map_get(m1, "x")); MapIter *iter = map_iter(m2); assert_string("x", map_next(iter, NULL)); assert_string("y", map_next(iter, NULL)); assert_null(map_next(iter, NULL)); }
std::vector<Sparsity> LrDpleInternal::getSparsity(const std::map<std::string, std::vector<Sparsity> >& st, const std::vector< std::vector<int> > &Hs_) { // Chop-up the arguments std::vector<Sparsity> As, Vs, Cs, Hs; if (st.count("a")) As = st.at("a"); if (st.count("v")) Vs = st.at("v"); if (st.count("c")) Cs = st.at("c"); if (st.count("h")) Hs = st.at("h"); bool with_H = !Hs.empty(); int K = As.size(); Sparsity A; if (K==1) { A = As[0]; } else { Sparsity AL = diagcat(vector_slice(As, range(As.size()-1))); Sparsity AL2 = horzcat(AL, Sparsity(AL.size1(), As[0].size2())); Sparsity AT = horzcat(Sparsity(As[0].size1(), AL.size2()), As.back()); A = vertcat(AT, AL2); } Sparsity V = diagcat(Vs.back(), diagcat(vector_slice(Vs, range(Vs.size()-1)))); Sparsity C; if (!Cs.empty()) { C = diagcat(Cs.back(), diagcat(vector_slice(Cs, range(Cs.size()-1)))); } Sparsity H; std::vector<int> Hs_agg; std::vector<int> Hi(1, 0); if (Hs_.size()>0 && with_H) { H = diagcat(Hs.back(), diagcat(vector_slice(Hs, range(Hs.size()-1)))); casadi_assert(K==Hs_.size()); for (int k=0;k<K;++k) { Hs_agg.insert(Hs_agg.end(), Hs_[k].begin(), Hs_[k].end()); int sum=0; for (int i=0;i<Hs_[k].size();++i) { sum+= Hs_[k][i]; } Hi.push_back(Hi.back()+sum); } } Sparsity res = LrDleInternal::getSparsity(make_map("a", A, "v", V, "c", C, "h", H), Hs_agg); if (with_H) { return diagsplit(res, Hi); } else { return diagsplit(res, As[0].size2()); } }
Matrix<double> RealtimeAPCSCP::calcApproxLagrangian() { std::map<std::string, Matrix<double> > eval; std::map<std::string, Matrix<double> > map = make_map("x", x_act); Matrix<double> result = Matrix<double>::zeros(x_act.size(), x_act.size()); for (int i = 0; i < G.size(); i++) { eval = this->hess_gi[i](map); result += y_act[i] * eval["jac"]; } return result; }
void RealtimeAPCSCP::updateDg_act() { std::chrono::time_point<std::chrono::system_clock> start, end; std::chrono::duration<double> duration; start = std::chrono::system_clock::now(); std::map<std::string, Matrix<double> > result = dG_f(make_map("x", x_act)); this->Dg_act = result["jac"]; end = std::chrono::system_clock::now(); duration = end - start; std::cout << "Duration Update dG: " << duration.count() << std::endl; }
double tests(int n, double p) { int i; double k; for (k = i = 0; i < n; i++) { make_map(p); k += (double)count_clusters() / ww; } return k / n; }
int main () { //these work fine - functions given by Allen Hashable *hashable1 = make_hashable_int (1); Hashable *hashable2 = make_hashable_string ("Allen"); Hashable *hashable3 = make_hashable_int (2); // make_int_value also given Value *value1 = make_int_value (17); //failing here! Node *node1 = make_node(hashable1, value1, NULL); fprintf(stdout, "Print node:\n"); print_node (node1); Value *value2 = make_string_value ("Downey"); Node *list = prepend(hashable2, value2, node1); fprintf(stdout, "Print list:\n"); print_list (list); // run some test lookups Value *value = list_lookup (list, hashable1); fprintf(stdout, "List lookup:\n"); print_lookup(value); fprintf(stdout, "List lookup:\n"); value = list_lookup (list, hashable2); print_lookup(value); fprintf(stdout, "List lookup:\n"); value = list_lookup (list, hashable3); print_lookup(value); // make a map Map *map = make_map(10); map_add(map, hashable1, value1); map_add(map, hashable2, value2); printf ("Map\n"); print_map(map); // run some test lookups value = map_lookup(map, hashable1); print_lookup(value); value = map_lookup(map, hashable2); print_lookup(value); value = map_lookup(map, hashable3); print_lookup(value); return 0; }
internal void game_init() { player = object_init(25, 23, '@', 0xffffffff, 0x000000ff); game_object *npc = object_init((GRID_COL_COUNT / 2) - 3, GRID_ROW_COUNT / 2, '@', 0xff0000ff, 0x000000ff); object_list_append(&gameObjects, player); object_list_append(&gameObjects, npc); make_map(); }
int main(void) { w = 15; make_map(.5); printf("width=15, p=0.5, %d clusters:\n", count_clusters()); show_cluster(); printf("\np=0.5, iter=5:\n"); for (w = 1<<2; w <= 1<<14; w<<=2) printf("%5d %9.6f\n", w, tests(5, .5)); free(map); return 0; }
int main(int argc,char *argv[]) { int i,gene_num, seq_len; //1番目の引数で指定した転写因子の複数の結合部位配列を読み込む gene_num=read_promoter(argv[1]); for(i=0;i<gene_num;i++){ printf(">%s\n%s\n", pro[i].name, pro[i].seq); } printf("------------------\n"); seq_len = strlen(pro[0].seq); make_map(seq_len); traceback(max.x, max.y, max.z); print_result(gene_num); return 0; }
void QpToQcqp::init() { // Initialize the base classes QpSolverInternal::init(); Dict options; if (hasSetOption(optionsname())) options = getOption(optionsname()); options = OptionsFunctionality::addOptionRecipe(options, "qp"); // Create an QcqpSolver instance solver_ = QcqpSolver("qcqpsolver", getOption(solvername()), make_map("h", input(QP_SOLVER_H).sparsity(), "p", Sparsity(n_, 0), "a", input(QP_SOLVER_A).sparsity()), options); }
int main(){ std::string input1,input2; std::getline(std::cin,input1); if(std::getline(std::cin,input2)){ std::cout<<"decoding"<<std::endl; //decode std::map<std::string,char> m = make_map(input1); std::cout<<decode(input2,m)<<std::endl; } else { std::cout<<"encoding"<<std::endl; //encode //std::map<char, std::string> m = gen_simple_encoding(input1); std::map<char,std::string> m = gen_huffman_encoding(input1); std::cout<<encode(input1,m)<<std::endl; } }
OBJ build_map(OBJ *keys, OBJ *values, uint32 size) { if (size == 0) return make_empty_rel(); uint32 actual_size = sort_and_check_no_dups(keys, values, size); BIN_REL_OBJ *map = new_map(actual_size); OBJ *ks = map->buffer; OBJ *vs = ks + map->size; for (uint32 i=0 ; i < actual_size ; i++) { ks[i] = keys[i]; vs[i] = values[i]; } return make_map(map); }
int main(void) { srand(time(NULL)); SDL_Init(SDL_INIT_EVERYTHING); screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_HWSURFACE); make_map(); heightmap_to_screen(); SDL_Flip(screen); while(1) get_keypress(); SDL_FreeSurface(screen); SDL_Quit(); return 0; }
int main () { Hashable *hashable1 = make_hashable_int (1); Hashable *hashable2 = make_hashable_string ("Allen"); Hashable *hashable3 = make_hashable_int (2); // make a list by hand Value *value1 = make_int_value (17); Node *node1 = make_node(hashable1, value1, NULL); print_node (node1); Value *value2 = make_string_value ("Downey"); Node *list = prepend(hashable2, value2, node1); print_list (list); // run some test lookups Value *value = list_lookup (list, hashable1); print_lookup(value); value = list_lookup (list, hashable2); print_lookup(value); value = list_lookup (list, hashable3); print_lookup(value); // make a map Map *map = make_map(10); map_add(map, hashable1, value1); map_add(map, hashable2, value2); printf ("Map\n"); print_map(map); // run some test lookups value = map_lookup(map, hashable1); print_lookup(value); value = map_lookup(map, hashable2); print_lookup(value); value = map_lookup(map, hashable3); print_lookup(value); return 0; }
std::map<string, Matrix<double> > RealtimeAPCSCP::solveConvexSubproblem() { std::map<std::string, Matrix<double> > arg = make_map("lbx", model->getVMIN(), "ubx", model->getVMAX(), "lbg", this->G_bound, "ubg", this->G_bound, "x0", model->getVINIT()); if (!firstIteration) { arg.insert(std::pair<std::string, Matrix<double> >("lam_g0", model->getLAM_G())); arg.insert(std::pair<std::string, Matrix<double> >("lam_x0", model->getLAM_X())); } NlpSolver nlpSolver = NlpSolver("solver", "ipopt", nlp_sub, opts); nlpSolver.setOption("warn_initial_bounds", true); nlpSolver.setOption("eval_errors_fatal", true); std::map<string, Matrix<double> > result = nlpSolver(arg); storeStatsIpopt(&nlpSolver); return result; }
static void test_map(void) { Map *m = make_map(NULL); assert_null(map_get(m, "abc")); // Insert 10000 values for (int i = 0; i < 10000; i++) { char *k = format("%d", i); map_put(m, k, (void *)(intptr_t)i); assert_int(i, (int)(intptr_t)map_get(m, k)); } // Insert again for (int i = 0; i < 1000; i++) { char *k = format("%d", i); map_put(m, k, (void *)(intptr_t)i); assert_int(i, (int)(intptr_t)map_get(m, k)); } // Verify that the iterator iterates over all the elements { bool x[10000]; for (int i = 0; i < 10000; i++) x[i] = 0; MapIter *iter = map_iter(m); void *v; char *k = map_next(iter, &v); for (; k; k = map_next(iter, &v)) { int i = (intptr_t)v; x[i] = 1; } for (int i = 0; i < 10000; i++) assert_true(x[i] == 1); } // Remove them for (int i = 0; i < 10000; i++) { char *k = format("%d", i); assert_int(i, (intptr_t)map_get(m, k)); map_remove(m, k); assert_null(map_get(m, k)); } }
void go_down() { char flag; if (player.d_level < bottom) { flag = ' '; player.d_level++; make_map(); if (flag == ' ') { player.x = u_random(80)+10; player.y = u_random(80) + 10; while (player.map[player.x][player.y] != 7) { player.x = u_random(80)+10; player.y = u_random(80) + 10; } } player.map_x = player.x - 8; player.map_y = player.y - 8; if (player.map_x < 1) player.map_x = 1; if (player.map_y < 1) player.map_y = 1; if (player.map_x > 84) player.map_x = 84; if (player.map_y > 84) player.map_y = 84; show_screen(); } }
// requests the map from the mapping system, stores it in raw_map bool load_map() { nav_msgs::GetMap::Request req; nav_msgs::GetMap::Response resp; ROS_INFO("Requesting the map...\n"); if( !ros::service::call("/cu/get_map_cu", req, resp) ) { ROS_INFO("request failed\n"); return NULL; } ROS_INFO("Received a %d X %d map @ %.3f m/pix\n", resp.map.info.width, resp.map.info.height, resp.map.info.resolution); if (resp.map.info.width == 0 && resp.map.info.height == 0) return false; if(raw_map != NULL) // the map has been reloaded, so we need to clean up memory of old raw_map destroy_map(raw_map); while(change_token_used) {printf("change token used, load map \n");} change_token_used = true; float map_resolution = resp.map.info.resolution; int map_width = resp.map.info.width; int map_height = resp.map.info.height; raw_map = make_map(map_height, map_width, map_resolution); float** raw_map_cost = raw_map->cost; for(int i = 0; i < map_height; i++) for(int j = 0; j < map_width; j++) raw_map_cost[i][j] = prob_to_cost(((float)resp.map.data[i*map_width+j])/100); change_token_used = false; return true; }