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,50 @@
|
|
1
|
+
static void
|
2
|
+
iter_<%=c_func%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t n;
|
5
|
+
char *p1,*p2;
|
6
|
+
double *p3,*p4,*p5;
|
7
|
+
ssize_t s1, s2;
|
8
|
+
|
9
|
+
n = lp->args[0].shape[0];
|
10
|
+
INIT_PTR(lp, 0, p1, s1);
|
11
|
+
INIT_PTR(lp, 1, p2, s2);
|
12
|
+
p3 = (double*)GET_PTR(lp,2);
|
13
|
+
p4 = (double*)GET_PTR(lp,3);
|
14
|
+
p5 = (double*)GET_PTR(lp,4);
|
15
|
+
|
16
|
+
<%=func_name%>((double*)p1,s1/sizeof(double),
|
17
|
+
(double*)p2,s2/sizeof(double),
|
18
|
+
n,p3,p4,p5);
|
19
|
+
}
|
20
|
+
|
21
|
+
/*
|
22
|
+
@overload <%=name%>(<%=args[0][1]%>,<%=args[2][1]%>)
|
23
|
+
@param [DFloat] <%=args[0][1]%> (input array)
|
24
|
+
@param [DFloat] <%=args[2][1]%> (input array)
|
25
|
+
@return [GSL::Fit::<%=result_class%>] result Struct with members: <%=args[5][1]%>, <%=args[6][1]%>, <%=args[7][1]%>.
|
26
|
+
|
27
|
+
<%=desc%>
|
28
|
+
|
29
|
+
*/
|
30
|
+
static VALUE
|
31
|
+
<%=c_func(2)%>(VALUE mod, VALUE v1, VALUE v2)
|
32
|
+
{
|
33
|
+
VALUE r, result;
|
34
|
+
ndfunc_arg_in_t ain[2] = {{cDF,1},{cDF,1}};
|
35
|
+
ndfunc_arg_out_t aout[3] = {{cDF,0},{cDF,0},{cDF,0}};
|
36
|
+
ndfunc_t ndf = { iter_<%=c_func%>, STRIDE_LOOP_NIP|NDF_EXTRACT,
|
37
|
+
2, 3, ain, aout };
|
38
|
+
narray_t *x,*y;
|
39
|
+
|
40
|
+
GetNArray(v1,x);
|
41
|
+
GetNArray(v2,y);
|
42
|
+
CHECK_GE_1D(x);
|
43
|
+
CHECK_GE_1D(y);
|
44
|
+
CHECK_SIZE_EQ(VEC_SIZE(x),VEC_SIZE(y),"x size does not match y size");
|
45
|
+
|
46
|
+
r = na_ndloop(&ndf, 2, v1, v2);
|
47
|
+
result = rb_class_new_instance(3, RARRAY_PTR(r), c<%=result_class%>);
|
48
|
+
RB_GC_GUARD(r);
|
49
|
+
return result;
|
50
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
static void
|
2
|
+
iter_<%=c_func%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t i;
|
5
|
+
char *p1,*p2,*p3,*p4,*p5;
|
6
|
+
ssize_t s1, s2, s3, s4, s5;
|
7
|
+
double x,c1,cov11,y,ye;
|
8
|
+
|
9
|
+
INIT_COUNTER(lp, i);
|
10
|
+
INIT_PTR(lp, 0, p1, s1);
|
11
|
+
INIT_PTR(lp, 1, p2, s2);
|
12
|
+
INIT_PTR(lp, 2, p3, s3);
|
13
|
+
INIT_PTR(lp, 3, p4, s4);
|
14
|
+
INIT_PTR(lp, 4, p5, s5);
|
15
|
+
|
16
|
+
for (; i--; ) {
|
17
|
+
GET_DATA_STRIDE(p1,s1,double,x);
|
18
|
+
GET_DATA_STRIDE(p2,s2,double,c1);
|
19
|
+
GET_DATA_STRIDE(p3,s3,double,cov11);
|
20
|
+
<%=func_name%>(x, c1, cov11, &y, &ye);
|
21
|
+
SET_DATA_STRIDE(p4,s4,double,y);
|
22
|
+
SET_DATA_STRIDE(p5,s5,double,ye);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
/*
|
27
|
+
@overload <%=name%>(<%=args[0][1]%>, mul_result)
|
28
|
+
@param [DFloat] <%=args[0][1]%>
|
29
|
+
@param [(M|Wm)ulResult] mul_result Result of GSL::Fit.mul|wmul
|
30
|
+
@return [[DFloat,DFloat]] array of [<%=args[3][1]%>,<%=args[4][1]%>]
|
31
|
+
|
32
|
+
<%=desc%>
|
33
|
+
|
34
|
+
*/
|
35
|
+
static VALUE
|
36
|
+
<%=c_func(2)%>(VALUE mod, VALUE v1, VALUE v2)
|
37
|
+
{
|
38
|
+
ndfunc_arg_in_t ain[3] = {{cDF,0},{cDF,0},{cDF,0}};
|
39
|
+
ndfunc_arg_out_t aout[2] = {{cDF,0},{cDF,0}};
|
40
|
+
ndfunc_t ndf = { iter_<%=c_func%>, STRIDE_LOOP_NIP|NDF_EXTRACT,
|
41
|
+
3, 2, ain, aout };
|
42
|
+
VALUE c1, cov11;
|
43
|
+
|
44
|
+
c1 = RSTRUCT_GET(v2,0);
|
45
|
+
cov11 = RSTRUCT_GET(v2,1);
|
46
|
+
return na_ndloop(&ndf, 3, v1, c1, cov11);
|
47
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
static void
|
2
|
+
iter_<%=c_func%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t n;
|
5
|
+
char *p1,*p2,*p3;
|
6
|
+
double *p4,*p5,*p6,*p7,*p8,*p9;
|
7
|
+
ssize_t s1, s2, s3;
|
8
|
+
|
9
|
+
n = lp->args[0].shape[0];
|
10
|
+
INIT_PTR(lp, 0, p1, s1);
|
11
|
+
INIT_PTR(lp, 1, p2, s2);
|
12
|
+
INIT_PTR(lp, 2, p3, s3);
|
13
|
+
p4 = (double*)GET_PTR(lp,3);
|
14
|
+
p5 = (double*)GET_PTR(lp,4);
|
15
|
+
p6 = (double*)GET_PTR(lp,5);
|
16
|
+
p7 = (double*)GET_PTR(lp,6);
|
17
|
+
p8 = (double*)GET_PTR(lp,7);
|
18
|
+
p9 = (double*)GET_PTR(lp,8);
|
19
|
+
|
20
|
+
<%=func_name%>((double*)p1,s1/sizeof(double),
|
21
|
+
(double*)p2,s2/sizeof(double),
|
22
|
+
(double*)p3,s3/sizeof(double),
|
23
|
+
n,p4,p5,p6,p7,p8,p9);
|
24
|
+
}
|
25
|
+
|
26
|
+
/*
|
27
|
+
@overload <%=name%>(<%=args[0][1]%>,<%=args[2][1]%>,<%=args[4][1]%>)
|
28
|
+
@param [DFloat] <%=args[0][1]%> (input array)
|
29
|
+
@param [DFloat] <%=args[2][1]%> (input array)
|
30
|
+
@param [DFloat] <%=args[4][1]%> (input array)
|
31
|
+
@return [GSL::Fit::<%=result_class%>] result Struct with members: <%=args[7][1]%>, <%=args[8][1]%>, <%=args[9][1]%>, <%=args[10][1]%>, <%=args[11][1]%>, <%=args[12][1]%>.
|
32
|
+
|
33
|
+
<%=desc%>
|
34
|
+
|
35
|
+
*/
|
36
|
+
static VALUE
|
37
|
+
<%=c_func(3)%>(VALUE mod, VALUE v1, VALUE v2, VALUE v3)
|
38
|
+
{
|
39
|
+
ndfunc_arg_in_t ain[3] = {{cDF,1},{cDF,1},{cDF,1}};
|
40
|
+
ndfunc_arg_out_t aout[6] = {{cDF,0},{cDF,0},{cDF,0},{cDF,0},{cDF,0},{cDF,0}};
|
41
|
+
ndfunc_t ndf = { iter_<%=c_func%>, STRIDE_LOOP_NIP|NDF_EXTRACT,
|
42
|
+
3, 6, ain, aout };
|
43
|
+
narray_t *x, *y, *w;
|
44
|
+
VALUE r, result;
|
45
|
+
|
46
|
+
GetNArray(v1,x);
|
47
|
+
GetNArray(v2,y);
|
48
|
+
GetNArray(v3,w);
|
49
|
+
CHECK_GE_1D(x);
|
50
|
+
CHECK_GE_1D(y);
|
51
|
+
CHECK_GE_1D(w);
|
52
|
+
CHECK_SIZE_EQ(VEC_SIZE(x),VEC_SIZE(y),"y size does not match x size");
|
53
|
+
CHECK_SIZE_EQ(VEC_SIZE(x),VEC_SIZE(w),"w size does not match x size");
|
54
|
+
|
55
|
+
r = na_ndloop(&ndf, 3, v1, v2, v3);
|
56
|
+
result = rb_class_new_instance(6, RARRAY_PTR(r), c<%=result_class%>);
|
57
|
+
RB_GC_GUARD(r);
|
58
|
+
return result;
|
59
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
static void
|
2
|
+
iter_<%=c_func%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t n;
|
5
|
+
char *p1,*p2,*p3;
|
6
|
+
double *p4,*p5,*p6;
|
7
|
+
ssize_t s1, s2, s3;
|
8
|
+
|
9
|
+
n = lp->args[0].shape[0];
|
10
|
+
INIT_PTR(lp, 0, p1, s1);
|
11
|
+
INIT_PTR(lp, 1, p2, s2);
|
12
|
+
INIT_PTR(lp, 2, p3, s3);
|
13
|
+
p4 = (double*)GET_PTR(lp,3);
|
14
|
+
p5 = (double*)GET_PTR(lp,4);
|
15
|
+
p6 = (double*)GET_PTR(lp,5);
|
16
|
+
|
17
|
+
<%=func_name%>((double*)p1,s1/sizeof(double),
|
18
|
+
(double*)p2,s2/sizeof(double),
|
19
|
+
(double*)p3,s3/sizeof(double),
|
20
|
+
n,p4,p5,p6);
|
21
|
+
}
|
22
|
+
|
23
|
+
/*
|
24
|
+
@overload <%=name%>(<%=args[0][1]%>,<%=args[2][1]%>,<%=args[4][1]%>)
|
25
|
+
@param [DFloat] <%=args[0][1]%> (input array)
|
26
|
+
@param [DFloat] <%=args[2][1]%> (input array)
|
27
|
+
@param [DFloat] <%=args[4][1]%> (input array)
|
28
|
+
@return [GSL::Fit::<%=result_class%>] result Struct with members: <%=args[7][1]%>, <%=args[8][1]%>, <%=args[9][1]%>.
|
29
|
+
|
30
|
+
<%=desc%>
|
31
|
+
|
32
|
+
*/
|
33
|
+
static VALUE
|
34
|
+
<%=c_func(3)%>(VALUE mod, VALUE v1, VALUE v2, VALUE v3)
|
35
|
+
{
|
36
|
+
VALUE r, result;
|
37
|
+
ndfunc_arg_in_t ain[3] = {{cDF,1},{cDF,1},{cDF,1}};
|
38
|
+
ndfunc_arg_out_t aout[3] = {{cDF,0},{cDF,0},{cDF,0}};
|
39
|
+
ndfunc_t ndf = { iter_<%=c_func%>, STRIDE_LOOP_NIP|NDF_EXTRACT,
|
40
|
+
3, 3, ain, aout };
|
41
|
+
narray_t *x,*y,*w;
|
42
|
+
|
43
|
+
GetNArray(v1,x);
|
44
|
+
GetNArray(v2,y);
|
45
|
+
GetNArray(v3,w);
|
46
|
+
CHECK_GE_1D(x);
|
47
|
+
CHECK_GE_1D(y);
|
48
|
+
CHECK_GE_1D(w);
|
49
|
+
CHECK_SIZE_EQ(VEC_SIZE(x),VEC_SIZE(y),"y size does not match x size");
|
50
|
+
CHECK_SIZE_EQ(VEC_SIZE(x),VEC_SIZE(w),"w size does not match x size");
|
51
|
+
|
52
|
+
r = na_ndloop(&ndf, 3, v1, v2, v3);
|
53
|
+
result = rb_class_new_instance(3, RARRAY_PTR(r), c<%=result_class%>);
|
54
|
+
RB_GC_GUARD(r);
|
55
|
+
return result;
|
56
|
+
}
|
@@ -0,0 +1,306 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
class ErbPP
|
4
|
+
|
5
|
+
def initialize(parent=nil, erb_base=nil, **opts, &block)
|
6
|
+
@parent = parent
|
7
|
+
@children = []
|
8
|
+
@opts = opts
|
9
|
+
set erb_base: erb_base if erb_base
|
10
|
+
@parent.add_child(self) if @parent
|
11
|
+
instance_eval(&block) if block
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :children
|
15
|
+
attr_accessor :parent
|
16
|
+
|
17
|
+
def add_child(child)
|
18
|
+
@children.push(child)
|
19
|
+
end
|
20
|
+
|
21
|
+
def set(**opts)
|
22
|
+
@opts.merge!(opts)
|
23
|
+
end
|
24
|
+
|
25
|
+
def get(key, *args, &block)
|
26
|
+
if respond_to?(key)
|
27
|
+
return send(key, *args, &block)
|
28
|
+
end
|
29
|
+
if args.empty? && block.nil? && @opts.has_key?(key)
|
30
|
+
return @opts[key]
|
31
|
+
end
|
32
|
+
if @parent
|
33
|
+
return @parent.get(key, *args, &block)
|
34
|
+
end
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def description
|
39
|
+
if s = @opts[:description] || @opts[:desc]
|
40
|
+
s.gsub(/\@\{/,"[").gsub(/\@\}/,"]")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
alias desc description
|
45
|
+
|
46
|
+
alias method_missing_alias method_missing
|
47
|
+
|
48
|
+
def method_missing(_meth_id, *args, &block)
|
49
|
+
if args.empty?
|
50
|
+
#$stderr.puts _meth_id.inspect
|
51
|
+
v = get(_meth_id, *args, &block)
|
52
|
+
return v if !v.nil?
|
53
|
+
end
|
54
|
+
method_missing_alias(_meth_id, *args, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
# ERB Loader
|
58
|
+
|
59
|
+
def load_erb(base_name)
|
60
|
+
safe_level = nil
|
61
|
+
trim_mode = '%<>'
|
62
|
+
file = base_name + get(:erb_suffix)
|
63
|
+
dirs = get(:erb_dir)
|
64
|
+
dirs = [dirs] if !dirs.kind_of?(Array)
|
65
|
+
dirs.each do |x|
|
66
|
+
Dir.glob(x).each do |dir|
|
67
|
+
path = File.join(dir,file)
|
68
|
+
if File.exist?(path)
|
69
|
+
erb = ERB.new(File.read(path), safe_level, trim_mode)
|
70
|
+
erb.filename = path
|
71
|
+
return erb
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
raise "file not found: #{file.inspect} in #{dirs.inspect}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def run
|
79
|
+
if base = @opts[:erb_base]
|
80
|
+
load_erb(base).run(binding)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def result
|
85
|
+
if base = @opts[:erb_base]
|
86
|
+
load_erb(base).result(binding)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def write(output)
|
91
|
+
File.open(output,"wt") do |f|
|
92
|
+
f.print(result)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def init_def
|
97
|
+
end
|
98
|
+
|
99
|
+
def find_tmpl(name)
|
100
|
+
@parent.children.find{|x| x.name == name }
|
101
|
+
end
|
102
|
+
|
103
|
+
def find(name)
|
104
|
+
children.find{|x| x.name == name }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
class DefLib < ErbPP
|
110
|
+
def initialize(parent=nil, **opts, &block)
|
111
|
+
opts[:erb_base] ||= 'lib'
|
112
|
+
super(parent, **opts, &block)
|
113
|
+
end
|
114
|
+
def id_assign
|
115
|
+
ids = []
|
116
|
+
@children.each{|c| a=c.get(:id_list); ids.concat(a) if a}
|
117
|
+
ids.sort.uniq.map{|x| "id_#{x[1]} = rb_intern(\"#{x[0]}\");"}
|
118
|
+
end
|
119
|
+
def id_decl
|
120
|
+
ids = []
|
121
|
+
@children.each{|c| a=c.get(:id_list); ids.concat(a) if a}
|
122
|
+
ids.sort.uniq.map{|x| "static ID id_#{x[1]};\n"}
|
123
|
+
end
|
124
|
+
def def_class(**opts, &block)
|
125
|
+
DefClass.new(self, **opts, &block)
|
126
|
+
end
|
127
|
+
def def_module(**opts, &block)
|
128
|
+
DefModule.new(self, **opts, &block)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
module DeclMethod
|
133
|
+
def def_alloc_func(m, erb_path=nil, **opts, &block)
|
134
|
+
DefAllocFunc.new(self, erb_path||m, name:m, singleton:true, **opts, &block)
|
135
|
+
end
|
136
|
+
def undef_alloc_func
|
137
|
+
UndefAllocFunc.new(self)
|
138
|
+
end
|
139
|
+
def def_method(m, erb_path=nil, **opts, &block)
|
140
|
+
DefMethod.new(self, erb_path||m, name:m, **opts, &block)
|
141
|
+
end
|
142
|
+
def def_singleton_method(m, erb_path=nil, **opts, &block)
|
143
|
+
DefMethod.new(self, erb_path||m, name:m, singleton:true, **opts, &block)
|
144
|
+
end
|
145
|
+
def def_module_function(m, erb_path=nil, **opts, &block)
|
146
|
+
DefModuleFunction.new(self, erb_path||m, name:m, **opts, &block)
|
147
|
+
end
|
148
|
+
def def_alias(from, to)
|
149
|
+
DefAlias.new(self, from:from, to:to)
|
150
|
+
end
|
151
|
+
def def_const(m, v, **opts, &block)
|
152
|
+
DefConst.new(self, name:m, value:v, **opts, &block)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
class DefModule < ErbPP
|
157
|
+
include DeclMethod
|
158
|
+
def initialize(parent, **opts, &block)
|
159
|
+
eb = opts[:erb_base] || 'module'
|
160
|
+
super(parent, erb_base:eb, **opts, &block)
|
161
|
+
end
|
162
|
+
def id_list
|
163
|
+
@id_list ||= []
|
164
|
+
end
|
165
|
+
def def_id(name,var=nil)
|
166
|
+
var = name.gsub(/\?/,"_p").gsub(/\!/,"_bang") if var.nil?
|
167
|
+
id_list << [name,var]
|
168
|
+
end
|
169
|
+
def init_def
|
170
|
+
load_erb(init_erb).result(binding)
|
171
|
+
end
|
172
|
+
def init_erb
|
173
|
+
@opts[:init_erb] || "init_module"
|
174
|
+
end
|
175
|
+
def method_code
|
176
|
+
@children.map{|c| c.result}.join("\n")
|
177
|
+
end
|
178
|
+
def _mod_var
|
179
|
+
@opts[:module_var]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
class DefClass < DefModule
|
184
|
+
def initialize(parent, **opts, &block)
|
185
|
+
eb = opts[:erb_base] || 'class'
|
186
|
+
super(parent, erb_base:eb, **opts, &block)
|
187
|
+
end
|
188
|
+
def _mod_var
|
189
|
+
@opts[:class_var]
|
190
|
+
end
|
191
|
+
def init_erb
|
192
|
+
@opts[:init_erb] || "init_class"
|
193
|
+
end
|
194
|
+
def super_class
|
195
|
+
@opts[:super_class] || "rb_cObject"
|
196
|
+
end
|
197
|
+
def free_func
|
198
|
+
@opts[:free_func] || "gsl_"+get(:name)+"_free"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
class DefMethod < ErbPP
|
203
|
+
include DeclMethod
|
204
|
+
|
205
|
+
def initialize(parent, erb_base, **opts, &block)
|
206
|
+
super(parent, **opts, &block)
|
207
|
+
set erb_base: erb_base
|
208
|
+
end
|
209
|
+
|
210
|
+
def id_op
|
211
|
+
if op.size == 1
|
212
|
+
"'#{op}'"
|
213
|
+
else
|
214
|
+
"id_#{c_name}"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def c_name
|
219
|
+
@opts[:name].gsub(/\?/,"_p").gsub(/\!/,"_bang")
|
220
|
+
end
|
221
|
+
|
222
|
+
def op_map
|
223
|
+
@opts[:op] || @opts[:name]
|
224
|
+
end
|
225
|
+
|
226
|
+
def c_func(n_arg=nil)
|
227
|
+
set n_arg: n_arg if n_arg
|
228
|
+
s = (singleton) ? "_s" : ""
|
229
|
+
"#{@parent.name}#{s}_#{c_name}"
|
230
|
+
end
|
231
|
+
|
232
|
+
def c_iter
|
233
|
+
"iter_#{c_func}"
|
234
|
+
end
|
235
|
+
|
236
|
+
def define_method_args
|
237
|
+
"#{_mod_var}, \"#{op_map}\", #{c_func}, #{n_arg}"
|
238
|
+
end
|
239
|
+
|
240
|
+
def init_def
|
241
|
+
return if n_arg == :nodef
|
242
|
+
s = (singleton) ? "_singleton" : ""
|
243
|
+
"rb_define#{s}_method(#{define_method_args});"
|
244
|
+
end
|
245
|
+
|
246
|
+
def singleton
|
247
|
+
@opts[:singleton]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
class DefModuleFunction < DefMethod
|
252
|
+
def initialize(parent, erb_base, **opts, &block)
|
253
|
+
super(parent, erb_base, **opts, &block)
|
254
|
+
set singleton: true
|
255
|
+
end
|
256
|
+
|
257
|
+
def init_def
|
258
|
+
return if n_arg == :nodef
|
259
|
+
"rb_define_module_function(#{define_method_args});"
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
class DefAlias < ErbPP
|
264
|
+
def init_def
|
265
|
+
"rb_define_alias(#{_mod_var}, \"#{from}\", \"#{to}\");"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
class DefAllocFunc < DefMethod
|
270
|
+
def init_def
|
271
|
+
"rb_define_alloc_func(#{_mod_var}, #{c_func});"
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
class UndefAllocFunc < ErbPP
|
276
|
+
def init_def
|
277
|
+
"rb_undef_alloc_func(#{_mod_var});"
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
class DefConst < ErbPP
|
282
|
+
def init_def
|
283
|
+
"/*#{desc}*/
|
284
|
+
rb_define_const(#{_mod_var},\"#{name}\",#{value});"
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
class DefStruct < ErbPP
|
289
|
+
def method_code
|
290
|
+
"static VALUE #{class_var};"
|
291
|
+
end
|
292
|
+
def init_def
|
293
|
+
items = members.map{|s| "\"#{s}\""}.join(",")
|
294
|
+
"/*#{description}*/
|
295
|
+
#{class_var} = rb_struct_define(\"#{class_name}\",#{items},NULL);"
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
class DefInclueModule < ErbPP
|
300
|
+
def initialize(parent=nil, incl_class, incl_module, **opts, &block)
|
301
|
+
super(parent,incl_class:incl_class,incl_module:incl_module,**opts,&block)
|
302
|
+
end
|
303
|
+
def init_def
|
304
|
+
"rb_include_module(#{get(:incl_class)}, #{get(:incl_module)});"
|
305
|
+
end
|
306
|
+
end
|