Пример #1
0
void compaction_2() {
	t_swap* swap = create_swap("./spec/config_file_test.txt");
	initialize_program(swap, 0, 2, "asd");
	initialize_program(swap, 1, 3, "qwe");
	initialize_program(swap, 2, 1, "iop");
	initialize_program(swap, 3, 1, "mnb");
	remove_program(swap, 0);
	remove_program(swap, 2);
	int first_page_location = check_space_available(swap, 6);
	t_pages_table* table_1 = list_get(swap->pages_table_list, 0);
	t_pages_table* table_2 = list_get(swap->pages_table_list, 1);
	CU_ASSERT_EQUAL(*(table_1->pages_location), 0);
	CU_ASSERT_EQUAL(*(table_2->pages_location), 15);
	CU_ASSERT_EQUAL(*(swap->bitmap), 1);
	CU_ASSERT_EQUAL(*(swap->bitmap + 1), 1);
	CU_ASSERT_EQUAL(*(swap->bitmap + 2), 1);
	CU_ASSERT_EQUAL(*(swap->bitmap + 3), 1);
	CU_ASSERT_EQUAL(*(swap->bitmap + 4), 0);
	CU_ASSERT_EQUAL(*(swap->bitmap + 5), 0);
	CU_ASSERT_EQUAL(*(swap->bitmap + 6), 0);
	CU_ASSERT_EQUAL(*(swap->bitmap + 7), 0);
	CU_ASSERT_EQUAL(*(swap->bitmap + 8), 0);
	CU_ASSERT_EQUAL(*(swap->bitmap + 9), 0);
	char* page_1 = read_swap_file(swap, 0);
	char* page_4 = read_swap_file(swap, 15);
	CU_ASSERT_NSTRING_EQUAL(page_1, "qwe", 3);
	CU_ASSERT_NSTRING_EQUAL(page_4, "mnb", 3);
	CU_ASSERT_EQUAL(first_page_location, 4);
}
Пример #2
0
void remove_program_2() {
	t_swap* swap = create_swap("./spec/config_file_test.txt");
	initialize_program(swap, 1, 2, "1234567890");
	initialize_program(swap, 2, 3, "123456789012345");
	remove_program(swap, 2);
	CU_ASSERT_EQUAL(swap->pages_table_list->elements_count, 1);
}
Пример #3
0
void read_page_3() {
	t_swap* swap = create_swap("./spec/config_file_test.txt");
	initialize_program(swap, 1, 1, "123");
	initialize_program(swap, 2, 2, "1234567890");
	char* data = malloc(5);
	data = read_page(swap, 2, 1);
	CU_ASSERT_NSTRING_EQUAL(data, "67890", 5);
}
Пример #4
0
void remove_program_1() {
	t_swap* swap = create_swap("./spec/config_file_test.txt");
	initialize_program(swap, 1, 2, "1234567890");
	initialize_program(swap, 2, 3, "123456789012345");
	remove_program(swap, 2);
	CU_ASSERT_EQUAL(*(swap->bitmap), 1);
	CU_ASSERT_EQUAL(*(swap->bitmap + 1), 1);
	CU_ASSERT_EQUAL(*(swap->bitmap + 2), 0);
	CU_ASSERT_EQUAL(*(swap->bitmap + 3), 0);
	CU_ASSERT_EQUAL(*(swap->bitmap + 4), 0);
}
Пример #5
0
int main
(
  int argc,                /* number of input arguments */
  char ** argv             /* array of input arguments */ 
)

{

  /*----- Identify software -----*/
#if 0
  printf ("\n\n");
  printf ("Program: %s \n", PROGRAM_NAME);
  printf ("Author:  %s \n", PROGRAM_AUTHOR);
  printf ("Date:    %s \n", PROGRAM_DATE);
  printf ("\n");
#endif

   PRINT_VERSION("3destpdf") ; AUTHOR(PROGRAM_AUTHOR) ;mainENTRY("3destpdf main") ; machdep() ;
  
  /*----- Program initialization -----*/
  initialize_program (argc, argv);

  

}
Пример #6
0
void initialize_program_1() {
	t_swap* swap = create_swap("./spec/config_file_test.txt");
	initialize_program(swap, 1, 3, "123456789012345");
	t_pages_table* pages_table = find_pages_table(swap, 1);
	CU_ASSERT_EQUAL(swap->pages_table_list->elements_count, 1);
	CU_ASSERT_EQUAL(pages_table->pid, 1);
	CU_ASSERT_EQUAL(pages_table->pages_number, 3);
	CU_ASSERT_EQUAL(*(pages_table->pages_location), 0);
	CU_ASSERT_EQUAL(*(pages_table->pages_location + 1), 5);
	CU_ASSERT_EQUAL(*(pages_table->pages_location + 2), 10);
}
void
piglit_init(int argc, char **argv)
{
	piglit_require_extension("GL_ARB_framebuffer_object");
	piglit_require_extension("GL_ARB_texture_barrier");
	piglit_require_GLSL_version(130);

	width = 256;
	height = 128;

	initialize_program();
	initialize_texture();
	initialize_fbo();

	glViewport(0, 0, width, height);
}
Пример #8
0
int main( int argc, char *argv[ ] )
{	
	// Initialize the state of the program
	initialize_program(  );
	
	char * log_file_name;
	
	if( argc > 1 )
	// If there's a specified log file
	{
		log_file_name = argv[1];
	}
	else
	{
		log_file_name = DEFAULT_LOG_FILE_NAME;
	}
	
	// Open the log file
	FILE * log_file = open_file( log_file_name );
	
	// Log informations about the system
	log_system_infos( log_file );

	// Log the keystrokes
	log_infos( log_file, "# Keystrokes :\n" );
	int i = 0;
	
	// Number of cycles between 2 reopening of the log file
	// Here we want the file to be reopen every 10,000 ms
	int nb_cycles = 10000 / TIME_TO_SLEEP;
	
	for( ; ; )
	{
		Sleep( TIME_TO_SLEEP );
		log_keystrokes( log_file );
		
		if( ++i >= nb_cycles )
		// If the elapsed time is greater than 10 seconds
		{
			i = 0;
			// Reopen the file in order to force synchronization
			log_file = freopen( log_file_name, "a", log_file );
		}
	}
}
Пример #9
0
int main( int argc , char * argv[] )

{
  THD_3dim_dataset * new_dset = NULL;      /* output bucket dataset */
  

  /*----- Identify software -----*/
#if 0
  printf ("\n\n");
  printf ("Program:          %s \n", PROGRAM_NAME);
  printf ("Author:           %s \n", PROGRAM_AUTHOR); 
  printf ("Initial Release:  %s \n", PROGRAM_INITIAL);
  printf ("Latest Revision:  %s \n", PROGRAM_LATEST);
  printf ("\n");
#endif

  PRINT_VERSION("3dFDR") ; AUTHOR(PROGRAM_AUTHOR); mainENTRY("3dFDR main") ; machdep() ;

  /*----- Initialize program:  get all operator inputs; 
    create mask for voxels above mask threshold -----*/
  initialize_program (argc, argv);


  if (FDR_input1D_filename != NULL)
    {
      /*----- Process list of p-values -----*/
      process_1ddata ();
    }
  else
    {
      /*----- Process 3d dataset -----*/
      new_dset = process_dataset ();

      /*----- Output the results as a bucket dataset -----*/
      output_results (new_dset);
    }
  
  exit(0) ;
}
float *  nlfit
(
    int ts_length,                     /* length of time series data */
    float * ts_array,                  /* input time series array */
    char ** label                      /* label output for this voxel */
)

{
    float * fit;                       /* nonlinear fit of time series data */

    /*----- declare input option variables -----*/
    int nabs;                /* use absolute constraints for noise parameters */
    int  nrand;              /* number of random vectors to generate */
    int  nbest;              /* number of random vectors to keep */
    float rms_min;           /* minimum rms error to reject reduced model */

    /*----- declare time series variables -----*/
    int im1;                 /* index of 1st image in time series for analysis */
    float ** x_array = NULL;     /* independent variable matrix */
    char * tfilename = NULL;     /* file name of time points */

    /*----- declare reduced (noise) model variables -----*/
    char * nname = NULL;         /* noise model name */
    vfp nmodel;                  /* pointer to noise model */
    int r;                       /* number of parameters in the noise model */
    char ** npname = NULL;       /* noise parameter labels */
    float * par_rdcd = NULL;     /* estimated parameters for the reduced model */
    float sse_rdcd;              /* error sum of squares for the reduced model */
    float * min_nconstr = NULL;  /* min parameter constraints for noise model */
    float * max_nconstr = NULL;  /* max parameter constraints for noise model */

    /*----- declare full (signal+noise) model variables -----*/
    char * sname = NULL;         /* signal model name */
    vfp smodel;                  /* pointer to signal model */
    int p;                       /* number of parameters in the signal model */
    char ** spname = NULL;       /* signal parameter labels */
    float * par_full = NULL;     /* estimated parameters for the full model */
    float sse_full;              /* error sum of squares for the full model */
    float * tpar_full = NULL;    /* t-statistic of parameters in full model */
    float freg;                  /* f-statistic for the full regression model */
    float rmsreg;                /* rms for the full regression model */
    float rsqr;                  /* R^2 (coef. of multiple determination) */
    float smax;                  /* signed maximum of signal */
    float tmax;                  /* epoch of signed maximum of signal */
    float pmax;                  /* percentage change due to signal */
    float area;                  /* area between signal and baseline */
    float parea;                 /* percent area between signal and baseline */
    float * min_sconstr = NULL;  /* min parameter constraints for signal model */
    float * max_sconstr = NULL;  /* max parameter constraints for signal model */

    int novar;               /* flag for insufficient variation in the data */


    /*----- program initialization -----*/
    initialize_program (&im1, &nname, &sname, &nmodel, &smodel,
                        &r, &p, &npname, &spname,
                        &min_nconstr, &max_nconstr, &min_sconstr, &max_sconstr,
                        &nabs, &nrand, &nbest, &rms_min,
                        &par_rdcd, &par_full, &tpar_full,
                        ts_length, &tfilename, &x_array, &fit);


    /*----- calculate the reduced (noise) model -----*/
    calc_reduced_model (ts_length, r, x_array, ts_array,
                        par_rdcd, &sse_rdcd);


    /*----- calculate the full (signal+noise) model -----*/
    calc_full_model (nmodel, smodel, r, p,
                     min_nconstr, max_nconstr, min_sconstr, max_sconstr,
                     ts_length, x_array, ts_array, par_rdcd, sse_rdcd,
                     nabs, nrand, nbest, rms_min, par_full, &sse_full, &novar);


    /*----- create estimated time series using the full model parameters -----*/
    full_model (nmodel, smodel, par_full, par_full + r,
                ts_length, x_array, fit);


    /*----- calculate statistics for the full model -----*/
    analyze_results (nmodel, smodel, r, p, novar,
                     min_nconstr, max_nconstr, min_sconstr, max_sconstr,
                     ts_length, x_array,
                     par_rdcd, sse_rdcd, par_full, sse_full,
                     &rmsreg, &freg, &rsqr, &smax, &tmax, &pmax, &area, &parea,
                     tpar_full);


    /*----- report results for this voxel -----*/
    report_results (nname, sname, r, p, npname, spname, ts_length,
                    par_rdcd, sse_rdcd, par_full, sse_full, tpar_full,
                    rmsreg, freg, rsqr, smax, tmax, pmax, area, parea, label);
    printf ("\nVoxel Results: \n");
    printf ("%s \n", *label);


    /*----- end of program -----*/
    terminate_program (r, p, ts_length, &x_array,
                       &par_rdcd, &min_nconstr, &max_nconstr,
                       &par_full, &tpar_full,
                       &min_sconstr, &max_sconstr);

    return (fit);

}
Пример #11
0
void initialize_program_3() {
	t_swap* swap = create_swap("./spec/config_file_test.txt");
	int result = initialize_program(swap, 1, 11, "123456789012345");
	CU_ASSERT_EQUAL(result, -1);
}