int main( int argc, char *argv[] ){
    if( argc < 3 ){
        printf( "usage:<input> <input.day>\n" );
        return -1;
    }
    load_stats();
    char fout[ 256 ];
    sprintf( fout, "features/%s.UserDayInterpolation", argv[1] );
    FILE *fi = fopen_check( argv[1], "r" );
    FILE *fd = fopen_check( argv[2], "r" );
    FILE *fo = fopen_check( fout, "w" );

    fprintf( fo, "%d\n", num_index );
    int uid, iid, rate, day;
    while( fscanf( fi, "%d%d%d", &uid, &iid, &rate ) == 3 ){
        assert_true( fscanf( fd, "%d", &day ) == 1 );
        const int base = pustart[ uid ];
        if( day == first[ uid ] ){ 
            fprintf( fo, "1 %d:1\n", base ); continue;
        }
        if( day == last[ uid ] ){ 
            fprintf( fo, "1 %d:1\n", base+1 ); continue;
        }
        fprintf( fo, "2 %d:%f %d:%f\n", 
                 base  , static_cast<float>( last[uid] - day  )/(last[uid]-first[uid]),  
                 base+1, static_cast<float>( day - first[uid] )/(last[uid]-first[uid]) );        
    }
    fclose( fo );
    fclose( fd );
    fclose( fi );
    return 0;
}
int main( int argc, char *argv[] ){
    if( argc < 3 ){
        printf( "usage:<input> <input.userdayidx>\n" );
        return -1;
    }
    load_stats();
    char fout[ 256 ];
    sprintf( fout, "features/%s.UserDayBias", argv[1] );
    FILE *fi = fopen_check( argv[1], "r" );
    FILE *fd = fopen_check( argv[2], "r" );
    FILE *fo = fopen_check( fout, "w" );

    fprintf( fo, "%d\n", num_index );
    int uid, iid, rate, dayidx;
    while( fscanf( fi, "%d%d%d", &uid, &iid, &rate ) == 3 ){
        assert_true( fscanf( fd, "%d", &dayidx ) == 1 );
        fprintf( fo, "1 %d:1\n", start[ uid ] + dayidx );
    }
    fclose( fo );
    fclose( fd );
    fclose( fi );
    return 0;
}
Пример #3
0
int main(int argc, char *argv[]){

    FILE *stats_file;
    char *image_name = argv[1];
//    char input_string[100];
    int class_counter;
    double gray_feature, h_feature;
    int max_likelihood;

    // Checks arguments
    if(argc != 2){
        if(argc == 1)
            printf("No input image given");
        else
            printf("Wrong number of arguments");
        printf("Usage: $%s input_image_file", argv[0]);
        exit(EXIT_FAILURE);
    }

    // Opens training.stats file
    if( (stats_file = fopen("training.stats", "r")) == NULL){
        printf("Unable to open/locate training.stats file");
        exit(EXIT_FAILURE);
    }

    class_counter = count_lines(stats_file);
    bigauss_stats class_array[class_counter];
    load_stats(stats_file, class_array, class_counter);
    fclose(stats_file);

    extract_features(image_name, &gray_feature, &h_feature);
    max_likelihood = bigauss_likelihood(class_array, class_counter, gray_feature, h_feature);

    printf("Max bi-gaussian likelihood for %s class\n", class_array[max_likelihood].class_name);

    return 0;
}
Пример #4
0
int main(int argc, char **argv) {

   int i,j,num_runs=0,initial=0;
   int legend,spec2k6,num_benchmarks;
     
   char yaxis[]="Difference from Mean (log)";

    parse_command_line(argc,argv,
		       &num_runs,&initial,
		       &legend,&spec2k6,&num_benchmarks);
   
   init_stats=calloc(sizeof(struct stats),num_benchmarks);
   
   machines=spec2k_machines;
      
   for(j=0;j<num_benchmarks;j++) {
      load_stats(num_runs,spec2k6,init_stats,argv[(j*2)+BENCH_START],
		    argv[(j*2)+BENCH_START+1],"initial",j,FIXUP_NONE);
   }
   
   final_stats=calloc(sizeof(struct stats),num_benchmarks);
   for(j=0;j<num_benchmarks;j++) {
      load_stats(num_runs,spec2k6,final_stats,argv[(j*2)+BENCH_START],
		    argv[(j*2)+BENCH_START+1],"final",j,FIXUP_ALL);
   }


       /* begin graph */
    printf("(* Begin Graph *)\n");
    printf("newgraph\n");
   
    printf("\n(* Clipping *)\n");
    printf("clip Y %.2f\n",3.0);
   
       /* don't print legend on side */
    printf("\n(* Legend *)\n");
   
    if (legend) {
       printf("legend custom\n");
    }
   else {
      printf("legend off\n");
   }
   
#define WIDTH 16
#define HALF   8
#define OFFSET 2

#define LEGEND_XSCALE 12.0
#define LEGEND_YSCALE 1.25
   
       /* y-axis */
    printf("\n(* Y-Axis *)\n");
    printf("yaxis size 2.25 min -10 max 10\n");//,max);
    printf("grid_gray 0.9 grid_lines\n");
    printf("no_auto_hash_marks no_auto_hash_labels\n");   
    printf("label font Helvetica fontsize 14 x -%lf : %s\n",
	   (double)num_benchmarks,
	   yaxis);
    printf("hash_labels font Helvetica fontsize 14\n");
   

       /* custom hash labels */ 
   printf("hash_at 0 hash_label at 0 : 0\n");
   printf("hash_at 2 hash_label at 2 : 100\n");
   printf("hash_at 4 hash_label at 4 : 10K\n");
   printf("hash_at 6 hash_label at 6 : 1M\n");  
   printf("hash_at 8 hash_label at 8 : 100M\n"); 	  
   printf("hash_at 10 hash_label at 10 : 10B\n");	  	  	  
//   printf("hash_at 12 hash_label at 12 : 1T\n");   
	  
   printf("hash_at -2 hash_label at -2 : -100\n");
   printf("hash_at -4 hash_label at -4 : -10K\n");
   printf("hash_at -6 hash_label at -6 : -1M\n");	  
   printf("hash_at -8 hash_label at -8 : -100M\n");	  	  
   printf("hash_at -10 hash_label at -10 : -10B\n");	  	  	     
//   printf("hash_at -12 hash_label at -12 : -1T\n");
   
      
       /* x-axis */
    printf("\n(* X-Axis *)\n");
    printf("xaxis size 10 min 0 max %d\n",(num_benchmarks*WIDTH));
    printf("grid_gray 0.5 grid_lines\n");
    printf("no_auto_hash_marks no_auto_hash_labels\n");
    printf("hash_labels hjr vjc rotate 25 font Helvetica fontsize 12\n");
   
       /* custom hash labels */
    for(i=0;i<num_benchmarks;i++) {
      // printf("hash_at %i hash_label at %i : %s.%s\n",
      printf("hash_label at %i : %s.%s\n",
	                       // (i*WIDTH)+HALF,
	                        (i*WIDTH)+HALF,
	                        argv[(i*2)+BENCH_START],
		                argv[(i*2)+BENCH_START+1]);
    }
	
       /* only needed it +/- values? */
    //printf("copygraph xaxis draw_at 0\n");
	
       /* Title */
    printf("\n(* Title *)\n");
//    printf("newstring x 0 y %.2f hjl vjc\n",(max)+(max*0.1));
//    printf("font Helvetica fontsize 14 : %s\n",title);

    printf("copygraph xaxis draw_at 0\n\n");
	     

    // Valid marks are: circle box diamond triangle x cross ellipse 
    // general general_nf general_bez general_bez_nf postscript eps xbar ybar none text

   
       /* old */
    if (!initial) {
       printf("\nnewcurve color 0.85 0.0 0.0  marktype xbar marksize %f "
	      "label hjl vjc fontsize 12 font Helvetica x %lf y %lf : Original Standard Deviation\n",
	      (double)(num_benchmarks*WIDTH)/BIGMARK_SCALE,
	      1.0,13.0);	   
   
       printf("pts\n");	
       for(i=0;i<num_benchmarks;i++) {
          if (init_stats[i].bench_stdev!=0.0) {
	     printf("%d %.9f\n",(i*WIDTH)+HALF,log10(init_stats[i].bench_stdev));
          }
       }
   
       printf("\nnewcurve color 0.85 0.0 0.0 marktype xbar marksize %f \n",
	      	      (double)(num_benchmarks*WIDTH)/BIGMARK_SCALE);
       printf("pts\n");	
       for(i=0;i<num_benchmarks;i++) {
          if (init_stats[i].bench_stdev!=0.0) {
             printf("%d %.9f\n",(i*WIDTH)+HALF,-log10(init_stats[i].bench_stdev));
	  }  
       }
    }
   
    /* stdev */
    printf("\nnewcurve color 0.85 0.85 0.85 marktype xbar marksize %f "
	   "label hjl vjc fontsize 12 font Helvetica x %lf y %lf : Adjusted Standard Deviation\n",
	   (double)(num_benchmarks*WIDTH)/SMALLMARK_SCALE,
	   1.0,12.0);
   
    printf("pts\n");	
    for(i=0;i<num_benchmarks;i++) {
       if (initial) {
	  printf("%d %.9f\n",(i*WIDTH)+HALF,log10(init_stats[i].bench_stdev));
       }
       else {
	  printf("%d %.9f\n",(i*WIDTH)+HALF,log10(final_stats[i].bench_stdev));
       }
    }
   
    printf("\nnewcurve color 0.85 0.85 0.85 marktype xbar marksize %f\n",
	   	   (double)(num_benchmarks*WIDTH)/SMALLMARK_SCALE);
    printf("pts\n");	
    for(i=0;i<num_benchmarks;i++) {
       if (initial) {
          printf("%d %.9f\n",(i*WIDTH)+HALF,-log10(init_stats[i].bench_stdev));
       }
       else {
	  printf("%d %.9f\n",(i*WIDTH)+HALF,-log10(final_stats[i].bench_stdev));
       }
    }

   

    for(j=0;j<MAX_MACHINES;j++) {
       if (!(!machines[j].is_spec2k6&&spec2k6)) {

           printf("\nnewcurve color %s marktype text fontsize 12 font Helvetica-Bold : %s\n",
		  machine_colors[j],machines[j].mark);
           printf("label hjl vjc fontsize 12 font Helvetica "
		  "x %lf y %lf : %s\n",
//		  num_benchmarks*0.7,max+max*0.1,
		  ((double)((j/3)+1))*LEGEND_XSCALE+10.0,
		  (((double)((3-(j%3))))*LEGEND_YSCALE)+10.5,
		  machines[j].processor2);
           printf("pts\n");
	
           for(i=0;i<num_benchmarks;i++) {

	      double result;
	      int valid;

	      if (initial) {
		 result=(double)(init_stats[i].machine_mean[j]-init_stats[i].bench_mean);
		 valid=init_stats[i].machine_mean_valid[j];
	      }
	      else {
		 result=(double)(final_stats[i].machine_mean[j]-final_stats[i].bench_mean);
		 valid=final_stats[i].machine_mean_valid[j];		 
	      }
	      
	      if (valid) {
	      if (result<0.0) {
		 
	         printf("%d %.9f\n",(i*WIDTH)+j+OFFSET,
	               -log10(fabs(result)));
	      }
	      else if (result>0.0) {
		 printf("%d %.9f\n",(i*WIDTH)+j+OFFSET,log10(result));
	      }
	      else {
		 printf("%d 0.0\n",(i*WIDTH)+j+OFFSET);
	      }
	      }
	   }
       }
    }	  

    return 0;
}
Пример #5
0
int main(int argc, char **argv) {

    int i,j;
    int initial,fixup,spec2k6,legend;

    int num_benchmarks;
    char temp_input[BUFSIZ];

     parse_command_line(argc,argv,
			&num_runs,&initial,
			&legend,&spec2k6,&num_benchmarks);
   

    if (initial) fixup=FIXUP_NONE;
    else fixup=FIXUP_ALL;
   
    machines=spec2k_machines;
   
    printf("\\begin{table*}[tbp]\n");
    printf("\\begin{sf}\n");
    printf("\\begin{scriptsize}\n");
    printf("\\begin{center}\n");
    printf("\\begin{tabular}{|l||r||r|r|r||");
    for(i=0;i<REAL_MACHINES;i++) {
       if (!(!machines[i].is_spec2k6&&spec2k6)) {
          printf("r|");
       }
    }
    printf("}\n");
   
    printf("\\hline\n");
    printf("Benchmark & ");
    printf("\\parbox[b]{1.2cm}{\\flushright Overall\\\\Standard\\\\Deviation\\\\(mean)} & ");
    printf("\\begin{sideways}\\parbox{2cm}{Pin}\\end{sideways} &");   
    printf("\\begin{sideways}\\parbox{2cm}{Qemu}\\end{sideways} &");
    printf("\\begin{sideways}\\parbox{2cm}{Valgrind}\\end{sideways} ");
   
    for(i=0;i<REAL_MACHINES;i++) {
       if (!(!machines[i].is_spec2k6&&spec2k6)) {
          printf("& ");
          printf("\\begin{sideways}\\parbox{2cm}{");

          printf("%s",machines[i].processor2);
          printf("\\\\%s",machines[i].processor1);       	  
          printf("}\\end{sideways} ");
       }
    }
    printf("\\\\\n");
    printf("\\hline\n");

    our_stats=calloc(sizeof(struct stats),num_benchmarks);

    for(j=0;j<num_benchmarks;j++) {   
       load_stats(num_runs,spec2k6,our_stats,argv[(j*2)+BENCH_START],
		     argv[(j*2)+BENCH_START+1],argv[TREE_ARG],j,fixup);
    }
    for(j=0;j<num_benchmarks;j++) {   
	   
       if (!strcmp("makerand",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"mkrnd");
       }
       else if (!strcmp("default",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input," ");
       }
       else if (!strcmp("foreman_baseline",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"forebase");
       }
       else if (!strcmp("foreman_main",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"foremain");
       }	   
       else if (!strcmp("sss_main",argv[(j*2)+BENCH_START+1])) {
          strcpy(temp_input,"sss");
       }	   
       else {
          strcpy(temp_input,argv[(j*2)+BENCH_START+1]);
       }
	   
       printf("%s %s &",argv[(j*2)+BENCH_START],temp_input);
       /* mean */
       
       print_diff((long long)(our_stats[j].bench_stdev),LO,MID,HI);
       //print_commas( (long long)(our_stats[j].bench_stdev));

       printf(" & "); 
       
       /* PIN */
       if (!our_stats[j].machine_mean_valid[PIN]) {
          print_blank();
       }
       else {
	  print_diff((long long)(our_stats[j].machine_stdev[PIN]),LO,MID,HI);
	  print_num_points(our_stats[j].num_points[PIN]);       
       }

       printf(" & ");

       /* QEMU */
       if (!our_stats[j].machine_mean_valid[QEMU]) {
          print_blank();
       }
       else {
	  print_diff((long long)(our_stats[j].machine_stdev[QEMU]),LO,MID,HI);
	  print_num_points(our_stats[j].num_points[QEMU]);       
       }
       
       printf(" & ");

       if (!our_stats[j].machine_mean_valid[VALGRIND]) {
          print_blank();
       }
       else {
          print_diff((long long)(our_stats[j].machine_stdev[VALGRIND]),LO,MID,HI);
          print_num_points(our_stats[j].num_points[VALGRIND]);	  
       }

       
       for(i=0;i<REAL_MACHINES;i++) {
          if (!(!machines[i].is_spec2k6&&spec2k6)) {
             printf(" & ");
	     if (!our_stats[j].machine_mean_valid[i]) {
	        print_blank();
	     } else {
                print_diff((long long)(our_stats[j].machine_stdev[i]),LO,MID,HI);
		print_num_points(our_stats[j].num_points[i]);
	     }
	     
	  }
       }
       printf("\\\\\n");
   
       if (j%5==4) printf("\\hline\n");
    }
    printf("\\hline\n");
    printf("\\end{tabular}\n");
    printf("\\end{center}\n");
    
    return 0;
}