Beispiel #1
0
wr_abbrevs(FILE *outfile, int function_head, chainp vars)
#endif
{
    for (; vars; vars = vars -> nextp) {
	Namep name = (Namep) vars -> datap;
	if (!name->visused)
		continue;

	if (function_head)
	    nice_printf (outfile, "#define ");
	else
	    nice_printf (outfile, "#undef ");
	out_name (outfile, name);

	if (function_head) {
	    Extsym *comm = &extsymtab[name -> vardesc.varno];

	    nice_printf (outfile, " (");
	    extern_out (outfile, comm);
	    nice_printf (outfile, "%d.", comm->curno);
	    nice_printf (outfile, "%s)", name->cvarname);
	} /* if function_head */
	nice_printf (outfile, "\n");
    } /* for */
} /* wr_abbrevs */
Beispiel #2
0
wr_struct(FILE *outfile, chainp var_list)
#endif
{
    int last_type = -1;
    int did_one = 0;
    chainp this_var;

    for (this_var = var_list; this_var; this_var = this_var -> nextp) {
	Namep var = (Namep) this_var -> datap;
	int type;
	char *comment = NULL;

	if (var == (Namep) NULL)
	    err ("wr_struct:  null variable");
	else if (var -> tag != TNAME)
	    erri ("wr_struct:  bad tag on variable '%d'",
		    var -> tag);

	type = var -> vtype;

	if (last_type == type && did_one)
	    nice_printf (outfile, ", ");
	else {
	    if (did_one)
		nice_printf (outfile, ";\n");
	    nice_printf (outfile, "%s ",
		    c_type_decl (type, var -> vclass == CLPROC));
	} /* else */

/* Character type is really a string type.  Put out a '*' for parameters
   with unknown length and functions returning character */

	if (var -> vtype == TYCHAR && (!ISICON ((var -> vleng))
		|| var -> vclass == CLPROC))
	    nice_printf (outfile, "*");

	var -> vstg = STGAUTO;
	out_name (outfile, var);
	if (var -> vclass == CLPROC)
	    nice_printf (outfile, "()");
	else if (var -> vdim)
	    comment = wr_ardecls(outfile, var->vdim,
				var->vtype == TYCHAR && ISICON(var->vleng)
				? var->vleng->constblock.Const.ci : 1L);
	else if (var -> vtype == TYCHAR && var -> vclass != CLPROC &&
	    ISICON ((var -> vleng)))
	    nice_printf (outfile, "[%ld]",
		    var -> vleng -> constblock.Const.ci);

	if (comment)
	    nice_printf (outfile, "%s", comment);
	did_one = 1;
	last_type = type;
    } /* for this_var */

    if (did_one)
	nice_printf (outfile, ";\n");
} /* wr_struct */
Beispiel #3
0
/*void outname()
{
  printf("hello briuo\n");
}

int amount_salary(int salary)
{

   return salary * 12;
}
*/
int main(void)
{
  out_name();

  printf("please input your salary:");
  int salary;
  scanf("%d",&salary);
  int amount = amount_salary(salary);
  printf("amount:%d\n",amount);

  return 0;
 }
void H5Converter::write_aux() {
  std::string out_name(out_dir_ + "/run_info.json");

  plaintext_aux(
      out_name,
      std::string(std::to_string(n_targs_)),
      std::string(std::to_string(n_bs_)),
      kal_version_,
      std::string(std::to_string(idx_version_)),
      start_time_,
      call_
      );
}
 void DataFeed(std::istream& in, OutFiles& outs)
 {
     DataIn in_container;
     while (in >> in_container)
     {            
         std::string stock(in_container.stock_name, 8);
         std::ofstream& out = outs[stock];
         if (!out.is_open())
         {
             std::string out_name(BINARY_DIR "/output_");
             out_name.append(stock);
             out_name.append(".txt");
             out.open(out_name, std::ios::binary);
         }
         
         if (out.good())
         {
             out << DataOutStream(in_container);
         }
     }
 };
