int main(int argc, char *argv[]) { int i; unsigned char *ptrs[TOTAL_PAGES]; parse_args(argc, argv); for (i = 0; i < TOTAL_PAGES; i++) { ptrs[i] = malloc(PAGE_SIZE); if (ptrs[i] == NULL) fatal_perror("simple_multi_malloc: malloc"); /* Touch page. */ ptrs[i][0] = 'x'; } summarise(NULL); block(); /* Not strictly necessary, but good habit to free regardless. */ for (i = 0; i < TOTAL_PAGES; i++) free(ptrs[i]); return EXIT_SUCCESS; }
float classifynn(List<Pixel> *ps) { if (twopass) { if (pass==1) { Vnd *summary=summarise(ps); // writetraindata(summary,123.456); data.add(IOData(summary,123.456,ps->num(1))); // destroy(summary); return 123.456; } else { return getnextmeasure(); } } else { Vnd *summary=summarise(ps); traindata.clear(); traindata.add("SNNS pattern definition file V3.2"); // traindata.add(Sformat("generated at %s\n",timestring())); traindata.add("generated at unknown time\n"); traindata.add("No. of patterns: 1"); traindata.add(Sformat("No. of input units: %i",nummeasures)); if (!twooutnodes) traindata.add("No. of output units: 1"); else traindata.add("No. of output units: 2"); traindata.add(""); traindata.add("# Quick question for the NN"); writemeasures(summary); destroy(summary); traindata.add("# Don't know output"); if (!twooutnodes) traindata.add("123.456"); else traindata.add("123.456 654.321"); writelinestofile(traindata,"question.pat"); system("./asknn > tmp.txt"); List<String> ls=readlinesfromfile("answer.res"); // deletefile("answer.res"); float answer; // Haven't bothered with twooutnodes case. sscanf(ls.num(14),"%f",&answer); printf("Answer was %f\n",answer); return answer; } }
static void cleanup(void) { bind_cleanup(); pp_tidyup(); if (debugging(DEBUG_STORE)) { #ifndef TARGET_IS_HELIOS fprintf( stderr,"Time: %ldcs front-end %ldcs back-end\n", (long) tmuse_front,(long) tmuse_back); #endif show_store_use(); } cg_tidy(); #ifndef NO_OBJECT_OUTPUT # ifdef COMPILING_ON_ACORN_KIT { bool have_obj = (objstream != NULL); /* objstream cannot be stdout, so cc_close does a spurious test. */ cc_close(&objstream, objectfile); # ifdef COMPILING_ON_RISC_OS if (have_obj) set_time_stamp(objectfile, YES); # endif # ifdef COMPILING_ON_UNIX if (have_obj && system_flavour != NULL) { char *cmd; cmd = GlobAlloc(SU_Other, 24 + strlen(system_flavour) + strlen(objectfile)); sprintf(cmd,"/usr/bin/symrename -%s %s",system_flavour,objectfile); system(cmd); } # endif } # else cc_close(&objstream, objectfile); # endif #endif #ifndef NO_ASSEMBLER_OUTPUT cc_close(&asmstream, asmfile); #endif cc_close(&listingstream, listingfile); cc_close(&makestream, makefile); summarise(); #ifdef ENABLE_MAPSTORE if (debugging(DEBUG_MAPSTORE)) _mapstore(); #endif alloc_dispose(); }
float classifytrain(List<Pixel> *ps) { bool good=true; int cnt=0; List<Pixel> *qs; bool local=false; printf("A\n"); if (ps->len>1) qs=ps; else { local=true; qs=p2pixelsincircle(ps->num(1),max(glhistrad,eacrad)); } printf("B\n"); for (int i=1;i<=qs->len;i++) { Pixel p=qs->num(i); if (!expected->inmap(p)) { good=false; break; } if (expected->getpos(p.x,p.y)) cnt++; } printf("C\n"); float proportiontext=(float)cnt/(float)qs->len; // Desired output of NN if (local) destroy(qs); printf("D\n"); if (good) { printf("D1\n"); Vnd *summary=summarise(ps); printf("D2\n"); // printf("Input %s should have output %f\n",summary->toString(),proportiontext); data.add(IOData(summary,proportiontext,ps->num(1))); destroy(ps); // writetraindata(summary,proportiontext); // destroy(summary); if (positivedata(data.num(data.len))) positivecnt++; else if (negativedata(data.num(data.len))) negativecnt++; else naffcnt++; } else badcnt++; printf("E\n"); return proportiontext; // +floatrnd(-.2,.2); }