![]() |
libdspl-2.0
Digital Signal Processing Algorithm Library
|
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... | |
int DSPL_API | polyroots (double *a, int ord, complex_t *r, int *info) |
Function calculates real polynomial roots. More... | |
Detailed Description
Function Documentation
◆ log_cmplx()
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] x Pointer to the argument vector x
.
Vector size is[n x 1]
.
[in] n Input vector x
and the logarithm vectory
size.
[out] y Pointer to the output complex vector y
, corresponds to the input vectorx
.
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",
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
Definition at line 718 of file math.c.
Referenced by asin_cmplx().
◆ polyroots()
int polyroots | ( | double * | a, |
int | ord, | ||
complex_t * | r, | ||
int * | info | ||
) |
Function calculates real polynomial roots.
Function calculates roots of the real polynomial \(P_N(x)\) order \(N\) with a
coefficient vector size [(N+1) x 1]
.
\[ P_N(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^3 + ... a_N x^N. \]
The roots of the polynomial are calculated as eigenvalues of the polynomial companion matrix. To calculate the eigenvalues, a subroutine of the LAPACK package is used.
- Parameters
-
[in] a Pointer to the vector of coefficients.
Vector size is[ord+1 x 1]
.
Coefficienta[0]
corresponds to the \(a_0\) polynomial coefficient.
Coefficienta[ord]
cannot be zero.
[in] ord Polynomial order \(N\).
[out] r Pointer to the polynomial roots vector.
Vector size is[ord x 1]
.
Memory must be allocated.
The roots of a real polynomial can be either real or form simple or multiple complex conjugate pairs of roots. Therefore, the output root vector is of a complex data type.
[out] info Pointer to the LAPACK subroutine error code.
This code is returned by the LAPACK subroutine and translated through this variable for analysis..
- Returns
RES_OK
— roots are calculated successfully.
Else code error.
Example:
This program calculates the roots of the polynomial
\[ P(x) = 2 + 2x + x^2 \]
and prints the calculated roots. The result of the program:
Error code: 0x00000000 r[0] = -1.00000 1.00000 j r[1] = -1.00000-1.00000 j
◆ 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] x Pointer to the input vector \( x \).
Vector size is[n x 1]
.
[in] n Input and output vectors size.
[in] a Function parameter \( \textrm{sinc}(x,a) = \frac{\sin(ax)}{ax}\).
[out] y Pointer 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.
◆ sqrt_cmplx()
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] x Pointer to the input complex vector x
.
Vector size is[n x 1]
.
[in] n Size of input and output vectors x
andy
.
[out] y Pointer 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.
Examplecomplex_t x[3] = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}};complex_t y[3]int k;sqrt_cmplx(x, 3, y);for(k = 0; k < 3; k++)printf("sqrt_cmplx(%.1f%+.1fj) = %.3f%+.3fj\n",
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
Definition at line 1307 of file math.c.
Referenced by asin_cmplx(), ellip_acd_cmplx(), and ellip_asn_cmplx().
Generated on Mon Dec 14 2020 14:02:36 for libdspl-2.0 by
