diff --git a/Include/arm_math.h b/Include/arm_math.h index 4f3f68fb..50fa170a 100644 --- a/Include/arm_math.h +++ b/Include/arm_math.h @@ -2251,7 +2251,6 @@ __STATIC_INLINE q31_t arm_div_q63_to_q31(q63_t num, q31_t den) * @param[in,out] S points to an instance of the sorting structure. * @param[in] alg Selected algorithm. * @param[in] dir Sorting order. - * @param[in] inPlaceFlag In place flag. */ void arm_sort_init_f32( arm_sort_instance_f32 * S, diff --git a/Source/StatisticsFunctions/arm_max_no_idx_f32.c b/Source/StatisticsFunctions/arm_max_no_idx_f32.c index 8dd47457..76fe44ef 100755 --- a/Source/StatisticsFunctions/arm_max_no_idx_f32.c +++ b/Source/StatisticsFunctions/arm_max_no_idx_f32.c @@ -35,12 +35,6 @@ @ingroup groupStats */ -/** - @defgroup Max Maximum without index - - Computes the maximum value of an array of data. - The function returns only the maximum value and not its position within the array. - */ /** @addtogroup Max @@ -138,3 +132,7 @@ void arm_max_no_idx_f32( } #endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ + +/** + @} end of Max group + */ \ No newline at end of file diff --git a/Source/SupportFunctions/arm_bitonic_sort_f32.c b/Source/SupportFunctions/arm_bitonic_sort_f32.c index 67ecc8f8..a9160024 100644 --- a/Source/SupportFunctions/arm_bitonic_sort_f32.c +++ b/Source/SupportFunctions/arm_bitonic_sort_f32.c @@ -29,29 +29,7 @@ #include "arm_math.h" #include "arm_sorting.h" -/** - @ingroup groupSupport - */ - -/** - @defgroup Sorting Vector sorting algorithms - Sort the elements of a vector - - There are separate functions for floating-point, Q31, Q15, and Q7 data types. - */ - -/** - @addtogroup Sorting - @{ - */ - -/** - * @param[in] S points to an instance of the sorting structure. - * @param[in] pSrc points to the block of input data. - * @param[out] pDst points to the block of output data - * @param[in] blockSize number of samples to process. - */ static void arm_bitonic_sort_core_f32(float32_t *pSrc, uint32_t n, uint8_t dir) { @@ -903,6 +881,29 @@ static float32x4_t arm_bitonic_sort_4_f32(float32x4_t a, uint8_t dir) #endif +/** + @ingroup groupSupport + */ + +/** + @defgroup Sorting Vector sorting algorithms + + Sort the elements of a vector + + There are separate functions for floating-point, Q31, Q15, and Q7 data types. + */ + +/** + @addtogroup Sorting + @{ + */ + +/** + * @param[in] S points to an instance of the sorting structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ void arm_bitonic_sort_f32( const arm_sort_instance_f32 * S, float32_t * pSrc, diff --git a/Source/SupportFunctions/arm_heap_sort_f32.c b/Source/SupportFunctions/arm_heap_sort_f32.c index 09ae9240..4b81be33 100644 --- a/Source/SupportFunctions/arm_heap_sort_f32.c +++ b/Source/SupportFunctions/arm_heap_sort_f32.c @@ -29,31 +29,7 @@ #include "arm_math.h" #include "arm_sorting.h" -/** - @ingroup groupSupport - */ -/** - @addtogroup Sorting - @{ - */ - -/** - * @param[in] S points to an instance of the sorting structure. - * @param[in] pSrc points to the block of input data. - * @param[out] pDst points to the block of output data - * @param[in] blockSize number of samples to process. - * - * @par Algorithm - * The heap sort algorithm is a comparison algorithm that - * divides the input array into a sorted and an unsorted region, - * and shrinks the unsorted region by extracting the largest - * element and moving it to the sorted region. A heap data - * structure is used to find the maximum. - * - * @par It's an in-place algorithm. In order to obtain an out-of-place - * function, a memcpy of the source vector is performed. - */ static void arm_heapify(float32_t * pSrc, uint32_t n, uint32_t i, uint8_t dir) { @@ -79,6 +55,31 @@ static void arm_heapify(float32_t * pSrc, uint32_t n, uint32_t i, uint8_t dir) } } +/** + @ingroup groupSupport + */ + +/** + @addtogroup Sorting + @{ + */ + +/** + * @param[in] S points to an instance of the sorting structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + * + * @par Algorithm + * The heap sort algorithm is a comparison algorithm that + * divides the input array into a sorted and an unsorted region, + * and shrinks the unsorted region by extracting the largest + * element and moving it to the sorted region. A heap data + * structure is used to find the maximum. + * + * @par It's an in-place algorithm. In order to obtain an out-of-place + * function, a memcpy of the source vector is performed. + */ void arm_heap_sort_f32( const arm_sort_instance_f32 * S, float32_t * pSrc, diff --git a/Source/SupportFunctions/arm_merge_sort_f32.c b/Source/SupportFunctions/arm_merge_sort_f32.c index 7339ad15..7e3180b8 100644 --- a/Source/SupportFunctions/arm_merge_sort_f32.c +++ b/Source/SupportFunctions/arm_merge_sort_f32.c @@ -29,31 +29,6 @@ #include "arm_math.h" #include "arm_sorting.h" -/** - @ingroup groupSupport - */ - -/** - @addtogroup Sorting - @{ - */ - -/** - * @param[in] S points to an instance of the sorting structure. - * @param[in] pSrc points to the block of input data. - * @param[out] pDst points to the block of output data - * @param[in] blockSize number of samples to process. - * - * @par Algorithm - * The merge sort algorithm is a comparison algorithm that - * divide the input array in sublists and merge them to produce - * longer sorted sublists until there is only one list remaining. - * - * @par A work array is always needed, hence pSrc and pDst cannot be - * equal and the results will be stored in pDst. - */ - - static void topDownMerge(float32_t * pA, uint32_t begin, uint32_t middle, uint32_t end, float32_t * pB, uint8_t dir) { @@ -96,6 +71,32 @@ static void arm_merge_sort_core_f32(float32_t * pB, uint32_t begin, uint32_t end } } + +/** + @ingroup groupSupport + */ + +/** + @addtogroup Sorting + @{ + */ + +/** + * @param[in] S points to an instance of the sorting structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + * + * @par Algorithm + * The merge sort algorithm is a comparison algorithm that + * divide the input array in sublists and merge them to produce + * longer sorted sublists until there is only one list remaining. + * + * @par A work array is always needed, hence pSrc and pDst cannot be + * equal and the results will be stored in pDst. + */ + + void arm_merge_sort_f32( const arm_sort_instance_f32 * S, float32_t *pSrc, diff --git a/Source/SupportFunctions/arm_quick_sort_f32.c b/Source/SupportFunctions/arm_quick_sort_f32.c index ad473109..19773e33 100644 --- a/Source/SupportFunctions/arm_quick_sort_f32.c +++ b/Source/SupportFunctions/arm_quick_sort_f32.c @@ -29,36 +29,7 @@ #include "arm_math.h" #include "arm_sorting.h" -/** - @ingroup groupSupport - */ - -/** - @addtogroup Sorting - @{ - */ -/** - * @param[in] S points to an instance of the sorting structure. - * @param[in] pSrc points to the block of input data. - * @param[out] pDst points to the block of output data - * @param[in] blockSize number of samples to process. - * - * @par Algorithm - * The quick sort algorithm is a comparison algorithm that - * divides the input array into two smaller sub-arrays and - * recursively sort them. An element of the array (the pivot) - * is chosen, all the elements with values smaller than the - * pivot are moved before the pivot, while all elements with - * values greater than the pivot are moved after it (partition). - * - * @par - * In this implementation the Hoare partition scheme has been - * used and the first element has always been chosen as the pivot. - * - * @par It's an in-place algorithm. In order to obtain an out-of-place - * function, a memcpy of the source vector is performed. - */ static void arm_quick_sort_core_f32(float32_t *pSrc, uint32_t first, uint32_t last, uint8_t dir) { @@ -138,6 +109,36 @@ static void arm_quick_sort_core_f32(float32_t *pSrc, uint32_t first, uint32_t la } +/** + @ingroup groupSupport + */ + +/** + @addtogroup Sorting + @{ + */ + +/** + * @param[in] S points to an instance of the sorting structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + * + * @par Algorithm + * The quick sort algorithm is a comparison algorithm that + * divides the input array into two smaller sub-arrays and + * recursively sort them. An element of the array (the pivot) + * is chosen, all the elements with values smaller than the + * pivot are moved before the pivot, while all elements with + * values greater than the pivot are moved after it (partition). + * + * @par + * In this implementation the Hoare partition scheme has been + * used and the first element has always been chosen as the pivot. + * + * @par It's an in-place algorithm. In order to obtain an out-of-place + * function, a memcpy of the source vector is performed. + */ void arm_quick_sort_f32( const arm_sort_instance_f32 * S, float32_t * pSrc, diff --git a/Source/SupportFunctions/arm_sort_f32.c b/Source/SupportFunctions/arm_sort_f32.c index 5824b2d4..fea7aad4 100644 --- a/Source/SupportFunctions/arm_sort_f32.c +++ b/Source/SupportFunctions/arm_sort_f32.c @@ -30,6 +30,12 @@ #include "arm_sorting.h" /** + @ingroup groupSupport + */ + +/** + * @brief Generic sorting function + * * @param[in] S points to an instance of the sorting structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. @@ -73,3 +79,7 @@ void arm_sort_f32( break; } } + +/** + * @} end of groupSupport group + */ diff --git a/Source/SupportFunctions/arm_spline_interp_f32.c b/Source/SupportFunctions/arm_spline_interp_f32.c index d4e85448..cfbf3763 100644 --- a/Source/SupportFunctions/arm_spline_interp_f32.c +++ b/Source/SupportFunctions/arm_spline_interp_f32.c @@ -33,90 +33,108 @@ */ /** - * @defgroup SplineInterpolate Cubic Spline Interpolation - * - * Spline interpolation is a method of interpolation where the interpolant - * is a piecewise-defined polynomial called "spline". - * - * \par Introduction - * Given a function f defined on the interval [a,b], a set of n nodes x(i) - * where a=x(1) - *
- *         S1(x)       x(1) < x < x(2)
- * S(x) =   ...         
- *         Sn-1(x)   x(n-1) < x < x(n)
- * <\pre>
- * where
- *
 
- * Si(x) = a_i+b_i(x-xi)+c_i(x-xi)^2+d_i(x-xi)^3    i=1, ..., n-1
- * <\pre>
- *
- * \par Algorithm
- * Having defined h(i) = x(i+1) - x(i)
- *
- * h(i-1)c(i-1)+2[h(i-1)+h(i)]c(i)+h(i)c(i+1) = 3/h(i)*[a(i+1)-a(i)]-3/h(i-1)*[a(i)-a(i-1)]    i=2, ..., n-1
- * <\pre>
- * It is possible to write the previous conditions in matrix form (Ax=B).
- * In order to solve the system two boundary conidtions are needed.
- * - Natural spline: S1''(x1)=2*c(1)=0 ; Sn''(xn)=2*c(n)=0
- * In matrix form:
- *
- * |  1        0         0  ...    0         0           0     ||  c(1)  | |                        0                        |
- * | h(0) 2[h(0)+h(1)] h(1) ...    0         0           0     ||  c(2)  | |      3/h(2)*[a(3)-a(2)]-3/h(1)*[a(2)-a(1)]      |
- * | ...      ...       ... ...   ...       ...         ...    ||  ...   |=|                       ...                       |
- * |  0        0         0  ... h(n-2) 2[h(n-2)+h(n-1)] h(n-1) || c(n-1) | | 3/h(n-1)*[a(n)-a(n-1)]-3/h(n-2)*[a(n-1)-a(n-2)] |
- * |  0        0         0  ...    0         0           1     ||  c(n)  | |                        0                        |
- * 

- * - Parabolic runout spline: S1''(x1)=2*c(1)=S2''(x2)=2*c(2) ; Sn-1''(xn-1)=2*c(n-1)=Sn''(xn)=2*c(n)
- * In matrix form:
- *
- * |  1       -1         0  ...    0         0           0     ||  c(1)  | |                        0                        |
- * | h(0) 2[h(0)+h(1)] h(1) ...    0         0           0     ||  c(2)  | |      3/h(2)*[a(3)-a(2)]-3/h(1)*[a(2)-a(1)]      |
- * | ...      ...       ... ...   ...       ...         ...    ||  ...   |=|                       ...                       |
- * |  0        0         0  ... h(n-2) 2[h(n-2)+h(n-1)] h(n-1) || c(n-1) | | 3/h(n-1)*[a(n)-a(n-1)]-3/h(n-2)*[a(n-1)-a(n-2)] |
- * |  0        0         0  ...    0        -1           1     ||  c(n)  | |                        0                        |
- * 

- * A is a tridiagonal matrix (a band matrix of bandwidth 3) of size N=n+1. The factorization - * algorithms (A=LU) can be simplified considerably because a large number of zeros appear - * in regular patterns. The Crout method has been used:
- * 1) Solve LZ=B
- *
- * u(1,2) = A(1,2)/A(1,1)
- * z(1)   = B(1)/l(11)
- *
- * FOR i=2, ..., N-1
- *   l(i,i)   = A(i,i)-A(i,i-1)u(i-1,i)
- *   u(i,i+1) = a(i,i+1)/l(i,i)
- *   z(i)     = [B(i)-A(i,i-1)z(i-1)]/l(i,i)
- * 
- * l(N,N) = A(N,N)-A(N,N-1)u(N-1,N)
- * z(N)   = [B(N)-A(N,N-1)z(N-1)]/l(N,N)
- * 

