2022-06-21 15:13:10 +02:00
|
|
|
#include <math.h>
|
2022-12-01 17:29:47 +01:00
|
|
|
|
2023-06-01 17:22:38 +02:00
|
|
|
#include "./Include/power.h"
|
|
|
|
#include "./Include/getArray.h"
|
|
|
|
#include "./Include/fileGestion.h"
|
|
|
|
#include "./Include/initialParameters.h"
|
|
|
|
#include "./Include/queue.h"
|
2022-06-01 12:32:04 +02:00
|
|
|
|
2022-06-14 10:46:12 +02:00
|
|
|
/**
|
2022-06-15 11:57:15 +02:00
|
|
|
* @brief realize the powerThreadFunction calcul
|
2022-06-21 15:13:10 +02:00
|
|
|
*
|
2022-06-14 10:46:12 +02:00
|
|
|
* @param p array with all the values that will be used for the calcul
|
|
|
|
* @param powerArray array where results are stocked
|
|
|
|
*/
|
2022-06-21 15:13:10 +02:00
|
|
|
void powerCalculation(long **p, double powerArray[])
|
|
|
|
{
|
|
|
|
for (int i = 0; i < nCol; i++)
|
|
|
|
{
|
2022-06-01 12:32:04 +02:00
|
|
|
int j = 0;
|
2022-06-09 17:34:24 +02:00
|
|
|
powerArray[i] = 0;
|
2022-06-16 14:35:02 +02:00
|
|
|
|
2022-06-21 15:13:10 +02:00
|
|
|
while (j < nRowRawData)
|
|
|
|
{
|
|
|
|
powerArray[i] += pow(p[j][i + 1], 2);
|
2022-06-01 12:32:04 +02:00
|
|
|
j++;
|
|
|
|
}
|
2022-06-16 17:05:12 +02:00
|
|
|
powerArray[i] /= nRowRawData;
|
2022-06-01 12:32:04 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-14 10:46:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief function that realize all the action to write one lign in the file powerData.csv
|
2022-06-21 15:13:10 +02:00
|
|
|
*
|
2022-06-14 10:46:12 +02:00
|
|
|
* @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
|
|
|
|
*/
|
2022-06-21 15:13:10 +02:00
|
|
|
void powerFunction(char *rawDataFileName, double **pw)
|
|
|
|
{
|
2022-06-14 18:01:52 +02:00
|
|
|
long **p = getRawDataArray(rawDataFileName);
|
2022-06-24 15:42:25 +02:00
|
|
|
// printArrayData(p, nRowRawData, nCol);
|
2022-06-21 15:13:10 +02:00
|
|
|
double pww[nCol - 1];
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
|
|
|
if (pw == NULL)
|
|
|
|
{
|
|
|
|
powerCalculation(p, pww);
|
|
|
|
appendDataInFile("powerData.csv", pww, nCol - 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
powerCalculation(p, pw[1]);
|
|
|
|
appendDataInFile("powerData.csv", pw[1], nCol - 1);
|
2022-06-15 15:45:14 +02:00
|
|
|
}
|
2022-06-21 15:13:10 +02:00
|
|
|
freeArray(p, nRowRawData);
|
2022-06-07 14:28:32 +02:00
|
|
|
}
|
2022-06-01 12:32:04 +02:00
|
|
|
}
|