From d3051a937197801c60ebbb35f9282577599dfc98 Mon Sep 17 00:00:00 2001 From: Frederik Beimgraben Date: Fri, 17 Jan 2025 21:21:11 +0100 Subject: [PATCH] diff.txt --- diff.txt | 117 ++++++++++++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 62 deletions(-) diff --git a/diff.txt b/diff.txt index 9ca34af..580aab2 100644 --- a/diff.txt +++ b/diff.txt @@ -15,98 +15,91 @@ > memcpy(dst, src, len * sizeof(int)); > } > -230,231c245,251 -< // First find the old minimum -< double dOldMin = pdIn[0]; +216c231 +< * $ pdOut_i = pdIn_i *dFactor + (dMin - min(pdIn)) $. --- -> // Rescale the array -> for (int i = 0; i < iLen; i++) { -> pdOut[i] = pdIn[i] * dFactor; -> } -> -> // First find the minimum -> double dOldMin = pdOut[0]; -233,234c253,254 -< if (pdIn[i] < dOldMin) -< dOldMin = pdIn[i]; +> * $ pdOut_i = (pdIn_i + min(pdIn)) * dFactor + dMin $. +218c233 +< void rescaleDoubleArray( --- -> if (pdOut[i] < dOldMin) -> dOldMin = pdOut[i]; -239a260,264 -> // Move the values to the new minimum -> for (int i = 0; i < iLen; i++) { -> pdOut[i] += dOffset; -> } -> -244,248d268 +> void rescaleDoubleArray( +237,243c252 +< // Calculate the offset +< double dOffset = dMin - dOldMin; < -< // Rescale the array -< for (int i = 0; i < iLen; i++) { +< #ifdef _DEBUG +< _debug("rescaleDoubleArray: dOldMin = %lf", dOldMin); +< _debug("rescaleDoubleArray: dOffset = %lf", dOffset); +< #endif +--- +> _debug("dOldMin: %lf", dOldMin); +247c256 < pdOut[i] = pdIn[i] * dFactor + dOffset; -< } -252c272 +--- +> pdOut[i] = (pdIn[i] - dOldMin) * dFactor + dMin; +252c261 < * Generate an array of `iNumValues` double value, so that the values --- > * Generate an array of `iNumValues` double values, so that the values -283c303 +283c292 < if (iNumValues == 0) --- > if (iNumValues == 0) { -288a309,310 +288a298,299 > return NULL; > } -333c355 +333c344 < _warn("writeDoubleArray: iLen is 0."); --- > _warn("writeDoubleArray: iLen is 0."); -435,437c457 +435,437c446 < for (int i = 0; i < pexIn->iNumLocalExtrema; i++) { < localExtrema->piLocalExtremaPos[i] = pexIn->piLocalExtremaPos[i]; < } --- > _copy_int_array(localExtrema->piLocalExtremaPos, pexIn->piLocalExtremaPos, pexIn->iNumLocalExtrema); -474,476c494 +474,476c483 < for (int i = 0; i < pmmsIn->iNumValues; i++) { < signal->pdValues[i] = pmmsIn->pdValues[i]; < } --- > _copy_double_array(signal->pdValues, pmmsIn->pdValues, pmmsIn->iNumValues); -479c497 +479c486 < _error("createSignalFromSignal: pmmsIn->pdValues is NULL while pmmsIn->iNumValues is not %d", pmmsIn->iNumValues); --- > _error("createSignalFromSignal: pmmsIn->pdValues is NULL while pmmsIn->iNumValues is not %d", pmmsIn->iNumValues); -535,537c553 +535,537c542 < for (int i = 0; i < iArrayLen; i++) { < signal->pdValues[i] = pdIn[i]; < } --- > _copy_double_array(signal->pdValues, pdIn, iArrayLen); -553d568 +553d557 < signal->pdValues = NULL; -687,688c702,703 +687,688c691,692 < int val_a = * ( (double*) a ); < int val_b = * ( (double*) b ); --- > double val_a = * ( (double*) a ); > double val_b = * ( (double*) b ); -710,711d724 +710,711d713 < double *pdInSorted = NULL; < pdInSorted = (double*) malloc(sizeof(double) *iLen); -717a731,733 +717a720,722 > double *pdInSorted = NULL; > pdInSorted = (double*) malloc(sizeof(double) * iLen); > -721,723c737 +721,723c726 < for (int i = 0; i < iLen; i++) { < pdInSorted[i] = pdIn[i]; < } --- > _copy_double_array(pdInSorted, pdIn, iLen); -744c758 +744c747 < LocalExtrema *initLocalExtrema(int *piInPos, int iLen) { --- > LocalExtrema *createLocalExtrema() { -749,756c763,764 +749,756c752,753 < localExtrema->iNumLocalExtrema = iLen; < localExtrema->piLocalExtremaPos = (int*) malloc(sizeof(int) *iLen); < if (localExtrema->piLocalExtremaPos == NULL) @@ -118,7 +111,7 @@ --- > localExtrema->iNumLocalExtrema = 0; > localExtrema->piLocalExtremaPos = NULL; -789,792c797,804 +789,792c786,793 < int iNumLocalMax = 0; < int iNumLocalMin = 0; < int *piLocalMaxPos = NULL; @@ -132,63 +125,63 @@ > int **ppiLocalMinPos = &pexLocalMin->piLocalExtremaPos; > int *iNumLocalMax = &pexLocalMax->iNumLocalExtrema; > int *iNumLocalMin = &pexLocalMin->iNumLocalExtrema; -796c808 +796c797 < iNumLocalMax++; --- > (*iNumLocalMax)++; -802,803c814,815 +802,803c803,804 < if (piLocalMaxPos == NULL) < piLocalMaxPos = (int*) malloc(sizeof(int) *iNumLocalMax); --- > if (*ppiLocalMaxPos == NULL) > *ppiLocalMaxPos = (int*) malloc(sizeof(int) * (*iNumLocalMax)); -805c817 +805c806 < piLocalMaxPos = (int*) realloc(piLocalMaxPos, sizeof(int) *iNumLocalMax); --- > *ppiLocalMaxPos = (int*) realloc(*ppiLocalMaxPos, sizeof(int) * (*iNumLocalMax)); -807c819 +807c808 < if (piLocalMaxPos == NULL) --- > if (*ppiLocalMaxPos == NULL) -810c822 +810c811 < piLocalMaxPos[iNumLocalMax-1] = i; --- > *ppiLocalMaxPos[(*iNumLocalMax)-1] = i; -814c826 +814c815 < iNumLocalMin++; --- > (*iNumLocalMin)++; -820,821c832,833 +820,821c821,822 < if (piLocalMinPos == NULL) < piLocalMinPos = (int*) malloc(sizeof(int) *iNumLocalMin); --- > if (*ppiLocalMinPos == NULL) > *ppiLocalMinPos = (int*) malloc(sizeof(int) * (*iNumLocalMin)); -823c835 +823c824 < piLocalMinPos = (int*) realloc(piLocalMinPos, sizeof(int) *iNumLocalMin); --- > *ppiLocalMinPos = (int*) realloc(*ppiLocalMinPos, sizeof(int) * (*iNumLocalMin)); -825c837 +825c826 < if (piLocalMinPos == NULL) --- > if (*ppiLocalMinPos == NULL) -828c840 +828c829 < piLocalMinPos[iNumLocalMin-1] = i; --- > *ppiLocalMinPos[(*iNumLocalMin)-1] = i; -833,834c845,846 +833,834c834,835 < _debug("findLocalExtremaFromArray: Found %d local maxima", iNumLocalMax); < _debug("findLocalExtremaFromArray: Found %d local minima", iNumLocalMin); --- > _debug("findLocalExtremaFromArray: Found %d local maxima", *iNumLocalMax); > _debug("findLocalExtremaFromArray: Found %d local minima", *iNumLocalMin); -837,838c849,850 +837,838c838,839 < *ppexLocalMax = initLocalExtrema(piLocalMaxPos, iNumLocalMax); < *ppexLocalMin = initLocalExtrema(piLocalMinPos, iNumLocalMin); --- > *ppexLocalMax = pexLocalMax; > *ppexLocalMin = pexLocalMin; -898,908c910,913 +898,908c899,902 < if (iLen == 0) < _warn("initHistogram: iLen is 0"); < @@ -205,9 +198,9 @@ > getMinMaxPos(pdIn, iLen, &minPos, &maxPos); > histogram->dIntervalMin = pdIn[minPos]; > histogram->dIntervalMax = pdIn[maxPos]; -924a930 +924a919 > histogram->pdBinValues = NULL; // FIXME: This should be added in the final version -1000,1002c1006,1008 +1000,1002c995,997 < double *pdOut = (double*) malloc(sizeof(double) *iOutLen); < if (pdOut == NULL) < _mem_error("convoluteSignals: Failed to allocate memory for pdOut"); @@ -215,25 +208,25 @@ > // Create the output signal to write directly to the destination > MMSignal *signal = createSignalWithDefault(iOutLen, 0); > double *pdOut = signal->pdValues; -1014c1020 +1014c1009 < MMSignal *signal = createSignalFromDoubleArray(iOutLen, pdOut); --- > // Initialize the features of the signal -1028,1029c1034,1036 +1028,1029c1023,1025 < double *pdValues = NULL; < pdValues = (double*) malloc(sizeof(double) * iLinenum); --- > MMSignal *signal = createSignalWithDefault(iLinenum, 1); > double *pdValues = signal->pdValues; > -1034d1040 +1034d1029 < pdValues[i] = 1; -1036c1042 +1036c1031 < pdValues[j] = pdValues[j] + pdValues[j-1]; --- > pdValues[j] += pdValues[j-1]; -1040d1045 +1040d1034 < MMSignal *signal = createSignalFromDoubleArray(iLinenum, pdValues); -1042,1043d1046 +1042,1043d1035 < < free(pdValues);