static void readatomics(void) { int curpos,len; rrecs[currec].acnt=0; rrecs[currec].cura=0; begin: flushbuff(); if(rrecs[currec].eof==1 && rrecs[currec].comment==1) { longjmp(lex_jmp_buf,2); printf("\nEnd of file \"%s\" within comment /*...*/ \n", CurrentInputFile()); exit(0); } if(rrecs[currec].eof==1) return; len=strlen(cbuf); curpos=0; if(rrecs[currec].comment==1) { curpos=end_of_comment(-2); if(cbuf[curpos]!=0) rrecs[currec].comment=0; else goto begin; } while((isspace(cbuf[curpos])||iscntrl(cbuf[curpos])) && curpos<len) curpos++; if(curpos==len) goto begin; if(cbuf[curpos]=='%') goto begin; while(curpos<len) { int alen; if(cbuf[curpos]=='%') { if(rrecs[currec].acnt==0) goto begin; else return; } if(cbuf[curpos]=='/' && cbuf[curpos+1]=='*') { curpos=end_of_comment(curpos); if(cbuf[curpos]==0) rrecs[currec].comment=1; goto lll; } rrecs[currec].a[rrecs[currec].acnt]=read_a(cbuf+curpos,&alen); rrecs[currec].acnt++; curpos+=alen; lll: while((isspace(cbuf[curpos])||iscntrl(cbuf[curpos])) && curpos<len) curpos++; } if(rrecs[currec].acnt==0) goto begin; }
int main(int argc, char const *argv[]) { maxij (*func[NUM_FUNCTIONS]) (int*,int) = {maxsubarray_1,maxsubarray_2,maxsubarray_3,maxsubarray_4}; if (argc > 1){ experimentalAnalysis(func[atoi(argv[1])]); return 0; } FILE* rfile; FILE* wfile; int size = 0; int a[MAX_ARRAY_SIZE]; int eof_flag = 0; int i; if ((rfile = fopen(INPUT_FILE_NAME, "r")) == NULL) { printf("Cannot open '%s' for reading\n", INPUT_FILE_NAME); exit(-1); } if ((wfile = fopen(OUTPUT_FILE_NAME, "w")) == NULL) { printf("Cannot open '%s' for writing\n", OUTPUT_FILE_NAME); exit(-1); } while (eof_flag == 0) { if ((size = read_a(rfile, &a[0], &eof_flag)) == 0) { break; } write_array_file(wfile,a,size); maxij result; for(i = 0; i<NUM_FUNCTIONS; ++i){ result = (*func[i]) (a,size); write_array_file(wfile,a + result.i, result.j - result.i + 1); fprintf(wfile, "%d\n", result.max); } fprintf(wfile, "%s", "\n"); } fclose(rfile); fclose(wfile); return 0; }
void read_config(HMM* word, char **files,int job, int states, int len) { // variables int i; int N = states; int T = len; word->nstates = N; word->len = T; // allocate parameters word->b = (float*)malloc(sizeof(float)*N*T); word->a = (float*)malloc(sizeof(float)*N*N); word->pri = (float*)malloc(sizeof(float)*N); for(i = 0; i < 3; ++i){ //printf("%s\n",files[job*3+i]); // read B if(i == 0){ //printf("read B[%d][%d] \t\t", N, T); read_b(files[job*3],word,N,T); //printf("done!\n"); } // read A if(i == 1){ //printf("read A[%d][%d] \t\t", N, N); read_a(files[job*3+1],word,N,N); //printf("done!\n"); } // read prior if(i == 2){ //printf("read prior[%d] \t\t", N); read_pri(files[job*3+2],word,N); //printf("done!\n"); } } }