#include "power.h" #include "getArray.h" #include "fileGestion.h" #include "initialParameters.h" #include "queue.h" /** * @brief realize the power calcul * * @param p array with all the values that will be used for the calcul * @param powerArray array where results are stocked * @param N number of rows in p * @param M number of columns in p */ 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]); } } /** * @brief function that realize all the action to write one lign in the file powerData.csv * * @param rawDataFileName name of the raw data file to use to realize the calcul * @param N number of rows in the file * @param M number of columns in the file */ 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); writeDataInFile("powerData.csv",pw,8); freeArray(p,N); return true; } else{ return false; } }