/**
 * CSVファイルからVMDへの変換
 * @param const char* 入力ファイルのパス
 * @param const char* 出力ファイルのパス
 */
int wxMMDViewerUtil::CSV2VMD( const char* inputFile, const char* outputFile )
{
     size_t line = 0,size;
     FIELDS fields;
     clsVMDFile vmd;
     clsCSVFile csv;

     std::string in_name(inputFile);
     std::string out_name(outputFile);

     std::string::size_type pos = out_name.find_last_of(".");
     if ( pos == std::string::npos )
	  return -1;
     out_name.replace(pos,4,".vmd");
	
     if ( !csv.Open( in_name.c_str() ) )
	  return -1;
     PARSE_LINE_BUFFER& buff = csv.GetBuffer();
	
     if ( buff.size() < 3 ) 
	  return -2;
     buff[line++].Export( fields );
     vmd.GetHeader().Import( fields ) ;
     buff[line++].Export( fields );
     if ( fields.size() )
	  vmd.SetActor( fields[0].c_str() );
     else
	  return -2;

     buff[line++].Export( fields );
     fields >> size;
     if ( buff.size()<=line )
	  return -2;

     vmd.SetMotionChunkSize( size );

     for ( size_t i=0;i<size;i++ ) 
     {
	  buff[line++].Export( fields );
	  vmd.GetMotionChunk()[i].Import( fields );
	  if ( buff.size()<=line )
	       return -2;
     }
     buff[line++].Export( fields );
     fields >> size;
     vmd.SetMorpChunkSize( size );
     for ( size_t i=0;i<size;i++ ) 
     {
	  buff[line++].Export( fields );
	  vmd.GetMorpChunk()[i].Import( fields );
	  if ( buff.size()<=line )
	       return -2;
     }
     buff[line++].Export( fields );
     fields >> size;
     vmd.SetCameraChunkSize( size );
     for ( size_t i=0;i<size;i++ ) 
     {
	  buff[line++].Export( fields );
	  vmd.GetCameraChunk()[i].Import( fields );
	  if ( buff.size()<=line )
	       return -2;
     }
     buff[line++].Export( fields );
     fields >> size;
     vmd.SetLightChunkSize( size );
     for ( size_t i=0;i<size;i++ ) 
     {
	  buff[line++].Export( fields );
	  vmd.GetLightChunk()[i].Import( fields );
	  if ( buff.size()<=line )
	       return -2;
     }

     if ( !vmd.Commit( out_name.c_str() ) )
	  return -3;
     return 0;
}
/**
 * VMDファイルからCSVへの変換
 * @param const char* 入力ファイルのパス
 * @param const char* 出力ファイルのパス
 */
