added gitignore to obj dir

pull/6/merge
Dsplib 2018-11-17 18:12:29 +03:00
rodzic d1def49fad
commit 9bd67cec76
9 zmienionych plików z 165 dodań i 3 usunięć

Wyświetl plik

@ -76,6 +76,15 @@ $extrastylesheet
<li><a href="http://ru.dsplib.org">Содержание</a></li>
<li><a href="http://ru.dsplib.org/dspl">DSPL</a></li>
<li><a href="http://ru.dsplib.org/forum">Форум</a></li>
<div class="dsplib_search">
<div class="ya-site-form ya-site-form_inited_no" onclick="return {'action':'http://ru.dsplib.org/search_results.html','arrow':false,'bg':'transparent','fontsize':12,'fg':'#000000','language':'ru','logo':'rb','publicname':'ru.dsplib.org поиск','suggest':true,'target':'_self','tld':'ru','type':2,'usebigdictionary':true,'searchid':2332185,'input_fg':'#000000','input_bg':'#ffffff','input_fontStyle':'normal','input_fontWeight':'normal','input_placeholder':'поиск','input_placeholderColor':'#000000','input_borderColor':'#7f9db9'}"><form action="https://yandex.ru/search/site/" method="get" target="_self" accept-charset="utf-8"><input type="hidden" name="searchid" value="2332185"/><input type="hidden" name="l10n" value="ru"/><input type="hidden" name="reqenc" value=""/><input type="search" name="text" value="" style = "height: 24px; font-family: verdana,arial; font-size: 12px"/><input type="submit" value="Найти" style = "display: none; "/></form></div><style type="text/css">.ya-page_js_yes .ya-site-form_inited_no { display: none; }</style><script type="text/javascript">(function(w,d,c){var s=d.createElement('script'),h=d.getElementsByTagName('script')[0],e=d.documentElement;if((' '+e.className+' ').indexOf(' ya-page_js_yes ')===-1){e.className+=' ya-page_js_yes';}s.type='text/javascript';s.async=true;s.charset='utf-8';s.src=(d.location.protocol==='https:'?'https:':'http:')+'//site.yandex.net/v2.0/js/all.js';h.parentNode.insertBefore(s,h);(w[c]||(w[c]=[])).push(function(){Ya.Site.Form.init()})})(window,document,'yandex_site_callbacks');</script>
</div>
</ul>
</nav>
@ -86,6 +95,9 @@ $extrastylesheet
<div id="dsplib_maket">
<div id="dsplib_content">

8
dspl/obj/.gitignore vendored
Wyświetl plik

@ -0,0 +1,8 @@
*.o
*.so
*.dll
*.exe
*.txt
*.dat
*.bin
*.csv

Wyświetl plik

@ -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

Wyświetl plik

@ -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);

Wyświetl plik

@ -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

Wyświetl plik

@ -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);

Wyświetl plik

@ -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

Wyświetl plik

@ -3,7 +3,7 @@
#include <string.h>
#include <time.h>
#include "dspl.h"
#define N 8388608
#define N 2097152
int main()
{
void* handle; // DSPL handle

Wyświetl plik

@ -0,0 +1,79 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#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;
}