#include "./Include/average.h" #include "./Include/getArray.h" #include "./Include/fileGestion.h" #include "./Include/initialParameters.h" #include "./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 */ void averageCalculation(long **p, double averageArray[]) { // printArrayData(p, nRowRawData, nCol); // printf("\n"); for (int i = 1; i < nCol; i++) { int j = 0; averageArray[i] = 0; while (j < nRowRawData) { averageArray[i - 1] += (double)p[i][j]; j++; } averageArray[i] /= nRowRawData; } } /** * @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 */ void averageFunction(char *rawDataFileName, double **aver) { long **p = getRawDataArray(rawDataFileName); double averN[nCol - 1]; if (p != NULL) { if (p != NULL) { if (aver == NULL) { averageCalculation(p, averN); appendDataInFile("averageData.csv", averN, nCol - 1); } else { averageCalculation(p, aver[1]); appendDataInFile("averageData.csv", aver[1], nCol - 1); } freeArray(p, nRowRawData); } } }