/** Returns the next value of the generator. */ result_type operator()() { // While it may seem wasteful to recalculate this // every time, both msvc and gcc can propagate // constants, resolving this at compile time. base_unsigned range = detail::subtract<base_result>()((_base.max)(), (_base.min)()); std::size_t m = (range == (std::numeric_limits<base_unsigned>::max)()) ? std::numeric_limits<base_unsigned>::digits : detail::integer_log2(range + 1); std::size_t n = (w + m - 1) / m; std::size_t w0, n0; base_unsigned y0, y1; base_unsigned y0_mask, y1_mask; calc_params(n, range, w0, n0, y0, y1, y0_mask, y1_mask); if(base_unsigned(range - y0 + 1) > y0 / n) { // increment n and try again. ++n; calc_params(n, range, w0, n0, y0, y1, y0_mask, y1_mask); } BOOST_ASSERT(n0*w0 + (n - n0)*(w0 + 1) == w); result_type S = 0; for(std::size_t k = 0; k < n0; ++k) { base_unsigned u; do { u = detail::subtract<base_result>()(_base(), (_base.min)()); } while(u > base_unsigned(y0 - 1)); S = (S << w0) + (u & y0_mask); } for(std::size_t k = 0; k < (n - n0); ++k) { base_unsigned u; do { u = detail::subtract<base_result>()(_base(), (_base.min)()); } while(u > base_unsigned(y1 - 1)); S = (S << (w0 + 1)) + (u & y1_mask); } return S; }
int m_isr__(int i, int*pString) { void * pscr=NULL; int mode =1; for(;;) { char strmen[]="\40" " ISR scale = XXX " " Beamstralung ON " " Bunch x+y sizes (nm)= YYY " " Bunch lenght (mm) = ZZZ " " Number of particles = NNN " " * N_cl = NCL " " * Upsilon = UPS "; if(scale<=1) improveStr(strmen,"XXX","%.2fS^.5",scale); else improveStr(strmen,"XXX","%.0fGeV",scale); calc_params(); if(bOn) { improveStr(strmen,"YYY","%.1f",xy_nm); improveStr(strmen,"ZZZ","%.3f",z_mm); improveStr(strmen,"NNN","%.1e",qTot); improveStr(strmen,"NCL","%.2f",b_ncl); improveStr(strmen,"UPS","%.2f",b_ips); } else { improveStr(strmen,"ON","%3.3s","OFF"); strmen[2*strmen[0]+1]=0; } menu1(46,10,"",strmen,"n_sf_isr",&pscr,&mode); switch(mode) { case 0: return 1; case 1: messanykey(45,16,"Value >1 is scale in GeV;\n" "Value <=1 is fraction of sqrt(S)"); correctDouble(45,16,"Enter value: ",&scale,1);break; case 2: bOn=!bOn; break; case 3: correctDouble(52,16,"Enter new value ",&xy_nm,1);break; case 4: correctDouble(52,16,"Enter new value ",&z_mm,1);break; case 5: correctDouble(52,16,"Enter new value ",&qTot,1);break; case 6: case 7: messanykey(10,10, "This parameter is a function of\n" "above ones and Sqrt(S)"); } } return 1; }
int i_isr__(int ii,double * be,double * mass) { int i; static int bOn_old=-1; static double beta_old=0, coeff_old=0, b_ncl_old=0, b_ips_old=0; *mass=5.11E-4; calc_params(); if(beta==beta_old && coeff==coeff_old && bOn==bOn_old) { if(!bOn) {*be= beta; return 1;} if(b_ncl== b_ncl_old && b_ips==b_ips_old) {*be=beta; return 1;} } for (i = 0; i < NPOINTS; ++i) xi[i] = (double)(i)/NPOINTS; for(i= NPOINTS;i<NPOINTS+4;i++) xi[i]= 1- (1-xi[i-1])*0.5; for (i = 0; i < NPOINTS+4; ++i) { double x=xi[i]; x=1-x*x*x; yi[i] = cfisr(x); if (bOn) { double lx=-log(x); yi[i] = (yi[i] * (1 - exp(-(b_ncl))) + pow(1-x, B2)* pow(divy_(lx), 1-beta-B2) * convol_(cfisrLog, cfbeamLog, beta, B2, lx, EPS)) / b_ncl; } } #ifdef CHECK_NORN printf("Check of Beamstralung normalization %E =? %E\n",b_ncl-1+exp(-b_ncl), simpson9(n_test,0.,1.,1.E-8)); #endif beta_old=beta; coeff_old=coeff; bOn_old=bOn; b_ncl_old=b_ncl; b_ips_old=b_ips; *be=beta; return 1; }
// ----------------------------------------------------------------------------- void QALSH::init( // init params of qalsh int n, // number of points int d, // dimension of space int B, // page size float ratio, int N, // approximation ratio char* output_folder) // folder of info of qalsh { n_pts_ = n; // init <n_pts_> dim_ = d; // init <dim_> B_ = B; // init <B_> appr_ratio_ = ratio; // init <appr_ratio_> N_ = N; // init <index_path_> strcpy(index_path_, output_folder); strcat(index_path_, "L2_indices/"); // init <w_> <delta_> <beta_> <p1_> calc_params(); // <p2_> <alpha_> <m_> and <l_> gen_hash_func(); // init <a_array_> display_params(); // display params trees_ = NULL; // init <trees_> }