static void entropy(G_GNUC_UNUSED GwyContainer *data, GwyRunType run) { GwyDataField *dfield, *mfield; EntropyArgs args; gboolean ok, same_units; g_return_if_fail(run & ENTROPY_RUN_MODES); gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD, &dfield, GWY_APP_MASK_FIELD, &mfield, 0); g_return_if_fail(dfield); load_args(gwy_app_settings_get(), &args); same_units = gwy_si_unit_equal(gwy_data_field_get_si_unit_xy(dfield), gwy_data_field_get_si_unit_z(dfield)); if (run == GWY_RUN_INTERACTIVE) { if (!same_units && args.mode == ENTROPY_ANGLES) args.mode = ENTROPY_SLOPES; ok = entropy_dialog(&args, dfield, mfield); save_args(gwy_app_settings_get(), &args); if (!ok) return; } }
static int prev_exec(fko_cli_options_t *options, int argc, char **argv) { char args_save_file[MAX_PATH_LEN] = {0}; int res = 1; if(options->args_save_file[0] != 0x0) { strlcpy(args_save_file, options->args_save_file, sizeof(args_save_file)); } else { if (get_save_file(args_save_file) != 1) { log_msg(LOG_VERBOSITY_ERROR, "Unable to determine args save file"); return 0; } } if(options->run_last_command) res = run_last_args(options, args_save_file); else if(options->show_last_command) res = show_last_command(args_save_file); else if (!options->no_save_args) res = save_args(argc, argv, args_save_file); return res; }
static void poly_level(GwyContainer *data, GwyRunType run) { GwyDataField *dfield, *mfield; GQuark quark; PolyLevelArgs args; gboolean ok; gint id; g_return_if_fail(run & POLYLEVEL_RUN_MODES); gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &quark, GWY_APP_DATA_FIELD, &dfield, GWY_APP_MASK_FIELD, &mfield, GWY_APP_DATA_FIELD_ID, &id, 0); g_return_if_fail(dfield && quark); load_args(gwy_app_settings_get(), &args); if (run == GWY_RUN_INTERACTIVE) { ok = poly_level_dialog(&args, data, dfield, mfield, id); save_args(gwy_app_settings_get(), &args); if (!ok) return; } poly_level_do(data, dfield, mfield, quark, id, &args); }
static void fit(GwyGraph *graph) { GwyContainer *settings; FitArgs args; memset(&args, 0, sizeof(FitArgs)); args.auto_estimate = TRUE; args.auto_plot = TRUE; args.parent_graph = graph; args.xdata = gwy_data_line_new(1, 1.0, FALSE); args.ydata = gwy_data_line_new(1, 1.0, FALSE); args.param = g_array_new(FALSE, TRUE, sizeof(FitParamArg)); settings = gwy_app_settings_get(); load_args(settings, &args); fit_dialog(&args); save_args(settings, &args); g_object_unref(args.xdata); g_object_unref(args.ydata); g_array_free(args.param, TRUE); if (args.fitter) gwy_math_nlfit_free(args.fitter); if (args.abscissa_vf) gwy_si_unit_value_format_free(args.abscissa_vf); }
static void level_grains(GwyContainer *data, GwyRunType run) { GwyDataField *dfield; GwyDataField *mfield; LevelGrainsArgs args; gboolean ok; GQuark quark; gint id; g_return_if_fail(run & LEVEL_GRAINS_RUN_MODES); gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &quark, GWY_APP_DATA_FIELD_ID, &id, GWY_APP_DATA_FIELD, &dfield, GWY_APP_MASK_FIELD, &mfield, 0); g_return_if_fail(dfield && quark); load_args(gwy_app_settings_get(), &args); if (run != GWY_RUN_IMMEDIATE) { ok = level_grains_dialog(&args); save_args(gwy_app_settings_get(), &args); if (!ok) return; } level_grains_do(&args, data, quark, id, dfield, mfield); gwy_app_channel_log_add_proc(data, id, id); }
static void dialog_abandon(GwyUnitoolState *state) { ToolControls *controls; controls = (ToolControls*)state->user_data; if (controls->finished_id) g_signal_handler_disconnect(state->layer, controls->finished_id); save_args(gwy_app_settings_get(), controls); memset(state->user_data, 0, sizeof(ToolControls)); }
void nlp::Plsa::train_plsa() { _init_args(); for (int i = 0; i < _iter_nums; i++) { LOG(INFO) <<i<<"th iteration"<<std::endl; _Estep(); _Mstep(); } std::string save_path = "../data"; save_args(save_path); }
int get_args(int argc, char **argv, t_corewar *core) { if (is_error_in_args(argc, argv) == -1) return (usage()); get_dump(argc, argv, core); if ((save_args(argc, argv, core)) == -1) return (-1); if ((attribute_prog_number(core->champions, core->nb_champions)) == -1) return (-1); if ((attribute_address(core->champions, core->nb_champions)) == -1) return (-1); return (0); }
static void curvature(GwyContainer *data, GwyRunType run) { GwyDataField *dfield, *mfield; CurvatureArgs args; gboolean ok; gint id; g_return_if_fail(run & CURVATURE_RUN_MODES); g_return_if_fail(g_type_from_name("GwyLayerLine")); gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD, &dfield, GWY_APP_MASK_FIELD, &mfield, GWY_APP_DATA_FIELD_ID, &id, 0); g_return_if_fail(dfield); if (!gwy_si_unit_equal(gwy_data_field_get_si_unit_xy(dfield), gwy_data_field_get_si_unit_z(dfield))) { GtkWidget *dialog; dialog = gtk_message_dialog_new (gwy_app_find_window_for_channel(data, id), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("%s: Lateral dimensions and value must " "be the same physical quantity."), _("Curvature")); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); return; } load_args(gwy_app_settings_get(), &args); if (run == GWY_RUN_INTERACTIVE) { ok = curvature_dialog(&args, data, dfield, mfield, id); save_args(gwy_app_settings_get(), &args); if (!ok) return; } curvature_do(data, dfield, mfield, id, &args); if (args.set_selection) gwy_app_channel_log_add_proc(data, id, id); }
static void do_level(GwyContainer *data, GwyRunType run, LevelMethod level_type, const gchar *dialog_title) { GwyDataField *dfield; GwyDataField *mfield; LevelArgs args; gdouble c, bx, by; GQuark quark; gint id; g_return_if_fail(run & LEVEL_RUN_MODES); gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &quark, GWY_APP_DATA_FIELD, &dfield, GWY_APP_DATA_FIELD_ID, &id, GWY_APP_MASK_FIELD, &mfield, 0); g_return_if_fail(dfield && quark); load_args(gwy_app_settings_get(), &args); if (run != GWY_RUN_IMMEDIATE && mfield) { gboolean ok = level_dialog(&args, dialog_title); save_args(gwy_app_settings_get(), &args); if (!ok) return; } if (args.masking == GWY_MASK_IGNORE) mfield = NULL; if (mfield) { if (args.masking == GWY_MASK_EXCLUDE) { mfield = gwy_data_field_duplicate(mfield); gwy_data_field_multiply(mfield, -1.0); gwy_data_field_add(mfield, 1.0); } else g_object_ref(mfield); } gwy_app_undo_qcheckpoint(data, quark, NULL); if (mfield) gwy_data_field_area_fit_plane(dfield, mfield, 0, 0, gwy_data_field_get_xres(dfield), gwy_data_field_get_yres(dfield), &c, &bx, &by); else gwy_data_field_fit_plane(dfield, &c, &bx, &by); switch (level_type) { case LEVEL_SUBTRACT: c = -0.5*(bx*gwy_data_field_get_xres(dfield) + by*gwy_data_field_get_yres(dfield)); gwy_data_field_plane_level(dfield, c, bx, by); break; case LEVEL_ROTATE: bx = gwy_data_field_rtoj(dfield, bx); by = gwy_data_field_rtoi(dfield, by); gwy_data_field_plane_rotate(dfield, atan2(bx, 1), atan2(by, 1), GWY_INTERPOLATION_LINEAR); gwy_debug("b = %g, alpha = %g deg, c = %g, beta = %g deg", bx, 180/G_PI*atan2(bx, 1), by, 180/G_PI*atan2(by, 1)); break; default: g_assert_not_reached(); break; } gwy_app_channel_log_add_proc(data, id, id); gwy_data_field_data_changed(dfield); gwy_object_unref(mfield); }
static void unrotate(GwyContainer *data, GwyRunType run) { enum { nder = 4800 }; GwyDataField *dfield, *mfield, *sfield; UnrotateArgs args; gdouble correction[GWY_SYMMETRY_LAST]; GwyPlaneSymmetry symm; GwyDataLine *derdist; GQuark dquark, mquark, squark; gdouble phi; gboolean ok = TRUE; gint id; g_return_if_fail(run & UNROTATE_RUN_MODES); gwy_app_data_browser_get_current(GWY_APP_DATA_FIELD_KEY, &dquark, GWY_APP_DATA_FIELD, &dfield, GWY_APP_DATA_FIELD_ID, &id, GWY_APP_MASK_FIELD_KEY, &mquark, GWY_APP_MASK_FIELD, &mfield, GWY_APP_SHOW_FIELD_KEY, &squark, GWY_APP_SHOW_FIELD, &sfield, 0); g_return_if_fail(dfield && dquark && mquark && squark); load_args(gwy_app_settings_get(), &args); derdist = GWY_DATA_LINE(gwy_data_line_new(nder, 2*G_PI, FALSE)); gwy_data_field_slope_distribution(dfield, derdist, 5); symm = gwy_data_field_unrotate_find_corrections(derdist, correction); g_object_unref(derdist); if (run == GWY_RUN_INTERACTIVE) { ok = unrotate_dialog(&args, data, dfield, id, correction, symm); save_args(gwy_app_settings_get(), &args); if (!ok) return; } if (args.symmetry) symm = args.symmetry; phi = correction[symm]; if (!mfield) mquark = 0; if (!sfield) squark = 0; if (!mfield && sfield) GWY_SWAP(GQuark, mquark, squark); gwy_app_undo_qcheckpoint(data, dquark, mquark, squark, 0); gwy_data_field_rotate(dfield, phi, args.interp); gwy_data_field_data_changed(dfield); if (mfield) { gwy_data_field_rotate(mfield, phi, GWY_INTERPOLATION_ROUND); gwy_data_field_data_changed(mfield); } if (sfield) { gwy_data_field_rotate(sfield, phi, args.interp); gwy_data_field_data_changed(sfield); } gwy_app_channel_log_add_proc(data, id, id); }
int main(int argc, char **argv) { int i; int x; char *s; char *mpath; char *debuglog; FILE *debugfile; char *common_cflags="-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -D_CRT_SECURE_NO_DEPRECATE"; char *md = "-MD"; char *debug_flags = ""; char *optimize_flags = ""; char *outfile = ""; char *cmd = ""; char **sources = NULL; char *accum_objects = ""; char *linkcmd = ""; int md_forced = 0; int preprocessing = 0; int debug_build = 0; int optimized_build = 0; int linking = 1; int retval; save_args(argc,argv); for(i = 1; i < argc; ++i) { if (argv[i][0] == '-') { char *opt = argv[i]+1; switch(*opt) { case 'W': if(strcmp(opt,"Wall")) { goto filename; } break; case 'c': if(strlen(opt) > 1) { goto filename; } linking = 0; break; case 'E': if(strlen(opt) > 1) { if (opt[1] == 'H') { cmd = add_to(cmd," "); cmd = add_to(cmd,opt); } else { goto filename; } } preprocessing = 1; linking = 0; break; case 'O': /* ignore what opt is requested, set hard */ optimize_flags = "-Ox -Zi"; debug_flags = ""; debug_build = 0; if (!md_forced) { md = "-MD"; } optimized_build = 1; break; case 'g': if (strcmp(opt,"g") && strcmp(opt,"ggdb")) { goto filename; } if (!optimized_build) { debug_flags = "-Z7"; if (!md_forced) { md = "-MDd"; } linkcmd = add_to(linkcmd," -g"); debug_build = 1; } break; case 'm': case 'M': if(!strcmp(opt,"mt") || !strcmp(opt,"MT")) { md = "-MT"; } else if (!strcmp(opt,"md") || !strcmp(opt,"MD")) { md = "-MD"; } else if (!strcmp(opt,"ml") || !strcmp(opt,"ML")) { md = "-ML"; } else if (!strcmp(opt,"mdd") || !strcmp(opt,"MDd") || !strcmp(opt,"MDD")) { md = "-MDd"; } else if (!strcmp(opt,"mtd") || !strcmp(opt,"MTd") || !strcmp(opt,"MTD")) { md = "-MTd"; } else if (!strcmp(opt,"mld") || !strcmp(opt,"MLd") || !strcmp(opt,"MLD")) { md = "-MLd"; } else { goto filename; } md_forced = 1; break; case 'o': if (!strcmp(opt,"o")) { ++i; if (i >= argc) { error("-o without filename"); } outfile = argv[i]; } else { outfile = opt+1; } break; case 'I': if(opt[1] == '/') { mpath = do_cyp(opt+1); cmd = add_to(cmd," -I\""); cmd = add_to(cmd,mpath); cmd = add_to(cmd,"\""); free(mpath); } else { cmd = add_to(cmd," "); cmd = add_to(cmd,opt); } break; case 'D': cmd = add_to(cmd," -"); cmd = add_to(cmd,opt); case 'l': linkcmd = add_to(linkcmd," -"); linkcmd = add_to(linkcmd,opt); break; default: goto filename; } continue; } filename: s = argv[i]; x = strlen(s); if (x > 1 && s[x-1] == 'c' && s[x-2] == '.') { /* C source */ sources = add_to_src(sources,s); } else if (x > 3 && !strcmp(s + (x - 4),".cpp")) { /* C++ */ sources = add_to_src(sources,s); } else if (x > 1 && s[x-1] == 'o' && s[x-2] == '.') { linkcmd = add_to(linkcmd," "); linkcmd = add_to(linkcmd,s); } else { /* Pass rest to linker */ linkcmd = add_to(linkcmd," "); linkcmd = add_to(linkcmd,s); } } if ((debuglog = getenv("CC_SH_DEBUG_LOG")) != NULL) { debugfile = fopen(debuglog,"wb+"); if (debugfile) { fprintf(debugfile,"----------------\n"); } } else { debugfile = NULL; } tmpobjdir = add_to("","/tmp/tmpobj"); { char pidstr[100]; pid_t pid = getpid(); sprintf(pidstr,"%d",pid); tmpobjdir = add_to(tmpobjdir,pidstr); } mkdir(tmpobjdir,0777); if (sources != NULL) { char *output_filename; char *output_flag; char *params; for (i=0;sources[i] != NULL; ++i) { if (!linking) { int x = strlen(outfile); if (x > 1 && outfile[x-1] == 'o' && outfile[x-2] == '.') { if (*outfile != '/') { /* non absolute object */ if (i > 0) { error("Single object multiple sources"); } output_filename = add_to("",outfile); } else { if (i > 0) { error("Single object multiple sources"); } output_filename = do_cyp(outfile); } } else { char *tmp = object_name(sources[i]); /*fprintf(stderr,"sources[i] = %s\ntmp = %s\n", sources[i],tmp);*/ if (!x || outfile[0] != '/') { /* non absolute directory */ output_filename = add_to("",outfile); } else { output_filename = do_cyp(outfile); } /*fprintf(stderr,"output_filename = %s\n",output_filename);*/ if (*output_filename != '\0') { output_filename = add_to(output_filename,"/"); } output_filename = add_to(output_filename,tmp); free(tmp); } } else { char *tmp = object_name(sources[i]); output_filename = add_to("",tmpobjdir); output_filename = add_to(output_filename,"/"); output_filename = add_to(output_filename,tmp); accum_objects = add_to(accum_objects," "); accum_objects = add_to(accum_objects,output_filename); /* reform to dos path */ free(output_filename); output_filename = do_cyp(tmpobjdir); output_filename = add_to(output_filename,"/"); output_filename = add_to(output_filename,tmp); } mpath = do_cyp(sources[i]); if (preprocessing) { output_flag = add_to("","-E"); } else { output_flag = add_to("","-c -Fo"); output_flag = add_to(output_flag,output_filename); } params = add_to("","cl.exe "); params = add_to(params,common_cflags); params = add_to(params," "); params = add_to(params,md); params = add_to(params," "); params = add_to(params,debug_flags); params = add_to(params," "); params = add_to(params,optimize_flags); params = add_to(params," "); params = add_to(params,cmd); params = add_to(params," "); params = add_to(params,output_flag); params = add_to(params," "); params = add_to(params,mpath); free(output_filename); free(output_flag); free(mpath); if (debugfile) { fprintf(debugfile,"%s\n",save); fprintf(debugfile,"%s\n",params); } if (preprocessing) { retval = run(params,0,1); } else { retval = run(params,1,0); } if (retval != 0) { maybe_cleanup(); return retval; } free(params); } } if (linking) { char *out_spec; char *stdlib; char *params; if (strlen(outfile) == 0) { if (sources != NULL && sources[0] != NULL) { char *tmp = exe_name(sources[0]); out_spec = add_to("","-o "); out_spec = add_to(out_spec,tmp); free(tmp); } else { out_spec = add_to("",""); } } else { out_spec = add_to("","-o "); out_spec = add_to(out_spec,outfile); } if (!strcmp(md,"-ML")) { stdlib="-lLIBC"; } else if (!strcmp(md,"-MLd")) { stdlib="-lLIBCD"; } else if (!strcmp(md,"-MD")) { stdlib="-lMSVCRT"; } else if (!strcmp(md,"-MDd")) { stdlib="-lMSVCRTD"; } else if (!strcmp(md,"-MT")) { stdlib="-lLIBCMT"; } else if (!strcmp(md,"-MTd")) { stdlib="-lLIBMTD"; } else { stdlib = ""; } #if 0 params = add_to("","bash ld.sh "); #else params = add_to("","ld_wrap.exe "); #endif params = add_to(params,accum_objects); params = add_to(params," "); params = add_to(params,out_spec); params = add_to(params," "); params = add_to(params,linkcmd); params = add_to(params," "); params = add_to(params,stdlib); free(out_spec); free(accum_objects); if (debugfile) { fprintf(debugfile,"%s\n",params); } if (retval = run(params,0,0) != 0) { maybe_cleanup(); return retval; } free(params); } maybe_cleanup(); return 0; }