added some docs for ellipj

pull/6/merge
Dsplib 2019-10-13 17:19:50 +03:00
rodzic d732d5709c
commit 7a66faf4e0
15 zmienionych plików z 450 dodań i 138 usunięć

Wyświetl plik

@ -28,23 +28,51 @@ long_line_behaviour=1
long_line_column=72
[files]
current_page=14
FILE_NAME_0=360;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Ccheby_poly1_test.c;0;2
current_page=43
FILE_NAME_0=463;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Ccheby_poly1_test.c;0;2
FILE_NAME_1=507;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Ciir_test.c;0;2
FILE_NAME_2=80;None;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Cbin%5Cgnuplot%5Ciir_test.plt;0;2
FILE_NAME_3=1097;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Cru%5Ccontent%5Cfourier_series%5Cc%5Cfourier_series_dirichlet_ex.c;0;2
FILE_NAME_4=2672;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Cru%5Ccontent%5Cfourier_series%5Cc%5Cfourier_series_pimp_spectrum.c;0;2
FILE_NAME_5=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Cru%5Ccontent%5Cfourier_series%5Cc%5Cfourier_series_rec.c;0;2
FILE_NAME_6=12457;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Carray.c;0;2
FILE_NAME_7=28861;C++;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cblas.h;0;2
FILE_NAME_8=42098;C++;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cinclude%5Cdspl.h;0;2
FILE_NAME_9=12508;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cinclude%5Cdspl.c;0;2
FILE_NAME_6=714;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Carray.c;0;2
FILE_NAME_7=163;C++;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cblas.h;0;2
FILE_NAME_8=56628;C++;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cinclude%5Cdspl.h;0;2
FILE_NAME_9=14081;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cinclude%5Cdspl.c;0;2
FILE_NAME_10=323;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Carray_test.c;0;2
FILE_NAME_11=1012;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cmatrix.c;0;2
FILE_NAME_11=921;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cmatrix.c;0;2
FILE_NAME_12=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Cmatrix_print.c;0;2
FILE_NAME_13=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Cmatrix_transpose.c;0;2
FILE_NAME_14=131;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Cmatrix_mul.c;0;2
FILE_NAME_14=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Cmatrix_mul.c;0;2
FILE_NAME_15=523;Make;0;EUTF-8;1;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5CMakefile.dspl;0;2
FILE_NAME_16=630;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cexamples%5Csrc%5Cmatrix_eig.c;0;2
FILE_NAME_17=47;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Ccheby.c;0;2
FILE_NAME_18=5878;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Ccomplex.c;0;2
FILE_NAME_19=17821;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cconv.c;0;2
FILE_NAME_20=8338;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cdft.c;0;2
FILE_NAME_21=8117;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cellipj.c;0;2
FILE_NAME_22=9969;None;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_dox%5Cru%5Cellipj.dox;0;2
FILE_NAME_23=909;None;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_dox%5Cru%5Carray.dox;0;2
FILE_NAME_24=1074;C++;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cdspl_internal.h;0;2
FILE_NAME_25=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfft.c;0;2
FILE_NAME_26=11081;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfft_subkernel.c;0;2
FILE_NAME_27=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfillarray.c;0;2
FILE_NAME_28=11043;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfilter_an.c;0;2
FILE_NAME_29=872;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfilter_ap.c;0;2
FILE_NAME_30=4563;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfilter_fir.c;0;2
FILE_NAME_31=888;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfilter_ft.c;0;2
FILE_NAME_32=5440;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfilter_iir.c;0;2
FILE_NAME_33=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cfourier_series.c;0;2
FILE_NAME_34=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cgoertzel.c;0;2
FILE_NAME_35=1042;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cinout.c;0;2
FILE_NAME_36=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cmath.c;0;2
FILE_NAME_37=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cpolyval.c;0;2
FILE_NAME_38=3428;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Crandgen.c;0;2
FILE_NAME_39=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cresampling.c;0;2
FILE_NAME_40=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Csignals.c;0;2
FILE_NAME_41=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cstatistic.c;0;2
FILE_NAME_42=0;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Ctrapint.c;0;2
FILE_NAME_43=9115;C;0;EUTF-8;0;1;0;F%3A%5Cdsplib.org%5Clibdspl-2.0%5Cdspl%5Cdspl_src%5Cwin.c;0;2
[build-menu]
NF_00_LB=_Собрать

