void init_vector() { // prevent deadlock with EKA2 scheduler __LOCK_HOST; HINSTANCE instance; // Try loading dll with customised uid data first // instance = LoadLibraryA("ssmuiproviderdllcustomised.dll"); if (instance != NULL) { fill_vector(instance); return; } // Try loading dll with default uid data // instance = LoadLibraryA("ssmuiproviderdlldefault.dll"); if (instance != NULL) { fill_vector(instance); return; } // die // OutputDebugStringA("Unable to load ssm custom command uid implementation"); _asm int 3; }
void handle_values_tests(hpx::vector<T>& v) { fill_vector(v, T(42)); std::vector<std::size_t> positions(2); fill_vector(positions, 0, 2); std::vector<T> values(positions.size()); fill_vector(values, T(48), T(3)); v.set_values(0, positions, values); std::vector<T> result = v.get_values_sync(0, positions); compare_vectors(values, result); }
// redirects DLL calls to GCE or non-GCE implementation void init_vector() { // ask HAL which configuration to use TBool nga = EFalse; UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_gce", &nga); const char* library = nga ? "remotegc_nga.dll" : "remotegc_nonnga.dll"; #ifdef _DEBUG RDebug::Printf("Redirecting remotegc.dll to \"%s\" ...\n", library); #endif Emulator::Escape(); // prevent deadlock between EKA2 scheduler and MS kernel // try to load selected DLL HINSTANCE instance = LoadLibraryA(library); Emulator::Reenter(); if (instance == NULL) { Stop("... unable to load"); } else { fill_vector(instance); #ifdef _DEBUG RDebug::Printf("... DLL loaded successfully"); #endif } }
void run_benchmark() { std::size_t matrix_size = 1500; //some odd number, not too large std::size_t rhs_num = 153; viennacl::matrix<NumericT, F_A> vcl_A(matrix_size, matrix_size); viennacl::matrix<NumericT, F_B> vcl_B(matrix_size, rhs_num); viennacl::matrix<NumericT, F_B> result(matrix_size, rhs_num); viennacl::vector<NumericT> vcl_vec_B(matrix_size); viennacl::vector<NumericT> vcl_vec_result(matrix_size); fill_matrix(vcl_A); fill_matrix(vcl_B); fill_vector(vcl_vec_B); std::cout << "------- Solve Matrix-Matrix: ----------\n" << std::endl; run_solver_matrix<NumericT>(vcl_A,vcl_B,result,viennacl::linalg::lower_tag()); run_solver_matrix<NumericT>(vcl_A,vcl_B,result,viennacl::linalg::unit_lower_tag()); run_solver_matrix<NumericT>(vcl_A,vcl_B,result,viennacl::linalg::upper_tag()); run_solver_matrix<NumericT>(vcl_A,vcl_B,result,viennacl::linalg::unit_upper_tag()); std::cout << "------- End Matrix-Matrix: ----------\n" << std::endl; std::cout << "------- Solve Matrix-Vector: ----------\n" << std::endl; run_solver_vector<NumericT>(vcl_A,vcl_vec_B,vcl_vec_result,viennacl::linalg::lower_tag()); run_solver_vector<NumericT>(vcl_A,vcl_vec_B,vcl_vec_result,viennacl::linalg::unit_lower_tag()); run_solver_vector<NumericT>(vcl_A,vcl_vec_B,vcl_vec_result,viennacl::linalg::upper_tag()); run_solver_vector<NumericT>(vcl_A,vcl_vec_B,vcl_vec_result,viennacl::linalg::unit_upper_tag()); std::cout << "------- End Matrix-Vector: ----------\n" << std::endl; }
// (make-vector n e) Cell* op_makevector(Scheme *sc) { int len = long_value(first(sc->args)); Cell* vec = make_vector(sc, len); if (rest(sc->args) != &g_nil) { fill_vector(vec, second(sc->args)); } return s_return_helper(sc, vec); }
void handle_values_tests_distributed_access(hpx::vector<T>& v) { fill_vector (v, T(42)); std::vector<std::size_t> positions(5); fill_vector(positions, 0, 2); std::vector<std::size_t> positions2(5); fill_vector(positions2, 1, 2); std::vector<T> values(positions.size()); fill_vector(values, T(48), T(3)); std::vector<T> values2(positions2.size()); fill_vector(values2, T(42), T(0)); v.set_values(positions, values); std::vector<T> result = v.get_values_sync(positions ); std::vector<T> result2 = v.get_values_sync(positions2); compare_vectors(values , result); compare_vectors(values2, result2); }
/** * This function explores the partial matches that constitute the given match in order to produce * one or all possible outputs, depending on infos->ambiguous_output_policy. * The output(s) is(are) then used to add matches to the infos->matches list. */ void explore_match_to_get_outputs(struct locate_tfst_infos* infos,struct tfst_match* m, struct tfst_simple_match_list* element) { /* As m is a reversed list, we first need to get its elements in the right order */ vector_ptr* items=new_vector_ptr(16); fill_vector(items,m); Ustring* s=new_Ustring(1024); /* In MERGE/REPLACE mode, we have to explore the combination of partial matches */ struct list_pointer* ptr=NULL; explore_match_for_MERGE_or_REPLACE_mode(infos,element,items,0,s,-1,&ptr); free_list_pointer(ptr); free_Ustring(s); free_vector_ptr(items); }
int main() try { // make cin throw if it goes bad: cin.exceptions(cin.exceptions()|ios_base::badbit); vector<int> v; fill_vector(cin, v, '*'); } catch (exception& e) { cerr << "error: " << e.what() << '\n'; return 1; } catch (...) { cerr << "Oops: unknown exception!\n"; return 2; }
/* Function compute_clustering. * This function recomputes the clustering based on the current means. * * Inputs: * n : number of input descriptors * dim : dimension of each input descriptor * k : number of means * v : array of pointers to dim-dimensional descriptors * means : current means, stored in a k*dim dimensional array * * Output: * clustering : new assignment of descriptors to nearest means * (should range between 0 and k-1) * error_out : total error of the new assignment * * Return value : return the number of points that changed assignment */ int compute_clustering(int n, int dim, int k, unsigned char **v, double *means, unsigned int *clustering, double &error_out) { int i; double error = 0.0; int changed = 0; double *vec = (double *) malloc(sizeof(double) * dim); double *work = (double *) malloc(sizeof(double) * dim); for (i = 0; i < n; i++) { fill_vector(vec, v[i], dim); int j; double min_dist = DBL_MAX; unsigned int cluster = 0; for (j = 0; j < k; j++) { vec_diff(dim, vec, means + j * dim, work); double dist = vec_normsq(dim, work); if (dist < min_dist) { min_dist = dist; cluster = j; } } error += min_dist; if (clustering[i] != cluster) changed++; clustering[i] = cluster; } free(vec); free(work); error_out = error; return changed; }
// redirects DLL calls to GCE or non-GCE implementation void init_vector() { // ask HAL which configuration to use TBool gce = EFalse; UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_gce", &gce); const char* library = ""; if (gce) { // reference EGL is for NGA only TBool ref = EFalse; UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_egl_ref", &ref); library = ref ? "libegl_ref.dll" : "libegl_gce.dll"; } else { library = "libegl_nongce.dll"; } #ifdef _DEBUG RDebug::Printf("Redirecting libEGL.dll to \"%s\" ...\n", library); #endif Emulator::Escape(); // prevent deadlock between EKA2 scheduler and MS kernel // try to load selected DLL HINSTANCE instance = LoadLibraryA(library); Emulator::Reenter(); if (instance == NULL) { Stop("... unable to load"); } else { fill_vector(instance); #ifdef _DEBUG RDebug::Printf("... DLL loaded successfully"); #endif } }
/** * Saves the elements of 'list' in reverse order into 'items'. */ static void fill_vector(vector_ptr* items,struct tfst_match* list) { if (list==NULL) return; fill_vector(items,list->next); vector_ptr_add(items,list); }
/* Function kmeans. * Run kmeans clustering on a set of input descriptors. * * Inputs: * n : number of input descriptors * dim : dimension of each input descriptor * k : number of means to compute * restarts : number of random restarts to perform * v : array of pointers to dim-dimensional descriptors * * Output: * means : array of output means. The means should be * concatenated into one long array of length k*dim. * clustering : assignment of descriptors to means (should * range between 0 and k-1), stored as an array of * length n. clustering[i] contains the * cluster ID for point i */ double kmeans(int n, int dim, int k, int restarts, unsigned char **v, double *means, unsigned int *clustering) { int i; double min_error = DBL_MAX; double *means_curr, *means_new, *work; int *starts; unsigned int *clustering_curr; double changed_pct_threshold = 0.05; // 0.005; if (n <= k) { printf("[kmeans] Error: n <= k\n"); return -1; } means_curr = (double *) malloc(sizeof(double) * dim * k); means_new = (double *) malloc(sizeof(double) * dim * k); clustering_curr = (unsigned int *) malloc(sizeof(unsigned int) * n); starts = (int *) malloc(sizeof(int) * k); work = (double *) malloc(sizeof(double) * dim); if (means_curr == NULL) { printf("[kmeans] Error allocating means_curr\n"); exit(-1); } if (means_new == NULL) { printf("[kmeans] Error allocating means_new\n"); exit(-1); } if (clustering_curr == NULL) { printf("[kmeans] Error allocating clustering_curr\n"); exit(-1); } if (starts == NULL) { printf("[kmeans] Error allocating starts\n"); exit(-1); } if (work == NULL) { printf("[kmeans] Error allocating work\n"); exit(-1); } for (i = 0; i < restarts; i++) { int j; double max_change = 0.0; double error = 0.0; int round = 0; choose(n, k, starts); for (j = 0; j < k; j++) { fill_vector(means_curr + j * dim, v[starts[j]], dim); } /* Compute new assignments */ timeval start, stop; gettimeofday(&start, NULL); int changed = 0; changed = compute_clustering_kd_tree(n, dim, k, v, means_curr, clustering_curr, error); double changed_pct = (double) changed / n; do { gettimeofday(&stop, NULL); long seconds = stop.tv_sec - start.tv_sec; long useconds = stop.tv_usec - start.tv_usec; double etime = seconds + useconds * 0.000001; printf("Round %d: changed: %d\n", i, changed); printf("Round took %0.3lfs\n", etime); fflush(stdout); gettimeofday(&start, NULL); /* Recompute means */ max_change = compute_means(n, dim, k, v, clustering_curr, means_new); memcpy(means_curr, means_new, sizeof(double) * dim * k); /* Compute new assignments */ changed = compute_clustering_kd_tree(n, dim, k, v, means_curr, clustering_curr, error); changed_pct = (double) changed / n; round++; } while (changed_pct > changed_pct_threshold); max_change = compute_means(n, dim, k, v, clustering_curr, means_new); memcpy(means_curr, means_new, sizeof(double) * dim * k); if (error < min_error) { min_error = error; memcpy(means, means_curr, sizeof(double) * k * dim); memcpy(clustering, clustering_curr, sizeof(unsigned int) * n); } } free(means_curr); free(means_new); free(clustering_curr); free(starts); free(work); return compute_error(n, dim, k, v, means, clustering); }
int main() { vector<string>reading; //╤ахКнд╪Ч╣ддзхщ cout << "Please enter input file name: "; string name1; cin >> name1; ifstream ist1(name1.c_str()); if (!ist1) { cout << "someting was wrong" << endl; getchar(); getchar(); getchar(); } else { try //╡Бйтйг╥ЯспрЛЁё { fill_vector(ist1, reading); } catch (error) { cout << "something is wrong" << endl; return 0; } cout << "Please enter another input file name: "; string name2; cin >> name2; ifstream ist2(name2.c_str()); if (!ist2) { cout << "someting was wrong" << endl; getchar(); getchar(); getchar(); } else { try { fill_vector(ist2, reading); } catch (error) { cout << "something is wrong" << endl; getchar(); getchar(); getchar(); } for (int i = 0; i < reading.size(); i++) { check.push_back(reading[i]); } for (int i = 0; i < check.size(); i++) { tolower(check[i]); } BubbleSort(reading); //еепР cout << "Please enter name of output file: "; //йДЁЖ string name3; cin >> name3; ofstream ofs(name3.c_str()); if (!ofs) { cout << "someting was wrong" << endl; getchar(); getchar(); getchar(); } else { for (int i = 0; i < reading.size(); i++) { ofs << reading[i] << ' '; } } } } getchar(); getchar(); getchar(); }
int main(int argc ,char **argv){ /* Declare start and end of computation time */ struct timeval start, end; /* Variables declaration */ int i; int j; int rows_of_proc; /* Number of rounds that the parallel part will be computed */ int rounds = 0; /* Variable that shows the non zero elemets of the array */ int non_zero_elements = 0; /* Session start */ //session *s; //join_session(&argc, &argv, &s, "Master.spr"); //role *worker1 = s->get_role(s, "worker1"); //role *worker2 = s->get_role(s, "worker2"); //role *worker3 = s->get_role(s, "worker3"); /* Declaration of array results, which is the vector that will hold the results */ int *results = NULL; /* Declaration of array x, which is the vector that will bw multiplied with the array */ int *x = NULL; //Dynamic memory allocation x = (int *) malloc( ncolumns * sizeof(int) ); if(x == NULL) { fprintf(stderr, "out of memory\n"); exit(-1); } //Fill the vector x printf("Filling and printing vector x \n"); fill_vector(x, ncolumns); /* The array that contains the start of each row within the non-zero elements array*/ int *row_ptr = NULL; /* Dynamic memory allocation of the array row_ptr */ row_ptr = (int *) malloc( (nrows + 1) * sizeof(int) ); /* Check if we have enough memory */ if(row_ptr == NULL) { fprintf(stderr, "out of memory\n"); exit(-1); } //Declaration of array A int **A = NULL; //Dynamic memory allocation of the matrix A = malloc(nrows * sizeof(int *)); /* Check if we have enough memory */ if(A == NULL) { fprintf(stderr, "out of memory\n"); exit(-1); } for(i = 0; i < nrows; i++) { A[i] = malloc(ncolumns * sizeof(int)); /* Check if we have enough memory */ if(A[i] == NULL) { fprintf(stderr, "out of memory\n"); exit(-1); } } /* A[0][0] = 5; A[0][1] = 1; A[0][2] = 0; A[0][3] = 0; A[0][4] = 0; A[0][5] = 0; A[1][0] = 0; A[1][1] = 6; A[1][2] = 0; A[1][3] = 7; A[1][4] = 0; A[1][5] = 8; A[2][0] = 0; A[2][1] = 0; A[2][2] = 1; A[2][3] = 0; A[2][4] = 0; A[2][5] = 0; A[3][0] = 0; A[3][1] = 0; A[3][2] = 2; A[3][3] = 0; A[3][4] = 3; A[3][5] = 2; A[4][0] = 9; A[4][1] = 0; A[4][2] = 0; A[4][3] = 1; A[4][4] = 4; A[4][5] = 0; A[5][0] = 1; A[5][1] = 0; A[5][2] = 2; A[5][3] = 3; A[5][4] = 0; A[5][5] = 1; */ /* Fill tha matrix with values */ fill_matrix(A); /* Start counting the time */ gettimeofday(&start, NULL); /* Computation of non zero elements */ non_zero_elements = num_of_non_zero_elements(A); printf("Num of non zeros is %d \n", non_zero_elements); /* Master sends the non zero elements to the workers */ //send_int(worker1, non_zero_elements); //send_int(worker2, non_zero_elements); //send_int(worker3, non_zero_elements); /* Dynamically allocate memory for the array results */ results = (int *) malloc( nrows * sizeof(int) ); fill_with_zeros(results, nrows); /* Declaration af array values and memory allocation */ int *values = (int *) malloc(non_zero_elements * sizeof(int)); /* Check if we have enough memory */ if(values == NULL) { fprintf(stderr, "out of memory\n"); exit(-1); } /* Fill the values array */ fill_values(A, values); /* Declaration of the array values and dynamic memory allocation */ int *col_ind = (int *) malloc( non_zero_elements * sizeof(int) ); /* Check if we have enough memory */ if(col_ind == NULL) { fprintf(stderr, "out of memory\n"); exit(-1); } /* Fill the col_ind array */ fill_col_ind(A, col_ind); /* Fill the row_ptr array with zero*/ fill_with_zeros(row_ptr, nrows + 1); /* Print row_ptr initialized */ ////////////////print_vector(row_ptr, nrows + 1); /* Fill the row_ptr array */ fill_row_ptr(A, row_ptr); /* The results that workers will send to master */ int *buffer_results[participants] = {NULL}; /* Master sends tha arrays to workers */ //send_int_array(worker1, row_ptr, nrows + 1); //send_int_array(worker1, values, non_zero_elements); //send_int_array(worker1, col_ind, non_zero_elements); //send_int_array(worker1, x, ncolumns); //send_int_array(worker2, row_ptr, nrows + 1); //send_int_array(worker2, values, non_zero_elements); //send_int_array(worker2, col_ind, non_zero_elements); //send_int_array(worker2, x, ncolumns); //send_int_array(worker3, row_ptr, nrows + 1); //send_int_array(worker3, values, non_zero_elements); //send_int_array(worker3, col_ind, non_zero_elements); //send_int_array(worker3, x, ncolumns); /* print_vector(values, non_zero_elements); printf("\n"); print_vector(row_ptr, nrows + 1); printf("\n"); print_vector(col_ind, non_zero_elements); */ //print_vector(values, non_zero_elements); /* Define the work that master will do */ /*int start_work_i[participants]; int end_work_i[participants];*/ int start_work[participants]; int end_work[participants]; int amount_of_work[participants]; for(i = 0; i < participants; i++){ /* The amount of work that the master will do */ start_work[i] = floor((i * nrows)/participants); end_work[i] = floor(((i + 1) * nrows)/participants); amount_of_work[i] = end_work[i] - start_work[i]; printf("start = %d - end = %d - amount of work = %d\n", start_work[i], end_work[i], amount_of_work[i]); /* Dynamic allocation of buffer results */ buffer_results[i] = (int *) malloc(amount_of_work[i] * sizeof(int)); if(buffer_results[i] == NULL){ fprintf(stderr, "Out of memory, aborting program...\n"); } } /* The amount of work that the master will do */ //start_work[master] = floor((master * nrows)/participants); //end_work[master] = floor(((master + 1) * nrows)/participants); //printf("start = %d - end = %d\n", start_work[0], end_work[0]); /* Run for 40 rounds */ while(rounds++ < 40){ /* Main computation of the result. Each processor computes the work that is assigned to it*/ for(i = start_work[master]; i < end_work[master]; i++){ for(j = row_ptr[i]; j < row_ptr[i + 1]; j++) buffer_results[0][i] += values[j] * x[col_ind[j]]; //results[i] += values[j] * x[col_ind[j]]; } } /* Master node receives the results */ //receive_int_array(worker1, buffer_results[1], amount_of_work[1]); //receive_int_array(worker2, buffer_results[2], amount_of_work[2]); //receive_int_array(worker3, buffer_results[3], amount_of_work[3]); /* End counting of time here */ gettimeofday(&end, NULL); /* Computation of time */ long time_elapsed = ((end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec)) / 1000000; /* Print the time that has elapsed */ printf("Elapsed time is: %ld seconds\n", time_elapsed); /* int counter = 0; while(counter++ < 1000){ for(i = 0; i < nrows; i++){ //printf("rank = %d - i = %d\n", rank, i); //printf("RANK = %d\n", rank); for(j = row_ptr[i]; j < row_ptr[i + 1]; j++) results[i] += values[j] * x[col_ind[j]]; //results[i - start] += values[j] * x[col_ind[j]]; } }*/ /* Define the sub-buffers that we will send to the participants */ /*int *buffer_values[participants] = {NULL}; int *buffer_col_ind[participants] = {NULL}; int *buffer_row_ptr[participants] = {NULL};*/ /* Compute which part of the array each participant will compute */ //for(i = 0; i < participants; i++){ /*start_work_i[i] = floor((i * nrows)/participants); end_work_i[i] = floor(((i + 1) * nrows)/participants); start_work[i] = floor((i * non_zero_elements)/participants); end_work[i] = floor(((i + 1) * non_zero_elements)/participants); amount_of_work[i] = floor(((i + 1) * non_zero_elements)/participants) - floor(( i * non_zero_elements)/participants); //amount_of_work[i] = end_work[i] - start_work[i]; printf("start = %d - end = %d - amount of work = %d\n", start_work[i], end_work[i], amount_of_work[i]); */ /* Dynamically buffer allocation */ /*buffer_values[i] = (int *) malloc( (amount_of_work[i]) * sizeof(int)); buffer_col_ind[i] = (int *) malloc( (amount_of_work[i]) * sizeof(int)); */ //buffer_values[i] = (int *) malloc( (non_zero_elements) * sizeof(int)); //buffer_col_ind[i] = (int *) malloc( (non_zero_elements) * sizeof(int)); /* Check if memory is enough */ /*if(buffer_values[i] == NULL){ fprintf(stderr, "Out of memory.Aborting the program...\n"); exit(0); }*/ /* Check if memory is enough */ /*if(buffer_col_ind[i] == NULL){ fprintf(stderr, "Out of memory.Aborting the program...\n"); exit(0); }*/ //} ////////////////////////print_array(A); ////////////////////////print_vector(row_ptr, nrows + 1); //printf("row_ptr[%d] = %d\n", start_work[0], row_ptr[start_work[0]]); //printf("row_ptr[%d] = %d\n", end_work[0], row_ptr[end_work[0]]); //print_vector(buffer_values[0], amount_of_work[0]); //printf("\n\n"); /* Compute the buffer for each participant (amount of work) */ /*for(i = 0; i < participants; i++){ memcpy( buffer_values[i], values + start_work[i], amount_of_work[i] * sizeof(int) ); memcpy( buffer_col_ind[i], col_ind + start_work[i], amount_of_work[i] * sizeof(int)); //printf("buffer[%d] = %s\n", i, buffer[i]); }*/ //print_vector(buffer_values[0], amount_of_work[0]); //print_vector(buffer_col_ind[0], amount_of_work[0]); //print_vector(col_ind, non_zero_elements); //print_vector(values, non_zero_elements); ////////print_vector(col_ind, non_zero_elements); /* Main computation of the result. Master computes the work that is assigned to it*/ /*for(i = start_work[0]; i < end_work[0]; i++){ for(j = row_ptr[i]; j < row_ptr[i + 1]; j++) results[i] += values[j] * x[col_ind[j]]; //results[i - start] += values[j] * x[col_ind[j]]; }*/ /* for(i = start_work_i[1]; i < end_work_i[1]; i++){ for(j = row_ptr[i]; j < row_ptr[i + 1]; j++){ printf("j = %d\n", j); results[i] += buffer_values[1][j] * x[buffer_col_ind[1][j]]; } } */ //printf("buffer_values[%d][%d] = %d\n", 1, 12, buffer_values[1][12]); /* Main computation of the result. Each processor computes the work that is assigned to it*/ /*for(i = start; i < end; i++){ //printf("rank = %d - i = %d\n", rank, i); //printf("RANK = %d\n", rank); for(j = row_ptr[i]; j < row_ptr[i + 1]; j++) y[i] += values[j] * x[col_ind[j]]; //results[i - start] += values[j] * x[col_ind[j]]; }*/ /* The arrays that we will send to the workers */ //int *buffer_col_ind = NULL; //int *buffer_values = NULL; /* Free memory */ free(x); free(results); free(values); free(col_ind); free(row_ptr); return EXIT_SUCCESS; }
void run(char * filename, unsigned long nmaxvalues, double min, double max) { unsigned int i; unsigned int nvalues; double empty_space_needed; unsigned int left; unsigned int right; double median = 0, leftquartile = 0, rightquartile = 0, percentage = 0; gsl_vector * values = gsl_vector_alloc(nmaxvalues); gsl_vector * medians = gsl_vector_alloc(100); gsl_vector * leftquartiles = gsl_vector_alloc(100); gsl_vector * rightquartiles = gsl_vector_alloc(100); gsl_vector * percentages = gsl_vector_alloc(100); gsl_vector * vectors[4]; unsigned int npeaks = 0; vectors[0] = percentages; vectors[1] = medians; vectors[2] = leftquartiles; vectors[3] = rightquartiles; dump_ul("nmaxvalues", nmaxvalues); nvalues = fill_vector(values, filename, min, max); dump_ul("nvalues", nmaxvalues); debug("data ready!"); qsort(values->data, nvalues, sizeof(double), double_comp); debug("data sorted!"); /* 0.1% of parameter space */ empty_space_needed = (max - min) / 100; dump_d("empty_space_needed", empty_space_needed); dump_d("min", min); dump_d("max", max); assert(gsl_vector_get(values, 0) >= min); assert(gsl_vector_get(values, 0) <= max); assert(gsl_vector_get(values, nvalues - 1) >= min); assert(gsl_vector_get(values, nvalues - 1) <= max); left = 0; while (1) { dump_ui("found left side", left); dump_d("left side", gsl_vector_get(values, left)); right = left + 1; for (; right < nvalues; right++) { if (gsl_vector_get(values, right) - gsl_vector_get(values, right - 1) > empty_space_needed) { dump_d("gap till next", gsl_vector_get(values, right) - gsl_vector_get(values, right - 1)); break; } } right--; dump_ui("found right side", right); dump_d("right side", gsl_vector_get(values, right)); analyse_part(values, left, right, nvalues, &median, &leftquartile, &rightquartile, &percentage); gsl_vector_set(medians, npeaks, median); gsl_vector_set(leftquartiles, npeaks, leftquartile); gsl_vector_set(rightquartiles, npeaks, rightquartile); gsl_vector_set(percentages, npeaks, percentage); npeaks++; assert(npeaks < 100); if (right == nvalues - 1) break; left = right + 1; } #ifndef NOSORT sort(vectors, 4, npeaks); #endif printf("median\t-\t+\tpercent\n"); fflush(NULL); for (i = 0; i < npeaks; i++) { printf("%f\t%f\t%f\t%f\n", gsl_vector_get(medians, i), gsl_vector_get( medians, i) - gsl_vector_get(leftquartiles, i), gsl_vector_get( rightquartiles, i) - gsl_vector_get(medians, i), gsl_vector_get(percentages, i)); } gsl_vector_free(values); gsl_vector_free(medians); gsl_vector_free(leftquartiles); gsl_vector_free(rightquartiles); gsl_vector_free(percentages); }