#include "average.h" #include "getArray.h" #include "fileGestion.h" #include "initialParameters.h" #include "queue.h" /** * @brief realize the average calcul * * @param p array with all the values that will be used for the calcul * @param averageArray array where results are stocked * @param N number of rows in p * @param M number of columns in p */ void averageCalculation(long **p, double averageArray[] , int N, int M){ for(int i = 0; i < M-1; i++){ int j = 0; averageArray[i] = 0; while(j < N){ averageArray[i] += p[i][j]; j++; } averageArray[i] /= N; //printf("%f\n", powerArray[i]); } } /** * @brief function that realize all the action to write one lign in the file averageData.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 */ void average(char* rawDataFileName,int N , int M){ long **p = getRawDataArray(rawDataFileName,N, M); double aver[8]; if(p !=NULL){ averageCalculation(p,aver,N,M); writeDataInFile("averageData.csv",aver,8); freeArray(p,N); } }