diff --git a/MMS24-25.c b/MMS24-25.c index 93770d0..0fef081 100644 --- a/MMS24-25.c +++ b/MMS24-25.c @@ -19,12 +19,7 @@ #include #include -// Define NULL if not already provided -#ifndef NULL -#define NULL 0 -#endif - -void _error(char* fmt, ...) { +void _error(char *fmt, ...) { fprintf(stderr, "<\x1B[31;1m ERROR \x1B[0m: \x1B[34m'"); va_list args; @@ -35,11 +30,11 @@ void _error(char* fmt, ...) { fprintf(stderr, "'\x1B[0m >\n"); #ifndef _TESTS_NONSTOP - exit(-1); + exit(EXIT_FAILURE); #endif } -void _debug(char* fmt, ...) { +void _debug(char *fmt, ...) { fprintf(stderr, "[\x1B[31;1m DEBUG \x1B[0m] \x1B[34m'"); va_list args; @@ -50,7 +45,7 @@ void _debug(char* fmt, ...) { fprintf(stderr, "'\x1B[0m\n"); } -void _warn(char* fmt, ...) { +void _warn(char *fmt, ...) { fprintf(stderr, "[\x1B[33;1m WARN \x1B[0m] \x1B[34m'"); va_list args; @@ -71,9 +66,9 @@ double interpolateLine( if (dX2 == dX1) _error("interpolateLine: dX1 and dX2 must differ!"); - double y = dY1 * ( + double y = dY1 *( (dX2 - dXq) / (dX2 - dX1) - ) + dY2 * ( + ) + dY2 *( (dXq - dX1) / (dX2 - dX1) ); @@ -97,12 +92,12 @@ void rescaleDoubleArray( * Given $ |pdIn| = |pdOut| = iLen $ it should be, that: * $ min(pdIn) > dMin $, as well as * \[ \forall i, j \in (0,\dots,iLen-1): - * (pdOut_i - pdOut_j) = (pdIn_i - pdIn_j) * dFactor \], + * (pdOut_i - pdOut_j) = (pdIn_i - pdIn_j) *dFactor \], * which naturally results from: - * $ pdOut_i = pdIn_i * dFactor + dMin $ + * $ pdOut_i = pdIn_i *dFactor + dMin $ */ for (int i = 0; i < iLen; i++) { - pdOut[i] = pdIn[i] * dFactor + dMin; + pdOut[i] = pdIn[i] *dFactor + dMin; } } @@ -130,14 +125,14 @@ double *generateSineValues( // Initialize the output array - double* sineArray = NULL; - sineArray = (double*) malloc(sizeof(double) * iNumValues); + double *sineArray = NULL; + sineArray = (double*) malloc(sizeof(double) *iNumValues); - if (sineArray == NULL) + if (sineArray == NULL) _error("*generateSineValues: Failed to allocate memory for Sine Array\n"); for (int i=0; i