double three_body_system::calc_sf_hyper_summand(int kappa, int nr, int lr, int nrho, int lrho, vector<double> transformed_state, double h) { gsl_function F; F.function = &(hyper_helper_function); double eta = length_hyperspherical; double rho_max = h / sqrt(eta); hyper_integrand_helper hih(&transformed_state, h, eta, kappa, lr, nr, lrho, nrho, hyper_rescale_param); F.params = &hih; double m = 0.99*pow(rho_max, hyper_rescale_param); F.function = &(hyper_helper_function_scaled); m = minimise(F, 0.0, pow(rho_max, hyper_rescale_param), m, 1E-12, 1E-4); double mm = pow(m, 1.0 / hyper_rescale_param); double lim = min(100 * mm, rho_max); //cout << "rho_max = " << rho_max << ", min = " << mm << ", lim = " << lim << endl; F.function = &(hyper_helper_function); double res = integrate(F, 0.0, lim, 0.0, 1E-6); //double res = -integrate_to_inf(F, 0.0, 1E-8, 1E-6); return 2.0 * res; }
bool PersistentTransientWindow::onParentWindowStateEvent(GdkEventWindowState* ev) { // Check, if the event is of interest if ((ev->changed_mask & (GDK_WINDOW_STATE_ICONIFIED|GDK_WINDOW_STATE_WITHDRAWN)) != 0) { // Now let's see what the new state of the main window is if ((ev->new_window_state & (GDK_WINDOW_STATE_ICONIFIED|GDK_WINDOW_STATE_WITHDRAWN)) != 0) { // The parent got minimised, minimise the child as well minimise(); } else { // Restore the child as the parent is now visible again restore(); } } return false; }
int main(int argc, char *argv[]) { // Usage: // ordered_covering in_file out_file [target_length] if (argc < 3) { fprintf(stderr, "Usage: ordered_covering in_file out_file [target_length]\n"); return EXIT_FAILURE; } unsigned int target_length = 0; if (argc >= 4) { target_length = atoi(argv[3]); } // Open the input and output files FILE *in_file = fopen(argv[1], "rb"); if (in_file == NULL) { fprintf(stderr, "Could not open input file %s\n", argv[1]); return EXIT_FAILURE; } FILE *out_file = fopen(argv[2], "wb+"); if (out_file == NULL) { fprintf(stderr, "Could not open output file %s\n", argv[2]); return EXIT_FAILURE; } // Stream through the input file header_t h; while (fread(&h, sizeof(header_t), 1, in_file)) { // Print information about the current table printf("(%3u, %3u)\t%4u\t", h.x, h.y, h.length); fflush(stdout); // Read in the routing table table_t table; table.size = h.length; table.entries = malloc(sizeof(entry_t) * h.length); for (unsigned int i = 0; i < table.size; i++) { fentry_t t; if (!fread(&t, sizeof(fentry_t), 1, in_file)) { fprintf(stderr, "ERROR: Incomplete routing table\n"); return EXIT_FAILURE; } // Copy relevant fields across table.entries[i].keymask.key = t.key; table.entries[i].keymask.mask = t.mask; table.entries[i].route = t.route; table.entries[i].source = t.source; } // Sort the table qsort(table.entries, table.size, sizeof(entry_t), entry_cmp); // Perform the minimisation minimise(&table, target_length); printf("%u\n", table.size); // Dump the table into the output file h.length = table.size; fwrite(&h, sizeof(header_t), 1, out_file); for (unsigned int i = 0; i < table.size; i++) { fentry_t t = { // Copy relevant fields across table.entries[i].keymask.key, table.entries[i].keymask.mask, table.entries[i].source, table.entries[i].route, }; fwrite(&t, sizeof(fentry_t), 1, out_file); } } // Close the input and output files fclose(in_file); fclose(out_file); return EXIT_SUCCESS; }
int vertex(struct track trk[4],double * x,double * y,double * z, double * chi2, double init[3]) { gsl_vector * v_vertex = gsl_vector_calloc(3); gsl_vector * va_tracks[TRACK_NBR]; unsigned int i; for(i = 0; i < TRACK_NBR; i++) { va_tracks[i] = gsl_vector_calloc(6); } /* * pos. [mm] * mom. [MeV/c] */ /* Initial conditions */ gsl_vector_set(v_vertex,0,43.0); gsl_vector_set(v_vertex,1,0.0); gsl_vector_set(v_vertex,2,137728.0); unsigned int j; for(i=0;i<TRACK_NBR;i++) { for(j=0;j<6;j++) { gsl_vector_set(va_tracks[i],j,trk[i].param[j]); } } /* Covariance matricies */ gsl_matrix * m_V_alpha_zero = gsl_matrix_calloc(6*TRACK_NBR+3,6*TRACK_NBR+3); //VTX gsl_matrix_set(m_V_alpha_zero, 0, 0, init[0]); gsl_matrix_set(m_V_alpha_zero, 1, 1, init[1]); gsl_matrix_set(m_V_alpha_zero, 2, 2, init[2]); unsigned int k; for(i=0;i < TRACK_NBR; i++) { for(j=0;j<6;j++) { for(k=0;k<6;k++) { gsl_matrix_set(m_V_alpha_zero, 3+i*6+j, 3+i*6+k, trk[i].cov[j][k]); //printf("%i,%i,%g\n",3+i*6+j,3+i*6+k,trk[i].cov[j][k]); } } } /* Prepare inputs */ gsl_vector * v_alpha_zero = gsl_vector_calloc(6*TRACK_NBR+3); /* Ntracks + 1 : vector + tracks */ gsl_vector * va_inputs[1+TRACK_NBR]; va_inputs[0] = v_vertex; /* ! Merge this loop ! */ for(i = 0; i < TRACK_NBR; i++) { va_inputs[i+1] = va_tracks[i]; va_inputs[i+1] = va_tracks[i]; } stack_vector_array(va_inputs,1+TRACK_NBR,v_alpha_zero); gsl_vector * v_d = gsl_vector_calloc(CONSTRAINTS*TRACK_NBR); gsl_matrix * m_D = gsl_matrix_calloc(CONSTRAINTS*TRACK_NBR,6*TRACK_NBR+3); /* LOOP START HERE */ prepare(TRACK_NBR,v_alpha_zero,v_d,m_D); /* Ok now minimise ! */ /* Allocate memory for the updated results */ gsl_vector * v_alpha = gsl_vector_calloc(6*TRACK_NBR+3); gsl_matrix * m_V_alpha = gsl_matrix_calloc(6*TRACK_NBR+3,6*TRACK_NBR+3); minimise(v_alpha_zero,v_alpha_zero,m_V_alpha_zero,v_d,m_D,v_alpha,m_V_alpha,chi2); /* Compute D (back proj. to GTK) */ double gtk_pos = 102400.0; double xp = -1*(gsl_vector_get(v_alpha,2) - gtk_pos)*(gsl_vector_get(v_alpha,6)/gsl_vector_get(v_alpha,8)) + gsl_vector_get(v_alpha,0); double yp = -1*(gsl_vector_get(v_alpha,2) - gtk_pos)*(gsl_vector_get(v_alpha,7)/gsl_vector_get(v_alpha,8)) + gsl_vector_get(v_alpha,1); //printf("%g %g %g %g\n",chi2,gsl_vector_get(v_alpha,0),gsl_vector_get(v_alpha,1),gsl_vector_get(v_alpha,2)); *x = gsl_vector_get(v_alpha,0); *y = gsl_vector_get(v_alpha,1); *z = gsl_vector_get(v_alpha,2); //printf("*** %g %g %g\n",*x,*y,*z); /* LOOP END HERE */ /* Clear the memory */ gsl_matrix_free(m_V_alpha_zero); gsl_vector_free(v_alpha_zero); gsl_matrix_free(m_V_alpha); gsl_vector_free(v_alpha); gsl_vector_free(v_d); gsl_matrix_free(m_D); gsl_vector_free(v_vertex); for(i=0;i<TRACK_NBR;i++) { gsl_vector_free(va_tracks[i]); } return 0; }