diff --git a/Code-C/Makefile b/Code-C/Makefile index 8b874a0..44a0a3d 100644 --- a/Code-C/Makefile +++ b/Code-C/Makefile @@ -1,5 +1,5 @@ CC = gcc all: - $(CC) -g fileGestion.c getArray.c average.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main + $(CC) -g fileGestion.c getArray.c average.c growthRate.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main ./main < ../02400031.TXT \ No newline at end of file diff --git a/Code-C/growthRate.c b/Code-C/growthRate.c index 951e2c2..c381864 100644 --- a/Code-C/growthRate.c +++ b/Code-C/growthRate.c @@ -1,6 +1,7 @@ #include "initialParameters.h" #include "fileGestion.h" #include "getArray.h" +#include "growthRate.h" /** * @brief calculate de growth rate between to point next to each other * diff --git a/Code-C/growthRate.h b/Code-C/growthRate.h index 3a1f118..1e0b201 100644 --- a/Code-C/growthRate.h +++ b/Code-C/growthRate.h @@ -1 +1,4 @@ -void growthRateFunction(); \ No newline at end of file +#include +#include + +void growthRateFunction(double *dataLign); \ No newline at end of file diff --git a/Code-C/growthrate.c b/Code-C/growthrate.c deleted file mode 100644 index 2f8d4fc..0000000 --- a/Code-C/growthrate.c +++ /dev/null @@ -1,39 +0,0 @@ -#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 deleted file mode 100644 index 107db51..0000000 --- a/Code-C/growthrate.h +++ /dev/null @@ -1,4 +0,0 @@ -#include -#include - -void growthRate(char* rawDataFileName); \ No newline at end of file diff --git a/Code-C/main b/Code-C/main index d66df7a..a762195 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 b8f4190..5d747ef 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -29,7 +29,7 @@ void *threadCalculPower(void *vargp){ while(queueGetNextE(rawDataQueue) != NULL){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); - powerFunction(fileName); + powerFunction(fileName, NULL); remove(fileName); } } @@ -55,7 +55,7 @@ void *threadCalculBoth(void *vargp){ while(queueGetNextE(rawDataQueue) != NULL){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); - powerFunction(fileName); + powerFunction(fileName, NULL); averageThreadFunction(fileName); remove(fileName); } @@ -65,6 +65,9 @@ void *threadCalculBoth(void *vargp){ void *threadCalculGrowthRate(void * vargp){ Pqueue rawDataQueue = firstRawDataQueue; char* fileName; + //double pw[nCol-1]; + double *dataLign[2][nCol-1]; + int i = 0; while(rawDataWriteFlag){ //add case first file traitement //(possibility 1: call twice powerfunction , following while strat after 2 file encountered) @@ -72,8 +75,21 @@ void *threadCalculGrowthRate(void * vargp){ while(queueGetNextE(rawDataQueue) != NULL){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); - //double *dataLign = powerFunction(fileName); - growthRateFunction(dataLign); + if(i < 2){ + if(i == 1){ + powerFunction(fileName, dataLign[1]); + growthRateFunction(**dataLign); + }else{ + powerFunction(fileName, dataLign[0]); + } + i++; + }else{ + for(int y = 0; y < (nCol-1); y++){ + dataLign[0][y] = dataLign[1][y]; + } + powerFunction(fileName, dataLign[1]); + growthRateFunction(**dataLign); + } remove(fileName); } } diff --git a/Code-C/power.c b/Code-C/power.c index 7e6b1b3..b6ba5d9 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -30,13 +30,16 @@ void powerCalculation(long **p, double powerArray[]){ * @param N number of rows in the file * @param M number of columns in the file */ -double *powerFunction(char* rawDataFileName){ +void powerFunction(char* rawDataFileName, double **pw){ long **p = getRawDataArray(rawDataFileName); - double pw[nCol-1]; + double pww[nCol-1]; if(p !=NULL){ - powerCalculation(p,pw); - appendDataInFile("powerData.csv",pw,nCol-1); + if(pw == NULL){ + powerCalculation(p,pww); + }else{ + powerCalculation(p,*pw); + } + appendDataInFile("powerData.csv",*pw,nCol-1); freeArray(p,nRow); } - return pw; } \ No newline at end of file diff --git a/Code-C/power.h b/Code-C/power.h index a2a134e..043857c 100644 --- a/Code-C/power.h +++ b/Code-C/power.h @@ -1,4 +1,4 @@ #include #include -double *powerFunction(char* rawDataFileName); \ No newline at end of file +void powerFunction(char* rawDataFileName, double **pw); \ No newline at end of file