static int f2pmmatsolve_main(int argc, char ** argv, usage_t * pusage) { f2poly_t m = 0; f2polymod_t zero, one; if (argc != 4) pusage(argv[0]); if (!m.from_string(argv[1])) pusage(argv[0]); zero = f2polymod_t(m.prime_sfld_elt(0), m); one = f2polymod_t(m.prime_sfld_elt(1), m); tmatrix<f2polymod_t> A; tvector<f2polymod_t> x; tvector<f2polymod_t> b; A = f2polymod_t(zero); b = f2polymod_t(zero); if (!A.load_from_file(argv[2])) pusage(argv[0]); if (!b.load_from_file(argv[3])) pusage(argv[0]); if (!A.solve_unique(x, b, zero, one)) { std::cerr << "No unique solution.\n"; return 1; } std::cout << x << "\n"; return 0; }
int main(int argc, char ** argv) { f2poly_t im; f2npoly_t om; f2npolymod_t g; if (argc != 3) pusage(argv[0]); if (!im.from_string(argv[1])) pusage(argv[0]); if (!om.from_string(argv[2], im)) pusage(argv[0]); if (!f2npolymod_find_generator(om, g)) { std::cerr << "Couldn't find generator mod " << om << "\n"; exit(1); } tvector<f2npolymod_t> elts = f2npolymod_list(om, SP_LIST_UNITS); int n = elts.get_num_elements(); std::cout << "element power\n"; std::cout << "------- -----\n"; for (int i = 0; i < n; i++) { int e = f2npolymod_log(g, elts[i]); std::cout << elts[i] << " " << e << "\n"; } return 0; }
/* PPCONF *------------------------------------------------------------* */ int ppconf (int argc, char *argv[], config_t *config_p, char **display, char **geometry, char * (*GetDefault)(char const *, char const *), char last) { int32 i, parsed; int32 bad_usage = FALSE; char *str_p; Config_t *cp; if (GetDefault) { for (cp = (Config_t *)config_p; cp->arg_type != NOTYPE; cp++) { if ((str_p = GetDefault (argv[0], cp->LongName))) { bad_usage |= SetVal (cp, str_p); } } } for (i = 1; i < argc; i++) { /* argument has been processed already */ if (argv[i][0] == '\0') continue; for (parsed = FALSE, cp = (Config_t *)config_p; cp->arg_type != NOTYPE; cp++) { if (mystrcasecmp (argv[i], cp->swtch) == 0) { parsed = TRUE; /* remove this switch from consideration */ argv[i][0] = '\0'; if (++i < argc) { bad_usage |= SetVal (cp, argv[i]); argv[i][0] = '\0'; } else bad_usage = TRUE; } } if (parsed || !last) continue; if (geometry && (*argv[i] == '=')) { *geometry = argv[i]; continue; } if (display && (strchr (argv[i], ':') != 0)) { *display = argv[i]; continue; } if ((mystrcasecmp ("-?", argv[i]) == 0) || (mystrcasecmp ("-help", argv[i]) == 0)) pusage (argv[0], (Config_t *) config_p); printf ("%s: Unrecognized argument, %s\n", argv[0], argv[i]); bad_usage = TRUE; } return (bad_usage); }
void parse_args(int argc, char * const argv[]) { int c; while((c = getopt(argc, argv, "c:m:M:d:t:p:s:w:h")) != -1) { switch(c) { case 'c': { concurrent_values = atoi(optarg); } break; case 'm': { min_val_size = atoi(optarg); } break; case 'M': { max_val_size = atoi(optarg); } break; case 'd': { duration = atoi(optarg); } break; case 't': { values_timeout.tv_sec = atoi(optarg); } break; case 'p': { print_step = atoi(optarg); } break; case 's': { sample_frequency = atoi(optarg); samples = malloc(sizeof(double)*max_samples); } break; case 'w': { wait_after_init = atoi(optarg); } break; case 'h': default: { pusage(); exit(0); } } } }
int main(int argc, char **argv) { BCPPARAMDATA params; DBPROCESS *dbsrc; DBPROCESS *dbtarget; setlocale(LC_ALL, ""); memset(¶ms, '\0', sizeof(params)); if (process_parameters(argc, argv, ¶ms) == FALSE) { pusage(); return 1; } if (login_to_databases(¶ms, &dbsrc, &dbtarget) == FALSE) return 1; if (params.cflag) { if (create_target_table(params.src.dbobject, params.owner, params.dest.dbobject, dbsrc, dbtarget) == FALSE) { printf("datacopy: could not create target table %s.%s . terminating\n", params.owner, params.dest.dbobject); dbclose(dbsrc); dbclose(dbtarget); return 1; } } if (check_table_structures(params.src.dbobject, params.dest.dbobject, dbsrc, dbtarget) == FALSE) { printf("datacopy: table structures do not match. terminating\n"); dbclose(dbsrc); dbclose(dbtarget); return 1; } if (transfer_data(params, dbsrc, dbtarget) == FALSE) { printf("datacopy: table copy failed.\n"); printf(" the data may have been partially copied into the target database \n"); dbclose(dbsrc); dbclose(dbtarget); return 1; } dbclose(dbsrc); dbclose(dbtarget); return 0; }
/* PCONF *------------------------------------------------------------* */ int pconf (int argc, char *argv[], config_t *config_p, char **display, char **geometry, char * (*GetDefault)(char const *, char const *)) { int32 i, parsed; int32 bad_usage = FALSE; char *str_p; Config_t *cp; if (GetDefault) { for (cp = (Config_t *) config_p; cp->arg_type != NOTYPE; cp++) { if ((str_p = GetDefault (argv[0], cp->LongName))) { bad_usage |= SetVal (cp, str_p); } } } for (i = 1; i < argc; i++) { for (parsed = FALSE, cp = (Config_t *) config_p; cp->arg_type != NOTYPE; cp++) { /* FIXME: do we *really* need our own strcasecmp? */ if (mystrcasecmp (argv[i], cp->swtch) == 0) { parsed = TRUE; if (++i < argc) bad_usage |= SetVal (cp, argv[i]); else bad_usage = TRUE; } } if (parsed) continue; if (geometry && (*argv[i] == '=')) { *geometry = argv[i]; continue; } if (display && (strchr (argv[i], ':') != 0)) { *display = argv[i]; continue; } if ((mystrcasecmp ("-?", argv[i]) == 0) || (mystrcasecmp ("-help", argv[i]) == 0)) pusage (argv[0], (Config_t *) config_p); bad_usage = TRUE; } return (bad_usage); }
void parse_args(int argc, char * const argv[]) { int c; while((c = getopt(argc, argv, "i:k:s:rlh")) != -1) { switch(c) { case 'i': proposer_id = atoi(optarg); break; case 'k': values_to_propose = atoi(optarg); break; case 's': value_size = atoi(optarg); break; case 'r': measure_avg_time = 1; break; case 'l': deliver_func = deliver; break; case 'h': default: { pusage(); exit(0); } } } }
int main(int argc, char * argv[]) { FSLIO *fslio; void *buffer; char *f1name; double ***vol; int x,y,z,t; /*** process commandline parameters */ if (argc < 2) { pusage(argv[0]); exit(1); } /************************* PRINT ***************************/ if (!strncmp(argv[1],"print",5)) { if (argc != 3) { fprintf(stderr, "\nError, print command takes one parameter: print <dataset>\n"); exit(1); } f1name = argv[2]; /** open nifti dataset */ fslio = FslInit(); buffer = FslReadAllVolumes(fslio,f1name); if (buffer == NULL) { fprintf(stderr, "\nError opening and reading %s.\n",f1name); exit(1); } nifti_image_infodump(fslio->niftiptr); exit(0); } /************************* PEEK ***************************/ if (!strncmp(argv[1],"peek",4)) { if (argc != 7) { fprintf(stderr, "\nError, peek command takes five parameters: peek <dataset> X Y Z T\n"); exit(1); } /**** get inputs */ f1name = argv[2]; x = atoi(argv[3]); y = atoi(argv[4]); z = atoi(argv[5]); t = atoi(argv[6]); /** open nifti dataset header */ fslio = FslReadHeader(f1name); if (fslio == NULL) { fprintf(stderr, "\nError, could not read header info for %s.\n",f1name); exit(1); } /**** check inputs */ if ( (x<0) || (x>=fslio->niftiptr->nx) ) { fprintf(stderr, "\nError: x index (%d) out of range [0..%d]\n",x,fslio->niftiptr->nx-1); exit(1); } if ( (y<0) || (y>=fslio->niftiptr->ny) ) { fprintf(stderr, "\nError: y index (%d) out of range [0..%d]\n",y,fslio->niftiptr->ny-1); exit(1); } if ( (z<0) || (z>=fslio->niftiptr->nz) ) { fprintf(stderr, "\nError: z index (%d) out of range [0..%d]\n",z,fslio->niftiptr->nz-1); exit(1); } if ( (t<0) || (t>=fslio->niftiptr->nt) ) { fprintf(stderr, "\nError: t index (%d) out of range [0..%d]\n",t,fslio->niftiptr->nt-1); exit(1); } /*** get volume data as scaled doubles */ vol = FslGetVolumeAsScaledDouble(fslio,t); if (vol == NULL) { fprintf(stderr, "\nError accessing %s\n",f1name); exit(1); } else { fprintf(stderr, "\nLocation %d %d %d %d: %.4f\n",x,y,z,t,vol[z][y][x]); exit(0); } } fprintf(stderr, "\nError, unrecognized command %s\n",argv[1]); pusage(argv[0]); exit(1); }
void kb (int argc, char *argv[], float ip, /* word insertion penalty */ float lw, /* langauge weight */ float pip) /* phone insertion penalty */ { char *pname = argv[0]; char hmm_file_name[256]; int32 num_phones, num_ci_phones; int32 i, use_darpa_lm; /* FIXME: This is evil. But if we do it, let's prototype it somewhere, OK? */ unlimit (); /* Remove memory size limits */ language_weight = lw; insertion_penalty = ip; phone_insertion_penalty = pip; pconf (argc, argv, kb_param, 0, 0, 0); if ((phone_file_name == 0) || (dict_file_name == 0)) pusage (pname, (Config_t *)kb_param); log_info("%s(%d): Reading phone file [%s]\n", __FILE__, __LINE__, phone_file_name); if (phone_read (phone_file_name)) exit (-1); if (useWDPhonesOnly) phone_add_diphones(); num_ci_phones = phoneCiCount(); /* Read the distribution map file */ log_info("%s(%d): Reading map file [%s]\n", __FILE__, __LINE__, mapFileName); read_map (mapFileName, TRUE /* useCiTrans compress */); log_info("%s(%d): Reading dict file [%s]\n", __FILE__, __LINE__, dict_file_name); word_dict = dict_new (); if (dict_read (word_dict, dict_file_name, phrase_dict_file_name, noise_dict_file_name, !useWDPhonesOnly)) exit (-1); use_darpa_lm = TRUE; if (use_darpa_lm) { lmSetStartSym (lm_start_sym); lmSetEndSym (lm_end_sym); /* * Read control file describing multiple LMs, if specified. * File format (optional stuff is indicated by enclosing in []): * * [{ LMClassFileName LMClassFilename ... }] * TrigramLMFileName LMName [{ LMClassName LMClassName ... }] * TrigramLMFileName LMName [{ LMClassName LMClassName ... }] * ... * (There should be whitespace around the { and } delimiters.) * * This is an extension of the older format that had only TrigramLMFilenName * and LMName pairs. The new format allows a set of LMClass files to be read * in and referred to by the trigram LMs. (Incidentally, if one wants to use * LM classes in a trigram LM, one MUST use the -lmctlfn flag. It is not * possible to read in a class-based trigram LM using the -lmfn flag.) * * No "comments" allowed in this file. */ if (lm_ctl_filename) { FILE *ctlfp; char lmfile[4096], lmname[4096], str[4096]; lmclass_set_t lmclass_set; lmclass_t *lmclass, cl; int32 n_lmclass, n_lmclass_used; lmclass_set = lmclass_newset(); E_INFO("Reading LM control file '%s'\n", lm_ctl_filename); ctlfp = CM_fopen (lm_ctl_filename, "r"); if (fscanf (ctlfp, "%s", str) == 1) { if (strcmp (str, "{") == 0) { /* Load LMclass files */ while ((fscanf (ctlfp, "%s", str) == 1) && (strcmp (str, "}") != 0)) lmclass_set = lmclass_loadfile (lmclass_set, str); if (strcmp (str, "}") != 0) E_FATAL("Unexpected EOF(%s)\n", lm_ctl_filename); if (fscanf (ctlfp, "%s", str) != 1) str[0] = '\0'; } } else str[0] = '\0'; /* Fill in dictionary word id information for each LMclass word */ for (cl = lmclass_firstclass(lmclass_set); lmclass_isclass(cl); cl = lmclass_nextclass(lmclass_set, cl)) { kb_init_lmclass_dictwid (cl); } /* At this point if str[0] != '\0', we have an LM filename */ n_lmclass = lmclass_get_nclass(lmclass_set); lmclass = (lmclass_t *) CM_calloc (n_lmclass, sizeof(lmclass_t)); /* Read in one LM at a time */ while (str[0] != '\0') { strcpy (lmfile, str); if (fscanf (ctlfp, "%s", lmname) != 1) E_FATAL("LMname missing after LMFileName '%s'\n", lmfile); n_lmclass_used = 0; if (fscanf (ctlfp, "%s", str) == 1) { if (strcmp (str, "{") == 0) { /* LM uses classes; read their names */ while ((fscanf (ctlfp, "%s", str) == 1) && (strcmp (str, "}") != 0)) { if (n_lmclass_used >= n_lmclass) E_FATAL("Too many LM classes specified for '%s'\n", lmfile); lmclass[n_lmclass_used] = lmclass_get_lmclass (lmclass_set, str); if (! (lmclass_isclass(lmclass[n_lmclass_used]))) E_FATAL("LM class '%s' not found\n", str); n_lmclass_used++; } if (strcmp (str, "}") != 0) E_FATAL("Unexpected EOF(%s)\n", lm_ctl_filename); if (fscanf (ctlfp, "%s", str) != 1) str[0] = '\0'; } } else str[0] = '\0'; if (n_lmclass_used > 0) lm_read_clm (lmfile, lmname, language_weight, unigramWeight, insertion_penalty, lmclass, n_lmclass_used); else lm_read (lmfile, lmname, language_weight, unigramWeight, insertion_penalty); } fclose (ctlfp); NoLangModel = FALSE; } /* Read "base" LM file, if specified */ if (lm_file_name) { lmSetStartSym (lm_start_sym); lmSetEndSym (lm_end_sym); lm_read (lm_file_name, "", language_weight, unigramWeight, insertion_penalty); /* Make initial OOV list known to this base LM */ lm_init_oov (); NoLangModel = FALSE; } #ifdef USE_ILM /* Init ILM module (non-std-Darpa LM, eg ug/bg cache LM) */ ilm_init (); #endif } #if 0 /* Compute the phrase lm probabilities */ computePhraseLMProbs (); #endif num_phones = phone_count (); numSmds = hmm_num_sseq(); smds = (SMD *) CM_calloc (numSmds, sizeof (SMD)); /* * Read the hmm's into the SMD structures */ if (useBigHmmFiles) { for (i = 0; i < num_ci_phones; i++) { sprintf (hmm_file_name, "%s.%s", phone_from_id (i), hmm_ext); hmm_tied_read_big_bin (hmm_dir_list, hmm_file_name, smds, transSmooth, NUMOFCODEENTRIES, TRUE, transWeight); } } else { for (i = 0; i < num_phones; i++) { if ((!useCiTrans) || (phone_id_to_base_id(i) == i)) { sprintf (hmm_file_name, "%s.%s", phone_from_id (i), hmm_ext); hmm_tied_read_bin (hmm_dir_list, hmm_file_name, &smds[hmm_pid2sid(i)], transSmooth, NUMOFCODEENTRIES, TRUE, transWeight); } } } /* * Use Ci transitions ? */ if (useCiTrans) { for (i = 0; i < num_phones; i++) { if (hmm_pid2sid(phone_id_to_base_id(i)) != hmm_pid2sid(i)) { /* * Just make a copy of the CI phone transitions */ memcpy (&smds[hmm_pid2sid(i)], &smds[hmm_pid2sid(phone_id_to_base_id(i))], sizeof (SMD)); } } } /* * Read the distributions */ read_dists (hmm_dir, code1_ext, code2_ext, code3_ext, code4_ext, NUMOFCODEENTRIES, hmm_smooth_min, useCiPhonesOnly); if (Use8BitSenProb) SCVQSetSenoneCompression (8); /* * Map the distributions to the correct locations */ remap (smds); }
int main( int argc, char *argv[] ){ int retries; int rv; uint32_t uv = 0; int tz = 0; struct ntp_t *ptr = (struct ntp_t *)buf; char *p; while ((rv = getopt( argc, argv, "p:o:ds" )) > 0 ){ switch (rv){ case 'p': port = atoi( optarg ); break; case 'o': tz = atoi( optarg ); if (tz < -12 || tz > 12){ fprintf(stderr, "bad timezone\n"); exit(1); } break; case 's': setflg = 1; break; case 'd': disflg = 1; break; case '?': pusage(); } } if( ! argv[optind] ) pusage(); my_open( argc, argv ); retries = 3; while (retries--){ sendq(); signal( SIGALRM, alarm_handler ); alarm(2); rv = read( fd, buf, MAXBUF); if (rv < 0 ) continue; if (rv >= sizeof( struct ntp_t )) goto process; } fprintf(stderr, "timeout\n"); exit(1); process: uv = ptr->xmit.sec; uv -= 2208988800L; uv += tz * 60 * 60; if (disflg || !setflg) printf(ctime((time_t *)&uv)); if (setflg){ rv = stime((time_t *)&uv); if (rv){ perror( "stime" ); exit(1); } } exit(0); }