ad comment for next time fix
This commit is contained in:
parent
a8c235bc65
commit
1c7d7edaae
|
@ -11,15 +11,15 @@
|
||||||
*/
|
*/
|
||||||
void averageCalculation(long **p, double averageArray[])
|
void averageCalculation(long **p, double averageArray[])
|
||||||
{
|
{
|
||||||
printArrayData(p, nRowRawData, nCol);
|
// printArrayData(p, nRowRawData, nCol);
|
||||||
printf("\n");
|
// printf("\n");
|
||||||
for (int i = 1; i < nCol; i++)
|
for (int i = 1; i < nCol; i++)
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
averageArray[i] = 0;
|
averageArray[i] = 0;
|
||||||
while (j < nRowRawData)
|
while (j < nRowRawData)
|
||||||
{
|
{
|
||||||
printf("pij = %ld\n", p[i][j]);
|
//printf("pij = %ld\n", p[i][j]);
|
||||||
averageArray[i - 1] += (double)p[i][j];
|
averageArray[i - 1] += (double)p[i][j];
|
||||||
// printf("%f , %ld\n", averageArray[i], p[i][j]);
|
// printf("%f , %ld\n", averageArray[i], p[i][j]);
|
||||||
j++;
|
j++;
|
||||||
|
|
|
@ -24,10 +24,24 @@ double **getDoubleArray(int N, int M) /* Allocate the array */
|
||||||
array[i] = (double *)malloc(M * sizeof(double));
|
array[i] = (double *)malloc(M * sizeof(double));
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief print all the element of a bidimensionnal array p of shape : N x M
|
||||||
|
*/
|
||||||
|
void printArrayData(long **p)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < nRowRawData; i++)
|
||||||
|
{
|
||||||
|
printf("line n°%d : ", i);
|
||||||
|
for (int j = 0; j < nCol; j++)
|
||||||
|
{
|
||||||
|
printf("%ld , ", p[i][j]);
|
||||||
|
if (j == (nCol - 1))
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
||||||
{
|
{
|
||||||
int i, j;
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
size_t bufsize = 200;
|
size_t bufsize = 200;
|
||||||
buffer = (char *)malloc(bufsize * sizeof(char));
|
buffer = (char *)malloc(bufsize * sizeof(char));
|
||||||
|
@ -35,36 +49,25 @@ void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
|
||||||
|
|
||||||
FILE *f = fopen(rawDataFileName, "r");
|
FILE *f = fopen(rawDataFileName, "r");
|
||||||
|
|
||||||
for (i = 0; i < N; i++)
|
for (int i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
long t, c1, c2, c3;
|
long t, c1, c2, c3;
|
||||||
while (fscanf(f, "%ld,%ld,%ld,%ld\n", &t, &c1, &c2, &c3) != EOF)
|
while (fscanf(f, "%ld,%ld,%ld,%ld\n", &t, &c1, &c2, &c3) != EOF)
|
||||||
{ // séparation valeur par virgule initiale : csv
|
{ // séparation valeur par virgule initiale : csv
|
||||||
// printf("%ld,%ld,%ld,%ld\n", t, c1, c2, c3);
|
//printf("%ld,%ld,%ld,%ld\n", t, c1, c2, c3);
|
||||||
p[i][0] = t;
|
p[i][0] = t;
|
||||||
p[i][1] = c1;
|
p[i][1] = c1;
|
||||||
p[i][2] = c2;
|
p[i][2] = c2;
|
||||||
p[i][3] = c3;
|
p[i][3] = c3;
|
||||||
}
|
}
|
||||||
|
printf("%ld,%ld,%ld,%ld,\n",p[0][0],p[0][1],p[0][2],p[0][3]);
|
||||||
|
for(int j = 0; j < nCol; j++){
|
||||||
|
printf("p[%d][%d] : %ld\n",i,j,p[i][j]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
printArrayData(p);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @brief print all the element of a bidimensionnal array p of shape : N x M
|
|
||||||
*/
|
|
||||||
void printArrayData(long **p, int N, int M)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
printf("line n°%d : ", i);
|
|
||||||
for (int j = 0; j < M; j++)
|
|
||||||
{
|
|
||||||
printf("%ld , ", p[i][j]);
|
|
||||||
if (j == (M - 1))
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief verify if all the element of an array are not NULL, return
|
* @brief verify if all the element of an array are not NULL, return
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
long **getRawDataArray(char *rawDataFileName);
|
long **getRawDataArray(char *rawDataFileName);
|
||||||
void printArrayData(long **p, int N, int M);
|
void printArrayData(long **p);
|
||||||
void freeArray(long **p, int N);
|
void freeArray(long **p, int N);
|
||||||
bool checkArrayFullyFill(long **p, int N);
|
bool checkArrayFullyFill(long **p, int N);
|
||||||
double **getDoubleArray(int N, int M);
|
double **getDoubleArray(int N, int M);
|
|
@ -163,12 +163,12 @@ int main(int argc, char **argv)
|
||||||
// exit(1);
|
// exit(1);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pthread_t calculGrowthRate;
|
// pthread_t calculGrowthRate;
|
||||||
if (pthread_create(&calculGrowthRate, NULL, threadCalculGrowthRate, "threadCalculGrowthRate"))
|
// if (pthread_create(&calculGrowthRate, NULL, threadCalculGrowthRate, "threadCalculGrowthRate"))
|
||||||
{
|
// {
|
||||||
perror("threadcalculGrowthRate() error");
|
// perror("threadcalculGrowthRate() error");
|
||||||
exit(1);
|
// exit(1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
|
@ -212,6 +212,7 @@ void *threadSimulateFlux(void *vargp)
|
||||||
// prepare next file now
|
// prepare next file now
|
||||||
fileName = createNewRawDataFileName();
|
fileName = createNewRawDataFileName();
|
||||||
rawDataFile = fopen(fileName, "w+");
|
rawDataFile = fopen(fileName, "w+");
|
||||||
|
//add test to get p then print it here // p is gotten from fileName file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rawDataWriteFlag = false;
|
rawDataWriteFlag = false;
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import numpy as np
|
|
||||||
|
|
Loading…
Reference in a new issue