diff --git a/.gitignore b/.gitignore index cd531cf..6065ccf 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ Module.symvers Mkfile.old dkms.conf +main \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..95d51a7 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,580 @@ + + + + + \ No newline at end of file diff --git a/MMS24_25.c b/MMS24_25.c index 070e9d6..12108f4 100644 --- a/MMS24_25.c +++ b/MMS24_25.c @@ -7,11 +7,6 @@ #include #include -#ifdef _DEBUG_ -printf("X=%f\n",x); -#endif - - double interpolateLine(double x1, double y1,double x2, double y2, double x){ double y = ((y2 - y1) / (x2 - x1)) * x + y1 - ((y2 - y1) / (x2 - x1)) * x1; return y; diff --git a/MMS24_25.h b/MMS24_25.h index 7cb9776..91ee884 100644 --- a/MMS24_25.h +++ b/MMS24_25.h @@ -1,14 +1,88 @@ // -// Created by minhd on 03.12.2024. +// Created by frederikbeimgraben, minhdancam, leahornberger on 03.12.2024. // -#ifndef MMS_LOESUNG_2024_25_MMS24_25_H -#define MMS_LOESUNG_2024_25_MMS24_25_H +#ifndef MMS24_25_H +#define MMS24_25_H + +typedef struct { + double *pdValues; + int iNumValues; +} MMSignal; + +typedef struct { + int iNumLocalExtrema; + int *piLocalExtremaPos; +} LocalExtrema; + +typedef struct { + int iGlobalMinPos; + int iGlobalMaxPos; + LocalExtrema *pexLocalMax; + LocalExtrema *pexLocalMin; +} Extrema; + +typedef struct { + double dIntervalMin; + double dIntervalMax; + double dBinWidth; + int iNumBins; + double *pdBinValues; +} Histogram; + +/*************************** +* AUFGABE 1 +****************************/ double interpolateLine(double dX1,double dY1,double dX2, double dY2, double dXq); -void rescaleDoubleArray(double *pdIn, int iLen, int iMin, double dFactor, double *pdOut); +void rescaleDoubleArray(double *pdIn, int iLen, double dMin, double dFactor, double *pdOut); double *generateSineValues(int iNumValues, int iNumSamplesPerPeriod, double dAmp); void writeDoubleArray(double *pdOut, int iLen, char *pcOutName); + +/************************************** +* read a linebreak separated numbers from a file +* +* input: +* pcInName - Name of the file to be read +* ppdIn - pointer holding the reference to the data array created by this function after reading +* +* output: +* Length of the array of double values created by this function +* +***************************************/ int readDoubleArray(char *pcInName, double **ppdIn); -#endif //MMS_LOESUNG_2024_25_MMS24_25_H +MMSignal *createSignal(); +MMSignal *createSignalFromDoubleArray(int iArrayLen, double *pdIn); +MMSignal *createSignalFromFile(char *pcInName); +MMSignal *readMMSignal(char *pcInName); +void writeMMSignal(char *pcInName, MMSignal *pmmsIn); + +void deleteSignal(MMSignal *pmmsIn); + +/******************************** +* AUFGABE 2 +********************************/ + +double calculateArea(double *pdIn, int iLen); +double calculateMean(double *pdIn, int iLen); +double calculateStddev(double *pdIn, int iLen); +double calculateMedian(double *pdIn, int iLen); +Extrema *initExtrema(double *pdIn, int iLen); +void deleteExtrema(Extrema *pexIn); +Histogram *initHistogram(double *pdIn, int iLen, int iNumBins); +void deleteHistogram(Histogram *phisIn); +double calculateEntropy(Histogram *phisIn); + +/******************************** +* AUFGABE 3 +********************************/ +MMSignal *convoluteSignals(MMSignal *pmmsInA,MMSignal *pmmsInB); +double *getPascalLine(int iLinenum); + +/******************************** +* AUFGABE 4 +********************************/ + +#endif //MMS24_25_H + diff --git a/README.md b/README.md index 5d1bec0..1e172b6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # MMS-Loesung-2024-25 -MMS-Lösung zum Headerfile im WiSe 2024/25 \ No newline at end of file +MMS-Lösung zum Headerfile im WiSe 2024/25 + +## Code Style and Conventions + +We adhere to the [Angular Commit Message Conventions](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) + +Function names as well as variables should be written in camelCase. \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..350f018 --- /dev/null +++ b/main.c @@ -0,0 +1,10 @@ +// +// Created by frederik on 12/3/24. +// + +#include "MMS24_25.h" +#include + +int main(const int argc, const char * argv[]) { + return 0; +} \ No newline at end of file