int wxMMDViewerUtil::VMD2CSV( const char* inputFile, const char* outputFile )
{
     FIELDS fields;
     clsVMDFile vmd;
     clsCSVFile csv;

     std::string in_name(inputFile);
     std::string out_name(outputFile);

     std::string::size_type pos = out_name.find_last_of(".");
     if ( pos == std::string::npos )
	  return -1;
	
     out_name.replace(pos,4,".csv");

     if ( !vmd.Open( in_name.c_str() ) )
	  return -1;

     if ( !vmd.GetActor() ) 
     {
	  return -1;
     }

     vmd.GetHeader().Export( fields );
     csv.AddFields( fields );

     NEW_FIELD(fields);
     fields << vmd.GetActor();
     csv.AddFields( fields );
     {
	  VMD_MOTION_CHUNK &buff = vmd.GetMotionChunk();

	  NEW_FIELD(fields);
	  fields << vmd.GetMotionChunkSize();
	  csv.AddFields( fields );

	  for (size_t i=0;i<vmd.GetMotionChunkSize();i++) 
	  {
	       VMD_MOTION_RECORD &rec = buff[i];
	       rec.Export( fields );
	       csv.AddFields( fields );
	  }
     }
     {
	  VMD_MORP_CHUNK &buff = vmd.GetMorpChunk();

	  NEW_FIELD(fields);
	  fields << vmd.GetMorpChunkSize();
	  csv.AddFields( fields );

	  for (size_t i=0;i<vmd.GetMorpChunkSize();i++) 
	  {
	       VMD_MORP_RECORD &rec = buff[i];
	       rec.Export( fields );
	       csv.AddFields( fields );
	  }
     }
     {
	  VMD_CAMERA_CHUNK &buff = vmd.GetCameraChunk();

	  NEW_FIELD(fields);
	  fields << vmd.GetCameraChunkSize();
	  csv.AddFields( fields );

	  for (size_t i=0;i<vmd.GetCameraChunkSize();i++) 
	  {
	       VMD_CAMERA_RECORD &rec = buff[i];
	       rec.Export( fields );
	       csv.AddFields( fields );
	  }
     }
     {
	  VMD_LIGHT_CHUNK &buff = vmd.GetLightChunk();

	  NEW_FIELD(fields);
	  fields << vmd.GetLightChunkSize();
	  csv.AddFields( fields );

	  for (size_t i=0;i<vmd.GetLightChunkSize();i++) 
	  {
	       VMD_LIGHT_RECORD &rec = buff[i];
	       rec.Export( fields );
	       csv.AddFields( fields );
	  }
     }
     if ( !csv.Commit( out_name.c_str() ) )
	  return -3;
     return 0;
}
int main(int argc, const char *argv[])
{
    signal(SIGINT, terminate);
    try {
        po::options_description desc("Allowed options");
        desc.add_options()
            ("help,h", "print this help message")
            ("config,c", po::value<std::string>()->required(), "path to config file")
        ;

        po::variables_map vm;
        po::store(po::parse_command_line(argc, argv, desc), vm);

        if (vm.count("help")) {
            std::cout << desc << std::endl;
            return 0;
        }

        po::notify(vm);

        std::shared_ptr<TextDetector::ConfigurationManager> config(
        	new TextDetector::ConfigurationManager(
        		vm["config"].as<std::string>()));
        TextDetector::ConfigurationManager::set_instance(config);


        float threshold = config->get_threshold();
        if (config->has_cache()) {
            CacheManager::set_instance(
                std::shared_ptr<CacheManager>((new CacheManager(config->get_cache_directory()))));
        }

        srand(config->get_random_seed());

        // creates the models
        TextDetector::ModelManager model_manager(config);

        if (config->verbose())
            std::cout << "Read inputs" << std::endl;

        if (!fs::is_directory(config->get_input_directory()) ||
            !fs::is_directory(config->get_responses_directory())) {
            std::cerr << "Error: response or input directory does not exist" << std::endl;
            return 1;
        }

        std::vector<fs::path> directories;
        std::copy(fs::directory_iterator(
            config->get_input_directory()),
            fs::directory_iterator(), 
            std::back_inserter(directories));
        std::sort(directories.begin(), directories.end());

        TextDetector::MserDetector detector(config);
        for (auto it = directories.begin(); it != directories.end(); ++it) {
            fs::path p(*it);
            //p = "../train_icdar_2005/332.jpg";
            //p = "../test_icdar_2005/214.jpg";

            if (p.extension() != ".jpg" && p.extension() != ".png") {
                std::cout << "Skipping: " << p << std::endl;
                continue;
            }

            fs::path number = p.stem();

            std::string response_name = number.generic_string() + "_response.png";
            fs::path response = config->get_responses_directory();
            response += "/";
            response += response_name;

            if (!fs::exists(response) && 
                !config->ignore_responses()) {
                std::cout << "Error, " << response
                		  << " does not exist -> skipping!" << std::endl;
                continue;
            }

            std::cout << "Processing: " << p.filename() << " " 
                      << number << " " << response << std::endl;

            if (CacheManager::instance()) {
                CacheManager::instance()->load_image(number.generic_string());
            }
            
            cv::Mat response_image;
            if (fs::exists(response)) {
                response_image = cv::imread(response.generic_string());
                if (response_image.channels() > 1) {
                    cv::cvtColor(response_image, response_image, cv::COLOR_RGB2GRAY);
                }
            }
            cv::Mat train_image = cv::imread(p.generic_string());
            cv::Mat mask;

            if (!response_image.empty()) 
                mask = response_image > (threshold * 255);

            if (config->ignore_responses()) {
                mask = cv::Mat(train_image.rows, train_image.cols, CV_8UC1, cv::Scalar(255));
            }

            cv::Mat gt_mask;
            if (config->include_binary_masks()) {
                std::string mask_path = config->get_input_directory() + number.generic_string() + "_mask.png";
                if (!fs::exists(mask_path)) {
                    std::cout << "Skipping: " << mask_path << " due to missing mask!" << std::endl;
                    continue;
                }
                gt_mask = cv::imread(mask_path);
            }
            cv::Mat result_image;
            std::vector<cv::Rect> words = detector(train_image, result_image, mask, gt_mask);

            fs::path out_name(config->get_responses_directory());
            std::string box_name = number.generic_string() + "_boxes.txt";
            out_name += "/"; out_name += box_name;
            std::ofstream ofs(out_name.generic_string());
//            cv::Mat result_img = show_groups_color(
//                groups,
//                cv::Size(train_image.cols, train_image.rows),
//                all_probs, false);
            for (size_t i = 0; i < words.size(); i++) {
                cv::Rect r = words[i];
                cv::rectangle(result_image, r.tl(), r.br(), cv::Scalar(0, 0, 255), 4);
                ofs << r.x << "," << r.y << "," << r.width << "," << r.height << std::endl;
            }
            ofs.close();

            std::string box_img_name = number.generic_string() + "_boxes.png";
            fs::path out_img_name(config->get_responses_directory());
            out_img_name += "/"; out_img_name += box_img_name;
            cv::imwrite(out_img_name.generic_string(), result_image);

            if (CacheManager::instance())
                CacheManager::instance()->save_image(number.generic_string());
        }
        
    } catch (const std::exception &e) {
        std::cerr << "Error: " << e.what() << std::endl;
        return 1;
    }

    return 0;
}
Beispiel #9
0
int32_t main(int32_t argc, char *argv[])
{
    if (argc < 2) {
        printf("Usage: %s <nom_de_fichier_tiff>\n",argv[0]);
        return 0;
    }

    FILE * f;
    f = fopen(argv[1],"r");
    if (f == 0) {
        printf("Fichier inexistant ou nom incorrect.\n");
        printf("Conversion du fichier '%s' échouée.\n",argv[1]);
        return -1;
    }

    if (_DISPLAY_HEAD >= 1 || _DISPLAY_BODY >= 1) {
        printf("\n*********** DECODAGE DE '%s' ***********\n",argv[1]);
    }


    /* I. Decodage de l'en-tete TIFF */

    /* Initialisation des variables */
    uint8_t quality = 3;
    uint8_t QT[2][_BSIZE];                 /* Tables de quantification */
    uint8_t MCU_size[2];
    image_t *im = malloc(sizeof(image_t)); /* Proprietes de l'image */
    im->nb_comp = 3;
    im->comp = calloc(3,sizeof(comp_t));
    im->comp[0].ic = 1;
    im->comp[1].ic = 2;
    im->comp[2].ic = 3;
    im->comp[0].iq = 0;
    im->comp[1].iq = 1;
    im->comp[2].iq = 1;


    printmark("\n+========== HEADER ===============================+\n");

    /* Decodage */
    read_tiff_file_header(f,&(im->height),&(im->width),&(MCU_size[1]));
    MCU_size[0] = 16;

    im->comp[0].echH = MCU_size[0]/8;
    im->comp[0].echV = MCU_size[1]/8;
    im->comp[1].echH = 1;
    im->comp[1].echV = 1;
    im->comp[2].echH = 1;
    im->comp[2].echV = 1;

    printmark("+========== END OF HEADER ========================+\n\n");

    if (_DISPLAY_HEAD == 0) {
        printbody("Analyse de l'en-tête\n");
    }


    /* II. Calculs preliminaires */

    /* Calcul du nombre de MCU dans l'image */
    uint32_t nb_MCU_width = im->width / MCU_size[0]
                            + ((im->width % MCU_size[0]) != 0);
    uint32_t nb_MCU_height = im->height / MCU_size[1]
                             + ((im->height % MCU_size[1]) != 0);
    printbody("Taille de l'image en MCU : %ux%u\n",nb_MCU_height,
              nb_MCU_width);
    uint32_t nb_RGB_MCU = nb_MCU_width * nb_MCU_height;
    printbody("Nb de MCU RGB : %u\n",nb_RGB_MCU);


    printbody("\n+========== BODY =================================+\n");

    /* Initialisation du fichier TIFF */
    char *out_file = out_name(argv[1]);
    printbody("Création du fichier '%s'\n",out_file);
    FILE *out_f = fopen(out_file,"w");
    init_tiff_file(out_f,im->width,im->height,MCU_size[1]);



    /* III. Decodage des donnees brutes */

    /* reconstruction des MCU*/
    printbody("Reconstitutions des MCU (decodage des donnees brutes)\n");
    uint32_t nb_pxl_in_MCU = MCU_size[0] * MCU_size[1];
    uint32_t *out_RGB_MCU = calloc(nb_pxl_in_MCU,sizeof(uint32_t));
    uint32_t *in_RGB_MCU = calloc(nb_pxl_in_MCU,sizeof(uint32_t));
    for (uint32_t i = 0; i < nb_RGB_MCU; i++) {
        if (nb_RGB_MCU > 10 && i % (nb_RGB_MCU/10) == 0) {
            printbody1("    %3u%%\n",i*100/nb_RGB_MCU);
        }
        get_tiff_MCU(f,MCU_size[0],in_RGB_MCU);
        change_RGB_MCU(in_RGB_MCU,out_RGB_MCU,im,MCU_size,quality);
        printbody2("\n");
        write_tiff_file(out_f,MCU_size[0],MCU_size[1],out_RGB_MCU);
    }
    free(in_RGB_MCU);
    free(out_RGB_MCU);

    printbody("+========== END OF BODY ==========================+\n\n");


    /* fin de procedure */
    printf("Conversion du fichier '%s'\nen '%s' réussie.\n",argv[1],
           out_file);
    free(out_file);
    close_tiff_file(out_f);
    printbody("Fichier TIFF fermé\n");

    if (_DRY_RUN) {
        printf("+========== END OF BODY ==========================+\n");
        printf("** Attention : mode Dry-Run actif **\n");
        printf("Lecture du fichier terminée avec succès\n");
    }
    fclose(f);
    printbody("Fichier JPEG fermé\n");
    free(im->comp);
    free(im);
    printbody("Mémoire libérée\n");
    return 0;
}
Beispiel #10
0
/*******************************************************************************************************
 * Calculate correlation function, using Simple or PAT correlator, in a Linear or Logarithmic fashion. *
 *******************************************************************************************************/
void CalcCorrelation (int method, char * filename = "test.flu") {
    FILE * fp_params = fopen ("params.txt","rt");
    if (fp_params == NULL) {LOG("!Could not find parameters file!"); return;}

    std::string fname (filename);
    std::string out_name ("corr");
    
    if (fname != "test.flu") //in case of custom filename, change the output name too
	out_name += fname.substr(8,100);

    out_name += ".dat";
    LOG ("*Output correlation to %s",out_name.c_str());


    int num_steps = -1;
    double dT = -1.0, TAU_MAX = -1.0;
    int STEPS_PER_BIN = -1;

    if (fscanf (fp_params,"NUM_FRAMES %d\ndT %lf\nTAU_MAX %lf\nBIN_SIZE %d\n",&num_steps, &dT, &TAU_MAX, &STEPS_PER_BIN) != 4)
     { LOG ("!Error reading parameters file (params.txt)."); exit (2); }
    
    LOG ("*Calculating correlation for %s.\nNUM_FRAMES %d, dT %f, TAU_MAX %f, BIN_SIZE %d\n",filename,num_steps, dT, TAU_MAX, STEPS_PER_BIN);

    FILE * fp;

    if (method == LINEAR) {
//      fp = fopen ("correlationLIN.dat","wt");
     fp = fopen (out_name.c_str(),"wt");
     
     if (STEPS_PER_BIN <= 0) {LOG ("!Need a fixed number of bins for LINEAR method. Currently params.txt defines BIN_SIZE as %d.",STEPS_PER_BIN); exit (54);} 

     LOG ("Calculating correlation (Linear).");
     fprintf (fp, "@title \"G(tau), %d Steps/bin, dT = %f\"\n",STEPS_PER_BIN,dT);

     Correlator * corr1 = new CorrelatorSimple (filename, dT, num_steps, STEPS_PER_BIN);

     for (double time=STEPS_PER_BIN*dT; time <= TAU_MAX; time+= STEPS_PER_BIN*dT) {
	fprintf (fp,"%le %lf\n",time/1e12, corr1->Calculate_correlation (time));

	static int counter = 0;
	if (counter > 100) {printf ("%2.2f%%\n",time/TAU_MAX*100);counter-=100;}
	counter++;
     }
    }

    else if (method == LOGARITHMIC) {
	fp = fopen (out_name.c_str(),"wt");
        LOG ("Calculating correlation (Logarithmic).");
        fprintf (fp, "@title \"G(tau), dT = %f\"\n",dT);

        int counter = 0; //counter=1;

	if (STEPS_PER_BIN <= 0)	{	//STEPS_PER_BIN undefined = varying bin size
	  STEPS_PER_BIN = 1;		//start form bin size = frame size, then increase
	  double time = 0;//STEPS_PER_BIN*dT;
	  Correlator * corr1;

	  while (time <= TAU_MAX) {
	      corr1 = new CorrelatorSimple (filename, dT, num_steps, STEPS_PER_BIN);

	      while (counter < 4) {
		time += STEPS_PER_BIN*dT;
		printf ("STEPS_PER_BIN=%d.\n",STEPS_PER_BIN);

		double result = corr1->Calculate_correlation (time);
		fprintf (fp,"%5.9le %5.9le\n",time/1e12, result);
		printf ("g(%5.9le)=%5.9le\n", time/1e12, result);

		counter++;
	      }
	      
	      delete corr1;
	      counter=0; STEPS_PER_BIN*=2;	//every 4 iterations, the bin size (and time change) is doubled
	  }
	}
	else {				//STEPS_PER_BIN constant, as defined in params.txt
	  LOG ("Calculating LOG correlation for BIN_SIZE = %d.",STEPS_PER_BIN);

	  double time = STEPS_PER_BIN*dT;
	  double TIME_STEP = STEPS_PER_BIN;
	  Correlator * corr1 = new CorrelatorSimple (filename, dT, num_steps, STEPS_PER_BIN);

	  printf ("STEPS_PER_BIN=%d.\n",STEPS_PER_BIN);

	  while (time <= TAU_MAX) {
	      double result = corr1->Calculate_correlation (time);
	      fprintf (fp,"%5.9le %5.9le\n",time/1e12, result);
	      printf ("g(%5.9le)=%5.9le\n", time/1e12, result);

	      counter++;
	      if (counter >= 4) {counter=0; TIME_STEP*=2;}	//every 4 iterations, the correlation time increase is doubled
	      time += TIME_STEP*dT;
	  }
	  delete corr1;
	}
    }
    else {LOG ("!Incorrect method choice!"); return;}		//should never happen // DEBUG
    fclose (fp);
    LOG ("Finished calculating correlation.");
}
Beispiel #11
0
/******************************
 * Cross-correlation analysis *
 ******************************/
