void out_float(TTPtr self, t_float value) { t_atom a; atom_setfloat(&a, value); out_list(self, _sym_float, 1, &a); }
RcppExport SEXP eigen_decomp_list_old(SEXP rate_matrix_list){ Rcpp::List rates_list(rate_matrix_list); int size=rates_list.size(); Rcpp::List out_list(size); out_list = Rcpp::lapply(rates_list, eigen_decomp_cpp); return(Rcpp::wrap(out_list)); }
RcppExport SEXP eigen_decomp_list(SEXP rate_matrix_list){ Rcpp::List rates_list(rate_matrix_list); int size=rates_list.size(); Rcpp::List out_list(size); for(int i=0;i<size;i++){ arma::mat rate=Rcpp::as<arma::mat>(rates_list[i]); arma::cx_colvec eigval; arma::cx_mat eigvec; arma::eig_gen(eigval, eigvec, rate); arma::cx_mat invvectors=arma::inv(eigvec); bool replicate=0; arma::colvec realvec=arma::real(eigval); for(int j=0; j<realvec.n_elem-1;j++){ if(((realvec(j+1)-realvec(j))<1e-5)||((realvec(j)-realvec(j+1))<1e-5)){ replicate=1; exit; } } //just adding this for now replicate=0; out_list[i]=Rcpp::List::create(Rcpp::Named("values") =eigval, Rcpp::Named("invvectors") =invvectors, Rcpp::Named("vectors") =eigvec, Rcpp::Named("rate") =real(rate),Rcpp::Named("replicate")=replicate); } return(wrap(out_list)); }
int main(int argc, char *argv[]) { struct mer_rule *mrule; mer_rule_new(mrule); switch (parse_args(argc, argv, mrule)) { /* Error */ case -1: out_error(); break; /* Output help */ case 0: out_help(); break; /* Add rule */ case 1: return handle_cmd(CMD_ADD, mrule); /* Delete rule */ case 2: return handle_cmd(CMD_DEL, mrule); /* List rules */ case 3: out_list(); break; /* List rules */ case 4: return handle_cmd(CMD_FLUSH, mrule); default: fprintf(stderr, "Unknown parse_args() return value.\n"); return -1; } return 0; }
Record *new_record(void) { extern Record *free_records; Record *p; int i; if (free_records==NULL) { if ((p=(Record *)malloc(sizeof(Record)))==NULL) { printf("Error : Memory allocation error\n"); exit(1); } in_list(&free_records,p); } return(out_list(&free_records)); }
struct item *main_menu(struct item *ptr) { /* Menu for user`s choice */ int choice = 0; for(;;) { printf("1.Initialize list of items\n"); printf("2.Add item in existing list\n"); printf("3.Delete item with specified name\n"); printf("4.Output list on monitor\n"); printf("5.Exit\n"); choice = getchar(); clear_buffer(); if(choice >= '1' && choice <= '4') { switch(choice) { case '1' : ptr = add_item(ptr, 0); break; case '2' : ptr = add_item(ptr, 1); break; case '3' : ptr = del_item(ptr); break; case '4' : out_list(ptr); break; } } else if(choice == '5') { break; } else { printf("Wrong choice. Please input again\n"); } } if(ptr != NULL) { while(ptr->prev != NULL) { ptr = ptr->prev; } } return ptr; }
enum plist_result Playlist::Save(std::string file, enum plist_format format) const { switch(format) { case PL_FORMAT_M3U: if(file.length() < 4 || strcasecmp(file.substr(file.length() - 4).c_str(), ".m3u")) { file += ".m3u"; } //cout << "Saving to " << file << endl; std::ofstream out_list(file.c_str()); if(!out_list) return E_PL_BAD; //out_list << MAGIC_ID << endl; std::vector<PlayItem>::const_iterator p = queue.begin(); while(p != queue.end()) { out_list << (*p).filename << std::endl; p++; } } return E_PL_SUCCESS; }
static void options(void) { int ch; /* return value from getopt() */ int n; /* for CR and LF modes */ /* * * Reads and processes the command line options. Added the -P option so arbitrary * PostScript code can be passed through. Expect it could be useful for changing * definitions in the prologue for which options have not been defined. * * Although any PostScript font can be used, things will only work for constant * width fonts. * */ while ( (ch = getopt(argc, argv, optnames)) != EOF ) { switch ( ch ) { case 'a': /* aspect ratio */ fprintf(stdout, "/aspectratio %s def\n", optarg); break; case 'c': /* copies */ copies = atoi(optarg); fprintf(stdout, "/#copies %s store\n", optarg); break; case 'f': /* use this PostScript font */ fontname = get_font(optarg); fprintf(stdout, "/font /%s def\n", fontname); break; case 'h': /* default character spacing */ ohmi = hmi = atoi(optarg) * HSCALE; fprintf(stdout, "/hmi %s def\n", optarg); break; case 'l': /* lines per page */ linespp = atoi(optarg); break; case 'm': /* magnification */ fprintf(stdout, "/magnification %s def\n", optarg); break; case 'n': /* forms per page */ formsperpage = atoi(optarg); fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); fprintf(stdout, "/formsperpage %s def\n", optarg); break; case 'o': /* output page list */ out_list(optarg); break; case 'p': /* landscape or portrait mode */ if ( *optarg == 'l' ) fprintf(stdout, "/landscape true def\n"); else fprintf(stdout, "/landscape false def\n"); break; case 'r': /* set CR and LF modes */ n = atoi(optarg); if ( n & 01 ) lfiscr = ON; else lfiscr = OFF; if ( n & 02 ) crislf = ON; else crislf = OFF; break; case 's': /* point size */ fprintf(stdout, "/pointsize %s def\n", optarg); break; case 'v': /* default line spacing */ ovmi = vmi = atoi(optarg) * VSCALE; break; case 'x': /* shift things horizontally */ fprintf(stdout, "/xoffset %s def\n", optarg); break; case 'y': /* and vertically on the page */ fprintf(stdout, "/yoffset %s def\n", optarg); break; case 'A': /* force job accounting */ case 'J': if ( (fp_acct = fopen(optarg, "a")) == NULL ) error(FATAL, "can't open accounting file %s", optarg); break; case 'C': /* copy file straight to output */ if ( cat(optarg) == FALSE ) error(FATAL, "can't read %s", optarg); break; case 'E': /* text font encoding */ fontencoding = optarg; break; case 'L': /* PostScript prologue file */ prologue = optarg; break; case 'P': /* PostScript pass through */ fprintf(stdout, "%s\n", optarg); break; case 'R': /* special global or page level request */ saverequest(optarg); break; case 'D': /* debug flag */ debug = ON; break; case 'I': /* ignore FATAL errors */ ignore = ON; break; case '?': /* don't understand the option */ error(FATAL, ""); break; default: /* don't know what to do for ch */ error(FATAL, "missing case for option %c\n", ch); break; } /* End switch */ } /* End while */ argc -= optind; /* get ready for non-option args */ argv += optind; } /* End of options */
static void options(void) { int ch; /* return value from getopt() */ char *optnames = "n:o:rvT:DI"; extern char *optarg; /* used by getopt() */ extern int optind; /* * * Reads and processes the command line options. The -r option (ie. the one that * turns page reversal off) is really only useful if you want to take dpost output * and produce a page independent output file. In that case global definitions * made within pages and bracketed by %%BeginGlobal/%%EndGlobal comments will be * moved into the prologue or setup section of the document. * */ while ( (ch = getopt(argc, argv, optnames)) != EOF ) { switch ( ch ) { case 'n': /* forms per page */ if ( (forms = atoi(optarg)) <= 0 ) error(FATAL, "illegal forms request %s", optarg); break; case 'o': /* output page list */ out_list(optarg); break; case 'r': /* don't reverse the pages */ noreverse = TRUE; break; case 'v': /* ignore possible forms.ps problems */ ignoreversion = TRUE; break; case 'T': /* temporary file directory */ temp_dir = optarg; break; case 'D': /* debug flag */ debug = ON; break; case 'I': /* ignore FATAL errors */ ignore = ON; break; case '?': /* don't understand the option */ error(FATAL, ""); break; default: /* don't know what to do for ch */ error(FATAL, "missing case for option %c\n", ch); break; } /* End switch */ } /* End while */ argc -= optind; /* get ready for non-option args */ argv += optind; } /* End of options */
void out_bang(TTPtr self) { out_list(self, _sym_bang, 0, NULL); }
static void options(void) { int ch; /* return value from getopt() */ /* * * Reads and processes the command line options. Added the -P option so arbitrary * PostScript code can be passed through. Expect it could be useful for changing * definitions in the prologue for which options have not been defined. * */ while ( (ch = getopt(argc, argv, optnames)) != EOF ) { switch ( ch ) { case 'a': /* aspect ratio */ fprintf(stdout, "/aspectratio %s def\n", optarg); break; case 'b': /* bytes per pattern - on output */ bytespp = atoi(optarg); break; case 'c': /* copies */ copies = atoi(optarg); fprintf(stdout, "/#copies %s store\n", optarg); break; case 'd': /* default matrix dimensions */ sscanf(optarg, "%dx%d", &dfltrows, &dfltcols); break; case 'g': /* set the colormap (ie. grayscale) */ colormap = optarg; break; case 'i': /* matrix element interval list */ interval = optarg; break; case 'm': /* magnification */ fprintf(stdout, "/magnification %s def\n", optarg); break; case 'n': /* forms per page */ formsperpage = atoi(optarg); fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); fprintf(stdout, "/formsperpage %s def\n", optarg); break; case 'o': /* output page list */ out_list(optarg); break; case 'p': /* landscape or portrait mode */ if ( *optarg == 'l' ) fprintf(stdout, "/landscape true def\n"); else fprintf(stdout, "/landscape false def\n"); break; case 'w': /* set the window */ window = optarg; break; case 'x': /* shift things horizontally */ fprintf(stdout, "/xoffset %s def\n", optarg); break; case 'y': /* and vertically on the page */ fprintf(stdout, "/yoffset %s def\n", optarg); break; case 'A': /* force job accounting */ case 'J': if ( (fp_acct = fopen(optarg, "a")) == NULL ) error(FATAL, "can't open accounting file %s", optarg); break; case 'C': /* copy file straight to output */ if ( cat(optarg) == FALSE ) error(FATAL, "can't read %s", optarg); break; case 'L': /* PostScript prologue file */ prologue = optarg; break; case 'P': /* PostScript pass through */ fprintf(stdout, "%s\n", optarg); break; case 'R': /* special global or page level request */ saverequest(optarg); break; case 'D': /* debug flag */ debug = ON; break; case 'I': /* ignore FATAL errors */ ignore = ON; break; case '?': /* don't understand the option */ error(FATAL, ""); break; default: /* don't know what to do for ch */ error(FATAL, "missing case for option %c\n", ch); break; } /* End switch */ } /* End while */ argc -= optind; /* get ready for non-option args */ argv += optind; } /* End of options */
static void options(void) { int ch; /* return value from getopt() */ int euro = 0; extern char *getenv(char *); /* * * Reads and processes the command line options. Added the -P option so arbitrary * PostScript code can be passed through. Expect it could be useful for changing * definitions in the prologue for which options have not been defined. * * Although any PostScript font can be used, things will only work well for * constant width fonts. * */ if (((locale = getenv("LC_MONETARY")) != NULL) || ((locale = getenv("LANG")) != NULL)) { char *tmp = NULL; /* if there is a locale specific prologue, use it as the default */ if ((tmp = calloc(1, strlen(POSTPRINT) + strlen(locale) + 2)) != NULL) { sprintf(tmp, "%s-%s", POSTPRINT, locale); if (access(tmp, R_OK) == 0) prologue = tmp; else free(tmp); } /* if the locale has 8859-15 or euro in it, add the symbol to font */ if ((strstr(locale, "8859-15") != NULL) || (strstr(locale, "euro") != NULL)) euro = 1; } while ( (ch = getopt(argc, argv, optnames)) != EOF ) { #if defined(DEBUG) fprintf(stderr, " Opt: %c, arg: %s\n", ch, optarg); #endif switch ( ch ) { case 'a': /* aspect ratio */ fprintf(stdout, "/aspectratio %s def\n", optarg); break; case 'c': /* copies */ copies = atoi(optarg); fprintf(stdout, "/#copies %s store\n", optarg); break; case 'e': /* should we add the euro ? */ euro = (strcasecmp(optarg, "on") == 0); break; case 'f': /* use this PostScript font */ fontname = get_font(optarg); fprintf(stdout, "/font /%s def\n", fontname); break; case 'l': /* lines per page */ linespp = atoi(optarg); break; case 'm': /* magnification */ fprintf(stdout, "/magnification %s def\n", optarg); break; case 'n': /* forms per page */ formsperpage = atoi(optarg); if (formsperpage <= 0) { /* set default value */ formsperpage = 1; } fprintf(stdout, "/formsperpage %d def\n", formsperpage); break; case 'o': /* output page list */ out_list(optarg); break; case 'p': /* landscape or portrait mode */ if ( *optarg == 'l' ) fprintf(stdout, "/landscape true def\n"); else fprintf(stdout, "/landscape false def\n"); break; case 'r': /* carriage return mode */ crmode = atoi(optarg); break; case 's': /* point size */ pointsize = atoi(optarg); fprintf(stdout, "/pointsize %s def\n", optarg); break; case 't': /* tabstops */ tabstops = atoi(optarg); if (tabstops <= 0) { /* set default */ tabstops = TABSTOPS; } break; case 'x': /* shift things horizontally */ fprintf(stdout, "/xoffset %s def\n", optarg); break; case 'y': /* and vertically on the page */ fprintf(stdout, "/yoffset %s def\n", optarg); break; case 'A': /* force job accounting */ case 'J': if ( (fp_acct = fopen(optarg, "a")) == NULL ) error(FATAL, "can't open accounting file %s", optarg); break; case 'C': /* copy file straight to output */ if ( cat(optarg) == FALSE ) error(FATAL, "can't read %s", optarg); break; case 'L': /* PostScript prologue file */ prologue = optarg; break; case 'P': /* PostScript pass through */ fprintf(stdout, "%s\n", optarg); break; case 'R': /* special global or page level request */ saverequest(optarg); break; case 'D': /* debug flag */ debug = ON; break; case 'I': /* ignore FATAL errors */ ignore = ON; break; case '?': /* don't understand the option */ error(FATAL, ""); break; default: /* don't know what to do for ch */ error(FATAL, "missing case for option %c\n", ch); break; } /* End switch */ } /* End while */ if (euro != 0) fprintf(stdout, "/must-add-euro-to-font true def\n"); argc -= optind; /* get ready for non-option args */ argv += optind; } /* End of options */