 |
libdspl-2.0
Digital Signal Processing Algorithm Library
|
28 #ifdef DOXYGEN_ENGLISH
86 #ifdef DOXYGEN_RUSSIAN
155 double dw = M_2PI / period;
158 if(!t || !s || !w || !y)
167 for(k = 0; k < nw; k++)
169 w[k] = (k - nw/2) * dw;
170 RE(e[1]) = s[0] * cos(w[k] * t[0]);
171 IM(e[1]) = -s[0] * sin(w[k] * t[0]);
172 for(m = 1; m < nt; m++)
176 RE(e[1]) = s[m] * cos(w[k] * t[m]);
177 IM(e[1]) = - s[m] * sin(w[k] * t[m]);
178 RE(y[k]) += 0.5 * (
RE(e[0]) +
RE(e[1]))*(t[m] - t[m-1]);
179 IM(y[k]) += 0.5 * (
IM(e[0]) +
IM(e[1]))*(t[m] - t[m-1]);
186 RE(y[0]) =
RE(y[1]) = 0.0;
193 #ifdef DOXYGEN_ENGLISH
196 #ifdef DOXYGEN_RUSSIAN
199 int DSPL_API fourier_series_dec_cmplx(
double* t,
complex_t* s,
int nt,
200 double period,
int nw,
double* w,
complex_t* y)
203 double dw = M_2PI / period;
206 if(!t || !s || !w || !y)
215 for(k = 0; k < nw; k++)
217 w[k] = (k - nw/2) * dw;
218 RE(e[1]) =
RE(s[0]) * cos(w[k] * t[0]) +
219 IM(s[0]) * sin(w[k] * t[0]);
220 IM(e[1]) = -
RE(s[0]) * sin(w[k] * t[0]) +
221 IM(s[0]) * cos(w[k] * t[0]);
222 for(m = 1; m < nt; m++)
226 RE(e[1]) =
RE(s[m]) * cos(w[k] * t[m]) +
227 IM(s[m]) * sin(w[k] * t[m]);
228 IM(e[1]) = -
RE(s[m]) * sin(w[k] * t[m]) +
229 IM(s[m]) * cos(w[k] * t[m]);
230 RE(y[k]) += 0.5 * (
RE(e[0]) +
RE(e[1]))*(t[m] - t[m-1]);
231 IM(y[k]) += 0.5 * (
IM(e[0]) +
IM(e[1]))*(t[m] - t[m-1]);
238 RE(y[0]) =
RE(y[1]) = 0.0;
247 #ifdef DOXYGEN_ENGLISH
250 #ifdef DOXYGEN_RUSSIAN
253 int DSPL_API fourier_integral_cmplx(
double* t,
complex_t* s,
int nt,
259 if(!t || !s || !w || !y)
267 for(k = 0; k < nw; k++)
269 RE(e[1]) =
RE(s[0]) * cos(w[k] * t[0]) +
270 IM(s[0]) * sin(w[k] * t[0]);
271 IM(e[1]) = -
RE(s[0]) * sin(w[k] * t[0]) +
272 IM(s[0]) * cos(w[k] * t[0]);
273 for(m = 1; m < nt; m++)
277 RE(e[1]) =
RE(s[m]) * cos(w[k] * t[m]) +
278 IM(s[m]) * sin(w[k] * t[m]);
279 IM(e[1]) = -
RE(s[m]) * sin(w[k] * t[m]) +
280 IM(s[m]) * cos(w[k] * t[m]);
281 RE(y[k]) += 0.5 * (
RE(e[0]) +
RE(e[1]))*(t[m] - t[m-1]);
282 IM(y[k]) += 0.5 * (
IM(e[0]) +
IM(e[1]))*(t[m] - t[m-1]);
294 #ifdef DOXYGEN_ENGLISH
353 #ifdef DOXYGEN_RUSSIAN
421 if(!t || !s || !w || !y)
429 for(k = 0; k < nw; k++)
431 for(m = 0; m < nt; m++)
433 RE(e) = cos(w[k] * t[m]);
434 IM(e) = sin(w[k] * t[m]);
436 RE(y[m]) += CMRE(s[k], e);
437 IM(y[m]) += CMIM(s[k], e);
int DSPL_API fourier_series_rec(double *w, complex_t *s, int nw, double *t, int nt, complex_t *y)
Time signal reconstruction from Fourier series coefficients.
#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 fourier_series_dec(double *t, double *s, int nt, double period, int nw, double *w, complex_t *y)
Fourier series coefficient calculation for periodic signal.
double complex_t[2]
Complex data type.
#define RES_OK
The function completed correctly. No errors.
#define IM(x)
Macro sets imaginary part of the complex number.
#define ERROR_NEGATIVE
Negative parameter. The function returns the given error code when it takes a negative parameter....