#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_ROOTPATH_LEN 100 #define MAX_FULLPATH_LEN 150 #define PATH_DATASET "PROC/DATASETS/" #define PATH_NORMDATA "PROC/NORMDATA/" #define MAX_NUM_SETS 100 #define DEBUG 1 #define SUBSET 10000 void quickSort(short unsigned int*, unsigned long long int); int main(int argc, char *argv[]){ char raw_fn[MAX_FULLPATH_LEN], dataset_fn[MAX_FULLPATH_LEN], normdata_fn[MAX_FULLPATH_LEN], obj_count_fn[MAX_FULLPATH_LEN], ROOT_PATH[MAX_ROOTPATH_LEN], curr_fn_index[5], curr_set_index[4], curr_obj_count[20], text[500], dataset_name[MAX_FULLPATH_LEN], error_string[200]; int num_frames, num_sets, num_cols, set_index[MAX_NUM_SETS], curr_set, field_size, success, curr_frame, output_thresh, output_flag=0, i, j, temp; unsigned int random_index; //initialize random number generator time_t t1; (void) time(&t1); srand((unsigned int) t1); unsigned long long int *col_sums; // max val ullong=18446744073709551615ULL unsigned char *row_preserve; unsigned long long int num_rows = 0, curr_row = 0; short unsigned int bead_info[7]; short unsigned int dataset_row[150]; short unsigned int ** bead_vals; short unsigned int ** subset_bead_vals; float ** norm_bead_vals; float * base_sums_multiplier; FILE *infile, *outfile; //short unsigned int input_frame=0, short unsigned int input_frame=0, input_set=0, input_size=0, input_centroid_x=0, input_centroid_y=0, input_border=0, input_value=0, input_border_temp=0; // short unsigned int input_frame[10]; field_size = sizeof(unsigned short int); //****************** Parse command-line arguments ********************** // strcpy(ROOT_PATH, argv[1]); strcpy(dataset_name, argv[2]); num_sets = atoi(argv[3]); num_cols = atoi(argv[3]) + 7; //num_sets = argc - 3; // //********************************************************************** if((col_sums = (unsigned long long int*) malloc(num_cols * sizeof(unsigned long long int)))==NULL){ fprintf(stderr, "Could not allocate enough memory for col_sums list.\n"); exit(42); } if((base_sums_multiplier = (float*) malloc(num_cols * sizeof(float)))==NULL){ fprintf(stderr, "Could not allocate enough memory for base_sums_multiplier list.\n"); exit(42); } if((bead_vals = (short unsigned int**) malloc(num_sets * sizeof(short unsigned int*)))==NULL){ fprintf(stderr, "Could not allocate enough memory for bead_vals list.\n"); exit(42); } if((norm_bead_vals = (float**) malloc(num_sets * sizeof(float*)))==NULL){ fprintf(stderr, "Could not allocate enough memory for norm_bead_vals list.\n"); } if((subset_bead_vals = (short unsigned int**) malloc(num_sets * sizeof(short unsigned int*)))==NULL){ fprintf(stderr, "Could not allocate enough memory for subset_bead_vals list.\n"); exit(42); } fprintf(stderr, "Allocating %iKB for subset_bead_vals array\n", (int) ( (SUBSET*num_sets*sizeof(short unsigned int)) / double(1024))); for(i=0; i< num_sets; i++){ if((*(subset_bead_vals+i) = (short unsigned int*) malloc(SUBSET * sizeof(short unsigned int)))==NULL){ fprintf(stderr, "Could not allocate enough memory for subset_bead_vals [%d] array.\n",i); exit(42); } } for(i=0; i= num_rows) fprintf(stderr, "index problem -> %u\n", random_index); *(*(subset_bead_vals + i) + j) = *(*(bead_vals + i) + random_index); } } fprintf(stderr, " done.\n"); fprintf(stderr, "Sorting bead data in memory to determine percentile... "); for(i=0; i< num_sets; i++){ quickSort(*(subset_bead_vals + i), SUBSET); } fprintf(stderr, " done.\n"); /* for(i=0; i highest){ highest = *(col_sums + i + 1); } if(*(col_sums + i + 2) > highest){ highest = *(col_sums + i + 2); } if(*(col_sums + i + 3) > highest){ highest = *(col_sums + i + 3); } *(base_sums_multiplier + i) = (float) (highest / (double)(*(col_sums + i))); *(base_sums_multiplier + i + 1) = (float) (highest / (double)(*(col_sums + i + 1))); *(base_sums_multiplier + i + 2) = (float) (highest / (double)(*(col_sums + i + 2))); *(base_sums_multiplier + i + 3) = (float) (highest / (double)(*(col_sums + i + 3))); } //all vals now in norm_bead_vals will sum to the same value for each base for(i=0; i= pivot) && (left < right)) right--; if (left != right) { numbers[left] = numbers[right]; left++; } while ((numbers[left] <= pivot) && (left < right)) left++; if (left != right) { numbers[right] = numbers[left]; right--; } } numbers[left] = (short unsigned int) pivot; pivot = left; left = l_hold; right = r_hold; if (left < pivot) q_sort(numbers, left, pivot-1); if (right > pivot) q_sort(numbers, pivot+1, right); } void quickSort(short unsigned int numbers[], unsigned long long int array_size) { q_sort(numbers, 0, (long long int) (array_size) - 1); }