Line data Source code
1 1 : /** 2 : * @file mathUtility.h 3 : * 4 : * @brief Provides functions for math. utilities 5 : */ 6 : 7 : #ifndef MATH_UTILITY_H 8 : #define MATH_UTILITY_H 9 : 10 : #include "commonTypes.h" 11 : 12 : namespace Coruh 13 : { 14 0 : namespace Utility 15 : { 16 : /** 17 : @class MathUtility 18 : @brief Provides Math. functions for various operations. 19 : */ 20 1 : class MathUtility 21 : { 22 : public: 23 : /** 24 : * @brief Calculates the mean (average) of an array of data. 25 : * 26 : * This function calculates the mean (average) of the given array of data. 27 : * The data array should contain datalen elements. 28 : * 29 : * @param fiArray The array of data. 30 : * @param fiArrayLen The length of the data array. 31 : * @return The calculated mean. 32 : */ 33 1 : static double calculateMean(const double fiArray[], int fiArrayLen); 34 : 35 : /** 36 : * @brief Calculates the median of an array of data. 37 : * 38 : * This function calculates the median of the given array of data. 39 : * The data array should contain datalen elements. 40 : * 41 : * @param fiArray The array of data. 42 : * @param fiArrayLen The length of the data array. 43 : * @return The calculated median. 44 : */ 45 1 : static double calculateMedian(const double fiArray[], int fiArrayLen); 46 : 47 : /** 48 : * @brief Compares two double values for sorting purposes. 49 : * 50 : * This function is used as a comparison function for sorting an array of doubles in ascending order. 51 : * 52 : * @param fiPtrLhs Pointer to the first double value. 53 : * @param fiPtrRhs Pointer to the second double value. 54 : * @return An integer value indicating the comparison result. 55 : * - -1 if the first value is less than the second value. 56 : * - 0 if the values are equal. 57 : * - 1 if the first value is greater than the second value. 58 : */ 59 1 : static int compareDouble(const void *fiPtrLhs, const void *fiPtrRhs); 60 : 61 : /** 62 : * @brief Calculates the minimum and maximum values in an array of data. 63 : * 64 : * This function calculates the minimum and maximum values in the given array of data. 65 : * The data array should contain datalen elements. 66 : * 67 : * @param fiArray The array of data. 68 : * @param fiArrayLen The length of the data array. 69 : * @param foMin Pointer to store the minimum value. 70 : * @param foMax Pointer to store the maximum value. 71 : */ 72 1 : static void calculateMinMax(const double fiArray[], int fiArrayLen, double *foMin, double *foMax); 73 : 74 : }; 75 : } 76 : } 77 : 78 : #endif // FILE_UTILITY_H