numo-gsl 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/README.md +84 -0
- data/Rakefile +16 -0
- data/ext/numo/gsl/cdf/depend +17 -0
- data/ext/numo/gsl/cdf/erbpp_cdf.rb +44 -0
- data/ext/numo/gsl/cdf/extconf.rb +9 -0
- data/ext/numo/gsl/cdf/func_def.rb +610 -0
- data/ext/numo/gsl/const/const_def.rb +419 -0
- data/ext/numo/gsl/const/depend +17 -0
- data/ext/numo/gsl/const/erbpp_const.rb +30 -0
- data/ext/numo/gsl/const/extconf.rb +9 -0
- data/ext/numo/gsl/err/depend +1 -0
- data/ext/numo/gsl/err/err.c +22 -0
- data/ext/numo/gsl/err/extconf.rb +9 -0
- data/ext/numo/gsl/extconf_gsl.rb +44 -0
- data/ext/numo/gsl/fit/depend +17 -0
- data/ext/numo/gsl/fit/erbpp_fit.rb +74 -0
- data/ext/numo/gsl/fit/extconf.rb +9 -0
- data/ext/numo/gsl/fit/func_def.rb +129 -0
- data/ext/numo/gsl/fit/tmpl/check_1d.c +9 -0
- data/ext/numo/gsl/fit/tmpl/fit_linear.c +53 -0
- data/ext/numo/gsl/fit/tmpl/fit_linear_est.c +56 -0
- data/ext/numo/gsl/fit/tmpl/fit_mul.c +50 -0
- data/ext/numo/gsl/fit/tmpl/fit_mul_est.c +47 -0
- data/ext/numo/gsl/fit/tmpl/fit_wlinear.c +59 -0
- data/ext/numo/gsl/fit/tmpl/fit_wmul.c +56 -0
- data/ext/numo/gsl/gen/erbpp2.rb +306 -0
- data/ext/numo/gsl/gen/erbpp_gsl.rb +166 -0
- data/ext/numo/gsl/gen/func_parser.rb +520 -0
- data/ext/numo/gsl/gen/tmpl/c_DFloat_f_DFloat.c +40 -0
- data/ext/numo/gsl/gen/tmpl/c_DFloat_f_SZ.c +41 -0
- data/ext/numo/gsl/gen/tmpl/c_DFloat_f_SZ_x2.c +44 -0
- data/ext/numo/gsl/gen/tmpl/c_DFloat_x2_f_DFloat_x2.c +45 -0
- data/ext/numo/gsl/gen/tmpl/c_double_f_double.c +16 -0
- data/ext/numo/gsl/gen/tmpl/c_double_f_sizet.c +16 -0
- data/ext/numo/gsl/gen/tmpl/c_double_f_sizet_x2.c +17 -0
- data/ext/numo/gsl/gen/tmpl/c_double_f_void.c +15 -0
- data/ext/numo/gsl/gen/tmpl/c_double_x2_f_void.c +17 -0
- data/ext/numo/gsl/gen/tmpl/c_new_DFloat.c +29 -0
- data/ext/numo/gsl/gen/tmpl/c_new_double.c +22 -0
- data/ext/numo/gsl/gen/tmpl/c_new_f_other.c +25 -0
- data/ext/numo/gsl/gen/tmpl/c_new_sizet.c +22 -0
- data/ext/numo/gsl/gen/tmpl/c_new_sizet_double.c +23 -0
- data/ext/numo/gsl/gen/tmpl/c_new_sizet_x2.c +23 -0
- data/ext/numo/gsl/gen/tmpl/c_new_void.c +21 -0
- data/ext/numo/gsl/gen/tmpl/c_other_f_void.c +19 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat.c +46 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat_x2.c +41 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat_x3.c +44 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat_x4.c +47 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_SZ_x2_DFloat.c +45 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_double.c +17 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_other.c +17 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_sizet.c +21 -0
- data/ext/numo/gsl/gen/tmpl/c_self_f_void.c +14 -0
- data/ext/numo/gsl/gen/tmpl/c_sizet_f_void.c +15 -0
- data/ext/numo/gsl/gen/tmpl/c_sizet_x2_f_void.c +17 -0
- data/ext/numo/gsl/gen/tmpl/c_str_f_void.c +15 -0
- data/ext/numo/gsl/gen/tmpl/c_super_new_void.c +18 -0
- data/ext/numo/gsl/gen/tmpl/c_uint_f_void.c +15 -0
- data/ext/numo/gsl/gen/tmpl/c_ulong_f_void.c +15 -0
- data/ext/numo/gsl/gen/tmpl/c_void_f_double.c +17 -0
- data/ext/numo/gsl/gen/tmpl/c_void_f_double_x2.c +18 -0
- data/ext/numo/gsl/gen/tmpl/c_void_f_double_x4.c +20 -0
- data/ext/numo/gsl/gen/tmpl/c_void_f_ulong.c +17 -0
- data/ext/numo/gsl/gen/tmpl/c_void_f_void.c +14 -0
- data/ext/numo/gsl/gen/tmpl/cast_1d_contiguous.c +15 -0
- data/ext/numo/gsl/gen/tmpl/cast_2d_contiguous.c +15 -0
- data/ext/numo/gsl/gen/tmpl/class.c +26 -0
- data/ext/numo/gsl/gen/tmpl/create_new_narray.c +26 -0
- data/ext/numo/gsl/gen/tmpl/init_class.c +10 -0
- data/ext/numo/gsl/gen/tmpl/init_module.c +12 -0
- data/ext/numo/gsl/gen/tmpl/lib.c +41 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_Int_f_DFloat.c +38 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat.c +35 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_Int.c +39 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_UInt.c +39 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_double.c +42 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_double_x2.c +47 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_int.c +42 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_x2.c +38 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_x3.c +41 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_Int.c +36 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt.c +36 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32.c +36 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_double.c +43 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_double_uint.c +49 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_double_x2.c +48 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_uint_x3.c +51 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_double.c +43 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_double_uint.c +50 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_double_x2.c +48 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_uint_x3.c +51 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_int_DFloat.c +41 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_int_DFloat_x2.c +44 -0
- data/ext/numo/gsl/gen/tmpl/m_DFloat_f_int_x2_DFloat_x2.c +46 -0
- data/ext/numo/gsl/gen/tmpl/m_Int_f_DFloat.c +36 -0
- data/ext/numo/gsl/gen/tmpl/m_Int_f_DFloat_x3.c +42 -0
- data/ext/numo/gsl/gen/tmpl/m_Int_f_int_DFloat.c +42 -0
- data/ext/numo/gsl/gen/tmpl/m_Int_f_int_DFloat_x2.c +45 -0
- data/ext/numo/gsl/gen/tmpl/mod_func_noloop.c +54 -0
- data/ext/numo/gsl/gen/tmpl/mod_func_scalar.c +27 -0
- data/ext/numo/gsl/gen/tmpl/module.c +9 -0
- data/ext/numo/gsl/histogram/depend +17 -0
- data/ext/numo/gsl/histogram/erbpp_histogram.rb +109 -0
- data/ext/numo/gsl/histogram/extconf.rb +9 -0
- data/ext/numo/gsl/histogram/func_def.rb +763 -0
- data/ext/numo/gsl/histogram/tmpl/c_DFloat_f_2d_get.c +54 -0
- data/ext/numo/gsl/histogram/tmpl/c_DFloat_f_field.c +35 -0
- data/ext/numo/gsl/histogram/tmpl/c_DFloat_f_get.c +47 -0
- data/ext/numo/gsl/histogram/tmpl/c_DFloat_x2_f_get_range.c +56 -0
- data/ext/numo/gsl/histogram/tmpl/c_bool_f_other.c +19 -0
- data/ext/numo/gsl/histogram/tmpl/c_bool_f_pdf_init.c +24 -0
- data/ext/numo/gsl/histogram/tmpl/c_self_f_2d_set_ranges.c +26 -0
- data/ext/numo/gsl/histogram/tmpl/c_self_f_set_ranges.c +21 -0
- data/ext/numo/gsl/histogram/tmpl/c_sizet_f_field.c +15 -0
- data/ext/numo/gsl/interp/depend +17 -0
- data/ext/numo/gsl/interp/erbpp_interp.rb +59 -0
- data/ext/numo/gsl/interp/extconf.rb +9 -0
- data/ext/numo/gsl/interp/func_def.rb +816 -0
- data/ext/numo/gsl/interp/parse_interp.rb +67 -0
- data/ext/numo/gsl/interp/tmpl/interp2d_new.c +36 -0
- data/ext/numo/gsl/interp/tmpl/interp2d_type_new.c +17 -0
- data/ext/numo/gsl/interp/tmpl/interp_bsearch.c +57 -0
- data/ext/numo/gsl/interp/tmpl/interp_new.c +29 -0
- data/ext/numo/gsl/interp/tmpl/interp_type_new.c +16 -0
- data/ext/numo/gsl/interp/tmpl/spline2d_eval.c +61 -0
- data/ext/numo/gsl/interp/tmpl/spline_eval.c +55 -0
- data/ext/numo/gsl/interp/tmpl/spline_integ.c +56 -0
- data/ext/numo/gsl/interp/type_def.rb +9 -0
- data/ext/numo/gsl/multifit/depend +17 -0
- data/ext/numo/gsl/multifit/erbpp_multifit.rb +99 -0
- data/ext/numo/gsl/multifit/extconf.rb +9 -0
- data/ext/numo/gsl/multifit/func_2.1.rb +1035 -0
- data/ext/numo/gsl/multifit/func_2.2.1.rb +736 -0
- data/ext/numo/gsl/multifit/func_2.2.rb +736 -0
- data/ext/numo/gsl/multifit/func_2.3.rb +872 -0
- data/ext/numo/gsl/multifit/func_def.rb +1012 -0
- data/ext/numo/gsl/multifit/tmpl/multifit_linear.c +66 -0
- data/ext/numo/gsl/multifit/tmpl/multifit_linear_est.c +48 -0
- data/ext/numo/gsl/multifit/tmpl/multifit_linear_residuals.c +47 -0
- data/ext/numo/gsl/multifit/tmpl/multifit_wlinear.c +70 -0
- data/ext/numo/gsl/multifit/type_def.rb +1 -0
- data/ext/numo/gsl/numo_gsl.h +117 -0
- data/ext/numo/gsl/pdf/depend +17 -0
- data/ext/numo/gsl/pdf/erbpp_pdf.rb +26 -0
- data/ext/numo/gsl/pdf/extconf.rb +9 -0
- data/ext/numo/gsl/pdf/func_2.2.1.rb +306 -0
- data/ext/numo/gsl/pdf/func_2.2.rb +306 -0
- data/ext/numo/gsl/pdf/func_2.3.rb +306 -0
- data/ext/numo/gsl/pdf/func_def.rb +282 -0
- data/ext/numo/gsl/pdf/parse_pdf.rb +42 -0
- data/ext/numo/gsl/pdf/tmpl/dirichlet.c +39 -0
- data/ext/numo/gsl/pdf/tmpl/multinomial.c +39 -0
- data/ext/numo/gsl/poly/depend +17 -0
- data/ext/numo/gsl/poly/erbpp_poly.rb +70 -0
- data/ext/numo/gsl/poly/extconf.rb +9 -0
- data/ext/numo/gsl/poly/func_def.rb +234 -0
- data/ext/numo/gsl/poly/tmpl/poly_complex_solve.c +59 -0
- data/ext/numo/gsl/poly/tmpl/poly_eval.c +70 -0
- data/ext/numo/gsl/poly/tmpl/poly_eval_derivs.c +40 -0
- data/ext/numo/gsl/ran/depend +17 -0
- data/ext/numo/gsl/ran/erbpp_ran.rb +42 -0
- data/ext/numo/gsl/ran/extconf.rb +9 -0
- data/ext/numo/gsl/ran/func_2.2.1.rb +1658 -0
- data/ext/numo/gsl/ran/func_2.2.rb +1658 -0
- data/ext/numo/gsl/ran/func_2.3.rb +1658 -0
- data/ext/numo/gsl/ran/func_def.rb +1594 -0
- data/ext/numo/gsl/ran/parse_ran.rb +10 -0
- data/ext/numo/gsl/rng/depend +17 -0
- data/ext/numo/gsl/rng/erbpp_rng.rb +58 -0
- data/ext/numo/gsl/rng/extconf.rb +9 -0
- data/ext/numo/gsl/rng/func_def.rb +230 -0
- data/ext/numo/gsl/rng/parse_rng.rb +125 -0
- data/ext/numo/gsl/rng/tmpl/ran.c +40 -0
- data/ext/numo/gsl/rng/tmpl/ran_DFloat_f_DFloat.c +28 -0
- data/ext/numo/gsl/rng/tmpl/ran_DFloat_x2.c +45 -0
- data/ext/numo/gsl/rng/tmpl/ran_DFloat_x3.c +51 -0
- data/ext/numo/gsl/rng/tmpl/ran_multinomial.c +32 -0
- data/ext/numo/gsl/rng/tmpl/rng_DFloat.c +29 -0
- data/ext/numo/gsl/rng/tmpl/rng_UInt.c +44 -0
- data/ext/numo/gsl/rng/tmpl/rng_alloc.c +24 -0
- data/ext/numo/gsl/rng/tmpl/rng_type_new.c +14 -0
- data/ext/numo/gsl/rng/type_def.rb +63 -0
- data/ext/numo/gsl/rstat/depend +17 -0
- data/ext/numo/gsl/rstat/erbpp_rstat.rb +64 -0
- data/ext/numo/gsl/rstat/extconf.rb +9 -0
- data/ext/numo/gsl/rstat/func_2.2.1.rb +116 -0
- data/ext/numo/gsl/rstat/func_2.2.rb +116 -0
- data/ext/numo/gsl/rstat/func_2.3.rb +123 -0
- data/ext/numo/gsl/rstat/func_def.rb +102 -0
- data/ext/numo/gsl/sf/depend +17 -0
- data/ext/numo/gsl/sf/erbpp_sf.rb +51 -0
- data/ext/numo/gsl/sf/extconf.rb +9 -0
- data/ext/numo/gsl/sf/func_def.rb +4703 -0
- data/ext/numo/gsl/sf/parse_sf.rb +277 -0
- data/ext/numo/gsl/sf/tmpl/c_DFloat_f_int_x2_DFloat.c +50 -0
- data/ext/numo/gsl/sf/tmpl/c_DFloat_f_int_x2_DFloat_x2.c +52 -0
- data/ext/numo/gsl/sf/tmpl/c_DFloat_f_int_x3_DFloat_x2.c +55 -0
- data/ext/numo/gsl/sf/tmpl/m_DFloat_f_DFloat_mode.c +47 -0
- data/ext/numo/gsl/sf/tmpl/m_DFloat_f_lmax_array.c +41 -0
- data/ext/numo/gsl/sf/tmpl/m_DFloat_f_nmin_nmax_array.c +49 -0
- data/ext/numo/gsl/spmatrix/const_2.2.1.rb +3 -0
- data/ext/numo/gsl/spmatrix/const_2.2.rb +3 -0
- data/ext/numo/gsl/spmatrix/const_2.3.rb +3 -0
- data/ext/numo/gsl/spmatrix/const_def.rb +2 -0
- data/ext/numo/gsl/spmatrix/depend +17 -0
- data/ext/numo/gsl/spmatrix/erbpp_spmatrix.rb +100 -0
- data/ext/numo/gsl/spmatrix/extconf.rb +9 -0
- data/ext/numo/gsl/spmatrix/func_2.2.1.rb +297 -0
- data/ext/numo/gsl/spmatrix/func_2.2.rb +297 -0
- data/ext/numo/gsl/spmatrix/func_2.3.rb +297 -0
- data/ext/numo/gsl/spmatrix/func_def.rb +218 -0
- data/ext/numo/gsl/spmatrix/parse_spmatrix.rb +70 -0
- data/ext/numo/gsl/spmatrix/tmpl/itersolve_iterate.c +47 -0
- data/ext/numo/gsl/spmatrix/tmpl/itersolve_new.c +22 -0
- data/ext/numo/gsl/spmatrix/tmpl/itersolve_type_new.c +16 -0
- data/ext/numo/gsl/spmatrix/tmpl/spblas_dgemm.c +35 -0
- data/ext/numo/gsl/spmatrix/tmpl/spblas_dgemv.c +43 -0
- data/ext/numo/gsl/spmatrix/tmpl/spmatrix_add.c +22 -0
- data/ext/numo/gsl/spmatrix/tmpl/spmatrix_d2sp.c +28 -0
- data/ext/numo/gsl/spmatrix/tmpl/spmatrix_new.c +40 -0
- data/ext/numo/gsl/spmatrix/tmpl/spmatrix_sp2d.c +25 -0
- data/ext/numo/gsl/spmatrix/type_def.rb +1 -0
- data/ext/numo/gsl/stats/depend +17 -0
- data/ext/numo/gsl/stats/erbpp_stats.rb +29 -0
- data/ext/numo/gsl/stats/extconf.rb +9 -0
- data/ext/numo/gsl/stats/func_2.2.1.rb +608 -0
- data/ext/numo/gsl/stats/func_2.2.rb +608 -0
- data/ext/numo/gsl/stats/func_2.3.rb +608 -0
- data/ext/numo/gsl/stats/func_def.rb +608 -0
- data/ext/numo/gsl/stats/parse_stats.rb +63 -0
- data/ext/numo/gsl/stats/tmpl/stats_1a0p.c +37 -0
- data/ext/numo/gsl/stats/tmpl/stats_1a0p_index.c +60 -0
- data/ext/numo/gsl/stats/tmpl/stats_1a1p.c +41 -0
- data/ext/numo/gsl/stats/tmpl/stats_1a2p.c +42 -0
- data/ext/numo/gsl/stats/tmpl/stats_2a0p.c +39 -0
- data/ext/numo/gsl/stats/tmpl/stats_2a1p.c +43 -0
- data/ext/numo/gsl/stats/tmpl/stats_2a2p.c +44 -0
- data/ext/numo/gsl/stats/tmpl/stats_minmax.c +37 -0
- data/ext/numo/gsl/stats/tmpl/stats_minmax_index.c +67 -0
- data/ext/numo/gsl/stats/tmpl/stats_spearman.c +46 -0
- data/ext/numo/gsl/sys/const_def.rb +21 -0
- data/ext/numo/gsl/sys/depend +17 -0
- data/ext/numo/gsl/sys/enum_def.rb +75 -0
- data/ext/numo/gsl/sys/erbpp_sys.rb +60 -0
- data/ext/numo/gsl/sys/extconf.rb +9 -0
- data/ext/numo/gsl/sys/func_def.rb +249 -0
- data/ext/numo/gsl/version.h +1 -0
- data/ext/numo/gsl/wavelet/depend +17 -0
- data/ext/numo/gsl/wavelet/erbpp_wavelet.rb +48 -0
- data/ext/numo/gsl/wavelet/extconf.rb +9 -0
- data/ext/numo/gsl/wavelet/func_def.rb +337 -0
- data/ext/numo/gsl/wavelet/parse_wavelet.rb +47 -0
- data/ext/numo/gsl/wavelet/tmpl/wavelet2d_transform.c +56 -0
- data/ext/numo/gsl/wavelet/tmpl/wavelet_array_check.c +56 -0
- data/ext/numo/gsl/wavelet/tmpl/wavelet_macro.c +1 -0
- data/ext/numo/gsl/wavelet/tmpl/wavelet_new.c +20 -0
- data/ext/numo/gsl/wavelet/tmpl/wavelet_transform.c +55 -0
- data/ext/numo/gsl/wavelet/tmpl/wavelet_transform2.c +22 -0
- data/ext/numo/gsl/wavelet/tmpl/wavelet_type_new.c +15 -0
- data/ext/numo/gsl/wavelet/type_def.rb +6 -0
- data/lib/numo/gsl.rb +17 -0
- data/numo-gsl.gemspec +33 -0
- metadata +367 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative "../gen/erbpp_gsl"
|
2
|
+
|
3
|
+
class DefInterp < DefGslClass
|
4
|
+
include ErbppGsl
|
5
|
+
|
6
|
+
types = ErbppGsl.read_type
|
7
|
+
INTERP_TYPES = types.select{|s| /gsl_interp_/ =~ s}
|
8
|
+
INTERP2D_TYPES = types.select{|s| /gsl_interp2d_/ =~ s}
|
9
|
+
|
10
|
+
def lookup(h)
|
11
|
+
dblbk = [dbl, /\[\]$/]
|
12
|
+
case h
|
13
|
+
when FM(name:/_free$/); false
|
14
|
+
when FM(tp,*[dblbk]*3,szt,szt,name:/_init$/); "interp2d_new"
|
15
|
+
when FM(tp,*[dblbk]*2,szt,name:/_init$/); "interp_new"
|
16
|
+
when FM(name:"gsl_interp_bsearch"); "interp_bsearch"
|
17
|
+
when FM(tp, type:str); "c_str_f_void"
|
18
|
+
when FM(tp, type:uint); "c_uint_f_void"
|
19
|
+
when FM(tp, dbl, /accel/, type:dbl); "spline_eval"
|
20
|
+
when FM(tp,*[dbl]*2, /accel/, type:dbl); "spline_integ"
|
21
|
+
when FM(tp,*[dbl]*2,*[/accel/]*2,type:dbl); "spline2d_eval"
|
22
|
+
|
23
|
+
when FM(name:"gsl_interp_accel_alloc"); "c_new_void"
|
24
|
+
when FM(tp); "c_self_f_void"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def check_func(h)
|
29
|
+
if t = lookup(h)
|
30
|
+
m = h[:func_name].sub(/^gsl_[^_]+_(accel_)?/,"")
|
31
|
+
DefMethod.new(self, t, name:m, **h)
|
32
|
+
def_type_new(h)
|
33
|
+
return true
|
34
|
+
end
|
35
|
+
$stderr.puts "skip #{h[:func_name]}"
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def def_type_new(h)
|
40
|
+
case h[:func_name]
|
41
|
+
when "gsl_interp_init"
|
42
|
+
t = "interp_type_new"
|
43
|
+
INTERP_TYPES.each do |v|
|
44
|
+
st = v.sub(/^gsl_interp_/,"")
|
45
|
+
DefSubclassNew.new(self, t, v, st, **h)
|
46
|
+
end
|
47
|
+
when "gsl_spline_init"
|
48
|
+
t = "interp_type_new"
|
49
|
+
INTERP_TYPES.each do |v|
|
50
|
+
st = v.sub(/^gsl_interp_/,"")
|
51
|
+
DefSubclassNew.new(self, t, v, st, **h)
|
52
|
+
end
|
53
|
+
when "gsl_interp2d_init"
|
54
|
+
t = "interp2d_type_new"
|
55
|
+
INTERP2D_TYPES.each do |v|
|
56
|
+
st = v.sub(/^gsl_interp2d_/,"")
|
57
|
+
DefSubclassNew.new(self, t, v, st, **h)
|
58
|
+
end
|
59
|
+
when "gsl_spline2d_init"
|
60
|
+
t = "interp2d_type_new"
|
61
|
+
INTERP2D_TYPES.each do |v|
|
62
|
+
st = v.sub(/^gsl_interp2d_/,"")
|
63
|
+
DefSubclassNew.new(self, t, v, st, **h)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%
|
2
|
+
set name: "new"
|
3
|
+
set singleton: true
|
4
|
+
set alloc_func: func_name.sub(/_init$/,"_alloc")
|
5
|
+
%>
|
6
|
+
/*
|
7
|
+
:nodoc:
|
8
|
+
*/
|
9
|
+
static VALUE
|
10
|
+
<%=c_func(:nodef)%>(VALUE self, const gsl_interp2d_type *t, VALUE v1, VALUE v2, VALUE v3)
|
11
|
+
{
|
12
|
+
double *p1, *p2, *p3;
|
13
|
+
size_t nx, ny;
|
14
|
+
narray_t *na;
|
15
|
+
<%=struct%> *w;
|
16
|
+
|
17
|
+
v1 = cast_1d_contiguous(v1, cDF);
|
18
|
+
v2 = cast_1d_contiguous(v2, cDF);
|
19
|
+
v3 = cast_2d_contiguous(v3, cDF);
|
20
|
+
nx = RNARRAY_SIZE(v1);
|
21
|
+
ny = RNARRAY_SIZE(v2);
|
22
|
+
GetNArray(v3,na);
|
23
|
+
if (na->shape[1] != nx || na->shape[0] != ny) {
|
24
|
+
rb_raise(nary_eShapeError,"za.shape should be [ya.size,xa.size]");
|
25
|
+
}
|
26
|
+
w = <%=alloc_func%>(t, nx, ny);
|
27
|
+
p1 = (double*)na_get_pointer_for_read(v1);
|
28
|
+
p2 = (double*)na_get_pointer_for_read(v2);
|
29
|
+
p3 = (double*)na_get_pointer_for_read(v3);
|
30
|
+
<%=func_name%>(w, p1, p2, p3, nx, ny);
|
31
|
+
RB_GC_GUARD(v1);
|
32
|
+
RB_GC_GUARD(v2);
|
33
|
+
RB_GC_GUARD(v3);
|
34
|
+
|
35
|
+
return TypedData_Wrap_Struct(<%=class_var%>, &<%=data_type_var%>, (void*)w);
|
36
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%=name%>(<%=args[0][1]%>,<%=args[1][1]%>,<%=args[2][1]%>)
|
3
|
+
@param [DFloat] <%=args[0][1]%>
|
4
|
+
@param [DFloat] <%=args[1][1]%>
|
5
|
+
@param [DFloat] <%=args[2][1]%>
|
6
|
+
|
7
|
+
Generate an instance of <%=full_class_name%>::<%=subtype_class%> class,
|
8
|
+
a subclass of <%=full_class_name%> class with <%=subtype_var%> type.
|
9
|
+
|
10
|
+
<%= desc %>
|
11
|
+
|
12
|
+
*/
|
13
|
+
static VALUE
|
14
|
+
<%=c_func(3)%>(VALUE self, VALUE v1, VALUE v2, VALUE v3)
|
15
|
+
{
|
16
|
+
return <%=c_superclass_new%>(self, <%=subtype_var%>, v1, v2, v3);
|
17
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<%
|
2
|
+
set singleton: true
|
3
|
+
%>
|
4
|
+
/*
|
5
|
+
@overload <%=name%>(<%=args[0][1]%>,<%=args[1][1]%>)
|
6
|
+
@param [DFloat] <%=args[0][1]%>
|
7
|
+
@param [Float] <%=args[0][1]%>
|
8
|
+
|
9
|
+
@overload <%=name%>(<%=args[0][1]%>,<%=args[1][1]%>,range)
|
10
|
+
@param [DFloat] <%=args[0][1]%>
|
11
|
+
@param [Float] <%=args[0][1]%>
|
12
|
+
@param [Range] range
|
13
|
+
|
14
|
+
@overload <%=name%>(<%=args[0][1]%>,<%=args[1][1]%>,<%=args[2][1]%>,<%=args[2][1]%>)
|
15
|
+
@param [DFloat] <%=args[0][1]%>
|
16
|
+
@param [Float] <%=args[1][1]%>
|
17
|
+
@param [Integer] <%=args[2][1]%>
|
18
|
+
@param [Integer] <%=args[3][1]%>
|
19
|
+
|
20
|
+
allocate instance of <%=class_name%> class.
|
21
|
+
|
22
|
+
<%= desc %>
|
23
|
+
*/
|
24
|
+
static VALUE
|
25
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE klass)
|
26
|
+
{
|
27
|
+
double *p1;
|
28
|
+
size_t n1, lo=0, hi=0, idx;
|
29
|
+
VALUE v1, v2, v3, v4;
|
30
|
+
long beg, len;
|
31
|
+
double x;
|
32
|
+
int nargs;
|
33
|
+
|
34
|
+
nargs = rb_scan_args(argc, argv, "22", &v1, &v2, &v3, &v4);
|
35
|
+
v1 = cast_1d_contiguous(v1, cDF);
|
36
|
+
n1 = RNARRAY_SIZE(v1);
|
37
|
+
x = NUM2DBL(v2);
|
38
|
+
switch(nargs) {
|
39
|
+
case 4:
|
40
|
+
v3 = rb_range_new(v3,v4,0);
|
41
|
+
case 3:
|
42
|
+
if (rb_range_beg_len(v3, &beg, &len, n1, 2) != Qtrue) {
|
43
|
+
rb_raise(rb_eRangeError, "range error");
|
44
|
+
}
|
45
|
+
lo = beg;
|
46
|
+
hi = beg+len-1;
|
47
|
+
break;
|
48
|
+
case 2:
|
49
|
+
lo = 0;
|
50
|
+
hi = n1-1;
|
51
|
+
}
|
52
|
+
p1 = (double*)na_get_pointer_for_read(v1);
|
53
|
+
idx = <%=func_name%>(p1, x, lo, hi);
|
54
|
+
RB_GC_GUARD(v1);
|
55
|
+
|
56
|
+
return SIZET2NUM(idx);
|
57
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%
|
2
|
+
set name: "new"
|
3
|
+
set singleton: true
|
4
|
+
set alloc_func: func_name.sub(/_init$/,"_alloc")
|
5
|
+
%>
|
6
|
+
/*
|
7
|
+
:nodoc:
|
8
|
+
*/
|
9
|
+
static VALUE
|
10
|
+
<%=c_func(:nodef)%>(VALUE self, const gsl_interp_type *t, VALUE v1, VALUE v2)
|
11
|
+
{
|
12
|
+
<%=struct%> *w;
|
13
|
+
double *p1, *p2;
|
14
|
+
size_t n1, n2, sz;
|
15
|
+
|
16
|
+
v1 = cast_1d_contiguous(v1, cDF);
|
17
|
+
v2 = cast_1d_contiguous(v2, cDF);
|
18
|
+
n1 = RNARRAY_SIZE(v1);
|
19
|
+
n2 = RNARRAY_SIZE(v2);
|
20
|
+
sz = (n1 < n2) ? n1 : n2;
|
21
|
+
w = <%=alloc_func%>(t, sz);
|
22
|
+
p1 = (double*)na_get_pointer_for_read(v1);
|
23
|
+
p2 = (double*)na_get_pointer_for_read(v2);
|
24
|
+
<%=func_name%>(w, p1, p2, sz);
|
25
|
+
RB_GC_GUARD(v1);
|
26
|
+
RB_GC_GUARD(v2);
|
27
|
+
|
28
|
+
return TypedData_Wrap_Struct(<%=class_var%>, &<%=data_type_var%>, (void*)w);
|
29
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%=name%>(<%=args[1][1]%>,<%=args[2][1]%>)
|
3
|
+
@param [DFloat] <%=args[1][1]%>
|
4
|
+
@param [DFloat] <%=args[2][1]%>
|
5
|
+
|
6
|
+
Generate an instance of <%=full_class_name%>::<%=subtype_class%> class,
|
7
|
+
a subclass of <%=full_class_name%> class with <%=subtype_var%> type.
|
8
|
+
|
9
|
+
<%= desc %>
|
10
|
+
|
11
|
+
*/
|
12
|
+
static VALUE
|
13
|
+
<%=c_func(2)%>(VALUE self, VALUE v1, VALUE v2)
|
14
|
+
{
|
15
|
+
return <%=c_superclass_new%>(self, <%=subtype_var%>, v1, v2);
|
16
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
static void
|
2
|
+
iter_<%=c_func%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t i;
|
5
|
+
char *p1, *p2, *p3;
|
6
|
+
ssize_t s1, s2, s3;
|
7
|
+
double x, y, z;
|
8
|
+
void **opts;
|
9
|
+
<%=struct%> *w;
|
10
|
+
gsl_interp_accel *a1, *a2;
|
11
|
+
|
12
|
+
opts = (void **)(lp->opt_ptr);
|
13
|
+
w = (<%=struct%>*)(opts[0]);
|
14
|
+
a1 = (gsl_interp_accel*)(opts[1]);
|
15
|
+
a2 = (gsl_interp_accel*)(opts[2]);
|
16
|
+
|
17
|
+
INIT_COUNTER(lp, i);
|
18
|
+
INIT_PTR(lp, 0, p1, s1);
|
19
|
+
INIT_PTR(lp, 1, p2, s2);
|
20
|
+
INIT_PTR(lp, 2, p3, s3);
|
21
|
+
|
22
|
+
for (; i--; ) {
|
23
|
+
GET_DATA_STRIDE(p1,s1,double,x);
|
24
|
+
GET_DATA_STRIDE(p2,s2,double,y);
|
25
|
+
z = <%=func_name%>(w, x, y, a1, a2);
|
26
|
+
SET_DATA_STRIDE(p3,s3,double,z);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
/*
|
31
|
+
@overload <%=name%>(<%=args[1][1]%>,<%=args[2][1]%>)
|
32
|
+
@param [DFloat] <%=args[1][1]%>
|
33
|
+
@param [DFloat] <%=args[2][1]%>
|
34
|
+
@return [DFloat] result
|
35
|
+
|
36
|
+
<%= description %>
|
37
|
+
*/
|
38
|
+
static VALUE
|
39
|
+
<%=c_func(2)%>(VALUE self, VALUE v1, VALUE v2)
|
40
|
+
{
|
41
|
+
ndfunc_arg_in_t ain[2] = {{cDF,0},{cDF,0}};
|
42
|
+
ndfunc_arg_out_t aout[1] = {{cDF,0}};
|
43
|
+
ndfunc_t ndf = {iter_<%=c_func%>, STRIDE_LOOP|NDF_EXTRACT, 2,1, ain,aout};
|
44
|
+
<%=struct%> *w;
|
45
|
+
gsl_interp_accel *a1, *a2;
|
46
|
+
void *opts[3];
|
47
|
+
VALUE vac1, vac2, v;
|
48
|
+
|
49
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, w);
|
50
|
+
opts[0] = w;
|
51
|
+
vac1 = interp_accel_s_new(cInterpAccel);
|
52
|
+
TypedData_Get_Struct(vac1, gsl_interp_accel, &interp_accel_data_type, a1);
|
53
|
+
opts[1] = a1;
|
54
|
+
vac2 = interp_accel_s_new(cInterpAccel);
|
55
|
+
TypedData_Get_Struct(vac2, gsl_interp_accel, &interp_accel_data_type, a2);
|
56
|
+
opts[2] = a2;
|
57
|
+
v = na_ndloop3(&ndf, opts, 2, v1, v2);
|
58
|
+
RB_GC_GUARD(vac1);
|
59
|
+
RB_GC_GUARD(vac2);
|
60
|
+
return v;
|
61
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
static void
|
2
|
+
iter_<%=c_func%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t i;
|
5
|
+
char *p1, *p2;
|
6
|
+
ssize_t s1, s2;
|
7
|
+
double x, y;
|
8
|
+
void **opts;
|
9
|
+
<%=struct%> *w;
|
10
|
+
gsl_interp_accel *a;
|
11
|
+
|
12
|
+
opts = (void **)(lp->opt_ptr);
|
13
|
+
w = (<%=struct%>*)(opts[0]);
|
14
|
+
a = (gsl_interp_accel*)(opts[1]);
|
15
|
+
|
16
|
+
INIT_COUNTER(lp, i);
|
17
|
+
INIT_PTR(lp, 0, p1, s1);
|
18
|
+
INIT_PTR(lp, 1, p2, s2);
|
19
|
+
|
20
|
+
for (; i--; ) {
|
21
|
+
GET_DATA_STRIDE(p1,s1,double,x);
|
22
|
+
y = <%=func_name%>(w, x, a);
|
23
|
+
SET_DATA_STRIDE(p2,s2,double,y);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
/*
|
28
|
+
@overload <%=name%>(<%=args[1][1]%>)
|
29
|
+
@param [DFloat] <%=args[1][1]%>
|
30
|
+
@return [DFloat] result
|
31
|
+
|
32
|
+
<%= description %>
|
33
|
+
*/
|
34
|
+
static VALUE
|
35
|
+
<%=c_func(1)%>(VALUE self, VALUE v1)
|
36
|
+
{
|
37
|
+
ndfunc_arg_in_t ain[1] = {{cDF,0}};
|
38
|
+
ndfunc_arg_out_t aout[1] = {{cDF,0}};
|
39
|
+
ndfunc_t ndf = {iter_<%=c_func%>, STRIDE_LOOP|NDF_EXTRACT, 1,1, ain,aout};
|
40
|
+
<%=struct%> *w;
|
41
|
+
gsl_interp_accel *a;
|
42
|
+
void *opts[2];
|
43
|
+
VALUE vac, v;
|
44
|
+
|
45
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, w);
|
46
|
+
opts[0] = w;
|
47
|
+
|
48
|
+
vac = interp_accel_s_new(cInterpAccel);
|
49
|
+
TypedData_Get_Struct(vac, gsl_interp_accel, &interp_accel_data_type, a);
|
50
|
+
opts[1] = a;
|
51
|
+
|
52
|
+
v = na_ndloop3(&ndf, opts, 1, v1);
|
53
|
+
RB_GC_GUARD(vac);
|
54
|
+
return v;
|
55
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
static void
|
2
|
+
iter_<%=c_func%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t i;
|
5
|
+
char *p1, *p2, *p3;
|
6
|
+
ssize_t s1, s2, s3;
|
7
|
+
double x, y, z;
|
8
|
+
void **opts;
|
9
|
+
<%=struct%> *w;
|
10
|
+
gsl_interp_accel *a;
|
11
|
+
|
12
|
+
opts = (void **)(lp->opt_ptr);
|
13
|
+
w = (<%=struct%>*)(opts[0]);
|
14
|
+
a = (gsl_interp_accel*)(opts[1]);
|
15
|
+
|
16
|
+
INIT_COUNTER(lp, i);
|
17
|
+
INIT_PTR(lp, 0, p1, s1);
|
18
|
+
INIT_PTR(lp, 1, p2, s2);
|
19
|
+
INIT_PTR(lp, 2, p3, s3);
|
20
|
+
|
21
|
+
for (; i--; ) {
|
22
|
+
GET_DATA_STRIDE(p1,s1,double,x);
|
23
|
+
GET_DATA_STRIDE(p2,s2,double,y);
|
24
|
+
z = <%=func_name%>(w, x, y, a);
|
25
|
+
SET_DATA_STRIDE(p3,s3,double,z);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
/*
|
30
|
+
@overload <%=name%>(<%=args[1][1]%>,<%=args[2][1]%>)
|
31
|
+
@param [DFloat] <%=args[1][1]%>
|
32
|
+
@param [DFloat] <%=args[2][1]%>
|
33
|
+
@return [DFloat] result
|
34
|
+
|
35
|
+
<%= description %>
|
36
|
+
*/
|
37
|
+
static VALUE
|
38
|
+
<%=c_func(2)%>(VALUE self, VALUE v1, VALUE v2)
|
39
|
+
{
|
40
|
+
ndfunc_arg_in_t ain[2] = {{cDF,0},{cDF,0}};
|
41
|
+
ndfunc_arg_out_t aout[1] = {{cDF,0}};
|
42
|
+
ndfunc_t ndf = {iter_<%=c_func%>, STRIDE_LOOP|NDF_EXTRACT, 2,1, ain,aout};
|
43
|
+
<%=struct%> *w;
|
44
|
+
gsl_interp_accel *a;
|
45
|
+
void *opts[2];
|
46
|
+
VALUE vac, v;
|
47
|
+
|
48
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, w);
|
49
|
+
opts[0] = w;
|
50
|
+
vac = interp_accel_s_new(cInterpAccel);
|
51
|
+
TypedData_Get_Struct(vac, gsl_interp_accel, &interp_accel_data_type, a);
|
52
|
+
opts[1] = a;
|
53
|
+
v = na_ndloop3(&ndf, opts, 2, v1, v2);
|
54
|
+
RB_GC_GUARD(vac);
|
55
|
+
return v;
|
56
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
COGEN=ruby erbpp_multifit.rb
|
2
|
+
GENSRC=gsl_multifit.c
|
3
|
+
GENDEPS=erbpp_multifit.rb ../gen/*.rb ../gen/tmpl/*.c
|
4
|
+
|
5
|
+
src : $(GENSRC)
|
6
|
+
|
7
|
+
$(GENSRC) : $(GENDEPS)
|
8
|
+
$(COGEN) $@
|
9
|
+
|
10
|
+
doc : $(GENSRC)
|
11
|
+
yard doc $(GENSRC)
|
12
|
+
|
13
|
+
clean: cleansrc cleandoc
|
14
|
+
cleansrc:
|
15
|
+
-$(Q)$(RM) $(GENSRC)
|
16
|
+
cleandoc:
|
17
|
+
-$(Q)$(RM_RF) doc .yardoc
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require_relative "../gen/erbpp_gsl"
|
2
|
+
require "erbpp/line_number"
|
3
|
+
require "pp"
|
4
|
+
|
5
|
+
ErbppGsl.read_func_pattern(
|
6
|
+
[/^gsl_multifit_w?linear$/, mfit_list=[]],
|
7
|
+
[/^gsl_multifit_linear(_alloc|_free)$/, linws_list=[]],
|
8
|
+
[/^gsl_multifit_w?linear/, linear_list=[]],
|
9
|
+
[/^gsl_multifit_nlinear/, nlinear_list=[]],
|
10
|
+
)
|
11
|
+
|
12
|
+
class DefMultifit < DefGslModule
|
13
|
+
def lookup(h)
|
14
|
+
fn = h[:func_name].sub(/gsl_/,"")
|
15
|
+
return fn if File.exist?("tmpl/#{fn}.c")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class DefLinearWorkspace < DefGslClass
|
20
|
+
def lookup(h)
|
21
|
+
case h
|
22
|
+
when FM(szt,szt, name:/_alloc$/); "c_new_sizet_x2"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class MultifitLinear < DefGslModuleFunction
|
28
|
+
def _mod_var
|
29
|
+
parent.module_var
|
30
|
+
end
|
31
|
+
|
32
|
+
def init_def
|
33
|
+
case func_name
|
34
|
+
when /_linear$/
|
35
|
+
super + "
|
36
|
+
#{struct_def("LinearResult",%w[c cov chisq])}"
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def struct_def(cls,vars)
|
43
|
+
items = vars.map{|v| "\"#{v}\""}.join(",")
|
44
|
+
"/*
|
45
|
+
Document-class: Numo::GSL::Multifit::LinearResult
|
46
|
+
*/
|
47
|
+
c#{cls} = rb_struct_define_under(#{_mod_var},\"#{cls}\",#{items},NULL);"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
DefLib.new do
|
53
|
+
set erb_dir: %w[tmpl ../gen/tmpl]
|
54
|
+
set erb_suffix: ".c"
|
55
|
+
|
56
|
+
name = "Multifit"
|
57
|
+
set file_name: "gsl_#{name}.c"
|
58
|
+
set include_files: ["gsl/gsl_multifit.h"]
|
59
|
+
set lib_name: name.downcase
|
60
|
+
set ns_var: "mG"
|
61
|
+
|
62
|
+
DefMultifit.new(self) do
|
63
|
+
mname = "Multifit"
|
64
|
+
mbase = "multifit"
|
65
|
+
set name: mbase
|
66
|
+
set module_name: mname
|
67
|
+
set module_var: "m"+mname
|
68
|
+
set full_module_name: "Numo::GSL::"+mname
|
69
|
+
|
70
|
+
cname = "LinearWorkspace"
|
71
|
+
cbase = "multifit_linear_workspace"
|
72
|
+
|
73
|
+
DefLinearWorkspace.new(self) do
|
74
|
+
set name: cbase
|
75
|
+
set class_name: cname
|
76
|
+
set class_var: "c"+cname
|
77
|
+
set full_class_name: "Numo::GSL::#{mname}::"+cname
|
78
|
+
set struct: "gsl_#{cbase}"
|
79
|
+
set postpose: true
|
80
|
+
set ns_var: "m"+mname
|
81
|
+
|
82
|
+
undef_alloc_func
|
83
|
+
linws_list.each do |h|
|
84
|
+
check_func(h)
|
85
|
+
end
|
86
|
+
|
87
|
+
mfit_list.each do |h|
|
88
|
+
m = h[:func_name].sub(/^gsl_#{mbase}_/,"")
|
89
|
+
t = mbase+"_"+m
|
90
|
+
MultifitLinear.new(self, t, name:m, **h)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
linear_list.each do |h|
|
95
|
+
check_func(h)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end.write(ARGV[0])
|