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,40 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%= name %>(<%@params.each{|x|%><%=x[0]%>,<%}%>[shape])
|
3
|
+
<% @params.each do |x|%>
|
4
|
+
@param [<%=x[1]%>] <%=x[0]%><% end %>
|
5
|
+
@param [Array or Integer] shape (optional) shape for result NArray
|
6
|
+
@return [<%=get(:ret_class)%>] returns random number
|
7
|
+
|
8
|
+
<%= desc %>
|
9
|
+
|
10
|
+
*/
|
11
|
+
static VALUE
|
12
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
13
|
+
{
|
14
|
+
VALUE vshape, vna;
|
15
|
+
size_t i, size;
|
16
|
+
int nargs;
|
17
|
+
<%=func_type%> *ptr;
|
18
|
+
<% @vn.each do |v|%>
|
19
|
+
VALUE <%=v%>;<% end %>
|
20
|
+
<% @vardef.each do |x|%>
|
21
|
+
<%=x%>;<% end %>
|
22
|
+
gsl_rng *r;
|
23
|
+
|
24
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, r);
|
25
|
+
|
26
|
+
nargs = rb_scan_args(argc, argv, "<%=@params.size%>1" <%@vn.map{|v|%>, &<%=v%><%}%>, &vshape);
|
27
|
+
<% @varconv.each do |x|%><%=x%>
|
28
|
+
<% end %>
|
29
|
+
if (nargs == <%=@params.size%>) {
|
30
|
+
return rb_float_new(<%=func_name%>(r <%@an.map{|a|%>, <%=a%><%}%>));
|
31
|
+
} else {
|
32
|
+
vna = create_new_narray(<%=get(:func_type_var)%>,vshape);
|
33
|
+
ptr = (<%=func_type%>*)na_get_pointer_for_write(vna);
|
34
|
+
size = RNARRAY_SIZE(vna);
|
35
|
+
for (i=0; i<size; i++) {
|
36
|
+
ptr[i] = <%=func_name%>(r <%@an.map{|a|%>, <%=a%><%}%>);
|
37
|
+
}
|
38
|
+
return vna;
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%=name%>(<%=args[2][1]%>)
|
3
|
+
@param [DFloat] <%=args[2][1]%>
|
4
|
+
@return [DFloat] <%=args[3][1]%>
|
5
|
+
|
6
|
+
<%= desc %>
|
7
|
+
|
8
|
+
*/
|
9
|
+
static VALUE
|
10
|
+
<%=c_func(1)%>(VALUE self, VALUE valpha)
|
11
|
+
{
|
12
|
+
VALUE vtheta;
|
13
|
+
double *alpha, *theta;
|
14
|
+
narray_t *na;
|
15
|
+
gsl_rng *r;
|
16
|
+
|
17
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, r);
|
18
|
+
|
19
|
+
valpha = cast_1d_contiguous(valpha, cDF);
|
20
|
+
GetNArray(valpha,na);
|
21
|
+
vtheta = rb_narray_new(cDF,na->ndim,na->shape);
|
22
|
+
theta = (double*)na_get_pointer_for_write(vtheta);
|
23
|
+
alpha = (double*)na_get_pointer_for_read(valpha);
|
24
|
+
|
25
|
+
<%=func_name%>(r, na->size, alpha, theta);
|
26
|
+
RB_GC_GUARD(valpha);
|
27
|
+
return vtheta;
|
28
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%= name %>(<%@params.each{|x|%><%=x[0]%>,<%}%>[shape])
|
3
|
+
<% @params.each do |x|%>
|
4
|
+
@param [<%=x[1]%>] <%=x[0]%><% end %>
|
5
|
+
@param [Array or Integer] shape (optional) shape for result NArray
|
6
|
+
@return [<%=get(:ret_class)%>] returns random number
|
7
|
+
|
8
|
+
<%= desc %>
|
9
|
+
|
10
|
+
*/
|
11
|
+
static VALUE
|
12
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
13
|
+
{
|
14
|
+
VALUE vshape, vx, vy;
|
15
|
+
size_t i, size;
|
16
|
+
int nargs;
|
17
|
+
double x, y;
|
18
|
+
double *px, *py;
|
19
|
+
<% @vn.each do |v|%>
|
20
|
+
VALUE <%=v%>;<% end %>
|
21
|
+
<% @vardef.each do |x|%>
|
22
|
+
<%=x%>;<% end %>
|
23
|
+
gsl_rng *r;
|
24
|
+
|
25
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, r);
|
26
|
+
|
27
|
+
nargs = rb_scan_args(argc, argv, "<%=@params.size%>1" <%@vn.map{|v|%>, &<%=v%><%}%>, &vshape);
|
28
|
+
<% @varconv.each do |x|%>
|
29
|
+
<%=x%><% end %>
|
30
|
+
if (nargs == <%=@params.size%>) {
|
31
|
+
<%=func_name%>(r <%@an.map{|a|%>, <%=a%><%}%>, &x, &y);
|
32
|
+
return rb_assoc_new(DBL2NUM(x),DBL2NUM(y));
|
33
|
+
} else {
|
34
|
+
vx = create_new_narray(cDF,vshape);
|
35
|
+
vy = create_new_narray(cDF,vshape);
|
36
|
+
px = (double*)na_get_pointer_for_write(vx);
|
37
|
+
py = (double*)na_get_pointer_for_write(vy);
|
38
|
+
size = RNARRAY_SIZE(vx);
|
39
|
+
for (i=0; i<size; i++) {
|
40
|
+
<%=func_name%>(r <%@an.map{|a|%>, <%=a%><%}%>, px, py);
|
41
|
+
px++; py++;
|
42
|
+
}
|
43
|
+
return rb_assoc_new(vx,vy);
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%= name %>(<%@params.each{|x|%><%=x[0]%>,<%}%>[shape])
|
3
|
+
<% @params.each do |x|%>
|
4
|
+
@param [<%=x[1]%>] <%=x[0]%><% end %>
|
5
|
+
@param [Array or Integer] shape (optional) shape for result Numo::NArray
|
6
|
+
@return [Array] returns array of [x,y,z], where x,y,z are Float or Numo::DFloat
|
7
|
+
|
8
|
+
<%= desc %>
|
9
|
+
|
10
|
+
*/
|
11
|
+
static VALUE
|
12
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
13
|
+
{
|
14
|
+
VALUE vshape;
|
15
|
+
VALUE v[3];
|
16
|
+
size_t i, size;
|
17
|
+
int nargs;
|
18
|
+
double x, y, z;
|
19
|
+
double *px, *py, *pz;
|
20
|
+
<% @vn.each do |v|%>
|
21
|
+
VALUE <%=v%>;<% end %>
|
22
|
+
<% @vardef.each do |x|%>
|
23
|
+
<%=x%>;<% end %>
|
24
|
+
gsl_rng *r;
|
25
|
+
|
26
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, r);
|
27
|
+
|
28
|
+
nargs = rb_scan_args(argc, argv, "<%=@params.size%>1" <%@vn.map{|v|%>, &<%=v%><%}%>, &vshape);
|
29
|
+
<% @varconv.each do |x|%>
|
30
|
+
<%=x%><% end %>
|
31
|
+
if (nargs == <%=@params.size%>) {
|
32
|
+
<%=func_name%>(r <%@an.map{|a|%>, <%=a%><%}%>, &x, &y, &z);
|
33
|
+
v[0] = DBL2NUM(x);
|
34
|
+
v[1] = DBL2NUM(y);
|
35
|
+
v[2] = DBL2NUM(z);
|
36
|
+
return rb_ary_new4(3,v);
|
37
|
+
} else {
|
38
|
+
v[0] = create_new_narray(cDF,vshape);
|
39
|
+
v[1] = create_new_narray(cDF,vshape);
|
40
|
+
v[2] = create_new_narray(cDF,vshape);
|
41
|
+
px = (double*)na_get_pointer_for_write(v[0]);
|
42
|
+
py = (double*)na_get_pointer_for_write(v[1]);
|
43
|
+
pz = (double*)na_get_pointer_for_write(v[2]);
|
44
|
+
size = RNARRAY_SIZE(v[0]);
|
45
|
+
for (i=0; i<size; i++) {
|
46
|
+
<%=func_name%>(r <%@an.map{|a|%>, <%=a%><%}%>, px, py, pz);
|
47
|
+
px++; py++; pz++;
|
48
|
+
}
|
49
|
+
return rb_ary_new4(3,v);
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%=name%>(<%=args[2][1]%>, <%=args[3][1]%>)
|
3
|
+
@param [Integer] <%=args[2][1]%>
|
4
|
+
@param [DFloat] <%=args[3][1]%>
|
5
|
+
@return [UInt] <%=args[4][1]%>
|
6
|
+
|
7
|
+
<%= desc %>
|
8
|
+
|
9
|
+
*/
|
10
|
+
static VALUE
|
11
|
+
<%=c_func(1)%>(VALUE self, VALUE vN, VALUE vp)
|
12
|
+
{
|
13
|
+
VALUE vn;
|
14
|
+
double *p;
|
15
|
+
unsigned int *n;
|
16
|
+
unsigned int N;
|
17
|
+
narray_t *na;
|
18
|
+
gsl_rng *r;
|
19
|
+
|
20
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, r);
|
21
|
+
|
22
|
+
N = NUM2UINT(vN);
|
23
|
+
vp = cast_1d_contiguous(vp, cDF);
|
24
|
+
GetNArray(vp,na);
|
25
|
+
p = (double*)na_get_pointer_for_read(vp);
|
26
|
+
vn = rb_narray_new(cUInt,na->ndim,na->shape);
|
27
|
+
n = (unsigned int*)na_get_pointer_for_write(vn);
|
28
|
+
|
29
|
+
<%=func_name%>(r, na->size, N, p, n);
|
30
|
+
RB_GC_GUARD(vp);
|
31
|
+
return vn;
|
32
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%=name%>([shape])
|
3
|
+
@param [Array or Integer] shape (optional) shape for result NArray
|
4
|
+
@return [Float or DFloat] returns random number
|
5
|
+
|
6
|
+
<%= desc %>
|
7
|
+
*/
|
8
|
+
static VALUE
|
9
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
10
|
+
{
|
11
|
+
VALUE vshape, vna;
|
12
|
+
size_t i, size;
|
13
|
+
double *ptr;
|
14
|
+
<%=struct%> *r;
|
15
|
+
|
16
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, r);
|
17
|
+
|
18
|
+
if (rb_scan_args(argc, argv, "01", &vshape) == 0) {
|
19
|
+
return rb_float_new(<%=func_name%>(r));
|
20
|
+
} else {
|
21
|
+
vna = create_new_narray(cDF,vshape);
|
22
|
+
ptr = (double*)na_get_pointer_for_write(vna);
|
23
|
+
size = RNARRAY_SIZE(vna);
|
24
|
+
for (i=0; i<size; i++) {
|
25
|
+
ptr[i] = <%=func_name%>(r);
|
26
|
+
}
|
27
|
+
return vna;
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%=name%>(n,[shape])
|
3
|
+
@param [Integer] n
|
4
|
+
@param [Array or Integer] shape (optional) shape for result NArray
|
5
|
+
@return [Integer or UInt32/UInt64] returns random number
|
6
|
+
|
7
|
+
<%= desc %>
|
8
|
+
*/
|
9
|
+
static VALUE
|
10
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
11
|
+
{
|
12
|
+
VALUE vshape, vna, vn;
|
13
|
+
size_t i, size;
|
14
|
+
int nargs;
|
15
|
+
unsigned long n;
|
16
|
+
u_int32_t *p32;
|
17
|
+
u_int64_t *p64;
|
18
|
+
<%=struct%> *r;
|
19
|
+
|
20
|
+
TypedData_Get_Struct(self, <%=struct%>, &<%=data_type_var%>, r);
|
21
|
+
|
22
|
+
nargs = rb_scan_args(argc, argv, "11", &vn, &vshape);
|
23
|
+
n = NUM2ULONG(vn);
|
24
|
+
if (nargs == 1) {
|
25
|
+
return ULONG2NUM(<%=func_name%>(r, n));
|
26
|
+
} else {
|
27
|
+
if (n > 4294967295ul) {
|
28
|
+
vna = create_new_narray(numo_cUInt64,vshape);
|
29
|
+
p64 = (u_int64_t*)na_get_pointer_for_write(vna);
|
30
|
+
size = RNARRAY_SIZE(vna);
|
31
|
+
for (i=0; i<size; i++) {
|
32
|
+
p64[i] = (u_int64_t)<%=func_name%>(r, n);
|
33
|
+
}
|
34
|
+
} else {
|
35
|
+
vna = create_new_narray(numo_cUInt32,vshape);
|
36
|
+
p32 = (u_int32_t*)na_get_pointer_for_write(vna);
|
37
|
+
size = RNARRAY_SIZE(vna);
|
38
|
+
for (i=0; i<size; i++) {
|
39
|
+
p32[i] = (u_int32_t)<%=func_name%>(r, n);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
return vna;
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%
|
2
|
+
set name: "new"
|
3
|
+
set singleton: true
|
4
|
+
%>
|
5
|
+
/*
|
6
|
+
:nodoc:
|
7
|
+
*/
|
8
|
+
static VALUE
|
9
|
+
<%=c_func(:nodef)%>(int argc, VALUE *argv, VALUE self, const <%=type_struct%> *t)
|
10
|
+
{
|
11
|
+
<%=struct%> *w;
|
12
|
+
|
13
|
+
if (argc > 1) {
|
14
|
+
rb_raise(rb_eArgError,"wrong number of arguments (given %d, expected 0..1)", argc);
|
15
|
+
}
|
16
|
+
w = <%=func_name%>(t);
|
17
|
+
if (!w) {
|
18
|
+
rb_raise(rb_eNoMemError,"fail to allocate struct");
|
19
|
+
}
|
20
|
+
if (argc == 1) {
|
21
|
+
gsl_rng_set(w, NUM2ULONG(argv[0]));
|
22
|
+
}
|
23
|
+
return TypedData_Wrap_Struct(<%=class_var%>, &<%=data_type_var%>, (void*)w);
|
24
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
@overload <%=name%>([seed])
|
3
|
+
@param [Integer] seed Random seed.
|
4
|
+
|
5
|
+
Generate an instance of <%=full_class_name%>::<%=subtype_class%> class,
|
6
|
+
a subclass of <%=full_class_name%> class with <%=subtype_var%> type.
|
7
|
+
|
8
|
+
<%= desc %>
|
9
|
+
*/
|
10
|
+
static VALUE
|
11
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
12
|
+
{
|
13
|
+
return <%=c_superclass_new%>(argc, argv, self, <%=subtype_var%>);
|
14
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
["gsl_rng_borosh13",
|
2
|
+
"gsl_rng_coveyou",
|
3
|
+
"gsl_rng_cmrg",
|
4
|
+
"gsl_rng_fishman18",
|
5
|
+
"gsl_rng_fishman20",
|
6
|
+
"gsl_rng_fishman2x",
|
7
|
+
"gsl_rng_gfsr4",
|
8
|
+
"gsl_rng_knuthran",
|
9
|
+
"gsl_rng_knuthran2",
|
10
|
+
"gsl_rng_knuthran2002",
|
11
|
+
"gsl_rng_lecuyer21",
|
12
|
+
"gsl_rng_minstd",
|
13
|
+
"gsl_rng_mrg",
|
14
|
+
"gsl_rng_mt19937",
|
15
|
+
"gsl_rng_mt19937_1999",
|
16
|
+
"gsl_rng_mt19937_1998",
|
17
|
+
"gsl_rng_r250",
|
18
|
+
"gsl_rng_ran0",
|
19
|
+
"gsl_rng_ran1",
|
20
|
+
"gsl_rng_ran2",
|
21
|
+
"gsl_rng_ran3",
|
22
|
+
"gsl_rng_rand",
|
23
|
+
"gsl_rng_rand48",
|
24
|
+
"gsl_rng_random128_bsd",
|
25
|
+
"gsl_rng_random128_glibc2",
|
26
|
+
"gsl_rng_random128_libc5",
|
27
|
+
"gsl_rng_random256_bsd",
|
28
|
+
"gsl_rng_random256_glibc2",
|
29
|
+
"gsl_rng_random256_libc5",
|
30
|
+
"gsl_rng_random32_bsd",
|
31
|
+
"gsl_rng_random32_glibc2",
|
32
|
+
"gsl_rng_random32_libc5",
|
33
|
+
"gsl_rng_random64_bsd",
|
34
|
+
"gsl_rng_random64_glibc2",
|
35
|
+
"gsl_rng_random64_libc5",
|
36
|
+
"gsl_rng_random8_bsd",
|
37
|
+
"gsl_rng_random8_glibc2",
|
38
|
+
"gsl_rng_random8_libc5",
|
39
|
+
"gsl_rng_random_bsd",
|
40
|
+
"gsl_rng_random_glibc2",
|
41
|
+
"gsl_rng_random_libc5",
|
42
|
+
"gsl_rng_randu",
|
43
|
+
"gsl_rng_ranf",
|
44
|
+
"gsl_rng_ranlux",
|
45
|
+
"gsl_rng_ranlux389",
|
46
|
+
"gsl_rng_ranlxd1",
|
47
|
+
"gsl_rng_ranlxd2",
|
48
|
+
"gsl_rng_ranlxs0",
|
49
|
+
"gsl_rng_ranlxs1",
|
50
|
+
"gsl_rng_ranlxs2",
|
51
|
+
"gsl_rng_ranmar",
|
52
|
+
"gsl_rng_slatec",
|
53
|
+
"gsl_rng_taus",
|
54
|
+
"gsl_rng_taus2",
|
55
|
+
"gsl_rng_taus113",
|
56
|
+
"gsl_rng_transputer",
|
57
|
+
"gsl_rng_tt800",
|
58
|
+
"gsl_rng_uni",
|
59
|
+
"gsl_rng_uni32",
|
60
|
+
"gsl_rng_vax",
|
61
|
+
"gsl_rng_waterman14",
|
62
|
+
"gsl_rng_zuf",
|
63
|
+
"gsl_rng_default"]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
COGEN=ruby erbpp_rstat.rb
|
2
|
+
GENSRC=gsl_rstat.c
|
3
|
+
GENDEPS=erbpp_rstat.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,64 @@
|
|
1
|
+
require_relative "../gen/erbpp_gsl"
|
2
|
+
require "erbpp/line_number"
|
3
|
+
|
4
|
+
ErbppGsl.read_func_pattern(
|
5
|
+
[/^gsl_rstat_quantile_(\w+)$/,rquantile_list=[]],
|
6
|
+
[/^gsl_rstat_(\w+)$/, rstat_list=[]],
|
7
|
+
)
|
8
|
+
|
9
|
+
class DefRstat < DefGslClass
|
10
|
+
def lookup(h)
|
11
|
+
case h
|
12
|
+
when FM(name:/_free$/); false
|
13
|
+
when FM(dbl, name:/_alloc$/); "c_new_double"
|
14
|
+
when FM("", name:/_alloc$/); "c_new_void"
|
15
|
+
|
16
|
+
when FM(tp, type:dbl); "c_double_f_void"
|
17
|
+
when FM(tp, type:szt); "c_sizet_f_void"
|
18
|
+
when FM(tp, type:int); "c_void_f_void"
|
19
|
+
when FM(dbl,tp); h[:postpose]=true; "c_self_f_DFloat"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
DefLib.new do
|
25
|
+
set erb_dir: %w[tmpl ../gen/tmpl]
|
26
|
+
set erb_suffix: ".c"
|
27
|
+
|
28
|
+
name = "Rstat"
|
29
|
+
set file_name: "gsl_#{name}.c"
|
30
|
+
set include_files: ["gsl/gsl_rstat.h"]
|
31
|
+
set lib_name: name.downcase
|
32
|
+
set ns_var: "mG"
|
33
|
+
|
34
|
+
DefRstat.new(self) do
|
35
|
+
name = "Rstat"
|
36
|
+
set name: name.downcase
|
37
|
+
set class_name: name
|
38
|
+
set class_var: "c"+name
|
39
|
+
set full_class_name: "Numo::GSL::"+name
|
40
|
+
set struct: "gsl_rstat_workspace"
|
41
|
+
|
42
|
+
undef_alloc_func
|
43
|
+
rstat_list.each do |h|
|
44
|
+
check_func(h)
|
45
|
+
end
|
46
|
+
def_alias("size", "n")
|
47
|
+
def_alias("length", "n")
|
48
|
+
end
|
49
|
+
|
50
|
+
DefRstat.new(self) do
|
51
|
+
name = "Quantile"
|
52
|
+
set name: "rstat_"+name.downcase
|
53
|
+
set class_name: name
|
54
|
+
set class_var: "c"+name
|
55
|
+
set full_class_name: "Numo::GSL::Rstat::"+name
|
56
|
+
set struct: "gsl_rstat_quantile_workspace"
|
57
|
+
set ns_var: "cRstat"
|
58
|
+
|
59
|
+
undef_alloc_func
|
60
|
+
rquantile_list.each do |h|
|
61
|
+
check_func(h)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end.run
|