Traitement-signal-plantes/Code-C/power.c

32 lines
861 B
C
Raw Normal View History

2022-06-01 12:32:04 +02:00
#include "power.h"
#include "getArray.h"
2022-06-02 14:29:21 +02:00
#include "fileGestion.h"
2022-06-01 12:32:04 +02:00
2022-06-07 14:28:32 +02:00
void powerCalculation(long **p, double a[] , int N, int M , double period , double timeBandwidth){
for(int i = 0; i < M-1; i++){
2022-06-01 12:32:04 +02:00
int j = 0;
a[i] = 0;
2022-06-07 14:28:32 +02:00
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;
2022-06-01 12:32:04 +02:00
j++;
}
2022-06-07 14:28:32 +02:00
a[i] *= timeBandwidth;
2022-06-02 15:07:04 +02:00
//printf("%f\n", a[i]);
2022-06-01 12:32:04 +02:00
}
}
2022-06-07 14:28:32 +02:00
int power(int N , int M, double periode , double timeBandwidth){
long **p = getRawDataArray(N, M);
//printArrayData(p,N,M);
double pw[8];
2022-06-07 14:28:32 +02:00
if(p !=NULL){
powerCalculation(p,pw,N,M,periode,timeBandwidth);
writePowerData(pw,8);
freeArray(p,N);
return 0;
}
else{
return 1;
}
2022-06-01 12:32:04 +02:00
}