regroup all il main

This commit is contained in:
quentin.perret 2022-06-07 14:28:32 +02:00
parent 92ed6e44ab
commit 5c9bdcb3dc
11 changed files with 53 additions and 54 deletions

View file

@ -9,6 +9,10 @@
"initialparameters.h": "c",
"filegestion.h": "c",
"power.h": "c",
"getarray.h": "c"
"getarray.h": "c",
"math.h": "c",
"limits": "c",
"*.tcc": "c",
"type_traits": "c"
}
}

View file

@ -3,8 +3,8 @@ CC = gcc
all:
# rm powerData.csv
$(CC) b2hd.c -o b2hd
$(CC) fileGestion.c getArray.c power.c -lm -o power
$(CC) fileGestion.c getArray.c power.c main.c -lm -o main
# getArray.c fileGestion.c power.c main.c -o main
./b2hd < ../02400001.TXT > rawData.csv
./power
./main

View file

@ -1,24 +0,0 @@
void divideChar(char *res[9] , char *lign , char delimiter){
int i = 0;
int j = 0;
int cptWord = 0;
int lignSize = sizeof(lign);
char *token;
token = (char *) malloc(20 * sizeof(char));
char space = ' ';
while(i < lignSize){
if(lign[i]==delimiter){
token[j+1] = '\0';
res[cptWord] = token;
cptWord++;
}
else if(lign[i] == space) continue;
else{
token[j] = lign[i];
j++;
}
i++;
}
}

View file

@ -53,6 +53,13 @@ void printArrayData(long** p, int N, int M) {
}
}
int checkArrayFullyFill(long **p, int N , int M){
for(int i = 0 ; i < N ; i++){
if(p[i][0] == '\0'){ return 1; }
}
return 0;
}
void freeArray(long **p, int N) {
int i;
for(i = 0 ; i < N ; i++)
@ -64,5 +71,14 @@ long **getRawDataArray(int N , int M){
long **p;
p = get(N, M);
fillRawData(p ,N, M);
return p;
//printf("before test\n");
if(checkArrayFullyFill(p,N,M)==0){
//printf("after test 0\n");
clearRawData(N);
return p;
}
else{
//printf("after test 1\n");
return NULL;
}
}

View file

@ -5,5 +5,6 @@
#include <inttypes.h>
long **getRawDataArray();
void printArray(long** p, int N, int M);
void freeArray(long **p, int N);
void printArrayData(long** p, int N, int M);
void freeArray(long **p, int N);
int checkArrayFullyFill(long **p, int N , int M);

View file

@ -1,3 +1,6 @@
int nRow = 100000;
int nCol = 9;
double freqEch = 250;
const int nRow = 100000;
const int nCol = 9;
const double freqEch = 250;
const double period = 1.0/freqEch;
const double timeBandwidth = 1.0 /(nRow * period);

BIN
Code-C/main Executable file

Binary file not shown.

View file

@ -2,7 +2,8 @@
#include "getArray.h"
#include "fileGestion.h"
#include "power.h"
#include "initialParameters.h"
int main(int argc , char** argv){
while(power(nRow,nCol,period,timeBandwidth)==0){}
}

Binary file not shown.

View file

@ -1,34 +1,32 @@
#include "power.h"
#include "getArray.h"
#include "fileGestion.h"
#include "initialParameters.h"
void power(long **p, double a[]){
double periode = 1.0/freqEch;
double temps = 1/(nRow * periode);
/*printf("periode : %f\n",periode);
printf("temps : %f\n",temps);*/
//Fill array with the power of the signal for each captor
for(int i = 0; i < nCol-1; i++){
void powerCalculation(long **p, double a[] , int N, int M , double period , double timeBandwidth){
for(int i = 0; i < M-1; i++){
int j = 0;
a[i] = 0;
while(j < nRow-1){
double aire = ( pow(p[j][i+1],2) + pow(p[j+1][i+1],2) ) / 2 * periode;
while(j < N-1){
double aire = ( pow(p[j][i+1],2) + pow(p[j+1][i+1],2) ) / 2 * period;
//printf("aire [%d,%d] : %f\n",j,i,aire);
a[i] += aire;
j++;
}
a[i] *= temps;
a[i] *= timeBandwidth;
//printf("%f\n", a[i]);
}
}
int main(int argc , char** argv){
long **p = getRawDataArray(nRow, nCol);
//printArray(p,nRow,nCol);
int power(int N , int M, double periode , double timeBandwidth){
long **p = getRawDataArray(N, M);
//printArrayData(p,N,M);
double pw[8];
power(p,pw);
writePowerData(pw,8);
freeArray(p,nRow);
if(p !=NULL){
powerCalculation(p,pw,N,M,periode,timeBandwidth);
writePowerData(pw,8);
freeArray(p,N);
return 0;
}
else{
return 1;
}
}

View file

@ -1,3 +1,3 @@
#include <math.h>
void power(long **p, double a[]);
int power(int N , int M, double periode , double timeBandwidth);