int main(int narg,char **arg) { if(narg<2) crash("Use: %s filein [clust_size]",arg[0]); //load read(arg[1]); if(data.size==0) crash("empty file %s",arg[1]); else cout<<"data size: "<<data.size<<endl; if(narg<3) data.clust_size=1; else data.clust_size=atoi(arg[2]); if(data.clust_size<0) crash("suggested negative clust_size %u",data.clust_size); if(data.clust_size>=data.size) crash("suggested too large clust_size %u>buf_size %u", data.clust_size,data.size); //compute average and error double ave,err; data.ave_err(ave,err); //write errors double med_tint,err_tint; data.compute_tint(med_tint,err_tint,"/tmp/autocorr.xmg"); cout<<"med_tint: "<<med_tint<<" "<<err_tint<<endl; double tau=(2*med_tint-1)/2; cout.precision(8); cout<<"value: "<<ave<<" +- "<<err*sqrt(2*tau+1)<<endl; return 0; }
static int pte_manipulate(struct pte_manip *manip) { int r; if(ADDR_OFFSET(manip->data.start) != 0) crash(); if(ADDR_OFFSET(manip->data.end+1) != 0) crash(); if((manip->data.op & PTE_OP_MAP) && (ADDR_OFFSET(manip->data.paddr) != 0)) crash(); manip->state = MSTATE_SPLIT_START; manip->mapped = manip->data.first = manip->data.start; manip->data.split_end = manip->data.end; if(KerextAmInKernel()) { return do_manipulation(manip); } //FUTURE: Do we actually have to go into the kernel all of the time //FUTURE: for PTE manipulation? We need to for the system space since //FUTURE: the X86 has to walk the mem_dir_list, but maybe not for //FUTURE: user space. The address space is usually locked (aside //FUTURE: from vmm_resize()) when manipulating the pgtbl, so we //FUTURE: might not even need a mutex. //FUTURE: Have to worry about SMP, where one CPU might be in a locked //FUTURE: kernel while we remove perms to access the memory being //FUTURE: referenced. manip->data.op |= PTE_OP_PREEMPT; do { r = __Ring0(ker_manipulate, manip); } while(r == EINTR); return r; }
jvec load_corr_all(oper_t &so,oper_t &si) { jvec out(T,njacks); out=0; int nave=0; //check spin if(so.spin!=si.spin) crash("spin of source %d does not agree wih spin of the sink %d",so.spin,si.spin); for(int iso=0;iso<so.ind->n;iso++) for(int isi=0;isi<si.ind->n;isi++) { jvec corr=so.ind->sign[iso]*si.ind->sign[isi]* jvec_load(combine("%s2pts_corr",base_path).c_str(), T,njacks,icombo(so.ind->gam[iso],so.sme,so.ind->der1[iso],so.ind->der2[iso], si.ind->gam[isi],si.sme,si.ind->der1[isi],si.ind->der2[isi])); out+=corr; cout<<"corr "<<nave<<": "<<corr[1]<<endl; double n=ndev(corr); int iszero=(fabs(n)<3); if(iszero) { cout<<corr<<endl; crash("seems zero: %d, %lg",iszero,n); } nave++; } return out; }
int main(int argc, char *argv[]) { printf("\n\n eXtremail 1.5.x Denial of Service \n"); printf("by Luca Ercoli <luca.e [at] seeweb.com>\n\n\n\n"); if (argc != 2) { fprintf(stderr,"\nUsage -> %s hostname\n\n",argv[0]); exit(1); } crash(argv[1],0); numbytes=0; printf ("\n[+] Checking server status ...\n"); if(!fork()) crash(argv[1],1); sleep(5); if (numbytes == 0) printf ("\n[!] Smtpd/Pop3d/Imapd/Remt crashed!\n\n\n"); return 0; }
void avr_core_watch_write(avr_t *avr, uint16_t addr, uint8_t v) { if (addr > avr->ramend) { AVR_LOG(avr, LOG_ERROR, "CORE: *** Invalid write address PC=%04x SP=%04x O=%04x Address %04x=%02x out of ram\n", avr->pc, _avr_sp_get(avr), avr->flash[avr->pc + 1] | (avr->flash[avr->pc]<<8), addr, v); crash(avr); } if (addr < 32) { AVR_LOG(avr, LOG_ERROR, "CORE: *** Invalid write address PC=%04x SP=%04x O=%04x Address %04x=%02x low registers\n", avr->pc, _avr_sp_get(avr), avr->flash[avr->pc + 1] | (avr->flash[avr->pc]<<8), addr, v); crash(avr); } #if AVR_STACK_WATCH /* * this checks that the current "function" is not doctoring the stack frame that is located * higher on the stack than it should be. It's a sign of code that has overrun it's stack * frame and is munching on it's own return address. */ if (avr->trace_data->stack_frame_index > 1 && addr > avr->trace_data->stack_frame[avr->trace_data->stack_frame_index-2].sp) { printf( FONT_RED "%04x : munching stack SP %04x, A=%04x <= %02x\n" FONT_DEFAULT, avr->pc, _avr_sp_get(avr), addr, v); } #endif if (avr->gdb) { avr_gdb_handle_watchpoints(avr, addr, AVR_GDB_WATCH_WRITE); } avr->data[addr] = v; }
double DistanceVdVdtMatrix::compare(const VdVdtMatrix & o) const { const DistanceVdVdtMatrix & other = dynamic_cast<const DistanceVdVdtMatrix &>(o); double errorValue = 0; if (other.getVLength() != vLength) crash("DistanceVdVdtMatrix","V dimensions don't match"); if (other.getdVdtLength() != dVdtLength) crash("DistanceVdVdtMatrix","dVdt dimensions don't match"); double diff; double distance, v1, v2, dVdt1, dVdt2; double maxDistance = pow((double)vLength,2)+pow((double)dVdtLength,2); for (map< const int, double >::const_iterator i = matrix.begin(); i != matrix.end(); i++) { for (map< const int, double >::const_iterator j = (other.matrix).begin(); j != (other.matrix).end(); j++) { diff = i->second-j->second; v1 = vIndex(i->first); v2 = other.vIndex(j->first); dVdt1 = dVdtIndex(i->first); dVdt2 = other.dVdtIndex(j->first); distance = pow(v1-v2,2)+pow(dVdt1-dVdt2,2); errorValue += pow(diff,2)*pow(maxDistance-distance,2); } } return sqrt(errorValue); }
/* * handlersetup() * Sets up signal handlers for SEGV and ALRM * * Precondition: None * Postcondition: Signal handlers are set up */ void handlersetup( ){ /* * set up a signal handlers for SEGV and ALRM */ sigset_t newset; struct sigaction act, alact; act.sa_sigaction = &segvhandler; alact.sa_handler = &catchalarm; sigfillset(&newset); /* let's do full mask */ sigdelset(&newset, SIGINT); /* and delete INT in case we get in trouble... */ sigdelset(&newset, SIGUSR1); act.sa_flags = SA_SIGINFO; act.sa_restorer = NULL; alact.sa_mask = newset; act.sa_mask = newset; alact.sa_flags = 0; alact.sa_flags |= SA_INTERRUPT; if (sigaction(SIGSEGV, &act, NULL) != 0) crash("sigaction"); if( sigaction( SIGALRM, &alact, NULL) != 0 ) crash("sigaction 2"); }
/* * malloc() * * Precondition: size: size of buffer to allocate * Postcondition: pointer to allocated buffer is * returned */ extern C_LINKAGE void *malloc(size_t size) { if( !first ) /* initialize everything if this is the very first malloc() call */ init(); else alarm(0); lock(); /* Allocate the buffer using mmap() */ caddr_t allocation = (caddr_t) mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0,0); /* Update memory manager if we have room for the new information */ if( myhandler.totalNumAddrs < myhandler.total_size){ setMemSlots(size, allocation, myhandler.totalNumAddrs); myhandler.totalNumAddrs++; }else{ /* Else use first fit algorithm to check for holes in memory * If one is found, we save the information in this location */ int i; for(i = 0; i < myhandler.total_size; i++){ if(memSlots[i].del == 1 ){ setMemSlots(size, allocation, myhandler.totalNumAddrs); break; } } /* Extend memory if we are out of room and place the * new information on the end */ if( i >= myhandler.total_size){ memSlots = extend1(memSlots, myhandler.total_size * sizeof(memSlots[0]) + pagesize); setMemSlots(size, allocation, myhandler.totalNumAddrs); } } /* If there is room for this page's information on the encryption * handler, then mprotect it with PROT_NONE */ if( !NO_OP && myhandler.encrNumAddrs < myhandler.encr_size ){ if ( mprotect(allocation, size, PROT_NONE) < 0 ) crash("mprotect - malloc"); }else{ /* Else extend encryption handler memory and then do mprotect */ if( myhandler.encrNumAddrs < myhandler.encr_size ) encrHandler = extend2( encrHandler, myhandler.encr_size * sizeof(encrHandler[0]) + pagesize); if ( mprotect(allocation, size, PROT_NONE) < 0 ) crash("mprotect - malloc"); } unlock(); /* return buffer */ return allocation; }
jvec load_otto_ir_combo(const char *name,int imass,const char *sl,int ir_combo,int reim=0) { if(ir_combo>=8||ir_combo<0) crash("check ir_combo %d in range [0,8)",ir_combo); if(imass>=nmass||imass<0) crash("check imass %d in range [0,%d)",imass,nmass); return jvec_load(combine("%s/otto_wL_R_%s_%s",base_path,name,sl).c_str(),T,njack,icombo_otto(imass,ir_combo,reim)); }
int dirichlet_code( char aa) { char x; x=tolower (aa); if ( (x<'a') || (x>'z')) crash ( "CODE UNDEFINED"); else if ( x<='a') return x-'a'; else if ( x<='i') return x-('a'+1); else if ( x<= 'n') return x-('a'+2); else if ( x<='t') return x-('a'+3); else if ( x<='w') return x-('a'+4); else if ( x=='y') return x-('a'+5); else { crash ("ERROR in dirichlet_code"); return 0; } return 0; }
void SENSORCOMMUNICATION_Initialize ( void ) { // the map. int h = 0; for (h; h < 75; h++) theMap[h][25] = 1; roverOrientation = 0; roverLocation[0] = 0; roverLocation[1] = 25; /* Place the App state machine in its initial state. */ //initDebugU(); sensor_debugTimerInit(); sensorcommunicationData.state = SENSORCOMMUNICATION_STATE_INIT; sensorcommunicationData.sensorrxByteCount = 0; sensorcommunicationData.sensorTxMsgSeq = 0x00; sensorcommunicationData.sensorRxMsgSeq = 0x00; sensorcommunicationData.sensortheQueue = xQueueCreate(COMMUNICATIONQUEUESIZE, sizeof(COMMUNICATION_MESSAGE)); //sizeof(communicationData.rxMessage)); if(sensorcommunicationData.sensortheQueue == 0) { crash("\nE: Comm msgQ"); } sensorcommunicationData.sensorIntQueue = xQueueCreate(COMMUNICATIONQUEUESIZE, sizeof(COMMUNICATION_MESSAGE)); //sizeof(communicationData.rxMessage)); if(sensorcommunicationData.sensorIntQueue == 0) { crash("\nE: Int msgQ"); } DRV_USART2_Initialize(); }
void mom_space_twisted_propagator_g2_d2_corr_of_imom(spin1prop prop,quark_info qu,gluon_info gl,int imom) { if(qu.kappa!=1.0/8 || qu.mass!=0) crash("implemented only for massless quark"); if(gl.c1!=0 && gl.c1!=-1.0/12) crash("implemented only for Wilson or Symanzik (c1=-1/12) gluons"); double lambda=gl.alpha; //implement equation 26 of 0907.0381 //Table VII double et2_W[3]={7.4696262,8.2395316,-3.21623339}; double et2_I[3]={5.95209802,7.16084231,-3.0693492}; double *et2; if(gl.c1==0) et2=et2_W; else et2=et2_I; momentum_t p,p3; double p2=0; for(int mu=0;mu<4;mu++) { p[mu]=M_PI*(2*glb_coord_of_loclx[imom][mu]+qu.bc[mu])/glb_size[mu]; p3[mu]=p[mu]*p[mu]*p[mu]; p2+=p[mu]*p[mu]; } double c_id=et2[0]-5.39301570*lambda-0.5*(3-2*lambda)*log(p2); memset(prop,0,sizeof(spin1prop)); spinspin_dirac_summ_the_prod_double(prop,&(base_gamma[0]),c_id); }
static void functionality_check(void) /* To the extent possible, check that standard functions and data types match * LVB's expectations. Crash verbosely if they are found not to. */ { /* time() is expected to work without error for logging the start * and end time, and for generating the default random number seed */ if (time(NULL) == -1) crash("cannot get system time"); /* if the system is not 32-bit, 64-bit, or more, some limits will be * less than documented and there may be memory allocation constraints * that LVB does not allow for */ if ((((long) INT_MAX) < 2147483647L) || ((sizeof(void *) * CHAR_BIT) < 32) || ((sizeof(size_t) * CHAR_BIT) < 32)) { crash("program requires at least a 32-bit system"); } /* LVB_EPS is assumed to be bigger than DBL_EPSILON in code that guards * against floating-point arithmetic problems */ if (DBL_EPSILON >= LVB_EPS) crash("program requires greater floating point precision"); /* DBL_MANT_DIG is checked in rinit() so check not necessary here */ } /* end functionality_check() */
void free(void *ptr) { extern int end; struct pageinfo *pi; int sz; if ((char *)ptr <= (char *)&end) { if (ptr == NULL) crash("free(): attempt to free NULL pointer"); crash("free(): attempt to free a pointer to code or static data"); } pi = GETPAGEINFO(ptr); sz = pi->blocksize; #ifdef DO_GC if (g.ignorefree) { if (g.clearfree) memset(ptr, 0, sz); return; } #endif if (sz < 1) { if (sz != -1) crash("free(): invalid pointer - not a large multipage block"); freepages(pi, pi->count); return; } FPRINTF((stderr, "free(%p) pi=%p blocksize=%d numblocks=%d\n", ptr, pi, pi->blocksize, pi->numblocks)); if (g.clearfree) memset(ptr, 0, sz); pi->count--; /* freed up all blocks in this page, so put it back in the freepage pool */ if (pi->count == 0) freeblockspage(pi); else { struct freeblock *e = (struct freeblock *)ptr; e->link = pi->block; pi->block = e; } return; }
//global barrier for spi void spi_global_barrier() { #ifdef SPI_BARRIER if(MUSPI_GIBarrierEnter(&spi_barrier)) crash("while entering spi barrier"); if(MUSPI_GIBarrierPollWithTimeout(&spi_barrier,60UL*1600000000)) crash("while waiting for barrier to finish"); #else MPI_Barrier(MPI_COMM_WORLD); #endif }
inline void MapVdVdtMatrix::set(const int v, const int dVdt, double value) { if (v < 0 || v >= vLength) { crash("MapVdVdtMatrix","Invalid v: "+str(v)); } if (dVdt < 0 || dVdt >= dVdtLength) { crash("MapVdVdtMatrix","Invalid dVdt: "+str(dVdt)); } matrix[mIndex(v,dVdt)] = value; }
int oh_what(int x) { /* We call crash() twice here, so that the compiler won't try to do a * tail-call optimization. Only the first call will actually happen, but * telling the compiler to maybe do the second call will prevent it from * replacing the first call with a jump. */ return crash(x) + crash(x*2); }
/* * cfree() * Frees a pointer * * Precondition: freeptr: pointer to be freed * Postcondtion: freeptr is freed by calling * munmap() */ extern C_LINKAGE void free( void *freeptr ){ ualarm(0,0); alarm(0); /* Don't think this is needed... */ sigset_t newmask, oldmask; sigemptyset( &newmask ); sigaddset( &newmask, SIGALRM ); if ( sigprocmask( SIG_BLOCK, &newmask, &oldmask ) < 0 ) crash( "SIG_BLOCK error" ); lock(); if( freeptr ){ if( myhandler.totalNumAddrs == 0 ) crash("free before first malloc!"); int i, j; ptr = freeptr; ptr2 = freeptr; /* search for pointer in memory handler */ for( i = 0; i < myhandler.total_size; i++ ){ if( memSlots[i].addrs == freeptr ){ /* if found set delete to true and * erase page info from encryption handler */ memSlots[i].del = 1; zero(ptr); /* If the buffer is more than one page, * we have to erase each page from the * encryption handler */ for( j = 0; j < memSlots[i].size; j += pagesize ){ if( (ptr + pagesize) <= (ptr2 + memSlots[i].size) ){ ptr += pagesize; zero(ptr); } } /* Erase the page */ munmap(freeptr, memSlots[i].size); break; } } if( i == myhandler.total_size ) crash("address not from malloc!"); } unlock(); if( sigprocmask( SIG_SETMASK, &oldmask, NULL ) < 0 ) crash( "SIG_SETMASK error" ); ualarm(TIMERVAL, 0); return; }
int (xferiov)(THREAD *sthp, IOV *dst, IOV *src, int dparts, int sparts, int doff, int soff) { char *daddr, *saddr; unsigned dlen, slen, ret; #ifndef NDEBUG if(doff > GETIOVLEN(dst)) crash(); #endif daddr = (char *)GETIOVBASE(dst) + doff; dlen = GETIOVLEN(dst) - doff; #ifndef NDEBUG if(soff > GETIOVLEN(src)) crash(); #endif saddr = (char *)GETIOVBASE(src) + soff; slen = GETIOVLEN(src) - soff; /* Now we move the data. */ for(;;) { if(slen < dlen) { ret = xfer_cpy(daddr, saddr, slen); sthp->args.ms.msglen += slen; if((--sparts == 0) || ret) { break; } daddr += slen; dlen -= slen; ++src; saddr = (char *)GETIOVBASE(src); slen = GETIOVLEN(src); } else if(dlen < slen) { ret = xfer_cpy(daddr, saddr, dlen); sthp->args.ms.msglen += dlen; if((--dparts == 0) || ret) { break; } saddr += dlen; slen -= dlen; ++dst; daddr = (char *)GETIOVBASE(dst); dlen = GETIOVLEN(dst); } else { ret = xfer_cpy(daddr, saddr, slen); sthp->args.ms.msglen += slen; if((--dparts == 0) || (--sparts == 0) || ret) { break; } ++src; saddr = (char *)GETIOVBASE(src); slen = GETIOVLEN(src); ++dst; daddr = (char *)GETIOVBASE(dst); dlen = GETIOVLEN(dst); } } return(ret); }
static void check_block(Header m, const char *file, int line) { if (*m->end != CRT_MAGIC) crash("Bottom overwritten", m, file, line); if (m->next->prev != m) crash("next->prev != m", m, file, line); if (m->prev->next != m) crash("prev->next != m", m, file, line); }
/* * realloc() * * Precondition: size: size of buffer to allocate * newSize: new size of allocated buffer * Postcondition: pointer to reallocated buffer is * returned */ extern C_LINKAGE void *realloc(void *oldBuff, size_t newSize){ ualarm(0,0); alarm(0); /* I don't think this part is needed... */ sigset_t newmask, oldmask; sigemptyset( &newmask ); sigaddset( &newmask, SIGALRM ); if ( sigprocmask( SIG_BLOCK, &newmask, &oldmask ) < 0 ) crash( "SIG_BLOCK error" ); void *newBuff = malloc( newSize ); if (mprotect(newBuff, newSize, PROT_READ | PROT_WRITE) != 0) crash("mprotect REALLOC"); lock(); int i, size; if( oldBuff ){ /* Look for buffer address in memory handler * and get size */ for( i = 0; i < myhandler.total_size; i++ ){ if( oldBuff == memSlots[i].addrs ){ size = memSlots[i].size; break; } } if( i >= myhandler.total_size ) crash("address not from malloc!"); if( newSize < size ) size = newSize; if( size > 0 ) memcpy( newBuff, oldBuff, size ); free( oldBuff ); if( size < newSize ) memset(&(((char *)newBuff)[size]), 0, newSize - size); } unlock(); if( sigprocmask( SIG_SETMASK, &oldmask, NULL ) < 0 ) crash( "SIG_SETMASK error" ); return newBuff; }
void corr_command_t::read_prop_group_pair(int nprop_group,prop_group_t *prop_group,int ipair) { //the first is reverted int first,second; read_int(&first); read_int(&second); if(first<0||first>=nprop_group) crash("first group %d must be in the interval [0,%d)",first,nprop_group); if(second<0||second>=nprop_group) crash("second group %d must be in the interval [0,%d)",second,nprop_group); pair_list[ipair]=prop_group_pair_t(prop_group[first],prop_group[second]); }
void prop_group_t::check_itheta_mass_r(int itheta,int imass,int r) { int ntheta,nmass,nr; get_ntheta_mass_r(ntheta,nmass,nr); //check theta if(itheta<0||itheta>=ntheta) crash("asked for itheta=%d, prop group contains %d",itheta,ntheta); //check mass if(imass<0||imass>=nmass) crash("asked for imass=%d, prop group contains %d",imass,nmass); //check r if(r<0||r>=nr) crash("asked for r=%d, prop group contains %d",r,nr); }
//define the cartesian grid void create_MPI_cartesian_grid() { #ifdef USE_MPI coords periods; for(int mu=0;mu<NDIM;mu++) periods[mu]=1; MPI_Cart_create(MPI_COMM_WORLD,NDIM,nrank_dir,periods,1,&cart_comm); //takes rank and ccord of local rank MPI_Comm_rank(cart_comm,&cart_rank); MPI_Cart_coords(cart_comm,cart_rank,NDIM,rank_coord); //create communicator along plan for(int mu=0;mu<NDIM;mu++) { coords split_plan; coords proj_rank_coord; for(int nu=0;nu<NDIM;nu++) { split_plan[nu]=(nu==mu) ? 0 : 1; proj_rank_coord[nu]=(nu==mu) ? 0 : rank_coord[nu]; } MPI_Cart_sub(cart_comm,split_plan,&(plan_comm[mu])); MPI_Comm_rank(plan_comm[mu],&(plan_rank[mu])); if(plan_rank[mu]!=rank_of_coord(proj_rank_coord)) crash("Plan communicator has messed up coord: %d and rank %d (implement reorder!)", rank_of_coord(proj_rank_coord),plan_rank[mu]); } //create communicator along line for(int mu=0;mu<NDIM;mu++) { //split the communicator coords split_line; memset(split_line,0,sizeof(coords)); split_line[mu]=1; MPI_Cart_sub(cart_comm,split_line,&(line_comm[mu])); //get rank id MPI_Comm_rank(line_comm[mu],&(line_rank[mu])); //get rank coord along line comm MPI_Cart_coords(line_comm[mu],line_rank[mu],1,&(line_coord_rank[mu])); //check communicator if(line_rank[mu]!=rank_coord[mu] || line_rank[mu]!=line_coord_rank[mu]) crash("Line communicator has messed up coord and rank (implement reorder!)"); } #else cart_rank=plan_rank=line_rank=0; for(int mu=0;mu<NDIM;mu++) rank_coord[mu]=planline_coord[mu]=0; #endif }
Sample::Sample(char *filename) // Constructor for loading from a WAV File { unsigned char *buffer; long fileSize; ifstream file; // Read raw data from file to memory file.open(filename, ios::in); if(file.tellg() == -1) crash("File does not exist."); file.seekg(0, ios::end); fileSize = file.tellg(); buffer = new unsigned char[file.tellg()]; file.seekg(0, ios::beg); file.read((char *)buffer, fileSize); file.close(); // Check signature if(fileSize < 0x56) crash("Not a WAV file (file too small)"); for(int i = 0; i <= 3; i++) { if(buffer[i] != riff_signature[i]) crash("Not a WAV file (missing RIFF signature)"); } for(int i = 0x08; i <= 0x0B; i++) { if(buffer[i] != wav_signature[i - 0x08]) crash("Not a WAV file (missing WAVE signature)"); } // Get sample size, sample rate and channel count sampleSize = buffer[0x20]; // It's 1 word long, but there won't be more than 255 sampleRate = buffer[0x18] + (buffer[0x19] * 256); // Big endian channels = buffer[0x16]; // Again - it's 1 word long, but only 1 or 2 // Find data signature and offset bool flag = false; int pos = 0; for(; !flag; pos++) { if(pos >= fileSize) crash("Wrong WAV file format (missing data signature"); flag = true; for(int i = 0; i < 4; i++) { if(buffer[pos + i] != data_signature[i]) flag = false; } } pos += 6; // delete[] buffer; }
jvec load_2pts_LR(const char *name,int ispec,int imass,const char *sl,int LR,int rdiff,int reim=0) { if(ispec>=nspec||ispec<0) crash("check ispec %d in range [0,%d)",ispec,nspec); if(imass>=nmass||imass<0) crash("check imass %d in range [0,%d)",imass,nmass); int r1=0,r2=r1+rdiff; char LR_tag[2][3]={"L","R"}; return ( jvec_load(combine("%s/two_points_w%s_%s_%s",base_path,LR_tag[LR],name,sl).c_str(),T,njack,icombo_2pts(r1,ispec,r2,imass,reim)) +jvec_load(combine("%s/two_points_w%s_%s_%s",base_path,LR_tag[LR],name,sl).c_str(),T,njack,icombo_2pts(!r1,ispec,!r2,imass,reim)) )/2; }
void bootimage_init(void) { int code; if(imagefs_mount_mounter() == -1) { crash(); } code = pulse_attach(dpp, MSG_FLAG_ALLOC_PULSE, 0, bootimage_start, NULL); if(code == -1) { crash(); } MsgSendPulse(PROCMGR_COID, PROC_INIT_PRIORITY, code, 0); }
inline double MapVdVdtMatrix::get(const int v, const int dVdt) const { if (v < 0 || v >= vLength) { crash("MapVdVdtMatrix","Invalid v: "+str(v)); } if (dVdt < 0 || dVdt >= dVdtLength) { crash("MapVdVdtMatrix","Invalid dVdt: "+str(dVdt)); } map< const int, double >::const_iterator i = matrix.find(mIndex(v,dVdt)); if (i == matrix.end()) { return 0; } else { return i->second; } }
void vx_capability_check(void) { /* * Check compatibility with startup MMU configuration */ if ((SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_V6) == 0) { kprintf("startup did not set ARM_CPU_FLAG_V6\n"); crash(); } if ((SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_V6_ASID) == 0) { kprintf("startup did not set ARM_CPU_FLAG_V6_ASID\n"); crash(); } }
int main(int narg,char **arg) { int ib; double Lfra,me,er; ifstream in("data"); if(!in.good()) crash("unable to open \"data\""); while(in>>ib>>Lfra>>me>>er) data.push_back(make_tuple(ib,Lfra*a[ib],me,er)); vector<double> extr=fit(); ofstream out("extr.xmg"); out<<"@type xydy"<<endl; for(int ib=0;ib<nbeta;ib++) { for(auto &it : data) if(get<0>(it)==ib) out<<get<1>(it)<<" "<<get<2>(it)<<" "<<get<3>(it)<<endl; out<<"&"<<endl; } out<<"@type xy"<<endl; for(int ib=0;ib<nbeta;ib++) { for(double x=5;x<50;x+=1) out<<x<<" "<<extr[2*ib]+extr[2*ib+1]*exp(-extr[2*nbeta]*x)<<endl; out<<"&"<<endl; } return 0; }