From 83f8106416ddbd2380560e631163cb4de3553a39 Mon Sep 17 00:00:00 2001 From: Dsplib Date: Wed, 5 Jun 2024 17:13:21 +0300 Subject: [PATCH] Changes to be committed: modified: _release/dspl.c modified: _release/dspl.h modified: dspl/src/array/find_nearest.c modified: dspl/src/array/sum.c modified: dspl/src/array/sum_sqr.c modified: dspl/src/array/verif_cmplx.c modified: dspl/src/dft/fourier_series_rec.c --- _release/dspl.c | 4 ++ _release/dspl.h | 31 ++++++++++++ dspl/src/array/find_nearest.c | 79 ++++++++++++++++++++++++++++++- dspl/src/array/sum.c | 42 ++++++++++++++-- dspl/src/array/sum_sqr.c | 67 ++++++++++++++++++++++++++ dspl/src/array/verif_cmplx.c | 4 -- dspl/src/dft/fourier_series_rec.c | 9 ---- 7 files changed, 217 insertions(+), 19 deletions(-) diff --git a/_release/dspl.c b/_release/dspl.c index 6daddf3..6a83de4 100644 --- a/_release/dspl.c +++ b/_release/dspl.c @@ -55,6 +55,8 @@ p_cheby2_ap_wp1 cheby2_ap_wp1 ; p_cheby2_ap_zp cheby2_ap_zp ; p_cmplx2re cmplx2re ; p_concat concat ; +p_contour2d contour2d ; +p_contour2d_free contour2d_free ; p_conv conv ; p_conv_cmplx conv_cmplx ; p_conv_fft conv_fft ; @@ -274,6 +276,8 @@ void* dspl_load() LOAD_FUNC(cheby2_ap_zp); LOAD_FUNC(cmplx2re); LOAD_FUNC(concat); + LOAD_FUNC(contour2d); + LOAD_FUNC(contour2d_free); LOAD_FUNC(conv); LOAD_FUNC(conv_cmplx); LOAD_FUNC(conv_fft); diff --git a/_release/dspl.h b/_release/dspl.h index 62e4d37..6e21746 100644 --- a/_release/dspl.h +++ b/_release/dspl.h @@ -87,6 +87,27 @@ typedef double complex_t[2]; +/* Point 2D point2d_t[0] - x + point2d_t[1] - y +*/ +typedef double point2d_t[2]; + +typedef struct +{ + point2d_t* points; /* line points array */ + int npoints; /* number of points */ +}line2d_t; + +typedef struct +{ + line2d_t* lines; /* lines array */ + int nlines; /* number of lines */ + double level; /* contour level */ +}contour2d_t; + + + + #ifdef DOXYGEN_ENGLISH /*! **************************************************************************** \ingroup DFT_GROUP @@ -836,6 +857,16 @@ DECLARE_FUNC(int, concat, void* COMMA size_t COMMA void*); /*----------------------------------------------------------------------------*/ +DECLARE_FUNC(int, contour2d, double* z + COMMA double* x + COMMA double* y + COMMA int n + COMMA int m + COMMA double lev + COMMA contour2d_t* c); +/*----------------------------------------------------------------------------*/ +DECLARE_FUNC(void, contour2d_free, contour2d_t* c); +/*----------------------------------------------------------------------------*/ DECLARE_FUNC(int, conv, double* COMMA int COMMA double* diff --git a/dspl/src/array/find_nearest.c b/dspl/src/array/find_nearest.c index ba65269..6aa0b58 100644 --- a/dspl/src/array/find_nearest.c +++ b/dspl/src/array/find_nearest.c @@ -26,7 +26,84 @@ -int DSPL_API find_nearest(double* x, int n, double val, int *idx, double* dist) +#ifdef DOXYGEN_ENGLISH +/*! **************************************************************************** +\ingroup ARRAY_GROUP +\brief Find nearest to `val` vector `x` element. + +\param[in] x +Pointer to the vector `x`. \n +Vector size is `[n x 1]`. \n +\n + +\param[in] n +Size of vector `x`. \n +\n + +\param[in] val \n +Value nearest to which vector `x` element need to find. + +\param[out] idx +Pointer to the variable type `int` which will return index of the +nearest to `val` vector `x` element. \n +Pointer can be `NULL`. +Index doesn't return in this case. +\n + +\param[out] dist +Pointer to the variable type `double` which will return +distance from the nearest vector `x` element to the `val` . \n +Pointer can be `NULL`. +Distance doesn't return in this case. +\n + +\return +`RES_OK` if function calculated successfully. \n +Else \ref ERROR_CODE_GROUP "code error". + +\author Sergey Bakhurin www.dsplib.org +***************************************************************************** */ +#endif +#ifdef DOXYGEN_RUSSIAN +/*! **************************************************************************** +\ingroup ARRAY_GROUP +\brief Найти ближайший `val` элемент массива `x`. + +\param[in] x +Указатель на вещественный вектор `x`. \n +Размер вектора `[n x 1]`. \n +\n + +\param[in] n +Размер вектора `x`. \n +\n + +\param[in] val \n +Значение к которому ищется ближайший элемент массива. + +\param[out] idx +Указатель на переменную типа `int` в которую будет записан +индекс ближайшего к `val` элемента массива `x`. \n +Указатель может быть `NULL`. +Индекс в этом случае не возвращается. +\n + +\param[out] dist +Указатель на переменную типа `double` в которую будет записано +расстояние от ближайшего элемента массива `x` до `val` . \n +Указатель может быть `NULL`. +Значение расстояние от ближайшего элемента массива `x` до `val` +в этом случае не возвращается. +\n + +\return +`RES_OK` если функция выполнена успешно. \n +В противном случае \ref ERROR_CODE_GROUP "код ошибки". + +\author Бахурин Сергей www.dsplib.org +***************************************************************************** */ +#endif +int DSPL_API find_nearest(double* x, int n, double val, int* idx, double* dist) { double mind, dv; int iv, i; diff --git a/dspl/src/array/sum.c b/dspl/src/array/sum.c index 9daec13..9ee17a6 100644 --- a/dspl/src/array/sum.c +++ b/dspl/src/array/sum.c @@ -18,17 +18,48 @@ * along with Foobar. If not, see . */ - #include #include #include #include "dspl.h" - - #ifdef DOXYGEN_ENGLISH /*! **************************************************************************** \ingroup ARRAY_GROUP +\brief Sum of vector elements: + +\f$ s =\sum_{m = 0}^{n-1} x_n \f$ + +\param[in] x +Pointer to the real vector `x`. \n +Vector size is `[n x 1]`. \n +\n + +\param[in] n +Size of vector `x`. \n +\n + +\param[out] s +Pointer to the output variable. \n +This address will be written the sum of vector elements. +\n + +\return +`RES_OK` if function returns successfully. \n +Else \ref ERROR_CODE_GROUP "error code". + +Example: +\code{.cpp} +double y[5] = {0.0, 1.0, 2.0, 3.0, 4.0}; +double s; +sum(y, 5, &s); +printf("s = %6.1f% \n", s); +\endcode + \n +Result: +\verbatim + s = 10 +\endverbatim \author Sergey Bakhurin www.dsplib.org ***************************************************************************** */ @@ -38,6 +69,8 @@ \ingroup ARRAY_GROUP \brief Расчет суммы элеметов массива +\f$ s =\sum_{m = 0}^{n-1} x_n \f$ + \param[in] x Указатель на вещественный вектор `x`. \n Размер вектора `[n x 1]`. \n @@ -52,7 +85,6 @@ По данному указателю будет записан результат работы функции. \n - \return `RES_OK` если функция выполнена успешно. \n В противном случае \ref ERROR_CODE_GROUP "код ошибки". @@ -86,4 +118,4 @@ int DSPL_API sum(double* x, int n, double* s) z += x[i]; *s = z; return RES_OK; -} \ No newline at end of file +} diff --git a/dspl/src/array/sum_sqr.c b/dspl/src/array/sum_sqr.c index dd8238e..d6b2d42 100644 --- a/dspl/src/array/sum_sqr.c +++ b/dspl/src/array/sum_sqr.c @@ -28,14 +28,81 @@ #ifdef DOXYGEN_ENGLISH /*! **************************************************************************** \ingroup ARRAY_GROUP + +\brief Sum of vector elements: +\f$ s =\sum_{m = 0}^{n-1} x_n^2 \f$ + +\param[in] x +Pointer to the real vector `x`. \n +Vector size is `[n x 1]`. \n +\n + +\param[in] n +Size of vector `x`. \n +\n + +\param[out] s +Pointer to the output variable. \n +This address will be written the sum of squares of the vector elements. +\n + +\return +`RES_OK` if function returns successfully. \n +Else \ref ERROR_CODE_GROUP "error code". + +Example: +\code{.cpp} +double y[5] = {0.0, 1.0, 2.0, 3.0, 4.0}; +double s; +sum_sqr(y, 5, &s); +printf("s = %6.1f% \n", s); +\endcode + \n +Result: +\verbatim + s = 30.0 +\endverbatim \author Sergey Bakhurin www.dsplib.org ***************************************************************************** */ #endif #ifdef DOXYGEN_RUSSIAN /*! **************************************************************************** \ingroup ARRAY_GROUP +\brief Расчет суммы элеметов массива +\f$ s =\sum_{m = 0}^{n-1} x_n^2 \f$ + +\param[in] x +Указатель на вещественный вектор `x`. \n +Размер вектора `[n x 1]`. \n +\n + +\param[in] n +Размер вектора `x`. \n +\n + +\param[out] s +Указатель на переменную суммы квадратов элементов массива. \n +По данному указателю будет записан результат работы функции. +\n + +\return +`RES_OK` если функция выполнена успешно. \n +В противном случае \ref ERROR_CODE_GROUP "код ошибки". + +Пример: +\code{.cpp} +double y[5] = {0.0, 1.0, 2.0, 3.0, 4.0}; +double s; +sum_sqr(y, 5, &s); +printf("s = %6.1f% \n", s); +\endcode + \n +Результат выполнения: +\verbatim + s = 30.0 +\endverbatim \author Бахурин Сергей www.dsplib.org ***************************************************************************** */ #endif diff --git a/dspl/src/array/verif_cmplx.c b/dspl/src/array/verif_cmplx.c index 21becb8..e383a1e 100644 --- a/dspl/src/array/verif_cmplx.c +++ b/dspl/src/array/verif_cmplx.c @@ -18,16 +18,12 @@ * along with Foobar. If not, see . */ - #include #include #include #include "dspl.h" - - - #ifdef DOXYGEN_ENGLISH /*! **************************************************************************** \ingroup ARRAY_GROUP diff --git a/dspl/src/dft/fourier_series_rec.c b/dspl/src/dft/fourier_series_rec.c index 23cb5bd..3f8ac97 100644 --- a/dspl/src/dft/fourier_series_rec.c +++ b/dspl/src/dft/fourier_series_rec.c @@ -25,15 +25,6 @@ #include "dspl.h" - - - - - - - - - #ifdef DOXYGEN_ENGLISH /*! **************************************************************************** \ingroup DFT_GROUP