moved xError to heap.

This commit is contained in:
gurkenhabicht 2018-06-14 15:05:32 +02:00
parent f482ac5e70
commit b3e98801b2
1 changed files with 17 additions and 12 deletions

View File

@ -200,11 +200,11 @@ void standardNLMS( mldata_t *mlData, point_t points[] ) {
double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1); double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1);
memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1); memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1);
char fileName[50]; char fileName[512];
const unsigned xErrorLength = mlData->samplesCount; const unsigned xErrorLength = mlData->samplesCount;
double xError[xErrorLength]; double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
unsigned i, xCount = 0;
unsigned i, xCount = 0;
mkFileName ( fileName, sizeof(fileName), STANDARD_NLMS); mkFileName ( fileName, sizeof(fileName), STANDARD_NLMS);
FILE* fp01 = fopen( fileName, "w" ); FILE* fp01 = fopen( fileName, "w" );
fprintf( fp01, fileHeader(STANDARD_NLMS_HEADER) ); fprintf( fp01, fileHeader(STANDARD_NLMS_HEADER) );
@ -262,7 +262,7 @@ void standardNLMS( mldata_t *mlData, point_t points[] ) {
fprintf( fp01, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean ); fprintf( fp01, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean );
free(localWeights); free(localWeights);
free(xError);
} }
/* /*
@ -278,9 +278,10 @@ void localMean ( mldata_t *mlData, point_t points[] ) {
double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1); double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1);
memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1); memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1);
char fileName[50]; char fileName[512];
const unsigned xErrorLength = mlData->samplesCount; const unsigned xErrorLength = mlData->samplesCount;
double xError[xErrorLength]; double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
unsigned i, xCount = 0; // Runtime vars unsigned i, xCount = 0; // Runtime vars
mkFileName(fileName, sizeof(fileName), LOCAL_MEAN); // Create Logfile and its filename mkFileName(fileName, sizeof(fileName), LOCAL_MEAN); // Create Logfile and its filename
@ -343,6 +344,7 @@ void localMean ( mldata_t *mlData, point_t points[] ) {
fclose(fp4); fclose(fp4);
free(localWeights); free(localWeights);
free(xError);
} }
/* /*
@ -361,8 +363,9 @@ void directPredecessor( mldata_t *mlData, point_t points[]) {
char fileName[512]; char fileName[512];
const unsigned xErrorLength = mlData->samplesCount; const unsigned xErrorLength = mlData->samplesCount;
double xError[xErrorLength]; double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
unsigned xCount = 0, i;
unsigned xCount = 0, i;
double xActual = 0.0; double xActual = 0.0;
double xPredicted = 0.0; double xPredicted = 0.0;
@ -421,6 +424,7 @@ void directPredecessor( mldata_t *mlData, point_t points[]) {
fclose(fp3); fclose(fp3);
free(localWeights); free(localWeights);
free(xError);
} }
/* /*
@ -438,8 +442,8 @@ void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1); memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1);
const unsigned xErrorLength = mlData->samplesCount; const unsigned xErrorLength = mlData->samplesCount;
char fileName[512]; char fileName[512];
double xError[xErrorLength]; double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
unsigned xCount = 0, i; unsigned xCount = 0, i;
double xPredicted = 0.0; double xPredicted = 0.0;
@ -503,6 +507,7 @@ void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
fclose(fp6); fclose(fp6);
free(localWeights); free(localWeights);
free(xError);
} }
/* /*