EPNODE * getE3(void) /* E3 -> E4 ^ E3 */ /* E4 */ { EPNODE *ep1, *ep2; ep1 = getE4(); if (nextc != '^') return(ep1); ep2 = newnode(); ep2->type = nextc; scan(); addekid(ep2, ep1); addekid(ep2, getE3()); if (esupport&E_RCONST) { EPNODE *ep3 = ep1->sibling; if (ep1->type == NUM && ep3->type == NUM) { ep2 = rconst(ep2); } else if (ep1->type == NUM && ep1->v.num == 0) { epfree(ep3); /* (0 ^ E3) */ ep1->sibling = NULL; efree((char *)ep2); ep2 = ep1; } else if ((ep3->type == NUM && ep3->v.num == 0) || (ep1->type == NUM && ep1->v.num == 1)) { epfree(ep2); /* (E4 ^ 0) or (1 ^ E3) */ ep2 = newnode(); ep2->type = NUM; ep2->v.num = 1; } } return(ep2); }
EPNODE * getE1(void) /* E1 -> E1 ADDOP E2 */ /* E2 */ { EPNODE *ep1, *ep2; ep1 = getE2(); while (nextc == '+' || nextc == '-') { ep2 = newnode(); ep2->type = nextc; scan(); addekid(ep2, ep1); addekid(ep2, getE2()); if (esupport&E_RCONST && ep1->type == NUM && ep1->sibling->type == NUM) ep2 = rconst(ep2); ep1 = ep2; } return(ep1); }
EPNODE * getE2(void) /* E2 -> E2 MULOP E3 */ /* E3 */ { EPNODE *ep1, *ep2; ep1 = getE3(); while (nextc == '*' || nextc == '/') { ep2 = newnode(); ep2->type = nextc; scan(); addekid(ep2, ep1); addekid(ep2, getE3()); if (esupport&E_RCONST) { EPNODE *ep3 = ep1->sibling; if (ep1->type == NUM && ep3->type == NUM) { ep2 = rconst(ep2); } else if (ep3->type == NUM) { if (ep2->type == '/') { if (ep3->v.num == 0) syntax("divide by zero constant"); ep2->type = '*'; /* for speed */ ep3->v.num = 1./ep3->v.num; } else if (ep3->v.num == 0) { ep1->sibling = NULL; /* (E2 * 0) */ epfree(ep2); ep2 = ep3; } } else if (ep1->type == NUM && ep1->v.num == 0) { epfree(ep3); /* (0 * E3) or (0 / E3) */ ep1->sibling = NULL; efree((char *)ep2); ep2 = ep1; } } ep1 = ep2; } return(ep1); }
void run(int ch){ p.ch = ch; //darksusy channel double rcm = c.rh * kpc2cm ; double rmax = rconst(rcm); double mx_min; if(p.ch == 13) mx_min = 81; else mx_min = 5; double mx_max = 1000; double data; std::string channel; if(p.ch == 13){ channel = "WW"; } else if(p.ch == 15){ channel = "ee"; } else if(p.ch == 17){ channel = "mumu"; } else if(p.ch == 19){ channel = "tt"; } else if(p.ch == 25){ channel = "bb"; }; std::ostringstream makefilename; makefilename <<"NULL"<<c.name << "_" << channel << "_gamma_"<<c.gamma <<".txt" ; std::string filename = makefilename.str(); std::ofstream file(filename.c_str()); int n_mx = 50 ;//number of mx values used for (int i = 0 ; i < n_mx + 1 ; ++i){ // iteration timer start std::clock_t start; double duration; start = std::clock(); ///////before algorithm p.mx = mx_min * ( exp( (log(mx_max) - log(mx_min))/ n_mx * i)); if(c.SD==1) create_vLUT(); data = Calc_sv(rmax); file << p.mx << "\t" << data <<std::endl; std::cout << "sv( " << p.mx << " ) = " << data << std::endl; ////////after algorithm duration = (std::clock() - start)/(double) CLOCKS_PER_SEC; std::cout << i << "/"<< n_mx << " "; std::cout << p.ch << ", " << c.name << ", time = " << duration <<std::endl; }; //end runComa() }
EPNODE * getE5(void) /* E5 -> (E1) */ /* VAR */ /* NUM */ /* $N */ /* FUNC(E1,..) */ /* ARG */ { int i; char *nam; EPNODE *ep1, *ep2; if (nextc == '(') { scan(); ep1 = getE1(); if (nextc != ')') syntax("')' expected"); scan(); return(ep1); } if (esupport&E_INCHAN && nextc == '$') { scan(); ep1 = newnode(); ep1->type = CHAN; ep1->v.chan = getinum(); return(ep1); } if (esupport&(E_VARIABLE|E_FUNCTION) && (isalpha(nextc) || nextc == CNTXMARK)) { nam = getname(); ep1 = NULL; if ((esupport&(E_VARIABLE|E_FUNCTION)) == (E_VARIABLE|E_FUNCTION) && curfunc != NULL) for (i = 1, ep2 = curfunc->v.kid->sibling; ep2 != NULL; i++, ep2 = ep2->sibling) if (!strcmp(ep2->v.name, nam)) { ep1 = newnode(); ep1->type = ARG; ep1->v.chan = i; break; } if (ep1 == NULL) { ep1 = newnode(); ep1->type = VAR; ep1->v.ln = varinsert(nam); } if (esupport&E_FUNCTION && nextc == '(') { ep2 = newnode(); ep2->type = FUNC; addekid(ep2, ep1); ep1 = ep2; do { scan(); addekid(ep1, getE1()); } while (nextc == ','); if (nextc != ')') syntax("')' expected"); scan(); } else if (!(esupport&E_VARIABLE)) syntax("'(' expected"); if (esupport&E_RCONST && isconstvar(ep1)) ep1 = rconst(ep1); return(ep1); } if (isdecimal(nextc)) { ep1 = newnode(); ep1->type = NUM; ep1->v.num = getnum(); return(ep1); } syntax("unexpected character"); return NULL; /* pro forma return */ }
void runComa(int ch){ p.ch = ch; //darksusy channel c.name = "Coma"; c.z = 0.0232; //redshift c.rh = 0.415; //halo radius Mpc c.B0 = 4.7; //c.alpha = 1.0/3.0; // c.rcore = 0.291*mpc2cm; // double rcm = c.rh * mpc2cm ; double rmax = rconst(rcm); double mx_min = 300; double mx_max = 1000; double data; std::string channel; if(p.ch == 13){ channel = "WW"; } else if(p.ch == 15){ channel = "ee"; } else if(p.ch == 17){ channel = "mumu"; } else if(p.ch == 19){ channel = "tt"; } else if(p.ch == 25){ channel = "bb"; }; std::ostringstream makefilename; makefilename << "061316_"<<c.name << "_NONZERO_" << channel << "_alpha_" <<c.alpha <<"TEST.txt" ; std::string filename = makefilename.str(); std::ofstream file(filename.c_str()); int n_mx = 15 ;//number of mx values used /* p.mx = 500; createLUT(); std::cout << Calc_sv(rmax)<<std::endl;*/ //createLUT(); //double rt = 6.9984/1000*mpc2cm;f //std::cout << dndeeq(0.000511, rt)<<std::endl; for (int i = 0 ; i < n_mx + 1 ; ++i){ // iteration timer start std::clock_t start; double duration; start = std::clock(); int a ; ///////before algorithm p.mx = mx_min * ( exp( (log(mx_max) - log(mx_min))/ n_mx * i)); createLUT(); data = Calc_sv(rmax); file << p.mx << "\t" << data <<std::endl; std::cout << "sv( " << p.mx << " ) = " << data << std::endl; ////////after algorithm duration = (std::clock() - start)/(double) CLOCKS_PER_SEC; std::cout << i << "/"<< n_mx << " "; std::cout << p.ch << ", alpha = " << c.alpha << ", time = " << duration <<std::endl; }; //end runComa() }
void runComa(int ch){ c.name = "Coma"; c.ch = ch; //darksusy channel c.z = 0.0232; //redshift c.rh = 0.415; //halo radius Mpc c.B0 = 4.7; // c.rcore = 0.291*mpc2cm; // double rcm = c.rh * mpc2cm ; double rmax = rconst(rcm); std::string channel; if(c.ch == 13){ channel = "WW"; std::cout << channel << std::endl; } else if(c.ch == 15){ channel = "ee"; std::cout << channel << std::endl; } else if(c.ch == 17){ channel = "mumu"; std::cout << channel << std::endl; } else if(c.ch == 19){ channel = "tt"; std::cout << channel << std::endl; } else if(c.ch == 25){ channel = "bb"; std::cout << channel << std::endl; }; std::ostringstream makefilename; makefilename << c.name << "_" << channel << ".txt" ; std::string filename = makefilename.str(); int n_mx = 100 ;//number of mx values used std::ofstream file(filename.c_str()); for (int i = 0 ; i < n_mx +1 ; ++i){ // iteration timer start std::clock_t start; double duration; start = std::clock(); int a ; ///////before algorithm double mx_min = 5; double mx_max = 1000; double mx = mx_min * ( exp( (log(mx_max) - log(mx_min))/ n_mx * i)); file << mx << "\t" << Calc_sv(mx,rmax) <<std::endl; //std::cout << "sv( " << mx << " ) = " << Calc_sv(mx, rmax) << std::endl; ////////after algorithm duration = (std::clock() - start)/(double) CLOCKS_PER_SEC; std::cout << c.ch << " time = " << i << " " << duration <<std::endl; } //end runComa() }