32 lines
861 B
C
32 lines
861 B
C
#include "power.h"
|
|
#include "getArray.h"
|
|
#include "fileGestion.h"
|
|
|
|
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 < 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] *= timeBandwidth;
|
|
//printf("%f\n", a[i]);
|
|
}
|
|
}
|
|
int power(int N , int M, double periode , double timeBandwidth){
|
|
long **p = getRawDataArray(N, M);
|
|
//printArrayData(p,N,M);
|
|
double pw[8];
|
|
if(p !=NULL){
|
|
powerCalculation(p,pw,N,M,periode,timeBandwidth);
|
|
writePowerData(pw,8);
|
|
freeArray(p,N);
|
|
return 0;
|
|
}
|
|
else{
|
|
return 1;
|
|
}
|
|
} |