added examples for elliptic functions

pull/6/merge
Sergey Bakhurin 2020-10-02 23:20:49 +03:00
rodzic ac495581f5
commit b4b4fd82e0
3 zmienionych plików z 142 dodań i 3 usunięć

Wyświetl plik

@ -529,6 +529,15 @@ Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
Example
\include ellip_cd_test.c
The program calculates two periods of the \f$ y = \textrm{cd}(u K(k), k)\f$
function for different modulus values `k = 0`, `k= 0.9` и `k = 0.99`.
Also program draws the plot of calculated elliptic functions.
\image html ellip_cd.png
\author Sergey Bakhurin www.dsplib.org
***************************************************************************** */
#endif
@ -569,9 +578,17 @@ Memory must be allocated. \n \n
`RES_OK` Расчет произведен успешно. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n
\author
Бахурин Сергей
www.dsplib.org
Пример представлен в следующем листинге:
\include ellip_cd_test.c
Программа рассчитывает два периода эллиптической функции
\f$ y = \textrm{cd}(u K(k), k)\f$ для `k = 0`, `k= 0.9` и `k = 0.99`,
а также выводит графики данных функций
\image html ellip_cd.png
\author Бахурин Сергей www.dsplib.org
***************************************************************************** */
#endif
int DSPL_API ellip_cd(double* u, int n, double k, double* y)
@ -1028,6 +1045,15 @@ Memory must be allocated. \n \n
\return
`RES_OK` successful exit, else \ref ERROR_CODE_GROUP "error code". \n
Example
\include ellip_sn_test.c
The program calculates two periods of the \f$ y = \textrm{sn}(u K(k), k)\f$
function for different modulus values `k = 0`, `k= 0.9` и `k = 0.99`.
Also program draws the plot of calculated elliptic functions.
\image html ellip_sn.png
\author Sergey Bakhurin www.dsplib.org
**************************************************************************** */
#endif
@ -1068,6 +1094,17 @@ Memory must be allocated. \n \n
`RES_OK` Расчет произведен успешно. \n
В противном случае \ref ERROR_CODE_GROUP "код ошибки". \n
Пример представлен в следующем листинге:
\include ellip_sn_test.c
Программа рассчитывает два периода эллиптической функции
\f$ y = \textrm{sn}(u K(k), k)\f$ для `k = 0`, `k= 0.9` и `k = 0.99`,
а также выводит графики данных функций
\image html ellip_sn.png
\author Бахурин Сергей www.dsplib.org
***************************************************************************** */
#endif

Wyświetl plik

@ -0,0 +1,52 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dspl.h"
#define N 500
int main(int argc, char* argv[])
{
void* hdspl; /* DSPL handle */
void* hplot; /* GNUPLOT handle */
hdspl = dspl_load(); /* Load DSPL function */
double u[N];
double y[N];
/* fill u*K(k) vector from -4 to 4.
We will have 2 periods sn(uK(k), k) */
linspace(-4.0, 4.0, N, DSPL_PERIODIC, u);
/* sn(uK(0), 0) */
ellip_cd(u, N, 0.0, y);
writetxt(u,y,N,"dat/ellip_cd_0p00.txt");
/* sn(uK(0.9), 0.9) */
ellip_cd(u, N, 0.9, y);
writetxt(u,y,N,"dat/ellip_cd_0p90.txt");
/* sn(uK(0.99), 0.99) */
ellip_cd(u, N, 0.99, y);
writetxt(u,y,N,"dat/ellip_cd_0p99.txt");
/* plotting by GNUPLOT */
gnuplot_create(argc, argv, 560, 360, "img/ellip_cd.png", &hplot);
gnuplot_cmd(hplot, "set grid");
gnuplot_cmd(hplot, "set xlabel 'u'");
gnuplot_cmd(hplot, "set ylabel 'y = cd(u, k)'");
gnuplot_cmd(hplot, "set yrange [-1.2:1.2]");
gnuplot_cmd(hplot, "plot 'dat/ellip_cd_0p00.txt' w l,\\");
gnuplot_cmd(hplot, " 'dat/ellip_cd_0p90.txt' w l,\\");
gnuplot_cmd(hplot, " 'dat/ellip_cd_0p99.txt' w l");
gnuplot_close(hplot);
/* free dspl handle */
dspl_free(hdspl);
return RES_OK;
}

Wyświetl plik

@ -0,0 +1,50 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dspl.h"
#define N 500
int main(int argc, char* argv[])
{
void* hdspl; /* DSPL handle */
void* hplot; /* GNUPLOT handle */
hdspl = dspl_load(); /* Load DSPL function */
double u[N];
double y[N];
/* fill u*K(k) vector from -4 to 4.
We will have 2 periods sn(uK(k), k) */
linspace(-4.0, 4.0, N, DSPL_PERIODIC, u);
/* sn(uK(0), 0) */
ellip_sn(u, N, 0.0, y);
writetxt(u,y,N,"dat/ellip_sn_0p00.txt");
/* sn(uK(0.9), 0.9) */
ellip_sn(u, N, 0.9, y);
writetxt(u,y,N,"dat/ellip_sn_0p90.txt");
/* sn(uK(0.99), 0.99) */
ellip_sn(u, N, 0.99, y);
writetxt(u,y,N,"dat/ellip_sn_0p99.txt");
/* plotting by GNUPLOT */
gnuplot_create(argc, argv, 560, 360, "img/ellip_sn.png", &hplot);
gnuplot_cmd(hplot, "set grid");
gnuplot_cmd(hplot, "set xlabel 'u'");
gnuplot_cmd(hplot, "set ylabel 'y = sn(u, k)'");
gnuplot_cmd(hplot, "set yrange [-1.2:1.2]");
gnuplot_cmd(hplot, "plot 'dat/ellip_sn_0p00.txt' w l,\\");
gnuplot_cmd(hplot, " 'dat/ellip_sn_0p90.txt' w l,\\");
gnuplot_cmd(hplot, " 'dat/ellip_sn_0p99.txt' w l");
gnuplot_close(hplot);
/* free dspl handle */
dspl_free(hdspl);
return RES_OK;
}