libdspl-2.0
Digital Signal Processing Algorithm Library
Elliptic Jacobi functions of the real and complex arguments.

Functions

int DSPL_API ellip_acd (double *w, int n, double k, double *u)
 Inverse Jacobi elliptic function \( u = \textrm{cd}^{-1}(w, k)\) of the real vector argument. More...
 
int DSPL_API ellip_acd_cmplx (complex_t *w, int n, double k, complex_t *u)
 Inverse Jacobi elliptic function \( u = \textrm{cd}^{-1}(w, k)\) of complex vector argument. More...
 
int DSPL_API ellip_asn (double *w, int n, double k, double *u)
 Inverse Jacobi elliptic function \( u = \textrm{sn}^{-1}(w, k)\) of real vector argument. More...
 
int DSPL_API ellip_asn_cmplx (complex_t *w, int n, double k, complex_t *u)
 Inverse Jacobi elliptic function \( u = \textrm{sn}^{-1}(w, k)\) of complex vector argument. More...
 
int DSPL_API ellip_cd (double *u, int n, double k, double *y)
 Jacobi elliptic function \( y = \textrm{cd}(u K(k), k)\) of real vector argument. More...
 
int DSPL_API ellip_cd_cmplx (complex_t *u, int n, double k, complex_t *y)
 Jacobi elliptic function \( y = \textrm{cd}(u K(k), k)\) of complex vector argument. More...
 
int DSPL_API ellip_landen (double k, int n, double *y)
 Function calculates complete elliptical integral coefficients \( k_i \). More...
 
int DSPL_API ellip_sn (double *u, int n, double k, double *y)
 Jacobi elliptic function \( y = \textrm{sn}(u K(k), k)\) of real vector argument. More...
 
int DSPL_API ellip_sn_cmplx (complex_t *u, int n, double k, complex_t *y)
 Jacobi elliptic function \( y = \textrm{sn}(u K(k), k)\) of complex vector argument. More...
 

Detailed Description

Function Documentation

◆ ellip_acd()

int ellip_acd ( double *  w,
int  n,
double  k,
double *  u 
)

Inverse Jacobi elliptic function \( u = \textrm{cd}^{-1}(w, k)\) of the real vector argument.



Function calculates inverse Jacobi elliptic function
\( u = \textrm{cd}^{-1}(w, k)\) of the real vector w.

