#include "power.h" #include "getArray.h" #include "fileGestion.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]); } } int power(int N , int M, double periode , double invTimeBandwidth){ long **p = getRawDataArray(N, M); //printArrayData(p,N,M); double pw[8]; if(p !=NULL){ powerCalculation(p,pw,N,M,periode,invTimeBandwidth); writePowerData(pw,8); freeArray(p,N); return 0; } else{ return 1; } }