Basic functions of real and complex arguments.

Functions

int dspl_linspace (double x0, double x1, int n, int type, double *x)
 Linspace filling of the array x from x0 to x1 More...
 
int dspl_log_cmplx (double *xR, double *xI, int n, double *yR, double *yI)
 Logarithm of complex arguments. More...
 
int dspl_logspace (double x0, double x1, int n, int type, double *x)
 Logspace filling of the array x from 10^x0 to 10^x1 More...
 
int dspl_polyval (double *a, int ord, double *x, int n, double *y)
 Real polynomial calculation. More...
 
int dspl_polyval_cmplx (double *aR, double *aI, int ord, double *xR, double *xI, int n, double *yR, double *yI)
 Complex values polynomial calculation. More...
 
int dspl_sqrt_cmplx (double *xR, double *xI, int n, double *yR, double *yI)
 Square root of complex arguments. More...
 
int dspl_unwrap (double *phi, int n, double lev, double mar)
 Раскрытие периодичности арктангенса при расчете фазо-частотной характеристики. More...
 

Detailed Description

Function Documentation

◆ dspl_linspace()

int dspl_linspace ( double  x0,
double  x1,
int  n,
int  type,
double *  x 
)

Linspace filling of the array x from x0 to x1

Function supports two kind of filling according to parameter type:

Symmetric filling corresponds to equation

\(x(k) = x_0 + k \cdot dx\), here \(dx = \frac{x_1 - x_0}{n-1}\), \(k = 0 \ldots n-1.\)

Periodic filling corresponds to equation

\(x(k) = x_0 + k \cdot dx\), here \(dx = \frac{x_1 - x_0}{n}\), \(k = 0 \ldots n-1.\)

Parameters
[in]x0Initial value \(x_0\).
[in]x1Stop value \(x_1\).
[in]nArray x number of points.
[in]typeFilling type DSPL_SYMMETRIC - symmetric filling, DSPL_PERIODIC - periodic filling.
[in,out]xLinspace array pointer. Vector size is [n x 1]. Memory must be allocated.
Returns
DSPL_OK - Function has been finished successfully .
DSPL_ERROR_PTR - pointer x cannot be NULL.
DSPL_ERROR_SIZE - Vector x size must be more than 1.
Note
We can understand a difference between periodic and a symmetric types from the examples below.
Example 1. Periodic filling.
double x[5];
dspl_linspace(0, 5, 5, DSPL_PERIODIC, x);
Vector x will keep follow values:
0, 1, 2, 3, 4


Examples 2. Symmetric filling.
double x[5];
dspl_linspace(0, 5, 5, DSPL_SYMMETRIC, x);
Vector x will keep follow values:
0, 1.25, 2.5, 3.75, 5
Author
Sergey Bakhurin. www.dsplib.org
Examples:
hilbert_fft.c, resample_lagrange_ex_interp.c, resample_lagrange_filter_frac_delay.c, resample_lagrange_filter_interp.c, resample_spline_ex_interp.c, resample_spline_filter_frac_delay.c, and resample_spline_filter_interp.c.

◆ dspl_log_cmplx()

int dspl_log_cmplx ( double *  xR,
double *  xI,
int  n,
double *  yR,
double *  yI 
)

Logarithm of complex arguments.

Function calculates logarithm function of a complex vector argument \( x \).

\[ \ln(x) = \ln \left( |x| \right) + j \cdot \arg(x). \]

Parameters
[in]xRPointer to the complex vector \( x \) real part.
Vector size is [n x 1].

[in]xIPointer to the complex vector \( x \) image part.
Vector size is [n x 1].
This pointer can be a NULL if function uses real argument only.

[in]nInput vector size.

[out]yRPointer to the logarithm real part values.
Vector size is [n x 1].
Memory must be allocated.

[out]yIPointer to the logarithm image part values.
Vector size is [n x 1].
Memory must be allocated (even if xI is NULL).
Returns
DSPL_OK if complex logarithm has been calculated successfully, else error code.
Author
Sergey Bakhurin. www.dsplib.org

