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,17 @@
|
|
1
|
+
COGEN=ruby erbpp_rng.rb
|
2
|
+
GENSRC=gsl_rng.c
|
3
|
+
GENDEPS=erbpp_rng.rb ../gen/*.rb ../gen/tmpl/*.c # 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,58 @@
|
|
1
|
+
require_relative "parse_rng"
|
2
|
+
require "erbpp/line_number"
|
3
|
+
|
4
|
+
ErbppGsl.read_func_pattern(
|
5
|
+
[/gsl_rng_/, rng_list=[]],
|
6
|
+
)
|
7
|
+
|
8
|
+
ran_list = ErbppGsl.read_func("../ran/func").select{|h|
|
9
|
+
/gsl_rng \*/ =~ h[:args][0][0]
|
10
|
+
}
|
11
|
+
|
12
|
+
DefLib.new do
|
13
|
+
set erb_dir: %w[tmpl ../gen/tmpl]
|
14
|
+
set erb_suffix: ".c"
|
15
|
+
set ns_var: "mG"
|
16
|
+
|
17
|
+
cbase = "rng"
|
18
|
+
set file_name: "gsl_#{cbase}.c"
|
19
|
+
set include_files: %w[gsl/gsl_rng.h gsl/gsl_randist.h]
|
20
|
+
set lib_name: cbase
|
21
|
+
|
22
|
+
ErbPP.new(self,"create_new_narray")
|
23
|
+
ErbPP.new(self,"cast_1d_contiguous")
|
24
|
+
|
25
|
+
DefRng.new(self) do
|
26
|
+
name = "Rng"
|
27
|
+
base = "rng"
|
28
|
+
set name: base
|
29
|
+
set class_name: name
|
30
|
+
set class_var: "c"+name
|
31
|
+
set full_class_name: "Numo::GSL::"+name
|
32
|
+
set struct: "gsl_"+base
|
33
|
+
set type_struct: "gsl_"+base+"_type"
|
34
|
+
|
35
|
+
undef_alloc_func
|
36
|
+
rng_list.each do |h|
|
37
|
+
check_func(h)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
DefRan.new(self) do
|
42
|
+
name = "Ran"
|
43
|
+
base = "ran"
|
44
|
+
set name: base
|
45
|
+
set module_name: name
|
46
|
+
set module_var: "m"+name
|
47
|
+
set full_module_name: "Numo::GSL::"+name
|
48
|
+
set struct: "gsl_rng"
|
49
|
+
set data_type_var: "rng_data_type"
|
50
|
+
|
51
|
+
ran_list.each do |h|
|
52
|
+
check_func(h)
|
53
|
+
end
|
54
|
+
|
55
|
+
DefInclueModule.new(self,"cRng","mRan")
|
56
|
+
end
|
57
|
+
|
58
|
+
end.run
|
@@ -0,0 +1,230 @@
|
|
1
|
+
[{:func_name=>"gsl_rng_alloc",
|
2
|
+
:func_type=>"gsl_rng *",
|
3
|
+
:args=>[["const gsl_rng_type *", "T"]],
|
4
|
+
:desc=>
|
5
|
+
"This function returns a pointer to a newly-created\n" +
|
6
|
+
"instance of a random number generator of type T.\n" +
|
7
|
+
"For example, the following code creates an instance of the Tausworthe\n" +
|
8
|
+
"generator,\n" +
|
9
|
+
"\n" +
|
10
|
+
"gsl_rng * r = gsl_rng_alloc (gsl_rng_taus);\n" +
|
11
|
+
"\n" +
|
12
|
+
"If there is insufficient memory to create the generator then the\n" +
|
13
|
+
"function returns a null pointer and the error handler is invoked with an\n" +
|
14
|
+
"error code of GSL_ENOMEM.\n" +
|
15
|
+
"\n" +
|
16
|
+
"The generator is automatically initialized with the default seed,\n" +
|
17
|
+
"gsl_rng_default_seed. This is zero by default but can be changed\n" +
|
18
|
+
"either directly or by using the environment variable GSL_RNG_SEED\n" +
|
19
|
+
"(Random number environment variables).\n" +
|
20
|
+
"\n" +
|
21
|
+
"The details of the available generator types are\n" +
|
22
|
+
"described later in this chapter."},
|
23
|
+
{:func_name=>"gsl_rng_set",
|
24
|
+
:func_type=>"void",
|
25
|
+
:args=>[["const gsl_rng *", "r"], ["unsigned long int", "s"]],
|
26
|
+
:desc=>
|
27
|
+
"This function initializes (or `seeds') the random number generator. If\n" +
|
28
|
+
"the generator is seeded with the same value of s on two different\n" +
|
29
|
+
"runs, the same stream of random numbers will be generated by successive\n" +
|
30
|
+
"calls to the routines below. If different values of $s \\geq 1$\n" +
|
31
|
+
"s >= 1 are supplied, then the generated streams of random\n" +
|
32
|
+
"numbers should be completely different. If the seed s is zero\n" +
|
33
|
+
"then the standard seed from the original implementation is used\n" +
|
34
|
+
"instead. For example, the original Fortran source code for the\n" +
|
35
|
+
"ranlux generator used a seed of 314159265, and so choosing\n" +
|
36
|
+
"s equal to zero reproduces this when using\n" +
|
37
|
+
"gsl_rng_ranlux. \n" +
|
38
|
+
"\n" +
|
39
|
+
"When using multiple seeds with the same generator, choose seed values\n" +
|
40
|
+
"greater than zero to avoid collisions with the default setting. \n" +
|
41
|
+
"\n" +
|
42
|
+
"Note that the most generators only accept 32-bit seeds, with higher\n" +
|
43
|
+
"values being reduced modulo $2^{32}$ \n" +
|
44
|
+
"2^32. For generators\n" +
|
45
|
+
"with smaller ranges the maximum seed value will typically be lower."},
|
46
|
+
{:func_name=>"gsl_rng_free",
|
47
|
+
:func_type=>"void",
|
48
|
+
:args=>[["gsl_rng *", "r"]],
|
49
|
+
:desc=>
|
50
|
+
"This function frees all the memory associated with the generator\n" +
|
51
|
+
"r."},
|
52
|
+
{:func_name=>"gsl_rng_get",
|
53
|
+
:func_type=>"unsigned long int",
|
54
|
+
:args=>[["const gsl_rng *", "r"]],
|
55
|
+
:desc=>
|
56
|
+
"This function returns a random integer from the generator r. The\n" +
|
57
|
+
"minimum and maximum values depend on the algorithm used, but all\n" +
|
58
|
+
"integers in the range [min,max] are equally likely. The\n" +
|
59
|
+
"values of min and max can be determined using the auxiliary\n" +
|
60
|
+
"functions gsl_rng_max (r) and gsl_rng_min (r)."},
|
61
|
+
{:func_name=>"gsl_rng_uniform",
|
62
|
+
:func_type=>"double",
|
63
|
+
:args=>[["const gsl_rng *", "r"]],
|
64
|
+
:desc=>
|
65
|
+
"This function returns a double precision floating point number uniformly\n" +
|
66
|
+
"distributed in the range [0,1). The range includes 0.0 but excludes 1.0.\n" +
|
67
|
+
"The value is typically obtained by dividing the result of\n" +
|
68
|
+
"gsl_rng_get(r) by gsl_rng_max(r) + 1.0 in double\n" +
|
69
|
+
"precision. Some generators compute this ratio internally so that they\n" +
|
70
|
+
"can provide floating point numbers with more than 32 bits of randomness\n" +
|
71
|
+
"(the maximum number of bits that can be portably represented in a single\n" +
|
72
|
+
"unsigned long int)."},
|
73
|
+
{:func_name=>"gsl_rng_uniform_pos",
|
74
|
+
:func_type=>"double",
|
75
|
+
:args=>[["const gsl_rng *", "r"]],
|
76
|
+
:desc=>
|
77
|
+
"This function returns a positive double precision floating point number\n" +
|
78
|
+
"uniformly distributed in the range (0,1), excluding both 0.0 and 1.0.\n" +
|
79
|
+
"The number is obtained by sampling the generator with the algorithm of\n" +
|
80
|
+
"gsl_rng_uniform until a non-zero value is obtained. You can use\n" +
|
81
|
+
"this function if you need to avoid a singularity at 0.0."},
|
82
|
+
{:func_name=>"gsl_rng_uniform_int",
|
83
|
+
:func_type=>"unsigned long int",
|
84
|
+
:args=>[["const gsl_rng *", "r"], ["unsigned long int", "n"]],
|
85
|
+
:desc=>
|
86
|
+
"This function returns a random integer from 0 to n-1 inclusive\n" +
|
87
|
+
"by scaling down and/or discarding samples from the generator r.\n" +
|
88
|
+
"All integers in the range [0,n-1] are produced with equal\n" +
|
89
|
+
"probability. For generators with a non-zero minimum value an offset\n" +
|
90
|
+
"is applied so that zero is returned with the correct probability.\n" +
|
91
|
+
"\n" +
|
92
|
+
"Note that this function is designed for sampling from ranges smaller\n" +
|
93
|
+
"than the range of the underlying generator. The parameter n\n" +
|
94
|
+
"must be less than or equal to the range of the generator r.\n" +
|
95
|
+
"If n is larger than the range of the generator then the function\n" +
|
96
|
+
"calls the error handler with an error code of GSL_EINVAL and\n" +
|
97
|
+
"returns zero.\n" +
|
98
|
+
"\n" +
|
99
|
+
"In particular, this function is not intended for generating the full range of\n" +
|
100
|
+
"unsigned integer values $[0,2^{32}-1]$ \n" +
|
101
|
+
"[0,2^32-1]. Instead\n" +
|
102
|
+
"choose a generator with the maximal integer range and zero minimum\n" +
|
103
|
+
"value, such as gsl_rng_ranlxd1, gsl_rng_mt19937 or\n" +
|
104
|
+
"gsl_rng_taus, and sample it directly using\n" +
|
105
|
+
"gsl_rng_get. The range of each generator can be found using\n" +
|
106
|
+
"the auxiliary functions described in the next section."},
|
107
|
+
{:func_name=>"gsl_rng_name",
|
108
|
+
:func_type=>"const char *",
|
109
|
+
:args=>[["const gsl_rng *", "r"]],
|
110
|
+
:desc=>
|
111
|
+
"This function returns a pointer to the name of the generator.\n" +
|
112
|
+
"For example,\n" +
|
113
|
+
"\n" +
|
114
|
+
"printf (\"r is a '%s' generator\\n\", \n" +
|
115
|
+
" gsl_rng_name (r));\n" +
|
116
|
+
"\n" +
|
117
|
+
"would print something like r is a 'taus' generator."},
|
118
|
+
{:func_name=>"gsl_rng_max",
|
119
|
+
:func_type=>"unsigned long int",
|
120
|
+
:args=>[["const gsl_rng *", "r"]],
|
121
|
+
:desc=>
|
122
|
+
"gsl_rng_max returns the largest value that gsl_rng_get\n" + "can return."},
|
123
|
+
{:func_name=>"gsl_rng_min",
|
124
|
+
:func_type=>"unsigned long int",
|
125
|
+
:args=>[["const gsl_rng *", "r"]],
|
126
|
+
:desc=>
|
127
|
+
"gsl_rng_min returns the smallest value that gsl_rng_get\n" +
|
128
|
+
"can return. Usually this value is zero. There are some generators with\n" +
|
129
|
+
"algorithms that cannot return zero, and for these generators the minimum\n" +
|
130
|
+
"value is 1."},
|
131
|
+
{:func_name=>"gsl_rng_state",
|
132
|
+
:func_type=>"void *",
|
133
|
+
:args=>[["const gsl_rng *", "r"]],
|
134
|
+
:desc=>
|
135
|
+
"These functions return a pointer to the state of generator r and\n" +
|
136
|
+
"its size. You can use this information to access the state directly. For\n" +
|
137
|
+
"example, the following code will write the state of a generator to a\n" +
|
138
|
+
"stream,\n" +
|
139
|
+
"\n" +
|
140
|
+
"void * state = gsl_rng_state (r);\n" +
|
141
|
+
"size_t n = gsl_rng_size (r);\n" +
|
142
|
+
"fwrite (state, n, 1, stream);"},
|
143
|
+
{:func_name=>"gsl_rng_size",
|
144
|
+
:func_type=>"size_t",
|
145
|
+
:args=>[["const gsl_rng *", "r"]],
|
146
|
+
:desc=>
|
147
|
+
"These functions return a pointer to the state of generator r and\n" +
|
148
|
+
"its size. You can use this information to access the state directly. For\n" +
|
149
|
+
"example, the following code will write the state of a generator to a\n" +
|
150
|
+
"stream,\n" +
|
151
|
+
"\n" +
|
152
|
+
"void * state = gsl_rng_state (r);\n" +
|
153
|
+
"size_t n = gsl_rng_size (r);\n" +
|
154
|
+
"fwrite (state, n, 1, stream);"},
|
155
|
+
{:func_name=>"gsl_rng_types_setup",
|
156
|
+
:func_type=>"const gsl_rng_type **",
|
157
|
+
:args=>[["", "void"]],
|
158
|
+
:desc=>
|
159
|
+
"This function returns a pointer to an array of all the available\n" +
|
160
|
+
"generator types, terminated by a null pointer. The function should be\n" +
|
161
|
+
"called once at the start of the program, if needed. The following code\n" +
|
162
|
+
"fragment shows how to iterate over the array of generator types to print\n" +
|
163
|
+
"the names of the available algorithms,\n" +
|
164
|
+
"\n" +
|
165
|
+
"const gsl_rng_type **t, **t0;\n" +
|
166
|
+
"\n" +
|
167
|
+
"t0 = gsl_rng_types_setup ();\n" +
|
168
|
+
"\n" +
|
169
|
+
"printf (\"Available generators:\\n\");\n" +
|
170
|
+
"\n" +
|
171
|
+
"for (t = t0; *t != 0; t++)\n" +
|
172
|
+
" @{\n" +
|
173
|
+
" printf (\"%s\\n\", (*t)->name);\n" +
|
174
|
+
" @}"},
|
175
|
+
{:func_name=>"gsl_rng_env_setup",
|
176
|
+
:func_type=>"const gsl_rng_type *",
|
177
|
+
:args=>[["", "void"]],
|
178
|
+
:desc=>
|
179
|
+
"This function reads the environment variables GSL_RNG_TYPE and\n" +
|
180
|
+
"GSL_RNG_SEED and uses their values to set the corresponding\n" +
|
181
|
+
"library variables gsl_rng_default and\n" +
|
182
|
+
"gsl_rng_default_seed. These global variables are defined as\n" +
|
183
|
+
"follows,\n" +
|
184
|
+
"\n" +
|
185
|
+
"extern const gsl_rng_type *gsl_rng_default\n" +
|
186
|
+
"extern unsigned long int gsl_rng_default_seed\n" +
|
187
|
+
"\n" +
|
188
|
+
"The environment variable GSL_RNG_TYPE should be the name of a\n" +
|
189
|
+
"generator, such as taus or mt19937. The environment\n" +
|
190
|
+
"variable GSL_RNG_SEED should contain the desired seed value. It\n" +
|
191
|
+
"is converted to an unsigned long int using the C library function\n" +
|
192
|
+
"strtoul.\n" +
|
193
|
+
"\n" +
|
194
|
+
"If you don't specify a generator for GSL_RNG_TYPE then\n" +
|
195
|
+
"gsl_rng_mt19937 is used as the default. The initial value of\n" +
|
196
|
+
"gsl_rng_default_seed is zero.\n"},
|
197
|
+
{:func_name=>"gsl_rng_memcpy",
|
198
|
+
:func_type=>"int",
|
199
|
+
:args=>[["gsl_rng *", "dest"], ["const gsl_rng *", "src"]],
|
200
|
+
:desc=>
|
201
|
+
"This function copies the random number generator src into the\n" +
|
202
|
+
"pre-existing generator dest, making dest into an exact copy\n" +
|
203
|
+
"of src. The two generators must be of the same type."},
|
204
|
+
{:func_name=>"gsl_rng_clone",
|
205
|
+
:func_type=>"gsl_rng *",
|
206
|
+
:args=>[["const gsl_rng *", "r"]],
|
207
|
+
:desc=>
|
208
|
+
"This function returns a pointer to a newly created generator which is an\n" +
|
209
|
+
"exact copy of the generator r."},
|
210
|
+
{:func_name=>"gsl_rng_fwrite",
|
211
|
+
:func_type=>"int",
|
212
|
+
:args=>[["FILE *", "stream"], ["const gsl_rng *", "r"]],
|
213
|
+
:desc=>
|
214
|
+
"This function writes the random number state of the random number\n" +
|
215
|
+
"generator r to the stream stream in binary format. The\n" +
|
216
|
+
"return value is 0 for success and GSL_EFAILED if there was a\n" +
|
217
|
+
"problem writing to the file. Since the data is written in the native\n" +
|
218
|
+
"binary format it may not be portable between different architectures."},
|
219
|
+
{:func_name=>"gsl_rng_fread",
|
220
|
+
:func_type=>"int",
|
221
|
+
:args=>[["FILE *", "stream"], ["gsl_rng *", "r"]],
|
222
|
+
:desc=>
|
223
|
+
"This function reads the random number state into the random number\n" +
|
224
|
+
"generator r from the open stream stream in binary format.\n" +
|
225
|
+
"The random number generator r must be preinitialized with the\n" +
|
226
|
+
"correct random number generator type since type information is not\n" +
|
227
|
+
"saved. The return value is 0 for success and GSL_EFAILED if\n" +
|
228
|
+
"there was a problem reading from the file. The data is assumed to\n" +
|
229
|
+
"have been written in the native binary format on the same\n" +
|
230
|
+
"architecture."}]
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require_relative "../gen/erbpp_gsl"
|
2
|
+
|
3
|
+
class DefRng < DefGslClass
|
4
|
+
def lookup(h)
|
5
|
+
case h
|
6
|
+
when FM(name:/_free$/); false
|
7
|
+
when FM(name:/_alloc$/); "rng_alloc"
|
8
|
+
when FM(tp, type:dbl); "rng_DFloat"
|
9
|
+
when FM(tp, ulong, type:ulong); "rng_UInt"
|
10
|
+
when FM(tp, type:str); "c_str_f_void"
|
11
|
+
when FM(tp, type:szt); "c_sizet_f_void"
|
12
|
+
when FM(tp, type:ulong); "c_ulong_f_void"
|
13
|
+
when FM(tp, type:tp); "c_other_f_void"
|
14
|
+
when FM(tp, ulong); "c_void_f_ulong"
|
15
|
+
when FM(tp, tp); "c_self_f_other"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_func(h)
|
20
|
+
if t = lookup(h)
|
21
|
+
m = h[:func_name].sub(/^gsl_rng_/,"")
|
22
|
+
DefMethod.new(self, t, name:m, **h)
|
23
|
+
if /_alloc$/ =~ h[:func_name]
|
24
|
+
read_type.each do |tp|
|
25
|
+
DefSubclassNew.new(self, "rng_type_new", tp, **h)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
return true
|
29
|
+
end
|
30
|
+
$stderr.puts "skip #{h[:func_name]}"
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# ----------------------------------------------------------
|
36
|
+
|
37
|
+
class DefRan < DefGslModule
|
38
|
+
def lookup(h)
|
39
|
+
dblbk = [dbl,/\[\]/]
|
40
|
+
uintbk = [uint,/\[\]/]
|
41
|
+
case h
|
42
|
+
when FM(tp, type:dbl); "ran"
|
43
|
+
when FM(tp, dbl, type:dbl); "ran"
|
44
|
+
when FM(tp, *[dbl]*2, type:dbl); "ran"
|
45
|
+
when FM(tp, dbl, type:uint); "ran"
|
46
|
+
when FM(tp, dbl,uint, type:uint); "ran"
|
47
|
+
when FM(tp, *[uint]*3, type:uint); "ran"
|
48
|
+
when FM(tp, *[dbl]*3,*[dblp]*2,); "ran_DFloat_x2"
|
49
|
+
when FM(tp, *[dblp]*2,); "ran_DFloat_x2"
|
50
|
+
when FM(tp, *[dblp]*3,); "ran_DFloat_x3"
|
51
|
+
when FM(tp, szt,dblp,); false
|
52
|
+
when FM(tp, szt,*[dblbk]*2); "ran_DFloat_f_DFloat"
|
53
|
+
when FM(tp, szt,uint,dblbk,uintbk); "ran_multinomial"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def define_method(t,**h)
|
58
|
+
RanMethod.new(self, t, **h)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
class RanMethod < DefMethod
|
64
|
+
|
65
|
+
def initialize(parent,tmpl,**h)
|
66
|
+
name = h[:func_name].sub(/^gsl_ran_/,"")
|
67
|
+
super(parent, tmpl, name:name, **h)
|
68
|
+
|
69
|
+
args = get(:args).dup
|
70
|
+
unless /gsl_rng */ =~ args.shift[0]
|
71
|
+
$stderr.puts h.inspect
|
72
|
+
raise
|
73
|
+
end
|
74
|
+
if desc
|
75
|
+
desc.gsub!(/@{/,"[")
|
76
|
+
desc.gsub!(/@}/,"]")
|
77
|
+
end
|
78
|
+
|
79
|
+
case h[:func_type]
|
80
|
+
when "double"
|
81
|
+
set func_type_var: "cDF"
|
82
|
+
set ret_class: "Float or DFloat"
|
83
|
+
when "unsigned int"
|
84
|
+
set func_type_var: "cUInt"
|
85
|
+
set ret_class: "Integer or UInt"
|
86
|
+
end
|
87
|
+
|
88
|
+
@an = []
|
89
|
+
@vn = []
|
90
|
+
@vardef = []
|
91
|
+
@varconv = []
|
92
|
+
@params = []
|
93
|
+
|
94
|
+
unknown = false
|
95
|
+
args.each_with_index do |tn,i|
|
96
|
+
if /^\w+$/ !~ tn[1] # pointer?
|
97
|
+
unknown = true
|
98
|
+
break
|
99
|
+
end
|
100
|
+
a = "a#{i}"
|
101
|
+
v = "v#{i}"
|
102
|
+
case tn[0]
|
103
|
+
when "double"
|
104
|
+
@varconv << "#{a} = NUM2DBL(#{v});"
|
105
|
+
@params << [tn[1],"Float"]
|
106
|
+
when "unsigned int"
|
107
|
+
@varconv << "#{a} = NUM2UINT(#{v});"
|
108
|
+
@params << [tn[1],"Integer"]
|
109
|
+
when "double *"
|
110
|
+
# skip
|
111
|
+
next
|
112
|
+
else
|
113
|
+
unknown = true
|
114
|
+
break
|
115
|
+
end
|
116
|
+
@vn << v
|
117
|
+
@an << a
|
118
|
+
@vardef << "#{tn[0]} #{a}"
|
119
|
+
end
|
120
|
+
if unknown
|
121
|
+
$stderr.puts "not defined: #{name} #{h[:args].inspect}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|