beginning change power
This commit is contained in:
parent
7af7366247
commit
e23d744cdc
|
@ -3,7 +3,7 @@
|
|||
#include "initialParameters.h"
|
||||
//#include <string.h>
|
||||
|
||||
long **get(int N, int M) /* Allocate the array */
|
||||
long **getlongArray(int N, int M) /* Allocate the array */
|
||||
{
|
||||
/* Check if allocation succeeded. (check for NULL pointer) */
|
||||
int i;
|
||||
|
@ -14,6 +14,17 @@ long **get(int N, int M) /* Allocate the array */
|
|||
return array;
|
||||
}
|
||||
|
||||
double **getDoubleArray(int N, int M) /* Allocate the array */
|
||||
{
|
||||
/* Check if allocation succeeded. (check for NULL pointer) */
|
||||
int i;
|
||||
double **array;
|
||||
array = (double **) malloc(N*sizeof(double *));
|
||||
for(i = 0 ; i < N ; i++)
|
||||
array[i] = (double *) malloc( M*sizeof(double));
|
||||
return array;
|
||||
}
|
||||
|
||||
void fillArrayWithRawData(char *rawDataFileName,long** p, int N, int M) {
|
||||
int i, j;
|
||||
char *buffer;
|
||||
|
@ -86,7 +97,7 @@ void freeArray(long **p, int N) {
|
|||
*/
|
||||
long **getRawDataArray(char* rawDataFileName){
|
||||
long **p;
|
||||
p = get(nRow, nCol);
|
||||
p = getlongArray(nRow, nCol);
|
||||
fillArrayWithRawData(rawDataFileName,p ,nRow, nCol);
|
||||
//if(checkArrayFullyFill(p,nRow)){
|
||||
//clearRawData(N);
|
||||
|
|
|
@ -9,3 +9,4 @@ long **getRawDataArray(char *rawDataFileName);
|
|||
void printArrayData(long** p, int N, int M);
|
||||
void freeArray(long **p, int N);
|
||||
bool checkArrayFullyFill(long **p, int N );
|
||||
double **getDoubleArray(int N, int M);
|
|
@ -9,16 +9,17 @@
|
|||
* @param gRateArray array that contaigns results of the growth ratecalculation
|
||||
*/
|
||||
void growthRateCalculation(double **dataArray , double *gRateArray){
|
||||
double gRate = 0;
|
||||
for(int i = 0 ; i < nCol-1 ; i++){
|
||||
gRate = (dataArray[1][i] - dataArray[2][i]) / period;
|
||||
gRateArray[i] = (dataArray[0][i] - dataArray[1][i]) / period;
|
||||
}
|
||||
}
|
||||
|
||||
void growthRateFunction(double *dataLign){
|
||||
double **dataArray;
|
||||
//initialization + fill
|
||||
/**
|
||||
* @brief calcul then print differentiate in csv
|
||||
*
|
||||
* @param dataLign
|
||||
*/
|
||||
void growthRateFunction(double **dataLign){
|
||||
double gRateArray[nCol-1];
|
||||
growthRateCalculation(dataArray , gRateArray);
|
||||
growthRateCalculation(dataLign , gRateArray);
|
||||
appendDataInFile("growthRate.csv",gRateArray , nCol-1);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void growthRateFunction(double *dataLign);
|
||||
void growthRateFunction(double **dataLign);
|
BIN
Code-C/main
Executable file
BIN
Code-C/main
Executable file
Binary file not shown.
|
@ -6,14 +6,15 @@
|
|||
#include "queue.h"
|
||||
#include "average.h"
|
||||
#include "growthRate.h"
|
||||
#include "getArray.h"
|
||||
|
||||
bool rawDataWriteFlag;
|
||||
int nRow = 500;
|
||||
int nRow = 4;
|
||||
int nCol = 1;
|
||||
double freqEch = 250;
|
||||
|
||||
Pqueue firstRawDataQueue;
|
||||
|
||||
//Captor 1 2 3 4 5 6 7 8
|
||||
bool selectionCaptors[] = {true,false,true,false,false,false,true,false};
|
||||
|
||||
int cptData = 0;
|
||||
|
@ -66,31 +67,29 @@ void *threadCalculGrowthRate(void * vargp){
|
|||
Pqueue rawDataQueue = firstRawDataQueue;
|
||||
char* fileName;
|
||||
//double pw[nCol-1];
|
||||
double *dataLign[2][nCol-1];
|
||||
double **dataLign = getDoubleArray(2,nCol);
|
||||
|
||||
int i = 0;
|
||||
while(rawDataWriteFlag){
|
||||
//add case first file traitement
|
||||
//(possibility 1: call twice powerfunction , following while strat after 2 file encountered)
|
||||
//(posibilty 2 : initialiaze with a 0-fill array, move ligns for first encounter then let the following whil e do the job)
|
||||
while(queueGetNextE(rawDataQueue) != NULL){
|
||||
rawDataQueue = queueGetNextE(rawDataQueue);
|
||||
fileName = queueGetTabChar(rawDataQueue);
|
||||
if(i < 2){
|
||||
if(i == 1){
|
||||
powerFunction(fileName, dataLign[1]);
|
||||
growthRateFunction(**dataLign);
|
||||
powerFunction(fileName, dataLign);
|
||||
growthRateFunction(dataLign);
|
||||
}else{
|
||||
powerFunction(fileName, dataLign[0]);
|
||||
powerFunction(fileName, dataLign);
|
||||
}
|
||||
i++;
|
||||
}else{
|
||||
for(int y = 0; y < (nCol-1); y++){
|
||||
dataLign[0][y] = dataLign[1][y];
|
||||
}
|
||||
powerFunction(fileName, dataLign[1]);
|
||||
growthRateFunction(**dataLign);
|
||||
powerFunction(fileName, dataLign);
|
||||
growthRateFunction(dataLign);
|
||||
}
|
||||
remove(fileName);
|
||||
//remove(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,21 @@
|
|||
* @param powerArray array where results are stocked
|
||||
*/
|
||||
void powerCalculation(long **p, double powerArray[]){
|
||||
printArrayData(p,nRow,nCol);
|
||||
printf("data in pw : \n");
|
||||
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;
|
||||
|
||||
while(j < nRow){
|
||||
|
||||
printf("%d , %d , %d , %d\n" , p[j][i], p[j+1][i] , i ,j);
|
||||
powerArray[i] + pow(p[j][i],2);
|
||||
j++;
|
||||
}
|
||||
powerArray[i] *= invTimeBandWidth;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +35,7 @@ void powerCalculation(long **p, double powerArray[]){
|
|||
* @param N number of rows 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);
|
||||
double pww[nCol-1];
|
||||
if(p !=NULL){
|
||||
|
@ -38,7 +43,7 @@ void powerFunction(char* rawDataFileName, double **pw){
|
|||
powerCalculation(p,pww);
|
||||
appendDataInFile("powerData.csv",pww,nCol-1);
|
||||
}else{
|
||||
powerCalculation(p,*pw);
|
||||
powerCalculation(p,pw[1]);
|
||||
appendDataInFile("powerData.csv",*pw,nCol-1);
|
||||
}
|
||||
freeArray(p,nRow);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void powerFunction(char* rawDataFileName, double **pw);
|
||||
void powerFunction(char* rawDataFileName, double *pw[]);
|
|
@ -119,7 +119,7 @@ bool writeOneRawData(FILE *rawDataFile){
|
|||
}
|
||||
int lastIndex = lastIndexCaptor();
|
||||
for (int i = 1; i < 9; i++){
|
||||
if(selectionCaptors[i]){
|
||||
if(selectionCaptors[i-1]){
|
||||
value.octet1 = buff[3*i+1];
|
||||
value.octet2 = buff[3*i+2];
|
||||
value.octet3 = buff[3*i+3];
|
||||
|
@ -128,7 +128,7 @@ bool writeOneRawData(FILE *rawDataFile){
|
|||
valbin[i] = buff[3*i+1]*256*256*256 + buff[3*i+2]*256*256 + buff[3*i+3]*256;
|
||||
memcpy(&values[i], &valbin[i], sizeof(uint32_t));
|
||||
|
||||
if(i==lastIndex){
|
||||
if(i-1==lastIndex){
|
||||
fprintf(rawDataFile, "%d\n", values[i]/256);
|
||||
}
|
||||
else{
|
||||
|
|
Loading…
Reference in a new issue