2022-06-14 10:24:59 +02:00
|
|
|
#include "average.h"
|
|
|
|
#include "getArray.h"
|
|
|
|
#include "fileGestion.h"
|
|
|
|
#include "initialParameters.h"
|
|
|
|
#include "queue.h"
|
2022-06-14 10:46:04 +02:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2022-06-14 18:01:52 +02:00
|
|
|
void averageCalculation(long **p, double averageArray[]){
|
2022-06-15 10:49:21 +02:00
|
|
|
for(int i = 1; i < nCol; i++){
|
2022-06-14 10:24:59 +02:00
|
|
|
int j = 0;
|
|
|
|
averageArray[i] = 0;
|
2022-06-15 10:49:21 +02:00
|
|
|
while(j < nRow -1){
|
2022-06-14 10:24:59 +02:00
|
|
|
averageArray[i] += p[i][j];
|
|
|
|
j++;
|
|
|
|
}
|
2022-06-14 18:01:52 +02:00
|
|
|
averageArray[i] /= nRow;
|
2022-06-14 10:24:59 +02:00
|
|
|
//printf("%f\n", powerArray[i]);
|
|
|
|
}
|
|
|
|
}
|
2022-06-14 10:46:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2022-06-15 11:57:15 +02:00
|
|
|
void averageThreadFunction(char* rawDataFileName){
|
2022-06-14 18:01:52 +02:00
|
|
|
long **p = getRawDataArray(rawDataFileName);
|
|
|
|
double aver[nCol -1];
|
2022-06-14 10:24:59 +02:00
|
|
|
if(p !=NULL){
|
2022-06-14 18:01:52 +02:00
|
|
|
averageCalculation(p,aver);
|
|
|
|
appendDataInFile("averageData.csv",aver,nCol-1);
|
|
|
|
freeArray(p,nRow);
|
2022-06-14 10:24:59 +02:00
|
|
|
}
|
|
|
|
}
|