Parameters
[in]wPointer to the argument vector \( w \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector w.
[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]uPointer to the vector of inverse Jacobi elliptic function \( u = \textrm{cd}^{-1}(w, k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 103 of file ellipj.c.

◆ ellip_acd_cmplx()

int ellip_acd_cmplx ( complex_t w,
int  n,
double  k,
complex_t u 
)

Inverse Jacobi elliptic function \( u = \textrm{cd}^{-1}(w, k)\) of complex vector argument.


Function calculates inverse Jacobi elliptic function
\( u = \textrm{cd}^{-1}(w, k)\) of complex vector w.

Parameters
[in]wPointer to the argument vector \( w \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector w.

[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]uPointer to the vector of inverse Jacobi elliptic function \( u = \textrm{cd}^{-1}(w, k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 211 of file ellipj.c.

◆ ellip_asn()

int ellip_asn ( double *  w,
int  n,
double  k,
double *  u 
)

Inverse Jacobi elliptic function \( u = \textrm{sn}^{-1}(w, k)\) of real vector argument.



Function calculates inverse Jacobi elliptic function
\( u = \textrm{sn}^{-1}(w, k)\) of real vector w.

Parameters
[in]wPointer to the argument vector \( w \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector w.
[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]uPointer to the vector of inverse Jacobi elliptic function \( u = \textrm{sn}^{-1}(w, k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 339 of file ellipj.c.

◆ ellip_asn_cmplx()

int ellip_asn_cmplx ( complex_t w,
int  n,
double  k,
complex_t u 
)

Inverse Jacobi elliptic function \( u = \textrm{sn}^{-1}(w, k)\) of complex vector argument.


Function calculates inverse Jacobi elliptic function
\( u = \textrm{sn}^{-1}(w, k)\) of complex vector w.

Parameters
[in]wPointer to the argument vector \( w \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector w.
[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]uPointer to the vector of inverse Jacobi elliptic function \( u = \textrm{sn}^{-1}(w, k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 447 of file ellipj.c.

Referenced by ellip_ap_zp().

◆ ellip_cd()

int ellip_cd ( double *  u,
int  n,
double  k,
double *  y 
)

Jacobi elliptic function \( y = \textrm{cd}(u K(k), k)\) of real vector argument.


Function calculates Jacobi elliptic function
\( y = \textrm{cd}(u K(k), k)\) of real vector u and elliptical modulus k.

Parameters
[in]uPointer to the argument vector \( u \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector u.
[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]yPointer to the vector of Jacobi elliptic function \( y = \textrm{cd}(u K(k), k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Example
#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;
}

The program calculates two periods of the \( y = \textrm{cd}(u K(k), k)\)
function for different modulus values k = 0, k= 0.9 и k = 0.99. Also program draws the plot of calculated elliptic functions.

Author
Sergey Bakhurin www.dsplib.org

Definition at line 594 of file ellipj.c.

Referenced by ellip_ap_zp().

◆ ellip_cd_cmplx()

int ellip_cd_cmplx ( complex_t u,
int  n,
double  k,
complex_t y 
)

Jacobi elliptic function \( y = \textrm{cd}(u K(k), k)\) of complex vector argument.


Function calculates Jacobi elliptic function
\( y = \textrm{cd}(u K(k), k)\) of complex vector u and elliptical modulus k.

Parameters
[in]uPointer to the argument vector \( u \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector u.
[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]yPointer to the vector of Jacobi elliptic function \( y = \textrm{cd}(u K(k), k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 701 of file ellipj.c.

Referenced by ellip_ap_zp().

◆ ellip_landen()

int ellip_landen ( double  k,
int  n,
double *  y 
)

Function calculates complete elliptical integral coefficients \( k_i \).


Complete elliptical integral \( K(k) \) can be described as:

\[ K(k) = \frac{\pi}{2} \prod_{i = 1}^{\infty}(1+k_i), \]

here \( k_i \) – coefficients which calculated iterative from \( k_0 = k\):

\[ k_i = \left( \frac{k_{i-1}}{1+\sqrt{1-k_{i-1}^2}}\right)^2 \]

This function calculates n fist coefficients \( k_i \), which can be used for Complete elliptical integral.

Parameters
[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[in]nNumber of \( k_i \) which need to calculate.
Parameter n is size of output vector y.
[out]ypointer to the real vector which keep \( k_i \).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK – successful exit, else error code.
Example:
#include <stdio.h>
#include <stdlib.h>
#include "dspl.h"
#define N 14
int main()
{
void* handle; /* DSPL handle */
handle = dspl_load(); /* Load DSPL function */
double k[N];
int i, err;
err = ellip_landen(0.93, N, k);
if(err != RES_OK)
{
printf("Error code: %8x\n", err);
return err;
}
printf(" i%8sk[i]\n\n", "");
for(i = 1; i < N; i++)
printf("%2d %11.3e\n", i, k[i]);
dspl_free(handle); /* free dspl handle */
return 0;
}

Result:

 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
Note
Complete elliptical integral converges enough fast if modulus \( k<1 \). There are 10 to 20 coefficients \( k_i \) ​​ are sufficient for practical applications to ensure complete elliptic integral precision within EPS.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 889 of file ellipj.c.

Referenced by ellip_acd(), ellip_acd_cmplx(), ellip_asn(), ellip_asn_cmplx(), ellip_cd(), ellip_cd_cmplx(), ellip_sn(), and ellip_sn_cmplx().

◆ ellip_sn()

int ellip_sn ( double *  u,
int  n,
double  k,
double *  y 
)

Jacobi elliptic function \( y = \textrm{sn}(u K(k), k)\) of real vector argument.


Function calculates Jacobi elliptic function
\( y = \textrm{sn}(u K(k), k)\) of real vector u and elliptical modulus k.

Parameters
[in]uPointer to the argument vector \( u \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector u.

[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]yPointer to the vector of Jacobi elliptic function \( y = \textrm{sn}(u K(k), k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Example
#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;
}

The program calculates two periods of the \( y = \textrm{sn}(u K(k), k)\)
function for different modulus values k = 0, k= 0.9 и k = 0.99. Also program draws the plot of calculated elliptic functions.

Author
Sergey Bakhurin www.dsplib.org

Definition at line 1111 of file ellipj.c.

◆ ellip_sn_cmplx()

int ellip_sn_cmplx ( complex_t u,
int  n,
double  k,
complex_t y 
)

Jacobi elliptic function \( y = \textrm{sn}(u K(k), k)\) of complex vector argument.


Function calculates Jacobi elliptic function
\( y = \textrm{sn}(u K(k), k)\) of complex vector u and elliptical modulus k.

Parameters
[in]uPointer to the argument vector \( u \).
Vector size is [n x 1].
Memory must be allocated.

[in]nSize of vector u.
[in]kElliptical modulus \( k \).
Elliptical modulus is real parameter, which values can be from 0 to 1.

[out]yPointer to the vector of Jacobi elliptic function \( y = \textrm{sn}(u K(k), k)\).
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK successful exit, else error code.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 1216 of file ellipj.c.

Referenced by ellip_ap_zp().

int DSPL_API ellip_cd(double *u, int n, double k, double *y)
Jacobi elliptic function of real vector argument.
Definition: ellipj.c:594
void DSPL_API gnuplot_close(void *h)
Close GNUPLOT handle.
Definition: gnuplot.c:325
void * dspl_load()
Perform dynamic linking and load libdspl-2.0 functions.
int DSPL_API ellip_sn(double *u, int n, double k, double *y)
Jacobi elliptic function of real vector argument.
Definition: ellipj.c:1111
void DSPL_API gnuplot_cmd(void *h, char *cmd)
Function sends cmd command to GNUPLOT corresponds to h handle.
Definition: gnuplot.c:390
int DSPL_API writetxt(double *x, double *y, int n, char *fn)
Save real data to the text file fn. .
Definition: inout.c:491
void dspl_free(void *handle)
Cleans up the previously linked DSPL-2.0 dynamic library.
#define RES_OK
The function completed correctly. No errors.
Definition: dspl.h:558
int DSPL_API linspace(double x0, double x1, int n, int type, double *x)
Function fills a vector with n linearly spaced elements between x0 and x1.
Definition: array.c:1041
int DSPL_API ellip_landen(double k, int n, double *y)
Function calculates complete elliptical integral coefficients .
Definition: ellipj.c:889
int DSPL_API gnuplot_create(int argc, char *argv[], int w, int h, char *fn_png, void **hplot)
Create GNUPLOT chart.
Definition: gnuplot.c:200