updated .exe and src file
This commit is contained in:
parent
f48178dba2
commit
aa84dad655
BIN
bin/CPP_NLMS.exe
BIN
bin/CPP_NLMS.exe
Binary file not shown.
|
@ -11,7 +11,7 @@ Created by Stefan Friese on 26.04.2018
|
|||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "nlms_types.h" // added types
|
||||
#include "nlms_types.h"
|
||||
|
||||
#define RGB_COLOR 255
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -64,11 +64,11 @@ int main( int argc, char **argv ) {
|
|||
unsigned k, include = 0;
|
||||
unsigned windowSize = 5;
|
||||
unsigned samplesCount = 512;
|
||||
char *stdcolor = "green", xBuffer[512];
|
||||
char *stdcolor = (char*)"green", xBuffer[512];
|
||||
colorChannel = stdcolor;
|
||||
unsigned int uint_buffer[1], windowBuffer[1];
|
||||
double learnrate = 0.4;
|
||||
char *istrue = "true";
|
||||
char *istrue = (char*)"true";
|
||||
char *templatePath = NULL;
|
||||
|
||||
while ((argc > 1) && (argv[1][0] == '-')) { // Parses parameters from stdin
|
||||
|
@ -113,10 +113,12 @@ int main( int argc, char **argv ) {
|
|||
sscanf(&argv[1][3], "%s", xBuffer);
|
||||
if (strstr(xBuffer, istrue)) {
|
||||
include = 1;
|
||||
} else if ( xBuffer && !strstr(xBuffer, istrue) ) {
|
||||
}
|
||||
else if (xBuffer && !strstr(xBuffer, istrue)) {
|
||||
templatePath = xBuffer;
|
||||
include = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf("Wrong Argruments: %s\n", argv[1]);
|
||||
usage(argv);
|
||||
}
|
||||
|
@ -149,7 +151,8 @@ int main( int argc, char **argv ) {
|
|||
if ((seed != NULL)) {
|
||||
srand(*seed); // Seed for random number generating
|
||||
printf("srand is reproducable\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
srand((unsigned int)time(NULL));
|
||||
printf("srand depends on time\n"); // Default seed is time(NULL)
|
||||
}
|
||||
|
@ -197,8 +200,10 @@ void localMean ( mldata_t *mlData, point_t points[] ) {
|
|||
localWeights = mlData->weights;
|
||||
|
||||
char fileName[50];
|
||||
const unsigned xErrorLength = mlData->samplesCount;
|
||||
double xError[xErrorLength];
|
||||
unsigned xErrorLength = mlData->samplesCount;
|
||||
double *xError = (double *)malloc(sizeof(double) * xErrorLength+1);
|
||||
memset(xError, 0.0, sizeof(double) * xErrorLength);
|
||||
|
||||
unsigned i, xCount = 0; // Runtime vars
|
||||
|
||||
mkFileName(fileName, sizeof(fileName), LOCAL_MEAN); // Create Logfile and its filename
|
||||
|
@ -277,7 +282,8 @@ void directPredecessor( mldata_t *mlData, point_t points[]) {
|
|||
|
||||
char fileName[512];
|
||||
const unsigned xErrorLength = mlData->samplesCount;
|
||||
double xError[xErrorLength];
|
||||
double *xError = (double *)malloc(sizeof(double) * xErrorLength);
|
||||
memset(xError, 0.0, sizeof(double) * xErrorLength);
|
||||
unsigned xCount = 0, i;
|
||||
double xActual = 0.0;
|
||||
double xPredicted = 0.0;
|
||||
|
@ -350,7 +356,8 @@ void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
|
|||
localWeights = mlData->weights;
|
||||
const unsigned xErrorLength = mlData->samplesCount;
|
||||
char fileName[512];
|
||||
double xError[xErrorLength];
|
||||
double *xError = (double *)malloc(sizeof(double) * xErrorLength);
|
||||
memset(xError, 0.0, sizeof(double) * xErrorLength);
|
||||
|
||||
unsigned xCount = 0, i;
|
||||
double xPredicted = 0.0;
|
||||
|
@ -402,7 +409,6 @@ void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
|
|||
double mean = sum_array(xError, xErrorLength) / xErrorLength;
|
||||
double deviation = 0.0;
|
||||
|
||||
|
||||
for (i = 1; i < xErrorLength; i++) { // Mean square
|
||||
deviation += pow(xError[i] - mean, 2);
|
||||
}
|
||||
|
@ -445,15 +451,15 @@ Contains and returns every suffix for all existing filenames
|
|||
======================================================================================================
|
||||
*/
|
||||
char * fileSuffix(int id) {
|
||||
char * suffix[] = { "_weights_pure.txt",
|
||||
"_weights_used_dir_pred_.txt",
|
||||
"_direct_predecessor.txt",
|
||||
"_ergebnisse.txt",
|
||||
"_localMean.txt",
|
||||
"_testvalues.txt",
|
||||
"_differential_predecessor.txt",
|
||||
"_weights_used_local_mean.txt",
|
||||
"_weights_used_diff_pred.txt",
|
||||
char * suffix[] = { (char*)"_weights_pure.txt",
|
||||
(char*)"_weights_used_dir_pred_.txt",
|
||||
(char*)"_direct_predecessor.txt",
|
||||
(char*)"_ergebnisse.txt",
|
||||
(char*)"_localMean.txt",
|
||||
(char*)"_testvalues.txt",
|
||||
(char*)"_differential_predecessor.txt",
|
||||
(char*)"_weights_used_local_mean.txt",
|
||||
(char*)"_weights_used_diff_pred.txt",
|
||||
};
|
||||
return suffix[id];
|
||||
}
|
||||
|
@ -468,9 +474,9 @@ Contains and returns header from logfiles
|
|||
======================================================================================================
|
||||
*/
|
||||
char * fileHeader(int id) {
|
||||
char * header[] = { "\n=========================== Local Mean ===========================\nNo.\txPredicted\txAcutal\t\txError\n",
|
||||
"\n=========================== Direct Predecessor ===========================\nNo.\txPredicted\txAcutal\t\txError\n",
|
||||
"\n=========================== Differential Predecessor ===========================\nNo.\txPredicted\txAcutal\t\txError\n"
|
||||
char * header[] = { (char*)"\n=========================== Local Mean ===========================\nNo.\txPredicted\txAcutal\t\txError\n",
|
||||
(char*)"\n=========================== Direct Predecessor ===========================\nNo.\txPredicted\txAcutal\t\txError\n",
|
||||
(char*)"\n=========================== Differential Predecessor ===========================\nNo.\txPredicted\txAcutal\t\txError\n"
|
||||
};
|
||||
return header[id];
|
||||
}
|
||||
|
@ -599,7 +605,8 @@ void mkSvgGraph(point_t points[], char *templatePath) {
|
|||
if (templatePath) {
|
||||
printf("\ngraph template src at: %s\n", templatePath);
|
||||
input = fopen(templatePath, "r");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
input = fopen("graphResults_template.html", "r");
|
||||
}
|
||||
|
||||
|
@ -735,16 +742,19 @@ int ppmColorChannel(FILE* fp, imagePixel_t *image, char *colorChannel, mldata_t
|
|||
for (i = 0; i < mlData->samplesCount - 1; i++) {
|
||||
fprintf(fp, "%d\n", image->data[i].green);
|
||||
}
|
||||
} else if ( strcmp(colorChannel, "red") == 0 ){
|
||||
}
|
||||
else if (strcmp(colorChannel, "red") == 0) {
|
||||
for (i = 0; i < mlData->samplesCount - 1; i++) {
|
||||
fprintf(fp, "%d\n", image->data[i].red);
|
||||
}
|
||||
|
||||
} else if ( strcmp(colorChannel, "blue") == 0 ) {
|
||||
}
|
||||
else if (strcmp(colorChannel, "blue") == 0) {
|
||||
for (i = 0; i < mlData->samplesCount - 1; i++) {
|
||||
fprintf(fp, "%d\n", image->data[i].blue);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf("Colorchannels are red, green and blue. Pick one of them!");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue