int main(void) { int i; map *m; int lastcap; stats s; stat_list *l1, *l2; stat_list_iterator iter; double _max_load[] = {0.2, 0.3, 0.5, 0.7, 0.85, 1.0, 1.15, 1.3, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 6.0, 9.0, 12.0, 15.0, 20.0, 0.0}; double *max_load = _max_load; l1 = stat_list_new(); l2 = stat_list_new(); while (*max_load > 0) { m = map_new(); m->max_load = *max_load; ++max_load; lastcap = m->cap; s = map_stats(m); srand(0); for (i=0; i<=N; ++i) { while (m->cap == lastcap) { if ((m->len+1.0)/m->cap > m->max_load) { s = map_stats(m); } map_set(m, randt(), randt()); } lastcap = m->cap; } stat_list_insert(l1, s, -1); stat_list_insert(l2, map_stats(m), -1); map_free(m); } print_header(); print_hr(); for (iter=stat_list_iterate(l1); stat_list_next(l1, &iter); ) { print_stats(stat_list_get_at(l1, iter)); } print_hr(); print_header(); print_hr(); for (iter=stat_list_iterate(l2); stat_list_next(l2, &iter); ) { print_stats(stat_list_get_at(l2, iter)); } stat_list_free(l1); stat_list_free(l2); return 0; }
/*! Construct a density scoring object from the given Xmap. Fragments will then be scored based on the position of the densitied in a cumulative density distribution based on a Gaussian distribution derived from the the mean and variance of the map. \param xmap The electron density map. */ ScoreDensity::ScoreDensity( const clipper::Xmap<float>& xmap, double sig1, double sig2 ) { xmap_ = ⟼ clipper::Map_stats map_stats( xmap ); s1 = map_stats.mean() + sig1 * map_stats.std_dev(); s2 = sig2 * map_stats.std_dev(); }
int main(int argc, char *argv[]) { struct protox *tp = NULL; /* for printing cblocks & stats */ int ch; af = AF_UNSPEC; #ifdef LISP while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:rSstuWw:zX")) != -1) #else while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:rSstuWw:z")) != -1) #endif /* LISP */ switch(ch) { case 'A': Aflag = 1; break; case 'a': aflag = 1; break; case 'B': Bflag = 1; break; case 'b': bflag = 1; break; case 'd': dflag = 1; break; case 'f': if (strcmp(optarg, "ipx") == 0) af = AF_IPX; else if (strcmp(optarg, "inet") == 0) af = AF_INET; #ifdef INET6 else if (strcmp(optarg, "inet6") == 0) af = AF_INET6; #endif #ifdef IPSEC else if (strcmp(optarg, "pfkey") == 0) af = PF_KEY; #endif else if (strcmp(optarg, "unix") == 0) af = AF_UNIX; else if (strcmp(optarg, "atalk") == 0) af = AF_APPLETALK; #ifdef NETGRAPH else if (strcmp(optarg, "ng") == 0 || strcmp(optarg, "netgraph") == 0) af = AF_NETGRAPH; #endif else if (strcmp(optarg, "link") == 0) af = AF_LINK; else { errx(1, "%s: unknown address family", optarg); } break; case 'g': gflag = 1; break; case 'h': hflag = 1; break; case 'I': { char *cp; iflag = 1; for (cp = interface = optarg; isalpha(*cp); cp++) continue; unit = atoi(cp); break; } case 'i': iflag = 1; break; case 'L': Lflag = 1; break; case 'M': memf = optarg; break; case 'm': mflag = 1; break; case 'N': nlistf = optarg; break; case 'n': numeric_addr = numeric_port = 1; break; case 'p': if ((tp = name2protox(optarg)) == NULL) { errx(1, "%s: unknown or uninstrumented protocol", optarg); } pflag = 1; break; case 'r': rflag = 1; break; #ifdef LISP case 'X': Xflag = 1; break; #endif /* LISP */ case 's': ++sflag; break; case 'S': numeric_addr = 1; break; case 't': tflag = 1; break; case 'u': af = AF_UNIX; break; case 'W': case 'l': Wflag = 1; break; case 'w': interval = atoi(optarg); iflag = 1; break; case 'z': zflag = 1; break; case '?': default: usage(); } argv += optind; argc -= optind; #define BACKWARD_COMPATIBILITY #ifdef BACKWARD_COMPATIBILITY if (*argv) { if (isdigit(**argv)) { interval = atoi(*argv); if (interval <= 0) usage(); ++argv; iflag = 1; } if (*argv) { nlistf = *argv; if (*++argv) memf = *argv; } } #endif /* * Discard setgid privileges if not the running kernel so that bad * guys can't print interesting stuff from kernel memory. */ live = (nlistf == NULL && memf == NULL); if (!live) setgid(getgid()); if (Bflag) { if (!live) usage(); bpf_stats(interface); exit(0); } if (mflag) { if (!live) { if (kread(0, NULL, 0) == 0) mbpr(kvmd, nl[N_MBSTAT].n_value); } else mbpr(NULL, 0); exit(0); } #if 0 /* * Keep file descriptors open to avoid overhead * of open/close on each call to get* routines. */ sethostent(1); setnetent(1); #else /* * This does not make sense any more with DNS being default over * the files. Doing a setXXXXent(1) causes a tcp connection to be * used for the queries, which is slower. */ #endif kread(0, NULL, 0); if (iflag && !sflag) { intpr(interval, nl[N_IFNET].n_value, NULL); exit(0); } if (rflag) { if (sflag) rt_stats(nl[N_RTSTAT].n_value, nl[N_RTTRASH].n_value); else routepr(nl[N_RTREE].n_value); exit(0); } #ifdef LISP if (Xflag) { if (sflag) { map_stats(); exit(0); } else { kread(0, 0, 0); mappr(nl[N_MAPTREE].n_value); exit(0); }; }; #endif /* LISP */ if (gflag) { if (sflag) { if (af == AF_INET || af == AF_UNSPEC) mrt_stats(nl[N_MRTSTAT].n_value); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mrt6_stats(nl[N_MRT6STAT].n_value); #endif } else { if (af == AF_INET || af == AF_UNSPEC) mroutepr(nl[N_MFCTABLE].n_value, nl[N_VIFTABLE].n_value); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) mroute6pr(nl[N_MF6CTABLE].n_value, nl[N_MIF6TABLE].n_value); #endif } ifmalist_dump(); exit(0); } if (tp) { printproto(tp, tp->pr_name); exit(0); } if (af == AF_INET || af == AF_UNSPEC) for (tp = protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #ifdef INET6 if (af == AF_INET6 || af == AF_UNSPEC) for (tp = ip6protox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /*INET6*/ #ifdef IPSEC if (af == PF_KEY || af == AF_UNSPEC) for (tp = pfkeyprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /*IPSEC*/ #ifdef IPX if (af == AF_IPX || af == AF_UNSPEC) { for (tp = ipxprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); } #endif /* IPX */ if (af == AF_APPLETALK || af == AF_UNSPEC) for (tp = atalkprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #ifdef NETGRAPH if (af == AF_NETGRAPH || af == AF_UNSPEC) for (tp = netgraphprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /* NETGRAPH */ if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag) unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value, nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value); exit(0); }
void do_mapout( CHAR_DATA* ch, const char* argument) { char arg[MAX_INPUT_LENGTH]; OBJ_DATA *map_obj; /* an obj made with map as an ed */ OBJ_INDEX_DATA *map_obj_index; /* obj_index for previous */ EXTRA_DESCR_DATA *ed; /* the ed for it to go in */ int rooms, rows, cols, avail_rooms; if( !ch ) { bug( "%s", "do_mapout: null ch" ); return; } if( IS_NPC( ch ) ) { send_to_char( "Not in mobs.\r\n", ch ); return; } if( !ch->desc ) { bug( "%s", "do_mapout: no descriptor" ); return; } switch ( ch->substate ) { default: break; case SUB_WRITING_NOTE: if( ch->dest_buf != ch->pnote ) bug( "%s", "do_mapout: sub_writing_map: ch->dest_buf != ch->pnote" ); STRFREE( ch->pnote->text ); ch->pnote->text = copy_buffer( ch ); stop_editing( ch ); return; } set_char_color( AT_NOTE, ch ); argument = one_argument( argument, arg ); smash_tilde( argument ); if( !str_cmp( arg, "stat" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress.\r\n", ch ); return; } map_stats( ch, &rooms, &rows, &cols ); ch_printf( ch, "Map represents %d rooms, %d rows, and %d columns\r\n", rooms, rows, cols ); avail_rooms = num_rooms_avail( ch ); ch_printf( ch, "You currently have %d unused rooms.\r\n", avail_rooms ); act( AT_ACTION, "$n glances at an etherial map.", ch, NULL, NULL, TO_ROOM ); return; } if( !str_cmp( arg, "write" ) ) { note_attach( ch ); ch->substate = SUB_WRITING_NOTE; ch->dest_buf = ch->pnote; start_editing( ch, ch->pnote->text ); return; } if( !str_cmp( arg, "clear" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress\r\n", ch ); return; } STRFREE( ch->pnote->text ); STRFREE( ch->pnote->subject ); STRFREE( ch->pnote->to_list ); STRFREE( ch->pnote->date ); STRFREE( ch->pnote->sender ); DISPOSE( ch->pnote ); ch->pnote = NULL; send_to_char( "Map cleared.\r\n", ch ); return; } if( !str_cmp( arg, "show" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress.\r\n", ch ); return; } send_to_char( ch->pnote->text, ch ); do_mapout( ch, "stat" ); return; } if( !str_cmp( arg, "create" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress.\r\n", ch ); return; } map_stats( ch, &rooms, &rows, &cols ); avail_rooms = num_rooms_avail( ch ); /* * check for not enough rooms */ if( rooms > avail_rooms ) { send_to_char( "You don't have enough unused rooms allocated!\r\n", ch ); return; } act( AT_ACTION, "$n warps the very dimensions of space!", ch, NULL, NULL, TO_ROOM ); map_to_rooms( ch, NULL ); /* this does the grunt work */ map_obj_index = get_obj_index( 91 ); if( map_obj_index ) { map_obj = create_object( map_obj_index, 0 ); ed = SetOExtra( map_obj, "runes map scrawls" ); STRFREE( ed->description ); ed->description = QUICKLINK( ch->pnote->text ); obj_to_char( map_obj, ch ); } else { send_to_char( "Couldn't give you a map object. Need Great Eastern Desert\r\n", ch ); return; } do_mapout( ch, "clear" ); send_to_char( "Ok.\r\n", ch ); return; } send_to_char( "mapout write: create a map in edit buffer.\r\n", ch ); send_to_char( "mapout stat: get information about a written, but not yet created map.\r\n", ch ); send_to_char( "mapout clear: clear a written, but not yet created map.\r\n", ch ); send_to_char( "mapout show: show a written, but not yet created map.\r\n", ch ); send_to_char( "mapout create: turn a written map into rooms in your assigned room vnum range.\r\n", ch ); return; }