growth ok
This commit is contained in:
parent
efc3110b2d
commit
8ecdd37619
|
@ -13,12 +13,11 @@ void averageCalculation(long **p, double averageArray[]){
|
||||||
for(int i = 1; i < nCol; i++){
|
for(int i = 1; i < nCol; i++){
|
||||||
int j = 0;
|
int j = 0;
|
||||||
averageArray[i] = 0;
|
averageArray[i] = 0;
|
||||||
while(j < nRow -1){
|
while(j < nRowRawData){
|
||||||
averageArray[i] += p[i][j];
|
averageArray[i] += p[i][j];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
averageArray[i] /= nRow;
|
averageArray[i] /= nRowRawData;
|
||||||
//printf("%f\n", powerArray[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +26,19 @@ void averageCalculation(long **p, double averageArray[]){
|
||||||
*
|
*
|
||||||
* @param rawDataFileName name of the raw data file to use to realize the calcul
|
* @param rawDataFileName name of the raw data file to use to realize the calcul
|
||||||
*/
|
*/
|
||||||
void averageThreadFunction(char* rawDataFileName){
|
void averageFunction(char* rawDataFileName , double **aver){
|
||||||
long **p = getRawDataArray(rawDataFileName);
|
long **p = getRawDataArray(rawDataFileName);
|
||||||
double aver[nCol -1];
|
double averN[nCol -1];
|
||||||
if(p !=NULL){
|
if(p !=NULL){
|
||||||
averageCalculation(p,aver);
|
if(p !=NULL){
|
||||||
appendDataInFile("averageData.csv",aver,nCol-1);
|
if(aver == NULL){
|
||||||
freeArray(p,nRow);
|
averageCalculation(p,averN);
|
||||||
|
appendDataInFile("averageData.csv",averN,nCol-1);
|
||||||
|
}else{
|
||||||
|
averageCalculation(p,aver[1]);
|
||||||
|
appendDataInFile("averageData.csv",aver[1],nCol-1);
|
||||||
|
}
|
||||||
|
freeArray(p,nRowRawData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
void averageThreadFunction(char* rawDataFileName);
|
void averageFunction(char* rawDataFileName , double **aver);
|
|
@ -97,8 +97,8 @@ void freeArray(long **p, int N) {
|
||||||
*/
|
*/
|
||||||
long **getRawDataArray(char* rawDataFileName){
|
long **getRawDataArray(char* rawDataFileName){
|
||||||
long **p;
|
long **p;
|
||||||
p = getlongArray(nRow, nCol);
|
p = getlongArray(nRowRawData, nCol);
|
||||||
fillArrayWithRawData(rawDataFileName,p ,nRow, nCol);
|
fillArrayWithRawData(rawDataFileName,p ,nRowRawData, nCol);
|
||||||
//if(checkArrayFullyFill(p,nRow)){
|
//if(checkArrayFullyFill(p,nRow)){
|
||||||
//clearRawData(N);
|
//clearRawData(N);
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -18,8 +18,19 @@ void growthRateCalculation(double **dataArray , double *gRateArray){
|
||||||
*
|
*
|
||||||
* @param dataLign
|
* @param dataLign
|
||||||
*/
|
*/
|
||||||
void growthRateFunction(double **dataLign){
|
void growthRateFunction(double **dataLign , char* fileName){
|
||||||
double gRateArray[nCol-1];
|
double gRateArray[nCol-1];
|
||||||
growthRateCalculation(dataLign , gRateArray);
|
growthRateCalculation(dataLign , gRateArray);
|
||||||
appendDataInFile("growthRate.csv",gRateArray , nCol-1);
|
appendDataInFile(fileName,gRateArray , nCol-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sumColArray(long **p, double res[] , int N , int M){
|
||||||
|
for(int i = 1; i < M; i++){
|
||||||
|
int j = 0;
|
||||||
|
res[i] = 0;
|
||||||
|
while(j < N){
|
||||||
|
res[i] += p[i][j];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
void growthRateFunction(double **dataLign);
|
void growthRateFunction(double **dataLign , char* fileName);
|
|
@ -2,7 +2,8 @@
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
|
||||||
extern bool rawDataWriteFlag;
|
extern bool rawDataWriteFlag;
|
||||||
extern int nRow;
|
extern int nRowRawData;
|
||||||
|
extern int nRowGR;
|
||||||
extern int nCol;
|
extern int nCol;
|
||||||
extern double freqEch;
|
extern double freqEch;
|
||||||
|
|
||||||
|
|
BIN
Code-C/main
BIN
Code-C/main
Binary file not shown.
|
@ -9,7 +9,8 @@
|
||||||
#include "getArray.h"
|
#include "getArray.h"
|
||||||
|
|
||||||
bool rawDataWriteFlag;
|
bool rawDataWriteFlag;
|
||||||
int nRow = 500;
|
int nRowRawData = 500;
|
||||||
|
int nRowGR = 150;
|
||||||
int nCol = 1;
|
int nCol = 1;
|
||||||
double freqEch = 250;
|
double freqEch = 250;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ void *threadCalculAverage(void *vargp){
|
||||||
while(queueGetNextE(rawDataQueue) != NULL){
|
while(queueGetNextE(rawDataQueue) != NULL){
|
||||||
rawDataQueue = queueGetNextE(rawDataQueue);
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
||||||
fileName = queueGetTabChar(rawDataQueue);
|
fileName = queueGetTabChar(rawDataQueue);
|
||||||
averageThreadFunction(fileName);
|
averageFunction(fileName, NULL);
|
||||||
remove(fileName);
|
remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ void *threadCalculBoth(void *vargp){
|
||||||
rawDataQueue = queueGetNextE(rawDataQueue);
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
||||||
fileName = queueGetTabChar(rawDataQueue);
|
fileName = queueGetTabChar(rawDataQueue);
|
||||||
powerFunction(fileName, NULL);
|
powerFunction(fileName, NULL);
|
||||||
averageThreadFunction(fileName);
|
averageFunction(fileName , NULL);
|
||||||
remove(fileName);
|
remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +68,8 @@ void *threadCalculGrowthRate(void * vargp){
|
||||||
Pqueue rawDataQueue = firstRawDataQueue;
|
Pqueue rawDataQueue = firstRawDataQueue;
|
||||||
char* fileName;
|
char* fileName;
|
||||||
//double pw[nCol-1];
|
//double pw[nCol-1];
|
||||||
double **dataLign = getDoubleArray(2,nCol);
|
double **dataLignPw = getDoubleArray(2,nCol);
|
||||||
|
double **dataLignAv = getDoubleArray(2,nCol);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(rawDataWriteFlag){
|
while(rawDataWriteFlag){
|
||||||
|
@ -76,18 +78,24 @@ void *threadCalculGrowthRate(void * vargp){
|
||||||
fileName = queueGetTabChar(rawDataQueue);
|
fileName = queueGetTabChar(rawDataQueue);
|
||||||
if(i < 2){
|
if(i < 2){
|
||||||
if(i == 1){
|
if(i == 1){
|
||||||
powerFunction(fileName, dataLign);
|
powerFunction(fileName, dataLignPw);
|
||||||
growthRateFunction(dataLign);
|
averageFunction(fileName , dataLignAv);
|
||||||
|
growthRateFunction(dataLignPw , "growthRatePw.csv");
|
||||||
|
growthRateFunction(dataLignPw,"growthRateAv.csv");
|
||||||
}else{
|
}else{
|
||||||
powerFunction(fileName, dataLign);
|
averageFunction(fileName , dataLignAv);
|
||||||
|
powerFunction(fileName, dataLignPw);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}else{
|
}else{
|
||||||
for(int y = 0; y < (nCol-1); y++){
|
for(int y = 0; y < (nCol-1); y++){
|
||||||
dataLign[0][y] = dataLign[1][y];
|
dataLignPw[0][y] = dataLignPw[1][y];
|
||||||
|
dataLignAv[0][y] = dataLignAv[1][y];
|
||||||
}
|
}
|
||||||
powerFunction(fileName, dataLign);
|
powerFunction(fileName, dataLignPw);
|
||||||
growthRateFunction(dataLign);
|
averageFunction(fileName , dataLignAv);
|
||||||
|
growthRateFunction(dataLignPw,"growthRatePw.csv");
|
||||||
|
growthRateFunction(dataLignPw,"growthRateAv.csv");
|
||||||
}
|
}
|
||||||
//remove(fileName);
|
//remove(fileName);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +113,7 @@ int main(int argc , char** argv){
|
||||||
rawDataWriteFlag = true;
|
rawDataWriteFlag = true;
|
||||||
|
|
||||||
period = 1 / freqEch;
|
period = 1 / freqEch;
|
||||||
invTimeBandWidth = 1 /(nRow * period);
|
invTimeBandWidth = 1 /(nRowRawData * period);
|
||||||
firstRawDataQueue = queueCreateEmpty(); // change this for create empty
|
firstRawDataQueue = queueCreateEmpty(); // change this for create empty
|
||||||
|
|
||||||
pthread_t rawData;
|
pthread_t rawData;
|
||||||
|
|
|
@ -11,17 +11,15 @@
|
||||||
* @param powerArray array where results are stocked
|
* @param powerArray array where results are stocked
|
||||||
*/
|
*/
|
||||||
void powerCalculation(long **p, double powerArray[]){
|
void powerCalculation(long **p, double powerArray[]){
|
||||||
printf("data in pw : \n");
|
|
||||||
for(int i = 0; i < nCol; i++){
|
for(int i = 0; i < nCol; i++){
|
||||||
int j = 0;
|
int j = 0;
|
||||||
powerArray[i] = 0;
|
powerArray[i] = 0;
|
||||||
|
|
||||||
while(j < nRow){
|
while(j < nRowRawData){
|
||||||
printf("\np[%d,%d] = %d\npwArray[%d] = %lf\n" , j,i,p[j][i+1],i,powerArray[i]);
|
|
||||||
powerArray[i] += pow(p[j][i+1],2);
|
powerArray[i] += pow(p[j][i+1],2);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
powerArray[i] /= nRow;
|
powerArray[i] /= nRowRawData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +31,7 @@ void powerCalculation(long **p, double powerArray[]){
|
||||||
* @param N number of rows in the file
|
* @param N number of rows in the file
|
||||||
* @param M number of columns in the file
|
* @param M number of columns in the file
|
||||||
*/
|
*/
|
||||||
void powerFunction(char* rawDataFileName, double *pw[]){
|
void powerFunction(char* rawDataFileName, double **pw){
|
||||||
long **p = getRawDataArray(rawDataFileName);
|
long **p = getRawDataArray(rawDataFileName);
|
||||||
double pww[nCol-1];
|
double pww[nCol-1];
|
||||||
if(p !=NULL){
|
if(p !=NULL){
|
||||||
|
@ -42,8 +40,8 @@ void powerFunction(char* rawDataFileName, double *pw[]){
|
||||||
appendDataInFile("powerData.csv",pww,nCol-1);
|
appendDataInFile("powerData.csv",pww,nCol-1);
|
||||||
}else{
|
}else{
|
||||||
powerCalculation(p,pw[1]);
|
powerCalculation(p,pw[1]);
|
||||||
appendDataInFile("powerData.csv",*pw,nCol-1);
|
appendDataInFile("powerData.csv",pw[1],nCol-1);
|
||||||
}
|
}
|
||||||
freeArray(p,nRow);
|
freeArray(p,nRowRawData);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -151,7 +151,7 @@ void *threadSimulateFlux(void *vargp){
|
||||||
FILE *rawDataFile = fopen(fileName,"w+");
|
FILE *rawDataFile = fopen(fileName,"w+");
|
||||||
|
|
||||||
while(writeOneRawData(rawDataFile)){
|
while(writeOneRawData(rawDataFile)){
|
||||||
if(cptData == nRow){
|
if(cptData == nRowRawData){
|
||||||
fclose(rawDataFile);
|
fclose(rawDataFile);
|
||||||
cptData = 0;
|
cptData = 0;
|
||||||
cptFile++;
|
cptFile++;
|
||||||
|
|
Loading…
Reference in a new issue