42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
#include "power.h"
|
|
#include "getArray.h"
|
|
#include "fileGestion.h"
|
|
#include "initialParameters.h"
|
|
#include "queue.h"
|
|
|
|
/**
|
|
* @brief realize the power calcul
|
|
*
|
|
* @param p array with all the values that will be used for the calcul
|
|
* @param powerArray array where results are stocked
|
|
*/
|
|
void powerCalculation(long **p, double powerArray[]){
|
|
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;
|
|
j++;
|
|
}
|
|
powerArray[i] *= invTimeBandWidth;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief function that realize all the action to write one lign in the file powerData.csv
|
|
*
|
|
* @param rawDataFileName name of the raw data file to use to realize the calcul
|
|
* @param N number of rows in the file
|
|
* @param M number of columns in the file
|
|
*/
|
|
double * power(char* rawDataFileName){
|
|
long **p = getRawDataArray(rawDataFileName);
|
|
double pw[nCol-1];
|
|
if(p !=NULL){
|
|
powerCalculation(p,pw);
|
|
appendDataInFile("powerData.csv",pw,nCol-1);
|
|
freeArray(p,nRow);
|
|
}
|
|
return pw;
|
|
} |