int maxneb_disc () { Rcpp::IntegerVector targs(targets); Rcpp::IntegerVector nebs(neighbors); Rcpp::IntegerVector plot(plots); Rcpp::CharacterVector status(stat); Rcpp::IntegerVector xx(bqudx); Rcpp::IntegerVector yy(bqudy); Rcpp::IntegerVector tt(time); int rad = Rcpp::as<int>(sr); Rcpp::IntegerVector counts(targs.size()); int max_neb = 0; for (int i = 0, n = targs.size(); i < n; i++) { int targ = index(targs[i], nebs); int num_nebs= 0; for (int neb = 0, n2 = nebs.size(); neb < n2; neb++) { if (targ != neb && plot[targ] == plot[neb] && (std::strcmp("ALIVE", status[neb]) == 0) && (xx[targ] + sr > xx[neb]) && (xx[targ] - sr < xx[neb]) && (yy[targ] + sr > yy[neb]) && (yy[targ] - sr < yy[neb]) && tt[targ] == tt[neb]) num_nebs++; } counts[i] = num_nebs; } return std::max_element(counts.begin(), counts.end(), myfn); }
int main() { int mask; printf("/* WARNING: DO NOT EDIT THIS AUTOMATICALLY-GENERATED FILE */\n"); printf("#define JUMPTAB_ARGLIST(args) "); for (mask=0; mask < MAXBITS; mask++) printf(",args[%i]",mask); printf("\n"); printf("#define MAXBITS %i\n",MAXBITS); for (mask=0; mask< (1<<MAXBITS); mask++) { printf("typedef %s (*",typ[RES]); tnam(mask); printf(")("); targs(mask); printf(");\n"); printf("static %s ",typ[RES]); fnam(mask); protoargs(); printf("\n"); printf("{return (("); tnam(mask); printf(")f->tv.p)("); callargs(mask); printf(");}\n\n"); } printf("static UFUNC jumptab[%i]={\n",1<<MAXBITS); for (mask=0; mask < (1<<MAXBITS); mask++) { printf("\t"); fnam(mask); printf(",\n"); } printf("};\n"); return 0; }