void CalcCrossCorrelation (char * filename1 = "test.flu",char * filename2 = "test2.flu") {
    FILE * fp_params = fopen ("params.txt","rt");
    if (fp_params == NULL) {LOG("!Could not find parameters file!"); return;}

    std::string fname1 (filename1);
    std::string fname2 (filename2);
    std::string out_name ("Xcorr");
    
    if (fname1 != "test.flu" || fname2 != "test2.flu") //in case of custom filename, change the output name too
	out_name += fname1.substr(8,100) += fname2.substr(8,100);

    out_name += ".dat";
    LOG ("*Output correlation to %s",out_name.c_str());

    int num_steps = -1;
    double dT = -1.0, TAU_MAX = -1.0;
    int STEPS_PER_BIN = -1;

    if (fscanf (fp_params,"NUM_FRAMES %d\ndT %lf\nTAU_MAX %lf\nBIN_SIZE %d\n",&num_steps, &dT, &TAU_MAX, &STEPS_PER_BIN) != 4)
     { LOG ("!Error reading parameters file (params.txt)."); exit (2); }
    
    LOG ("*Calculating correlation for %s & %s.\nNUM_FRAMES %d, dT %f, TAU_MAX %f, BIN_SIZE %d\n",filename1,filename2,num_steps, dT, TAU_MAX, STEPS_PER_BIN);

    FILE * fp;

    fp = fopen (out_name.c_str(),"wt");
    LOG ("Calculating cross correlation (Logarithmic).");
    fprintf (fp, "@title \"G(tau), dT = %f\"\n",dT);

    int counter = 0; //counter=1;

    if (STEPS_PER_BIN <= 0)	{	//STEPS_PER_BIN undefined = varying bin size
      STEPS_PER_BIN = 1;		//start form bin size = frame size, then increase
      double time = STEPS_PER_BIN*dT;
      Correlator * corr1;

      while (time <= TAU_MAX) {
	  corr1 = new CrossCorrelator (filename1, filename2, dT, num_steps, STEPS_PER_BIN);
	  printf ("STEPS_PER_BIN=%d.\n",STEPS_PER_BIN);

	  double result = corr1->Calculate_correlation (time);
	  fprintf (fp,"%5.9le %5.9le\n",time/1e12, result);
	  printf ("g(%5.9le)=%5.9le\n", time/1e12, result);

	  delete corr1;

	  counter++;
	  if (counter >= 4) {counter=0; STEPS_PER_BIN*=2;}	//every 4 iterations, the bin size (and time change) is doubled
	  time += STEPS_PER_BIN*dT;
      }
    }
    else {				//STEPS_PER_BIN constant, as defined in params.txt
      LOG ("Calculating CROSS-correlation for BIN_SIZE = %d.",STEPS_PER_BIN);

      double time = STEPS_PER_BIN*dT;
      double TIME_STEP = STEPS_PER_BIN;
      Correlator * corr1 = new CrossCorrelator (filename1, filename2, dT, num_steps, STEPS_PER_BIN);

      printf ("STEPS_PER_BIN=%d.\n",STEPS_PER_BIN);

      while (time <= TAU_MAX) {
	  double result = corr1->Calculate_correlation (time);
	  fprintf (fp,"%5.9le %5.9le\n",time/1e12, result);
	  printf ("g(%5.9le)=%5.9le\n", time/1e12, result);

	  counter++;
	  if (counter >= 4) {counter=0; TIME_STEP*=2;}	//every 4 iterations, the correlation time increase is doubled
	  time += TIME_STEP*dT;
      }
      delete corr1;
    }

    fclose (fp);
    LOG ("Finished calculating cross-correlation.");
}