33 lines
985 B
C
33 lines
985 B
C
#include "power.h"
|
|
#include "getArray.h"
|
|
#include "fileGestion.h"
|
|
#include "initialParameters.h"
|
|
#include "queue.h"
|
|
|
|
void powerCalculation(long **p, double powerArray[] , int N, int M , double period , double invTimeBandwidth){
|
|
for(int i = 0; i < M-1; i++){
|
|
int j = 0;
|
|
powerArray[i] = 0;
|
|
while(j < N-1){
|
|
double aire = ( pow(p[j][i+1],2) + pow(p[j+1][i+1],2) ) / 2 * period;
|
|
//printf("aire [%d,%d] : %f\n",j,i,aire);
|
|
powerArray[i] += aire;
|
|
j++;
|
|
}
|
|
powerArray[i] *= invTimeBandwidth;
|
|
//printf("%f\n", powerArray[i]);
|
|
}
|
|
}
|
|
bool power(char* rawDataFileName,int N , int M, double periode , double invTimeBandwidth){
|
|
long **p = getRawDataArray(rawDataFileName,N, M);
|
|
double pw[8];
|
|
if(p !=NULL){
|
|
powerCalculation(p,pw,N,M,periode,invTimeBandwidth);
|
|
writePowerData(pw,8);
|
|
freeArray(p,N);
|
|
return true;
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
} |