diff --git a/Code-C/growthrate.c b/Code-C/growthrate.c new file mode 100644 index 0000000..2f8d4fc --- /dev/null +++ b/Code-C/growthrate.c @@ -0,0 +1,39 @@ +#include "average.h" +#include "getArray.h" +#include "fileGestion.h" +#include "initialParameters.h" +#include "queue.h" + +/** + * @brief realize the growthRate calcul + * + * @param p array with all the values that will be used for the calcul + * @param powerArray array where results are stocked + */ +void growthRateCalculation(long **p, double powerArray[]){ + for(int i = 1; i < nCol; i++){ + int j = 0; + powerArray[i] = 0; + while(j < nRow-1){ + double aire = ( pow(p[j][i],2) + pow(p[j+1][i],2) ) / 2 * period; + powerArray[i] += aire; + j++; + } + powerArray[i] *= invTimeBandWidth; + } +} + +/** + * @brief function that realize all the action to write one lign in the file growthRateData.csv + * + * @param rawDataFileName name of the raw data file to use to realize the calcul + */ +void growthRate(char* rawDataFileName){ + long **p = getRawDataArray(rawDataFileName), ; + double gRate[nCol -1]; + if(p !=NULL){ + growthRateCalculation(p,gRate); + appendDataInFile("averageData.csv",aver,nCol-1); + freeArray(p,nRow); + } +} \ No newline at end of file diff --git a/Code-C/growthrate.h b/Code-C/growthrate.h new file mode 100644 index 0000000..107db51 --- /dev/null +++ b/Code-C/growthrate.h @@ -0,0 +1,4 @@ +#include +#include + +void growthRate(char* rawDataFileName); \ No newline at end of file diff --git a/Code-C/main b/Code-C/main index 46f740e..d66df7a 100755 Binary files a/Code-C/main and b/Code-C/main differ diff --git a/Code-C/main.c b/Code-C/main.c index a66d853..1264c28 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -61,6 +61,19 @@ void *threadCalculBoth(void *vargp){ } } +void *threadGrowthRate(void *vargp){ + Pqueue rawDataQueue = firstRawDataQueue; + char* fileName; + while(rawDataWriteFlag){ + while(queueGetNextE(rawDataQueue) != NULL){ + rawDataQueue = queueGetNextE(rawDataQueue); + fileName = queueGetTabChar(rawDataQueue); + GrowthRate(fileName); + remove(fileName); + } + } +} + int main(int argc , char** argv){ diff --git a/Code-C/power.c b/Code-C/power.c index 66f4f75..6ac6709 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -30,7 +30,7 @@ void powerCalculation(long **p, double powerArray[]){ * @param N number of rows in the file * @param M number of columns in the file */ -void power(char* rawDataFileName){ +double * power(char* rawDataFileName){ long **p = getRawDataArray(rawDataFileName); double pw[nCol-1]; if(p !=NULL){ @@ -38,4 +38,5 @@ void power(char* rawDataFileName){ appendDataInFile("powerData.csv",pw,nCol-1); freeArray(p,nRow); } + return pw; } \ No newline at end of file