 |
libdspl-2.0
Digital Signal Processing Algorithm Library
|
31 #ifdef DOXYGEN_ENGLISH
78 #ifdef DOXYGEN_RUSSIAN
133 for(k = 1; k < n; k++)
149 #ifdef DOXYGEN_ENGLISH
152 #ifdef DOXYGEN_RUSSIAN
155 int DSPL_API histogram(
double* x,
int n,
int nh,
double* pedges,
double* ph)
161 if(!x || !pedges || !ph)
167 res = minmax(x, n, &xmin, &xmax);
171 res =
linspace(xmin, xmax, nh+1, DSPL_SYMMETRIC, pedges);
175 memset(ph, 0, nh*
sizeof(
double));
176 for(k = 0; k < n; k++)
179 while(ind<nh && x[k]>=pedges[ind])
189 #ifdef DOXYGEN_ENGLISH
192 #ifdef DOXYGEN_RUSSIAN
195 int DSPL_API histogram_norm(
double* y,
int n,
int nh,
double* x,
double* w)
197 double *pedges = NULL;
206 pedges = (
double*)malloc((nh+1)*
sizeof(double));
208 res = histogram(y, n, nh, pedges, w);
212 for(k = 1; k < nh+1; k++)
214 x[k-1] = 0.5*(pedges[k] + pedges[k-1]);
215 w[k-1] /= ((double)n * (pedges[k] - pedges[k-1]));
233 #ifdef DOXYGEN_ENGLISH
270 #ifdef DOXYGEN_RUSSIAN
309 int DSPL_API
mean(
double* x,
int n,
double* m)
319 for(k = 1; k < n; k++)
322 (*m) =
sum / (double)n;
331 #ifdef DOXYGEN_ENGLISH
368 #ifdef DOXYGEN_RUSSIAN
418 for(k = 1; k < n; k++)
423 RE(
sum) /= (double)n;
424 IM(
sum) /= (double)n;
436 #ifdef DOXYGEN_ENGLISH
439 #ifdef DOXYGEN_RUSSIAN
442 int DSPL_API minmax(
double* x,
int n,
double* xmin,
double* xmax)
454 for(k = 1; k < n; k++)
456 min = x[k] < min ? x[k] : min;
457 max = x[k] > max ? x[k] : max;
473 #ifdef DOXYGEN_ENGLISH
513 #ifdef DOXYGEN_RUSSIAN
556 int DSPL_API
std(
double* x,
int n,
double* s)
560 err =
mean(x, n, &m);
563 sum = (x[0] - m) * (x[0] - m);
564 for(k = 1; k < n; k++)
565 sum += (x[k] - m) * (x[k] - m);
566 (*s) = sqrt(
sum / (
double)(n-1));
577 #ifdef DOXYGEN_ENGLISH
617 #ifdef DOXYGEN_RUSSIAN
672 for(k = 0; k < n; k++)
674 RE(tmp) =
RE(x[k]) -
RE(m);
675 IM(tmp) =
IM(x[k]) -
IM(m);
678 *s = sqrt(
sum / (
double)(n-1));
#define RE(x)
Macro sets real part of the complex number.
#define ERROR_PTR
Pointer error. This error means that one of the required pointers (memory to be allocated for) is tra...
#define ERROR_SIZE
Error array size. This error occurs when in addition to the pointer the wrong input is passed to the ...
int DSPL_API std_cmplx(complex_t *x, int n, double *s)
Calculates the standard deviation of the complex input vector x
int DSPL_API std(double *x, int n, double *s)
Calculates the standard deviation of the input vector x
double complex_t[2]
Complex data type.
int DSPL_API find_max_abs(double *a, int n, double *m, int *ind)
Find maximum absolute value from the real vector a
#define RES_OK
The function completed correctly. No errors.
#define ABSSQR(x)
The macro returns the square of the modulus of a complex number x.
int DSPL_API sum(double *x, int n, double *s)
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.
int DSPL_API mean_cmplx(complex_t *x, int n, complex_t *m)
Calculates the mean of the complex input vector x
#define IM(x)
Macro sets imaginary part of the complex number.
int DSPL_API mean(double *x, int n, double *m)
Calculates the mean of the input vector x