growthRate thread implémentation
This commit is contained in:
parent
3435430c02
commit
21cb319b25
|
@ -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
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
void growthRateFunction();
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void growthRateFunction(double *dataLign);
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void growthRate(char* rawDataFileName);
|
BIN
Code-C/main
BIN
Code-C/main
Binary file not shown.
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
double *powerFunction(char* rawDataFileName);
|
||||
void powerFunction(char* rawDataFileName, double **pw);
|
Loading…
Reference in a new issue