author | francesco-ST <francesco.abbate@st.com> | 2010年07月26日 13:44:35 +0200 |
---|---|---|
committer | francesco-ST <francesco.abbate@st.com> | 2010年07月26日 13:44:35 +0200 |
commit | 83ae12b6466b3b824570103eb2860235779c4814 (patch) | |
tree | c3b81474b1cb8bce1c0421380429325f4942caee | |
parent | 4a8742d4109af38b035b97c0a55e9152ff5a762f (diff) | |
download | gsl-shell-83ae12b6466b3b824570103eb2860235779c4814.tar.gz |
-rw-r--r-- | examples/fft.lua | 4 | ||||
-rw-r--r-- | examples/plot.lua | 4 | ||||
-rw-r--r-- | fft.c | 65 | ||||
-rw-r--r-- | gs-types.c | 28 | ||||
-rw-r--r-- | gs-types.h | 3 |
diff --git a/examples/fft.lua b/examples/fft.lua index 77fa727d..d761aece 100644 --- a/examples/fft.lua +++ b/examples/fft.lua @@ -39,7 +39,7 @@ function demo1() pf:show() pt:show() - return p + return pt, pf end function demo2() @@ -56,7 +56,7 @@ function demo2() fftplot = plot('FFT power spectrum') bars = ibars(isample(|k| abs(bess:get(k)), 0, 60)) - fftplot:add(bars, 'darkblue') + fftplot:add(bars, 'darkgreen') fftplot:addline(bars, 'black') fftplot:show() diff --git a/examples/plot.lua b/examples/plot.lua index 928be6bf..9006ed0e 100644 --- a/examples/plot.lua +++ b/examples/plot.lua @@ -1,6 +1,4 @@ -require 'draw' - function demo1() local f = |t| exp(-0.3*t) * sin(2*pi*t) return fxplot(f, 0, 15, 'red') @@ -13,7 +11,7 @@ function demo2() local p = plot('Simulated Gaussian Distribution') local b = ibars(sample(|x| rnd.poisson(r, floor(f(x)*N)) / N, -3, 3, 25)) p:add(b, 'darkgreen') - p:add(b, 'black', {{'stroke', width= 0.5}}) + p:addline(b, rgba(0, 0, 0, 0.6)) p:addline(fxline(f, -4, 4), 'red') p:show() return p @@ -215,58 +215,35 @@ fft_hc_mixed_radix_transform (lua_State *L, gsl_matrix *hc) gsl_matrix * fft_hc_check (lua_State *L, int index, struct fft_hc_sel ** selptr) { - int sel; - gsl_matrix *p = gs_check_userdata_w_alt (L, index, - GS_HALFCMPL_R2, - GS_HALFCMPL_MR, &sel); - - *selptr = (sel == GS_HALFCMPL_R2 ? fft_hc_radix2_sel : \ - fft_hc_mixed_radix_sel); + gsl_matrix *p; - return p; -} + p = gs_is_userdata (L, index, GS_HALFCMPL_R2); - /* -gsl_matrix * -fft_hc_check (lua_State *L, int index, struct fft_hc_sel ** selptr) -{ - const char * const user_name = "half-complex vector"; - void *p = lua_touserdata (L, index); - const char *msg; + if (p != NULL) + { + if (selptr) + *selptr = fft_hc_radix2_sel; + return p; + } - if (p == NULL) - luaL_typerror(L, index, user_name); + p = gs_is_userdata (L, index, GS_HALFCMPL_MR); - if (lua_getmetatable(L, index)) + if (p != NULL) + { + if (selptr) + *selptr = fft_hc_mixed_radix_sel; + return p; + } + else { - lua_getfield(L, LUA_REGISTRYINDEX, GS_METATABLE(GS_HALFCMPL_R2)); - if (lua_rawequal(L, -1, -2)) - { - if (selptr) - *selptr = fft_hc_radix2_sel; - lua_pop (L, 2); - return p; - } - lua_pop (L, 1); - lua_getfield(L, LUA_REGISTRYINDEX, GS_METATABLE(GS_HALFCMPL_MR)); - if (lua_rawequal(L, -1, -2)) - { - if (selptr) - *selptr = fft_hc_mixed_radix_sel; - lua_pop (L, 2); - return p; - } - lua_pop (L, 2); + const char *msg = lua_pushfstring(L, "%s or %s", + type_qualified_name (GS_HALFCMPL_R2), + type_qualified_name (GS_HALFCMPL_MR)); + gs_type_error (L, index, msg); } - msg = lua_pushfstring(L, "%s or %s", - type_qualified_name (GS_HALFCMPL_R2), - type_qualified_name (GS_HALFCMPL_MR)); - - gs_type_error (L, index, msg); - return NULL; + return 0; } - */ int fft_hc_length (lua_State *L) diff --git a/gs-types.c b/gs-types.c index 13f32aa0..866d9bf6 100644 --- a/gs-types.c +++ b/gs-types.c @@ -186,34 +186,6 @@ gs_check_userdata (lua_State *L, int index, int typeid) return p; } -void * -gs_check_userdata_w_alt (lua_State *L, int index, int typeid1, int typeid2, - int *sel) -{ - void *p; - - p = gs_is_userdata (L, index, typeid1); - if (p == NULL) - { - p = gs_is_userdata (L, index, typeid2); - if (p == NULL) - { - const char *msg = lua_pushfstring(L, "%s or %s", - type_qualified_name (typeid1), - type_qualified_name (typeid2)); - gs_type_error (L, index, msg); - } - - if (sel) - *sel = typeid2; - } - - if (sel) - *sel = typeid1; - - return p; -} - int gs_gsl_errorcheck (lua_State *L, const char *routine, int status) { diff --git a/gs-types.h b/gs-types.h index c054b9a7..a6bfa1f6 100644 --- a/gs-types.h +++ b/gs-types.h @@ -49,9 +49,6 @@ extern const char * type_qualified_name (int type_id); extern int gs_type_error (lua_State *L, int narg, const char *req_type); extern void * gs_is_userdata (lua_State *L, int index, int type_id); extern void * gs_check_userdata (lua_State *L, int index, int type_id); -extern void * gs_check_userdata_w_alt (lua_State *L, int index, - int typeid1, int typeid2, - int *sel); extern int gs_gsl_errorcheck (lua_State *L, const char *routine, int status); extern void gs_set_metatable (lua_State *L, int type_id); extern double gs_check_number (lua_State *L, int index, int check_normal); |