◆ dspl_logspace()

int dspl_logspace ( double  x0,
double  x1,
int  n,
int  type,
double *  x 
)

Logspace filling of the array x from 10^x0 to 10^x1

Function supports two kind of filling according to parameter type:

Symmetric filling corresponds to equation

\(x(k) = 10^{x_0} \cdot dx^k\), где \(dx = \sqrt[n-1]{10^{x_1 - x_0}}\), \(k = 0 \ldots n-1.\)

Periodic filling corresponds to equation

\(x(k) = 10^{x_0} \cdot dx^k\), где \(dx = \sqrt[n]{10^{x_1 - x_0}}\), \(k = 0 \ldots n-1.\)

Parameters
[in]x0Initial value \(x_0\).
[in]x1Stop value \(x_1\).
[in]nArray x number of points.
[in]typeFilling type DSPL_SYMMETRIC - symmetric filling, DSPL_PERIODIC - periodic filling.
[in,out]xLogspace array pointer. Vector size is [n x 1]. Memory must be allocated.
Returns
DSPL_OK - Function has been finished successfully .
DSPL_ERROR_PTR - pointer x cannot be NULL.
DSPL_ERROR_SIZE - Vector x size must be more than 1.
Note
We can understand a difference between periodic and a symmetric types from the examples below.
Example 1. Periodic filling.
double x[5];
dspl_logspace(-2, 3, 5, DSPL_PERIODIC, x);
Vector x will keep follow values:
0.01, 0.1, 1, 10, 100


Examples 2. Symmetric filling.
double x[5];
dspl_logspace(-2, 3, 5, DSPL_SYMMETRIC, x);
Vector x will keep follow values:
0.01 0.178 3.162 56.234 1000
Author
Sergey Bakhurin. www.dsplib.org

◆ dspl_polyval()

int dspl_polyval ( double *  a,
int  ord,
double *  x,
int  n,
double *  y 
)

Real polynomial calculation.

Function calculates a \(N-\) th order polynomial \(P_N(x)\)

\[ P_N(x) = a_0 + a_1 \cdot x + a_2 \cdot x^2 + a_3*x^3 + ... a_N*x^N. \]

for vector argument x. Output is vector y which contains polynomial values for each x This function uses Horner's polynomial factorization:

\[ P_N(x) = a_0 + x \cdot (a_1 + x \cdot (a_2 + \cdot ( \ldots x \cdot (a_{N-1} + x\cdot a_N) \ldots ))) \]

Parameters
[in]aPolynomial coefficients vector pointer. Vector size is [ord+1 x 1]. Coefficient a[0] corresponds to \(a_0\) polynomial coefficient
[in]ordPolynomial order \(N\).
[in]xPolynomial argument vector pointer. Vector size is [n x 1]. Polynomial will be calculated for all x values.
[in]nPolynomial argument vector size.
[out]yPolynomial values for all arguments x. Vector size is [n x 1] Memory must be allocated.
Returns
DSPL_OK Polynomial is calculated successfully.
DSPL_ERROR_PTR Pointers a, x and y cannot to be as NULL.
DSPL_ERROR_SIZE Argument vector size is wrong (n < 1).
DSPL_ERROR_POLY_ORD Polynomial order less than 0.
Author
Sergey Bakhurin. www.dsplib.org
Examples:
resample_lagrange_ex_frac_delay.c, and resample_spline_ex_frac_delay.c.

◆ dspl_polyval_cmplx()

int dspl_polyval_cmplx ( double *  aR,
double *  aI,
int  ord,
double *  xR,
double *  xI,
int  n,
double *  yR,
double *  yI 
)

Complex values polynomial calculation.

Function calculates a \(N-\) th order polynomial \(P_N(x)\)

\[ P_N(x) = a_0 + a_1 \cdot x + a_2 \cdot x^2 + a_3*x^3 + ... a_N*x^N. \]

for vector argument x. Output is vector y which contains polynomial values for each x This function uses Horner's polynomial factorization:

\[ P_N(x) = a_0 + x \cdot (a_1 + x \cdot (a_2 + \cdot ( \ldots x \cdot (a_{N-1} + x\cdot a_N) \ldots ))) \]

Parameters
[in]aRPolynomial coefficients real part vector pointer. Vector size is [ord+1 x 1]. Coefficient a[0] corresponds to \(a_0\) polynomial coefficient
[in]aIPolynomial coefficients image part vector pointer. Vector size is [ord+1 x 1]. Coefficient a[0] corresponds to \(a_0\) polynomial coefficient
[in]ordPolynomial order \(N\).
[in]xRPolynomial argument real part vector pointer. Vector size is [n x 1]. Polynomial will be calculated for all x values.
[in]xIPolynomial argument image part vector pointer. Vector size is [n x 1]. Polynomial will be calculated for all x values.
[in]nPolynomial argument vector size.
[out]yRPolynomial real part values for all arguments x. Vector size is [n x 1] Memory must be allocated.
[out]yIPolynomial image part values for all arguments x. Vector size is [n x 1] Memory must be allocated.
Returns
DSPL_OK Polynomial is calculated successfully.
DSPL_ERROR_PTR Pointers aR, xR and yR cannot to be as NULL.
Pointer yI can be NULL only if aI and xI are NULL. DSPL_ERROR_SIZE Argument vector size is wrong (n < 1).
DSPL_ERROR_POLY_ORD Polynomial order less than 0.
Author
Sergey Bakhurin. www.dsplib.org

◆ dspl_sqrt_cmplx()

int dspl_sqrt_cmplx ( double *  xR,
double *  xI,
int  n,
double *  yR,
double *  yI 
)

Square root of complex arguments.

Function calculates square root function of a complex vector argument \( x \).

\[ \sqrt {x}={\sqrt {\frac {|x|+\Re (x)}{2}}} + \operatorname {sign} \left(\Im (x) \right) \cdot j\ {\sqrt {\frac {|x|-\Re (x)}{2}}}. \]

Parameters
[in]xRPointer to the complex vector \( x \) real part.
Vector size is [n x 1].

[in]xIPointer to the complex vector \( x \) image part.
Vector size is [n x 1].
This pointer can be a NULL if function uses real argument only.

[in]nInput vector size.

[out]yRPointer to the square root real part values.
Vector size is [n x 1].
Memory must be allocated.

[out]yIPointer to the square root image part values.
Vector size is [n x 1].
Memory must be allocated (even if xI is NULL).
Returns
DSPL_OK if complex square root has been calculated successfully, else error code.
Author
Sergey Bakhurin. www.dsplib.org

◆ dspl_unwrap()

int dspl_unwrap ( double *  phi,
int  n,
double  lev,
double  mar 
)

Раскрытие периодичности арктангенса при расчете фазо-частотной характеристики.

Parameters
[in,out]phiУказатель на вектор фазо-частотной характеристики. Размер вектора [n x 1]. ФЧХ после раскрытия будет помещена по этому же адресу.
[in]nРазмер вектора ФЧХ.
[in]levПериод арктангенса. M_2PI или M_PI в зависимости от способа расчета ФЧХ. Так при использовании функции atan периодичность составит M_PI, а при использовании atan2 периодичность равна M_2PI.
[in]marЗапас при котором считается, что произошел переход на следующий период арктангенса. Значение от 0 до 1. Так например если lev = M_PI и mar = 0.8, то переход на следующий период арктангенса будет зафиксирован если |p[k] - phi[k-1]| > 0.8 * M_PI.
Author
Бахурин Сергей. www.dsplib.org
Note
Данная функция является рекурсивной. Это означает что она выполняется до тех пор пока в исходном векторе будут определены переходы на следующий период арктангенса.
Так например функция работает корректно если в исходной фазо-частотной характеристике период фазы составляет \( 2\pi \), в то время как lev = M_PI. Функция осуществит два прохода в этом случае и корректно раскроет периодичность по фазе.

Select spelling error with your mouse and press Система Orphus