Wyświetl plik

@ -440,30 +440,6 @@ int DSPL_API flipip_cmplx(complex_t* x, int n)
/*******************************************************************************
* Vector dot product
******************************************************************************/
int DSPL_API vector_dot(double* x, double* y, int n, double* p)
{
int inc = 1;
if(!x || !y || !p)
return ERROR_PTR;
if(n<1)
return ERROR_SIZE;
*p = ddot_(&n, x, &inc, y, &inc);
return RES_OK;
}
/******************************************************************************
\ingroup SPEC_MATH_COMMON_GROUP
\fn int verif(double* x, double* y, size_t n, double eps, double* err)

Wyświetl plik

@ -159,14 +159,14 @@ int DSPL_API asin_cmplx(complex_t* x, int n, complex_t *y)
for(k = 0; k < n; k++)
{
RE(tmp) = 1.0 - CMRE(x[k], x[k]); // 1-x[k]^2
IM(tmp) = - CMIM(x[k], x[k]); // 1-x[k]^2
sqrt_cmplx(&tmp, 1, y+k); // sqrt(1 - x[k]^2)
RE(y[k]) -= IM(x[k]); // j * x[k] + sqrt(1 - x[k]^2)
IM(y[k]) += RE(x[k]); // j * x[k] + sqrt(1 - x[k]^2)
log_cmplx(y+k, 1, &tmp); // log( j * x[k] + sqrt(1 - x[k]^2) )
RE(y[k]) = IM(tmp); // -j * log( j * x[k] + sqrt(1 - x[k]^2) )
IM(y[k]) = -RE(tmp); // -j * log( j * x[k] + sqrt(1 - x[k]^2) )
RE(tmp) = 1.0 - CMRE(x[k], x[k]); /* 1-x[k]^2 */
IM(tmp) = - CMIM(x[k], x[k]); /* 1-x[k]^2 */
sqrt_cmplx(&tmp, 1, y+k); /* sqrt(1 - x[k]^2) */
RE(y[k]) -= IM(x[k]); /* j * x[k] + sqrt(1 - x[k]^2) */
IM(y[k]) += RE(x[k]); /* j * x[k] + sqrt(1 - x[k]^2) */
log_cmplx(y+k, 1, &tmp); /* log( j * x[k] + sqrt(1 - x[k]^2) ) */
RE(y[k]) = IM(tmp); /* -j * log( j * x[k] + sqrt(1 - x[k]^2) ) */
IM(y[k]) = -RE(tmp); /* -j * log( j * x[k] + sqrt(1 - x[k]^2) ) */
}
return RES_OK;
}

Wyświetl plik

@ -27,7 +27,7 @@
#define DSPL_RAND_MOD_X1 2147483647
#define DSPL_RAND_MOD_X2 2145483479
// sqrt(2^31)
/* sqrt(2^31) */
#define FFT_COMPOSITE_MAX 46340
int fft_krn(complex_t* t0, complex_t* t1, fft_t* p, int n, int addr);

Wyświetl plik

