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

Functions

int DSPL_API log_cmplx (complex_t *x, int n, complex_t *y)
 The logarithm function the complex vector argument x. More...
 
int DSPL_API sinc (double *x, int n, double a, double *y)
 Function \( \textrm{sinc}(x,a) = \frac{\sin(ax)}{ax}\) for the real vector x. More...
 
int DSPL_API sqrt_cmplx (complex_t *x, int n, complex_t *y)
 Square root of the complex vector argguument x. More...
 

Detailed Description

Function Documentation

◆ log_cmplx()

int log_cmplx ( complex_t x,
int  n,
complex_t y 
)

The logarithm function the complex vector argument x.


Function calculates the logarithm function as:

\[ \textrm{Ln}(x) = j \varphi + \ln(|x|), \]

here \(\varphi\) - the complex number phase.

Parameters
[in]xPointer to the argument vector x.
Vector size is [n x 1].

[in]nInput vector x and the logarithm vector y size.

[out]yPointer to the output complex vector y, corresponds to the input vector x.
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK if function calculated successfully.
Else code error.
Example:
complex_t x[3] = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}};
complex_t y[3];
int k;
log_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("log_cmplx(%.1f%+.1fj) = %.3f%+.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
int DSPL_API log_cmplx(complex_t *x, int n, complex_t *y)
The logarithm function the complex vector argument x.
Definition: log_cmplx.c:139
#define RE(x)
Macro sets real part of the complex number.
Definition: dspl.h:420
double complex_t[2]
Complex data type.
Definition: dspl.h:86
#define IM(x)
Macro sets imaginary part of the complex number.
Definition: dspl.h:478

Output is:
log_cmplx(1.0+2.0j) = 0.805+1.107j
log_cmplx(3.0+4.0j) = 1.609+0.927j
log_cmplx(5.0+6.0j) = 2.055+0.876j
Author
Sergey Bakhurin www.dsplib.org

Definition at line 139 of file log_cmplx.c.

Referenced by asin_cmplx().

◆ sinc()

int sinc ( double *  x,
int  n,
double  a,
double *  y 
)

Function \( \textrm{sinc}(x,a) = \frac{\sin(ax)}{ax}\) for the real vector x.


Parameters
[in]xPointer to the input vector \( x \).
Vector size is [n x 1].

[in]nInput and output vectors size.

[in]aFunction parameter \( \textrm{sinc}(x,a) = \frac{\sin(ax)}{ax}\).

[out]yPointer to the sinc function output vector.
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK if function calculated successfully.
Else code error.
Author
Sergey Bakhurin www.dsplib.org

Definition at line 88 of file sinc.c.

◆ sqrt_cmplx()

int sqrt_cmplx ( complex_t x,
int  n,
complex_t y 
)

Square root of the complex vector argguument x.


Function calculates square root value of vector x length n:

\[ y(k) = \sqrt{x(k)}, \qquad k = 0 \ldots n-1. \]

Parameters
[in]xPointer to the input complex vector x.
Vector size is [n x 1].

[in]nSize of input and output vectors x and y.

[out]yPointer to the square root vector y.
Vector size is [n x 1].
Memory must be allocated.

Returns
RES_OK if function is calculated successfully.
Else code error.
Example
complex_t x[3] = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}};
int k;
sqrt_cmplx(x, 3, y);
for(k = 0; k < 3; k++)
printf("sqrt_cmplx(%.1f%+.1fj) = %.3f%+.3fj\n",
RE(x[k]), IM(x[k]), RE(y[k]), IM(y[k]));
int DSPL_API sqrt_cmplx(complex_t *x, int n, complex_t *y)
Square root of the complex vector argguument x.
Definition: sqrt_cmplx.c:136

Result:
sqrt_cmplx(1.0+2.0j) = 1.272+0.786j
sqrt_cmplx(3.0+4.0j) = 2.000+1.000j
sqrt_cmplx(5.0+6.0j) = 2.531+1.185j
Author
Sergey Bakhurin www.dsplib.org

Definition at line 136 of file sqrt_cmplx.c.

Referenced by asin_cmplx(), ellip_acd_cmplx(), and ellip_asn_cmplx().