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
|
|
|
|
* @param N number of rows in p
|
|
|
|
* @param M number of columns in p
|
|
|
|
*/
|
2022-06-14 10:24:59 +02:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
* @param N number of rows in the file
|
|
|
|
* @param M number of columns in the file
|
|
|
|
*/
|
|
|
|
void average(char* rawDataFileName,int N , int M){
|
2022-06-14 10:24:59 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|