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
pull/9/head
Dsplib 2024-06-05 17:13:21 +03:00
rodzic 5ab7fffcad
commit 83f8106416
7 zmienionych plików z 217 dodań i 19 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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*

Wyświetl plik

@ -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;

Wyświetl plik

@ -18,17 +18,48 @@
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
}
}

Wyświetl plik

@ -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

Wyświetl plik

@ -18,16 +18,12 @@
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dspl.h"
#ifdef DOXYGEN_ENGLISH
/*! ****************************************************************************
\ingroup ARRAY_GROUP

Wyświetl plik

@ -25,15 +25,6 @@
#include "dspl.h"
#ifdef DOXYGEN_ENGLISH
/*! ****************************************************************************
\ingroup DFT_GROUP