regcntsSubs.c
/* sum region counts and area if we are in 'sum' mode */
sum region counts and area if we are in 'sum' mode
sum region counts and area if we are in ' sum ' mode
void regcntsSumCounts(Opts opts, Data src, Data bkg){
  int i;
  switch(opts->dosum){
  case 1:
    memcpy(src->savecnts, src->cnts, src->nreg*sizeof(double));
    memcpy(src->savearea, src->area, src->nreg*sizeof(int));
    for(i=1; i<src->nreg; i++){
      src->cnts[i] += src->cnts[i-1];
      src->area[i] += src->area[i-1];
    }
    if( opts->bktype != BKG_VAL ){
      memcpy(bkg->savecnts, bkg->cnts, bkg->nreg*sizeof(double));
      memcpy(bkg->savearea, bkg->area, bkg->nreg*sizeof(int));
      for(i=1; i<bkg->nreg; i++){
	bkg->cnts[i] += bkg->cnts[i-1];
	bkg->area[i] += bkg->area[i-1];
      }
    }
    break;
  case 2:
    memcpy(src->cnts, src->savecnts, src->nreg*sizeof(double));
    memcpy(src->area, src->savearea, src->nreg*sizeof(int));
    if( opts->bktype != BKG_VAL ){
      memcpy(bkg->cnts, bkg->savecnts, bkg->nreg*sizeof(double));
      memcpy(bkg->area, bkg->savearea, bkg->nreg*sizeof(int));
    }
    break;
  default:
    break;
  }
}
void regcntsSumCounts ( Opts opts , Data src , Data bkg ) { int i ; switch ( opts -> dosum ) { case 1 : memcpy ( src -> savecnts , src -> cnts , src -> nreg * sizeof ( double ) ) ; memcpy ( src -> savearea , src -> area , src -> nreg * sizeof ( int ) ) ; for ( i = 1 ; i < src -> nreg ; i ++ ) { src -> cnts [ i ] += src -> cnts [ i - 1 ] ; src -> area [ i ] += src -> area [ i - 1 ] ; } if ( opts -> bktype != BKG_VAL ) { memcpy ( bkg -> savecnts , bkg -> cnts , bkg -> nreg * sizeof ( double ) ) ; memcpy ( bkg -> savearea , bkg -> area , bkg -> nreg * sizeof ( int ) ) ; for ( i = 1 ; i < bkg -> nreg ; i ++ ) { bkg -> cnts [ i ] += bkg -> cnts [ i - 1 ] ; bkg -> area [ i ] += bkg -> area [ i - 1 ] ; } } break ; case 2 : memcpy ( src -> cnts , src -> savecnts , src -> nreg * sizeof ( double ) ) ; memcpy ( src -> area , src -> savearea , src -> nreg * sizeof ( int ) ) ; if ( opts -> bktype != BKG_VAL ) { memcpy ( bkg -> cnts , bkg -> savecnts , bkg -> nreg * sizeof ( double ) ) ; memcpy ( bkg -> area , bkg -> savearea , bkg -> nreg * sizeof ( int ) ) ; } break ; default : break ; } }
sum region counts and area if we are in 'sum' mode
sum region counts and area if we are in ' sum ' mode
/* if we need to display sums, do the sum now, but save unsummed values,
     because we will have to display those as well */ // save unsummed counts // sum counts // restore unsummed counts