@ -27,7 +27,35 @@
/*****************************************************************************
* inverse cd function
\ingroup SPEC_MATH_ELLIP_GROUP
\fn int ellip_acd(double* w, int n, double k, double* u)
\brief Inverse Jacobi elliptic function
\f$ u = \textrm{cd}^{-1}(w, k)\f$ of real vector argument
Function calculates inverse Jacobi elliptic function
\f$ u = \textrm{cd}^{-1}(w, k)\f$ of real vector `w`. \n
\param[in] w Pointer to the argument vector \f$ w \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `w`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] u Pointer to the vector of inverse Jacobi elliptic function
\f$ u = \textrm{cd}^{-1}(w, k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_acd(double* w, int n, double k, double* u)
{
@ -64,7 +92,35 @@ int DSPL_API ellip_acd(double* w, int n, double k, double* u)
/*****************************************************************************
* inverse cd function
\ingroup SPEC_MATH_ELLIP_GROUP
\fn int ellip_acd_cmplx(complex_t* w, int n, double k, complex_t* u)
\brief Inverse Jacobi elliptic function
\f$ u = \textrm{cd}^{-1}(w, k)\f$ of complex vector argument
Function calculates inverse Jacobi elliptic function
\f$ u = \textrm{cd}^{-1}(w, k)\f$ of complex vector `w`. \n
\param[in] w Pointer to the argument vector \f$ w \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `w`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] u Pointer to the vector of inverse Jacobi elliptic function
\f$ u = \textrm{cd}^{-1}(w, k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_acd_cmplx(complex_t* w, int n, double k, complex_t* u)
{
@ -121,7 +177,35 @@ int DSPL_API ellip_acd_cmplx(complex_t* w, int n, double k, complex_t* u)
/*****************************************************************************
* inverse sn function
\ingroup SPEC_MATH_ELLIP_GROUP
\fn int ellip_asn(double* w, int n, double k, double* u)
\brief Inverse Jacobi elliptic function
\f$ u = \textrm{sn}^{-1}(w, k)\f$ of real vector argument
Function calculates inverse Jacobi elliptic function
\f$ u = \textrm{sn}^{-1}(w, k)\f$ of real vector `w`. \n
\param[in] w Pointer to the argument vector \f$ w \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `w`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] u Pointer to the vector of inverse Jacobi elliptic function
\f$ u = \textrm{sn}^{-1}(w, k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_asn(double* w, int n, double k, double* u)
{
@ -158,7 +242,35 @@ int DSPL_API ellip_asn(double* w, int n, double k, double* u)
/*****************************************************************************
* inverse sn function
\ingroup SPEC_MATH_ELLIP_GROUP
\fn int ellip_asn_cmplx(complex_t* w, int n, double k, complex_t* u)
\brief Inverse Jacobi elliptic function
\f$ u = \textrm{sn}^{-1}(w, k)\f$ of complex vector argument
Function calculates inverse Jacobi elliptic function
\f$ u = \textrm{sn}^{-1}(w, k)\f$ of complex vector `w`. \n
\param[in] w Pointer to the argument vector \f$ w \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `w`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] u Pointer to the vector of inverse Jacobi elliptic function
\f$ u = \textrm{sn}^{-1}(w, k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_asn_cmplx(complex_t* w, int n, double k, complex_t* u)
{
@ -213,10 +325,37 @@ int DSPL_API ellip_asn_cmplx(complex_t* w, int n, double k, complex_t* u)
/*****************************************************************************
* Elliptic cd function
\ingroup SPEC_MATH_ELLIP_GROUP
int ellip_cd(double* u, int n, double k, double* y)
\brief Jacobi elliptic function
\f$ y = \textrm{cd}(u K(k), k)\f$ of real vector argument
Function calculates Jacobi elliptic function
\f$ y = \textrm{cd}(u K(k), k)\f$ of real vector `u` and
elliptical modulus `k`. \n
\param[in] u Pointer to the argument vector \f$ u \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `u`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] y Pointer to the vector of Jacobi elliptic function
\f$ y = \textrm{cd}(u K(k), k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_cd(double* u, int n, double k, double* y)
{
@ -249,8 +388,38 @@ int DSPL_API ellip_cd(double* u, int n, double k, double* y)
/*****************************************************************************
* Elliptic cd function
\ingroup SPEC_MATH_ELLIP_GROUP
int ellip_cd_cmplx(complex_t* u, int n, double k, complex_t* y)
\brief Jacobi elliptic function
\f$ y = \textrm{cd}(u K(k), k)\f$ of complex vector argument
Function calculates Jacobi elliptic function
\f$ y = \textrm{cd}(u K(k), k)\f$ of complex vector `u` and
elliptical modulus `k`. \n
\param[in] u Pointer to the argument vector \f$ u \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `u`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] y Pointer to the vector of Jacobi elliptic function
\f$ y = \textrm{cd}(u K(k), k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_cd_cmplx(complex_t* u, int n, double k, complex_t* y)
{
@ -298,7 +467,80 @@ int DSPL_API ellip_cd_cmplx(complex_t* u, int n, double k, complex_t* y)
/*****************************************************************************
* Landen transform
\ingroup SPEC_MATH_ELLIP_GROUP
\fn int ellip_landen(double k, int n, double* y)
\brief Function calculates complete elliptical integral
coefficients \f$ k_i \f$
Complete elliptical integral \f$ K(k) \f$ can be described as:
\f[
K(k) = \frac{\pi}{2} \prod_{i = 1}^{\infty}(1+k_i),
\f]
here \f$ k_i \f$ -- coefficients which calculated
iterative from \f$ k_0 = k\f$:
\f[
k_i =
\left(
\frac{k_{i-1}}
{
1+\sqrt{1-k_{i-1}^2}
}
\right)^2
\f]
This function calculates `n` fist coefficients \f$ k_i \f$, which can
be used for Complete elliptical integral.
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[in] n Number of \f$ k_i \f$ which need to calculate.\n
Parameter `n` is size of output vector `y`.\n
\param[out] y pointer to the real vector which keep \f$ k_i \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` -- successful exit, else \ref ERROR_CODE_GROUP "error code". \n
Example:
\include ellip_landen_test.c
Result:
\verbatim
i k[i]
1 4.625e-01
2 6.009e-02
3 9.042e-04
4 2.044e-07
5 1.044e-14
6 2.727e-29
7 1.859e-58
8 8.640e-117
9 1.866e-233
10 0.000e+00
11 0.000e+00
12 0.000e+00
13 0.000e+00
\endverbatim
\note Complete elliptical integral converges enough fast
if modulus \f$ k<1 \f$. There are 10 to 20 coefficients \f$ k_i \f$
are sufficient for practical applications
to ensure complete elliptic integral precision within EPS.
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_landen(double k, int n, double* y)
{
@ -421,7 +663,36 @@ int DSPL_API ellip_rat(double* w, int n, int ord, double k, double* u)
/*****************************************************************************
* Elliptic sn function
\ingroup SPEC_MATH_ELLIP_GROUP
int ellip_sn(double* u, int n, double k, double* y)
\brief Jacobi elliptic function
\f$ y = \textrm{sn}(u K(k), k)\f$ of real vector argument
Function calculates Jacobi elliptic function
\f$ y = \textrm{sn}(u K(k), k)\f$ of real vector `u` and
elliptical modulus `k`. \n
\param[in] u Pointer to the argument vector \f$ u \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `u`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] y Pointer to the vector of Jacobi elliptic function
\f$ y = \textrm{sn}(u K(k), k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_sn(double* u, int n, double k, double* y)
{
@ -450,8 +721,39 @@ int DSPL_API ellip_sn(double* u, int n, double k, double* y)
}
/*****************************************************************************
* Elliptic sn function
\ingroup SPEC_MATH_ELLIP_GROUP
int ellip_sn_cmplx(complex_t* u, int n, double k, complex_t* y)
\brief Jacobi elliptic function
\f$ y = \textrm{sn}(u K(k), k)\f$ of complex vector argument
Function calculates Jacobi elliptic function
\f$ y = \textrm{sn}(u K(k), k)\f$ of complex vector `u` and
elliptical modulus `k`. \n
\param[in] u Pointer to the argument vector \f$ u \f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\param[in] n Size of vector `u`. \n
\param[in] k Elliptical modulus \f$ k \f$. \n
Elliptical modulus is real parameter,
which values can be from 0 to 1. \n \n
\param[out] y Pointer to the vector of Jacobi elliptic function
\f$ y = \textrm{sn}(u K(k), k)\f$. \n
Vector size is `[n x 1]`. \n
Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
\author Sergey Bakhurin www.dsplib.org
******************************************************************************/
int DSPL_API ellip_sn_cmplx(complex_t* u, int n, double k, complex_t* y)
{

Wyświetl plik

@ -190,10 +190,10 @@ void dft7 (complex_t *x, complex_t* y)
RE(sum[4]) = RE(x[4]) - RE(x[3]);
IM(sum[4]) = IM(x[4]) - IM(x[3]);
// Winograd paper mistake?!
/* Winograd paper mistake?! */
RE(sum[5]) = RE(x[2]) + RE(x[5]);
IM(sum[5]) = IM(x[2]) + IM(x[5]);
// Winograd paper mistake?!
/* Winograd paper mistake?! */
RE(sum[6]) = RE(x[2]) - RE(x[5]);
IM(sum[6]) = IM(x[2]) - IM(x[5]);
@ -330,52 +330,52 @@ void dft16 (complex_t *x, complex_t* y)
dft4(t0+8, t1+8);
dft4(t0+12, t1+12);
//#define DFT16_W1 0.923879532511287
//#define DFT16_W2 0.382683432365090
//#define DFT16_W3 0.707106781186548
/* #define DFT16_W1 0.923879532511287 */
/* #define DFT16_W2 0.382683432365090 */
/* #define DFT16_W3 0.707106781186548 */
// 0.923879532511287 - 0.382683432365090i
/* 0.923879532511287 - 0.382683432365090i */
tmp = RE(t1[5]) * DFT16_W1 + IM(t1[5]) * DFT16_W2;
IM(t1[5]) = -RE(t1[5]) * DFT16_W2 + IM(t1[5]) * DFT16_W1;
RE(t1[5]) = tmp;
// 0.707106781186548 - 0.707106781186547i
/* 0.707106781186548 - 0.707106781186547i */
tmp = ( RE(t1[6]) + IM(t1[6])) * DFT16_W3;
IM(t1[6]) = (-RE(t1[6]) + IM(t1[6])) * DFT16_W3;
RE(t1[6]) = tmp;
// 0.382683432365090 - 0.923879532511287i
/* 0.382683432365090 - 0.923879532511287i */
tmp = RE(t1[7]) * DFT16_W2 + IM(t1[7]) * DFT16_W1;
IM(t1[7]) = -RE(t1[7]) * DFT16_W1 + IM(t1[7]) * DFT16_W2;
RE(t1[7]) = tmp;
// 0.707106781186548 - 0.707106781186547i
/* 0.707106781186548 - 0.707106781186547i */
tmp = ( RE(t1[9]) + IM(t1[9])) * DFT16_W3;
IM(t1[9]) = (-RE(t1[9]) + IM(t1[9])) * DFT16_W3;
RE(t1[9]) = tmp;
// 0.000000000000000 - 1.000000000000000i
/* 0.000000000000000 - 1.000000000000000i */
tmp = RE(t1[10]);
RE(t1[10]) = IM(t1[10]);
IM(t1[10]) = -tmp;
//-0.707106781186547 - 0.707106781186548i
/* -0.707106781186547 - 0.707106781186548i */
tmp = (-RE(t1[11]) + IM(t1[11])) * DFT16_W3;
IM(t1[11]) = (-RE(t1[11]) - IM(t1[11])) * DFT16_W3;
RE(t1[11]) = tmp;
// 0.382683432365090 - 0.923879532511287i
/* 0.382683432365090 - 0.923879532511287i */
tmp = RE(t1[13]) * DFT16_W2 + IM(t1[13]) * DFT16_W1;
IM(t1[13]) = -RE(t1[13]) * DFT16_W1 + IM(t1[13]) * DFT16_W2;
RE(t1[13]) = tmp;
//-0.707106781186547 - 0.707106781186548i
/* -0.707106781186547 - 0.707106781186548i */
tmp = (-RE(t1[14]) + IM(t1[14])) * DFT16_W3;
IM(t1[14]) = (-RE(t1[14]) - IM(t1[14])) * DFT16_W3;
RE(t1[14]) = tmp;
//-0.923879532511287 + 0.382683432365090i
/* -0.923879532511287 + 0.382683432365090i */
tmp = -RE(t1[15]) * DFT16_W1 - IM(t1[15]) * DFT16_W2;
IM(t1[15]) = RE(t1[15]) * DFT16_W2 - IM(t1[15]) * DFT16_W1;
RE(t1[15]) = tmp;

Wyświetl plik

@ -468,7 +468,7 @@ int DSPL_API freqz(double* b, double* a, int ord, double* w,
if(a)
{
// IIR filter if a != NULL
/* IIR filter if a != NULL */
ac = (complex_t*) malloc((ord+1) * sizeof(complex_t));
res = re2cmplx(a, ord+1, ac);
if( res!=RES_OK )
@ -496,7 +496,7 @@ int DSPL_API freqz(double* b, double* a, int ord, double* w,
}
else
{
// FIR filter if a == NULL
/* FIR filter if a == NULL */
for(k = 0; k < n; k++)
{
RE(jw) = cos(w[k]);

Wyświetl plik

@ -82,72 +82,72 @@ int DSPL_API fir_linphase(int ord, double w0, double w1, int filter_type,
switch(filter_type & DSPL_FILTER_TYPE_MASK)
{
// Lowpass FIR coefficients calculation
/* Lowpass FIR coefficients calculation */
case DSPL_FILTER_LPF:
err = fir_linphase_lpf(ord, w0, wintype, winparam, h);
break;
// Highpass FIR coefficients calculation
/* Highpass FIR coefficients calculation */
case DSPL_FILTER_HPF:
err = fir_linphase_lpf(ord, 1.0-w0, wintype, winparam, h);
if(err == RES_OK)
{
// LPF filter frequency inversion
/* LPF filter frequency inversion */
for(n = 0; n < ord+1; n+=2)
h[n] = -h[n];
}
break;
// Bandpass FIR coefficients calculation
/* Bandpass FIR coefficients calculation */
case DSPL_FILTER_BPASS:
if(w1 < w0)
{
err = ERROR_FILTER_WS;
break;
}
wc = (w0 + w1) * 0.5; // central frequency
b = w1 - w0; // bandwidth
wc = (w0 + w1) * 0.5; /* central frequency */
b = w1 - w0; /* bandwidth */
err = fir_linphase_lpf(ord, b*0.5, wintype, winparam, h);
if(err == RES_OK)
{
// LPF frequency shifting to the central frequency
/* LPF frequency shifting to the central frequency */
del = 0.5 * (double)ord;
for(n = 0; n < ord+1; n++)
h[n] *= 2.0 * cos(M_PI * ((double)n - del) * wc);
}
break;
// BandStop FIR coefficients calculation
// ATTENTION! Bandstop filter must be even order only!
/* BandStop FIR coefficients calculation */
/* ATTENTION! Bandstop filter must be even order only! */
case DSPL_FILTER_BSTOP:
{
double *h0 = NULL;
// check filter order. Return error if order is odd.
/* check filter order. Return error if order is odd. */
if(ord%2)
return ERROR_FILTER_ORD;
// check frequency (w1 must be higher than w0)
/* check frequency (w1 must be higher than w0) */
if(w1 < w0)
{
err = ERROR_FILTER_WS;
break;
}
// temp coeff vector
/* temp coeff vector */
h0 = (double*)malloc((ord+1) * sizeof(double));
// calculate LPF
/* calculate LPF */
err = fir_linphase(ord, w0, 0.0, DSPL_FILTER_LPF, wintype, winparam, h0);
if(err!=RES_OK)
{
free(h0);
return err;
}
// calculate HPF
/* calculate HPF */
err = fir_linphase(ord, w1, 0.0, DSPL_FILTER_HPF, wintype, winparam, h);
if(err==RES_OK)
{
// Bandstop filter is sum of lowpass and highpass filters
/* Bandstop filter is sum of lowpass and highpass filters */
for(n = 0; n < ord+1; n++)
h[n] += h0[n];
}

Wyświetl plik

@ -128,7 +128,7 @@ int DSPL_API iir(double rp, double rs, int ord, double w0, double w1,
if(err != RES_OK)
goto error_proc;
//frequency transformation
/* frequency transformation */
wa0 = tan(w0 * M_PI * 0.5);
wa1 = tan(w1 * M_PI * 0.5);
@ -150,7 +150,7 @@ int DSPL_API iir(double rp, double rs, int ord, double w0, double w1,
break;
case DSPL_FILTER_BSTOP:
// need frequency transform ws -> 1 rad/s
/* need frequency transform ws -> 1 rad/s */
ws = filter_ws1(ord_ap, rp, rs, type);
err = low2low( bs, as, ord_ap, 1.0, 1.0 / ws, bs, as);

Wyświetl plik

@ -31,9 +31,11 @@ Print DSPL info
void DSPL_API dspl_info()
{
printf("\n\n D S P L - 2.0\n");
printf(" version 2.19.06.18\n");
printf(" version 2.19.10.13\n");
printf("\n Copyright (C) 2015-2019\n");
printf(" Sergey Bakhurin www.dsplib.org\n\n");
printf(" Sergey Bakhurin www.dsplib.org\n");
printf(" ---------------------------------------------
printf(" BLAS and LAPACK ver.: 3.8.0 www.netlib.org\n")
}

Wyświetl plik

@ -418,3 +418,24 @@ int DSPL_API matrix_transpose_hermite(complex_t* a, int n, int m, complex_t* b)
return RES_OK;
}
/*******************************************************************************
* Vector dot product
******************************************************************************/
int DSPL_API vector_dot(double* x, double* y, int n, double* p)
{
int inc = 1;
if(!x || !y || !p)
return ERROR_PTR;
if(n<1)
return ERROR_SIZE;
*p = ddot_(&n, x, &inc, y, &inc);
return RES_OK;
}

Wyświetl plik

@ -33,7 +33,7 @@
void DSPL_API random_init(random_t* prnd)
{
srand(time(NULL));
// MRG32k3a init
/* MRG32k3a init */
prnd->mrg32k3a_x[0] = prnd->mrg32k3a_x[1] = 1.0;
prnd->mrg32k3a_y[0] = prnd->mrg32k3a_y[1] = prnd->mrg32k3a_y[2] = 1.0;
prnd->mrg32k3a_x[2] = rand();
@ -93,36 +93,19 @@ Uniform random numbers generator
*******************************************************************************/
int DSPL_API randu(double* x, int n, random_t* prnd)
{
/*int k,m;
unsigned int x1[4], x2[4], y;
if(!x)
return ERROR_PTR;
if(n<1)
return ERROR_SIZE;
x1[1] = rand();
x2[1] = rand();
x1[2] = rand();
x2[2] = rand();
x1[3] = rand();
x2[3] = rand();
for(k = 0; k<n; k++)
{
x1[0] = (63308 * x1[2] - 183326*x1[3]) % DSPL_RAND_MOD_X1;
x2[0] = (86098 * x2[1] - 539608*x2[3]) % DSPL_RAND_MOD_X2;
y = (x1[0] - x2[0]) % DSPL_RAND_MOD_X1;
for(m = 3; m > 0; m--)
{
x1[m] = x1[m-1];
x2[m] = x2[m-1];
}
x[k] = (double)y/DSPL_RAND_MOD_X1;
}
*/
return randu_mrg32k3a(x, n, prnd);
if(prnd)
return randu_mrg32k3a(x, n, prnd);
else
{
if(!x)
return ERROR_PTR;
if(n<1)
return ERROR_SIZE;
int i;
for(i = 0; i < n; i++)
x[n] = (double)rand()/RAND_MAX;
}
return RES_OK;
}

Wyświetl plik

@ -270,7 +270,7 @@ int win_cheby(double *w, int n, double param)
r1 = pow(10, param/20);
x0 = cosh((1.0/(double)(n-1)) * acosh(r1));
// check window length even or odd
/* check window length even or odd */
if(n%2==0)
{
dz = 0.5;
@ -298,12 +298,12 @@ int win_cheby(double *w, int n, double param)
w[k] = r1 + 2.0 * sum;
w[n-1-k] = w[k];
// max value calculation
/* max value calculation */
if(w[k]>wmax)
wmax=w[k];
}
// normalization
/* normalization */
for(k=0; k < n; k++)
w[k] /= wmax;
@ -388,7 +388,7 @@ int win_flat_top(double *w, int n, int win_type)
/******************************************************************************
Gaussian window function
Gaussian window function
******************************************************************************/
int win_gaussian(double *w, int n, int win_type, double alpha)
{

Wyświetl plik

@ -22,11 +22,11 @@
#ifdef WIN_OS
#include <windows.h>
#endif //WIN_OS
#endif /* WIN_OS */
#ifdef LINUX_OS
#include <dlfcn.h>
#endif //LINUX_OS
#endif /* LINUX_OS */
#include <stdio.h>
@ -157,7 +157,7 @@ p_writetxt_cmplx_im writetxt_cmplx_im ;
p_writetxt_cmplx_re writetxt_cmplx_re ;
#endif //BUILD_LIB
#endif /* BUILD_LIB */
@ -192,20 +192,20 @@ void* dspl_load()
printf("libdspl.dll loading ERROR!\n");
return NULL;
}
#endif //WIN_OS
#endif /* WIN_OS */
#ifdef LINUX_OS
char* error;
void *handle;
// open the *.so
/* open the *.so */
handle = dlopen ("./libdspl.so", RTLD_LAZY);
if (!handle)
{
printf("libdspl.so loading ERROR!\n");
return NULL;
}
#endif //LINUX_OS
#endif /* LINUX_OS */
LOAD_FUNC(acos_cmplx);
LOAD_FUNC(asin_cmplx);
@ -332,7 +332,7 @@ void* dspl_load()
if(handle)
FreeLibrary(handle);
return NULL;
#endif //WIN_OS
#endif /* WIN_OS */
#ifdef LINUX_OS
@ -342,7 +342,7 @@ void* dspl_load()
if(handle)
dlclose(handle);
return NULL;
#endif //LINUX_OS
#endif /* LINUX_OS */
}
@ -355,11 +355,11 @@ void dspl_free(void* handle)
{
#ifdef WIN_OS
FreeLibrary((HINSTANCE)handle);
#endif //WIN_OS
#endif /* WIN_OS */
#ifdef LINUX_OS
dlclose(handle);
#endif //LINUX_OS
#endif /* LINUX_OS */
}

Wyświetl plik

@ -215,15 +215,15 @@ typedef struct
#ifdef BUILD_LIB
// Declare DSPL_API for Windows OS
/* Declare DSPL_API for Windows OS */
#ifdef WIN_OS
#define DSPL_API __declspec(dllexport)
#endif // WIN_OS
// Declare DSPL_API for LINUX OS
#endif /* WIN_OS */
/* Declare DSPL_API for LINUX OS */
#ifdef LINUX_OS
#define DSPL_API
#endif //LINUX_OS
#endif //BUILD_DLL
#endif /* LINUX_OS */
#endif /* BUILD_DLL */
#define COMMA ,
@ -918,5 +918,5 @@ void dspl_free(void* handle);
#endif //DSPL_H
#endif /* DSPL_H */