PSI sics-cvs-psi-2006
This commit is contained in:
27
hmdata.c
27
hmdata.c
@@ -9,6 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include "fortify.h"
|
||||
#include "hmdata.h"
|
||||
#include "HistMem.h"
|
||||
@@ -36,6 +37,19 @@ void killHMData(pHMdata self){
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
void clearHMData(pHMdata self){
|
||||
long size;
|
||||
int i;
|
||||
size = 1;
|
||||
for(i = 0; i < self->rank; i++){
|
||||
size *= self->iDim[i];
|
||||
}
|
||||
if(self->tofMode){
|
||||
size *= self->nTimeChan;
|
||||
}
|
||||
memset(self->localBuffer,0,size*sizeof(HistInt));
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int resizeBuffer(pHMdata self){
|
||||
long size;
|
||||
@@ -136,9 +150,8 @@ int genTimeBinning(pHMdata self, float start, float step, int noSteps){
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
int setTimeBin(pHMdata self, int index, float value){
|
||||
if(index > 0 || index < MAXCHAN){
|
||||
if(index >= 0 && index < MAXCHAN){
|
||||
self->timeBinning[index] = value;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -316,7 +329,7 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
||||
pHMdata self = hist->pDriv->data;
|
||||
int i, iHistLength, status, iIndex;
|
||||
char pBueffel[256];
|
||||
long lSum;
|
||||
unsigned long lSum, lRowSum;
|
||||
|
||||
assert(self);
|
||||
|
||||
@@ -364,8 +377,9 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
||||
lSum = 0;
|
||||
for(i = iStart[0]; i < iEnd[0]; i++){
|
||||
iIndex = i*self->iDim[1];
|
||||
lSum += SumRow(self->localBuffer,iHistLength,
|
||||
lRowSum = SumRow(self->localBuffer,iHistLength,
|
||||
iIndex+iStart[1], iIndex+iEnd[1]);
|
||||
lSum += lRowSum;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -373,8 +387,11 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
||||
"ERROR: summing in %d dimensions not yet implemented",
|
||||
self->rank);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
lSum = -1;
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
if(lSum < 0){
|
||||
lSum = -lSum;
|
||||
}
|
||||
return lSum;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user