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-16 17:05:12 +02:00
|
|
|
while(j < nRowRawData){
|
2022-06-14 10:24:59 +02:00
|
|
|
averageArray[i] += p[i][j];
|
|
|
|
j++;
|
|
|
|
}
|
2022-06-17 17:38:53 +02:00
|
|
|
//printf("%f , %f\n", averageArray[i] , averageArray[i] / nRowRawData);
|
2022-06-16 17:05:12 +02:00
|
|
|
averageArray[i] /= nRowRawData;
|
2022-06-14 10:24:59 +02:00
|
|
|
}
|
|
|
|
}
|
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-16 17:05:12 +02:00
|
|
|
void averageFunction(char* rawDataFileName , double **aver){
|
2022-06-14 18:01:52 +02:00
|
|
|
long **p = getRawDataArray(rawDataFileName);
|
2022-06-16 17:05:12 +02:00
|
|
|
double averN[nCol -1];
|
2022-06-14 10:24:59 +02:00
|
|
|
if(p !=NULL){
|
2022-06-16 17:05:12 +02:00
|
|
|
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);
|
|
|
|
}
|
2022-06-14 10:24:59 +02:00
|
|
|
}
|
|
|
|
}
|