- * 2) Solve UX=Z
- *
- * c(N)=z(N)
- * 
- * FOR i=N-1, ..., 1
- *   c(i)=z(i)-u(i,i+1)c(i+1) 
- * 

- * c(i) for i=1, ..., n-1 are needed to compute the n-1 polynomials.
- * b(i) and d(i) are computed as:
- * - b(i) = [y(i+1)-y(i)]/h(i)-h(i)*[c(i+1)+2*c(i)]/3
- * - d(i) = [c(i+1)-c(i)]/[3*h(i)]
- * Moreover, a(i)=y(i). - * - * \par Usage - * The x input array must be strictly sorted in ascending order and it must - * not contain twice the same value (x(i)x(n)). The coefficients used to compute the y values for - * xqx(n) the - * coefficients used for the last interval. - * + @defgroup SplineInterpolate Cubic Spline Interpolation + + Spline interpolation is a method of interpolation where the interpolant + is a piecewise-defined polynomial called "spline". + + @par Introduction + + Given a function f defined on the interval [a,b], a set of n nodes x(i) + where a=x(1) + S1(x) x(1) < x < x(2) + S(x) = ... + Sn-1(x) x(n-1) < x < x(n) +
+ + where + +
 
+  Si(x) = a_i+b_i(x-xi)+c_i(x-xi)^2+d_i(x-xi)^3    i=1, ..., n-1
+  
+ + @par Algorithm + + Having defined h(i) = x(i+1) - x(i) + +
+  h(i-1)c(i-1)+2[h(i-1)+h(i)]c(i)+h(i)c(i+1) = 3/h(i)*[a(i+1)-a(i)]-3/h(i-1)*[a(i)-a(i-1)]    i=2, ..., n-1
+  
+ + It is possible to write the previous conditions in matrix form (Ax=B). + In order to solve the system two boundary conidtions are needed. + - Natural spline: S1''(x1)=2*c(1)=0 ; Sn''(xn)=2*c(n)=0 + In matrix form: + +
+  |  1        0         0  ...    0         0           0     ||  c(1)  | |                        0                        |
+  | h(0) 2[h(0)+h(1)] h(1) ...    0         0           0     ||  c(2)  | |      3/h(2)*[a(3)-a(2)]-3/h(1)*[a(2)-a(1)]      |
+  | ...      ...       ... ...   ...       ...         ...    ||  ...   |=|                       ...                       |
+  |  0        0         0  ... h(n-2) 2[h(n-2)+h(n-1)] h(n-1) || c(n-1) | | 3/h(n-1)*[a(n)-a(n-1)]-3/h(n-2)*[a(n-1)-a(n-2)] |
+  |  0        0         0  ...    0         0           1     ||  c(n)  | |                        0                        |
+  
+ + - Parabolic runout spline: S1''(x1)=2*c(1)=S2''(x2)=2*c(2) ; Sn-1''(xn-1)=2*c(n-1)=Sn''(xn)=2*c(n) + In matrix form: + +
+  |  1       -1         0  ...    0         0           0     ||  c(1)  | |                        0                        |
+  | h(0) 2[h(0)+h(1)] h(1) ...    0         0           0     ||  c(2)  | |      3/h(2)*[a(3)-a(2)]-3/h(1)*[a(2)-a(1)]      |
+  | ...      ...       ... ...   ...       ...         ...    ||  ...   |=|                       ...                       |
+  |  0        0         0  ... h(n-2) 2[h(n-2)+h(n-1)] h(n-1) || c(n-1) | | 3/h(n-1)*[a(n)-a(n-1)]-3/h(n-2)*[a(n-1)-a(n-2)] |
+  |  0        0         0  ...    0        -1           1     ||  c(n)  | |                        0                        |
+  
+ + A is a tridiagonal matrix (a band matrix of bandwidth 3) of size N=n+1. The factorization + algorithms (A=LU) can be simplified considerably because a large number of zeros appear + in regular patterns. The Crout method has been used: + 1) Solve LZ=B + +
+  u(1,2) = A(1,2)/A(1,1)
+  z(1)   = B(1)/l(11)
+ 
+  FOR i=2, ..., N-1
+    l(i,i)   = A(i,i)-A(i,i-1)u(i-1,i)
+    u(i,i+1) = a(i,i+1)/l(i,i)
+    z(i)     = [B(i)-A(i,i-1)z(i-1)]/l(i,i)
+  
+  l(N,N) = A(N,N)-A(N,N-1)u(N-1,N)
+  z(N)   = [B(N)-A(N,N-1)z(N-1)]/l(N,N)
+  
+ + 2) Solve UX=Z + +
+  c(N)=z(N)
+  
+  FOR i=N-1, ..., 1
+    c(i)=z(i)-u(i,i+1)c(i+1) 
+  
+ + c(i) for i=1, ..., n-1 are needed to compute the n-1 polynomials. + b(i) and d(i) are computed as: + - b(i) = [y(i+1)-y(i)]/h(i)-h(i)*[c(i+1)+2*c(i)]/3 + - d(i) = [c(i+1)-c(i)]/[3*h(i)] + Moreover, a(i)=y(i). + + @par Usage + + The x input array must be strictly sorted in ascending order and it must + not contain twice the same value (x(i)x(n)). The coefficients used to compute the y values for + xqx(n) the + coefficients used for the last interval. + */ + /** @addtogroup SplineInterpolate @{