diff --git a/dox/header.html b/dox/header.html index 9af3f08..7bc2bf4 100644 --- a/dox/header.html +++ b/dox/header.html @@ -76,6 +76,15 @@ $extrastylesheet
  • Содержание
  • DSPL
  • Форум
  • + + + + + @@ -86,6 +95,9 @@ $extrastylesheet
    + + +
    diff --git a/dspl/obj/.gitignore b/dspl/obj/.gitignore index e69de29..d739953 100755 --- a/dspl/obj/.gitignore +++ b/dspl/obj/.gitignore @@ -0,0 +1,8 @@ +*.o +*.so +*.dll +*.exe +*.txt +*.dat +*.bin +*.csv \ No newline at end of file diff --git a/dspl/src/fourier_series.c b/dspl/src/fourier_series.c index 9268483..994cd57 100755 --- a/dspl/src/fourier_series.c +++ b/dspl/src/fourier_series.c @@ -122,6 +122,49 @@ int DSPL_API fourier_series_dec_cmplx(double* t, complex_t* s, int nt, +/******************************************************************************* +Fourier Transform +*******************************************************************************/ +int DSPL_API fourier_integral_cmplx(double* t, complex_t* s, int nt, + int nw, double* w, complex_t* y) +{ + int k, m; + complex_t e[2]; + + if(!t || !s || !w || !y) + return ERROR_PTR; + if(nt<1 || nw < 1) + return ERROR_SIZE; + + + memset(y, 0 , nw*sizeof(complex_t)); + + for(k = 0; k < nw; k++) + { + RE(e[1]) = RE(s[0]) * cos(w[k] * t[0]) + + IM(s[0]) * sin(w[k] * t[0]); + IM(e[1]) = -RE(s[0]) * sin(w[k] * t[0]) + + IM(s[0]) * cos(w[k] * t[0]); + for(m = 1; m < nt; m++) + { + RE(e[0]) = RE(e[1]); + IM(e[0]) = IM(e[1]); + RE(e[1]) = RE(s[m]) * cos(w[k] * t[m]) + + IM(s[m]) * sin(w[k] * t[m]); + IM(e[1]) = -RE(s[m]) * sin(w[k] * t[m]) + + IM(s[m]) * cos(w[k] * t[m]); + RE(y[k]) += 0.5 * (RE(e[0]) + RE(e[1]))*(t[m] - t[m-1]); + IM(y[k]) += 0.5 * (IM(e[0]) + IM(e[1]))*(t[m] - t[m-1]); + } + } + + return RES_OK; +} + + + + + /******************************************************************************* Fourier Series Reconstruction diff --git a/include/dspl.c b/include/dspl.c index 5510bd0..0dd7622 100755 --- a/include/dspl.c +++ b/include/dspl.c @@ -86,6 +86,7 @@ p_fftn_create fftn_create ; p_fftn_krn fftn_krn ; p_flipip flipip ; p_flipip_cmplx flipip_cmplx ; +p_fourier_integral_cmplx fourier_integral_cmplx ; p_fourier_series_dec fourier_series_dec ; p_fourier_series_dec_cmplx fourier_series_dec_cmplx ; p_fourier_series_rec fourier_series_rec ; @@ -231,6 +232,7 @@ void* dspl_load() LOAD_FUNC(fftn_krn); LOAD_FUNC(flipip); LOAD_FUNC(flipip_cmplx); + LOAD_FUNC(fourier_integral_cmplx); LOAD_FUNC(fourier_series_dec); LOAD_FUNC(fourier_series_dec_cmplx); LOAD_FUNC(fourier_series_rec); diff --git a/include/dspl.h b/include/dspl.h index bba3c86..d566888 100755 --- a/include/dspl.h +++ b/include/dspl.h @@ -69,6 +69,7 @@ typedef struct #define SQR(x) ((x) * (x)) #define ABSSQR(x) ((SQR(RE(x))) + (SQR(IM(x)))) #define ABS(x) sqrt((ABSSQR(x))) +#define ARG(x) atan2(IM(x), RE(x)) #define CMRE(a,b) ((RE(a)) * (RE(b)) - (IM(a)) * (IM(b))) #define CMIM(a,b) ((RE(a)) * (IM(b)) + (IM(a)) * (RE(b))) @@ -457,7 +458,7 @@ DECLARE_FUNC(int, fft_shift_cmplx, complex_t* DECLARE_FUNC(int, fftn_create, fft_t* pfft COMMA int n); //------------------------------------------------------------------------------ -DECLARE_FUNC(int, fftn_krn, complex_t* t0 +DECLARE_FUNC(int, fftn_krn, complex_t* t0 COMMA complex_t* t1 COMMA fft_t* p COMMA int n @@ -469,6 +470,13 @@ DECLARE_FUNC(int, flipip, double* DECLARE_FUNC(int, flipip_cmplx, complex_t* COMMA int); //------------------------------------------------------------------------------ +DECLARE_FUNC(int, fourier_integral_cmplx, double* t + COMMA complex_t* s + COMMA int nt + COMMA int nw + COMMA double* w + COMMA complex_t* y); +//------------------------------------------------------------------------------ DECLARE_FUNC(int, fourier_series_dec, double* COMMA double* COMMA int diff --git a/release/include/dspl.c b/release/include/dspl.c index 5510bd0..0dd7622 100755 --- a/release/include/dspl.c +++ b/release/include/dspl.c @@ -86,6 +86,7 @@ p_fftn_create fftn_create ; p_fftn_krn fftn_krn ; p_flipip flipip ; p_flipip_cmplx flipip_cmplx ; +p_fourier_integral_cmplx fourier_integral_cmplx ; p_fourier_series_dec fourier_series_dec ; p_fourier_series_dec_cmplx fourier_series_dec_cmplx ; p_fourier_series_rec fourier_series_rec ; @@ -231,6 +232,7 @@ void* dspl_load() LOAD_FUNC(fftn_krn); LOAD_FUNC(flipip); LOAD_FUNC(flipip_cmplx); + LOAD_FUNC(fourier_integral_cmplx); LOAD_FUNC(fourier_series_dec); LOAD_FUNC(fourier_series_dec_cmplx); LOAD_FUNC(fourier_series_rec); diff --git a/release/include/dspl.h b/release/include/dspl.h index bba3c86..d566888 100755 --- a/release/include/dspl.h +++ b/release/include/dspl.h @@ -69,6 +69,7 @@ typedef struct #define SQR(x) ((x) * (x)) #define ABSSQR(x) ((SQR(RE(x))) + (SQR(IM(x)))) #define ABS(x) sqrt((ABSSQR(x))) +#define ARG(x) atan2(IM(x), RE(x)) #define CMRE(a,b) ((RE(a)) * (RE(b)) - (IM(a)) * (IM(b))) #define CMIM(a,b) ((RE(a)) * (IM(b)) + (IM(a)) * (RE(b))) @@ -457,7 +458,7 @@ DECLARE_FUNC(int, fft_shift_cmplx, complex_t* DECLARE_FUNC(int, fftn_create, fft_t* pfft COMMA int n); //------------------------------------------------------------------------------ -DECLARE_FUNC(int, fftn_krn, complex_t* t0 +DECLARE_FUNC(int, fftn_krn, complex_t* t0 COMMA complex_t* t1 COMMA fft_t* p COMMA int n @@ -469,6 +470,13 @@ DECLARE_FUNC(int, flipip, double* DECLARE_FUNC(int, flipip_cmplx, complex_t* COMMA int); //------------------------------------------------------------------------------ +DECLARE_FUNC(int, fourier_integral_cmplx, double* t + COMMA complex_t* s + COMMA int nt + COMMA int nw + COMMA double* w + COMMA complex_t* y); +//------------------------------------------------------------------------------ DECLARE_FUNC(int, fourier_series_dec, double* COMMA double* COMMA int diff --git a/test/src/fftn_performance.c b/test/src/fftn_performance.c index c7f9a63..42e934c 100644 --- a/test/src/fftn_performance.c +++ b/test/src/fftn_performance.c @@ -3,7 +3,7 @@ #include #include #include "dspl.h" -#define N 8388608 +#define N 2097152 int main() { void* handle; // DSPL handle diff --git a/test/src/fourier_transform_period_incr.c b/test/src/fourier_transform_period_incr.c new file mode 100644 index 0000000..3fdd2ed --- /dev/null +++ b/test/src/fourier_transform_period_incr.c @@ -0,0 +1,79 @@ +#include +#include +#include +#include "dspl.h" + +#define N 10000 +#define D 10 +#define TAU 1 +#define K 51 + +int main(int argc, char* argv[]) +{ + double *t = NULL, *s = NULL; + double *td = NULL, *sd = NULL; + complex_t S[K]; + double w[K], mag[K]; + double T; + void* handle; + int k, n; + + + + handle = dspl_load(); + if(!handle) + { + printf("cannot to load libdspl!\n"); + return 0; + } + + t = (double*)malloc(N*sizeof(double)); + s = (double*)malloc(N*sizeof(double)); + + td = (double*)malloc(N/D*sizeof(double)); + sd = (double*)malloc(N/D*sizeof(double)); + + linspace(-10, 10, N, DSPL_SYMMETRIC, t); + decimate(t, N, D,td, &n); + + T = 2.0; + signal_pimp(t, N, 2.0, TAU, 0.0, T, s); + decimate(s, N, D, sd, &n); + writetxt(td, sd, n, "dat/fourier_transform_period_2.0_time.txt"); + + + fourier_series_dec(t, s, N, T, K, w, S); + for(n = 0; n < K; n++) + mag[n] = T*ABS(S[n])/20.0; + writetxt(w, mag, K, "dat/fourier_transform_period_2.0_freq.txt"); + + + T = 4.0; + signal_pimp(t, N, 2.0, TAU, 0.0, T, s); + decimate(s, N, D, sd, &n); + writetxt(td, sd, n, "dat/fourier_transform_period_4.0_time.txt"); + + + fourier_series_dec(t, s, N, T, K, w, S); + for(n = 0; n < K; n++) + mag[n] = T*ABS(S[n])/20.0; + writetxt(w, mag, K, "dat/fourier_transform_period_4.0_freq.txt"); + + + T = 8.0; + signal_pimp(t, N, 2.0, TAU, 0.0, T, s); + decimate(s, N, D, sd, &n); + writetxt(td, sd, n, "dat/fourier_transform_period_8.0_time.txt"); + + + fourier_series_dec(t, s, N, T, K, w, S); + for(n = 0; n < K; n++) + mag[n] = T*ABS(S[n])/20.0; + writetxt(w, mag, K, "dat/fourier_transform_period_8.0_freq.txt"); + + + // remember to free the resource + dspl_free(handle); + + return 0; +}