numo-gsl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/README.md +84 -0
  4. data/Rakefile +16 -0
  5. data/ext/numo/gsl/cdf/depend +17 -0
  6. data/ext/numo/gsl/cdf/erbpp_cdf.rb +44 -0
  7. data/ext/numo/gsl/cdf/extconf.rb +9 -0
  8. data/ext/numo/gsl/cdf/func_def.rb +610 -0
  9. data/ext/numo/gsl/const/const_def.rb +419 -0
  10. data/ext/numo/gsl/const/depend +17 -0
  11. data/ext/numo/gsl/const/erbpp_const.rb +30 -0
  12. data/ext/numo/gsl/const/extconf.rb +9 -0
  13. data/ext/numo/gsl/err/depend +1 -0
  14. data/ext/numo/gsl/err/err.c +22 -0
  15. data/ext/numo/gsl/err/extconf.rb +9 -0
  16. data/ext/numo/gsl/extconf_gsl.rb +44 -0
  17. data/ext/numo/gsl/fit/depend +17 -0
  18. data/ext/numo/gsl/fit/erbpp_fit.rb +74 -0
  19. data/ext/numo/gsl/fit/extconf.rb +9 -0
  20. data/ext/numo/gsl/fit/func_def.rb +129 -0
  21. data/ext/numo/gsl/fit/tmpl/check_1d.c +9 -0
  22. data/ext/numo/gsl/fit/tmpl/fit_linear.c +53 -0
  23. data/ext/numo/gsl/fit/tmpl/fit_linear_est.c +56 -0
  24. data/ext/numo/gsl/fit/tmpl/fit_mul.c +50 -0
  25. data/ext/numo/gsl/fit/tmpl/fit_mul_est.c +47 -0
  26. data/ext/numo/gsl/fit/tmpl/fit_wlinear.c +59 -0
  27. data/ext/numo/gsl/fit/tmpl/fit_wmul.c +56 -0
  28. data/ext/numo/gsl/gen/erbpp2.rb +306 -0
  29. data/ext/numo/gsl/gen/erbpp_gsl.rb +166 -0
  30. data/ext/numo/gsl/gen/func_parser.rb +520 -0
  31. data/ext/numo/gsl/gen/tmpl/c_DFloat_f_DFloat.c +40 -0
  32. data/ext/numo/gsl/gen/tmpl/c_DFloat_f_SZ.c +41 -0
  33. data/ext/numo/gsl/gen/tmpl/c_DFloat_f_SZ_x2.c +44 -0
  34. data/ext/numo/gsl/gen/tmpl/c_DFloat_x2_f_DFloat_x2.c +45 -0
  35. data/ext/numo/gsl/gen/tmpl/c_double_f_double.c +16 -0
  36. data/ext/numo/gsl/gen/tmpl/c_double_f_sizet.c +16 -0
  37. data/ext/numo/gsl/gen/tmpl/c_double_f_sizet_x2.c +17 -0
  38. data/ext/numo/gsl/gen/tmpl/c_double_f_void.c +15 -0
  39. data/ext/numo/gsl/gen/tmpl/c_double_x2_f_void.c +17 -0
  40. data/ext/numo/gsl/gen/tmpl/c_new_DFloat.c +29 -0
  41. data/ext/numo/gsl/gen/tmpl/c_new_double.c +22 -0
  42. data/ext/numo/gsl/gen/tmpl/c_new_f_other.c +25 -0
  43. data/ext/numo/gsl/gen/tmpl/c_new_sizet.c +22 -0
  44. data/ext/numo/gsl/gen/tmpl/c_new_sizet_double.c +23 -0
  45. data/ext/numo/gsl/gen/tmpl/c_new_sizet_x2.c +23 -0
  46. data/ext/numo/gsl/gen/tmpl/c_new_void.c +21 -0
  47. data/ext/numo/gsl/gen/tmpl/c_other_f_void.c +19 -0
  48. data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat.c +46 -0
  49. data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat_x2.c +41 -0
  50. data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat_x3.c +44 -0
  51. data/ext/numo/gsl/gen/tmpl/c_self_f_DFloat_x4.c +47 -0
  52. data/ext/numo/gsl/gen/tmpl/c_self_f_SZ_x2_DFloat.c +45 -0
  53. data/ext/numo/gsl/gen/tmpl/c_self_f_double.c +17 -0
  54. data/ext/numo/gsl/gen/tmpl/c_self_f_other.c +17 -0
  55. data/ext/numo/gsl/gen/tmpl/c_self_f_sizet.c +21 -0
  56. data/ext/numo/gsl/gen/tmpl/c_self_f_void.c +14 -0
  57. data/ext/numo/gsl/gen/tmpl/c_sizet_f_void.c +15 -0
  58. data/ext/numo/gsl/gen/tmpl/c_sizet_x2_f_void.c +17 -0
  59. data/ext/numo/gsl/gen/tmpl/c_str_f_void.c +15 -0
  60. data/ext/numo/gsl/gen/tmpl/c_super_new_void.c +18 -0
  61. data/ext/numo/gsl/gen/tmpl/c_uint_f_void.c +15 -0
  62. data/ext/numo/gsl/gen/tmpl/c_ulong_f_void.c +15 -0
  63. data/ext/numo/gsl/gen/tmpl/c_void_f_double.c +17 -0
  64. data/ext/numo/gsl/gen/tmpl/c_void_f_double_x2.c +18 -0
  65. data/ext/numo/gsl/gen/tmpl/c_void_f_double_x4.c +20 -0
  66. data/ext/numo/gsl/gen/tmpl/c_void_f_ulong.c +17 -0
  67. data/ext/numo/gsl/gen/tmpl/c_void_f_void.c +14 -0
  68. data/ext/numo/gsl/gen/tmpl/cast_1d_contiguous.c +15 -0
  69. data/ext/numo/gsl/gen/tmpl/cast_2d_contiguous.c +15 -0
  70. data/ext/numo/gsl/gen/tmpl/class.c +26 -0
  71. data/ext/numo/gsl/gen/tmpl/create_new_narray.c +26 -0
  72. data/ext/numo/gsl/gen/tmpl/init_class.c +10 -0
  73. data/ext/numo/gsl/gen/tmpl/init_module.c +12 -0
  74. data/ext/numo/gsl/gen/tmpl/lib.c +41 -0
  75. data/ext/numo/gsl/gen/tmpl/m_DFloat_Int_f_DFloat.c +38 -0
  76. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat.c +35 -0
  77. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_Int.c +39 -0
  78. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_UInt.c +39 -0
  79. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_double.c +42 -0
  80. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_double_x2.c +47 -0
  81. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_int.c +42 -0
  82. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_x2.c +38 -0
  83. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_DFloat_x3.c +41 -0
  84. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_Int.c +36 -0
  85. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt.c +36 -0
  86. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32.c +36 -0
  87. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_double.c +43 -0
  88. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_double_uint.c +49 -0
  89. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_double_x2.c +48 -0
  90. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt32_uint_x3.c +51 -0
  91. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_double.c +43 -0
  92. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_double_uint.c +50 -0
  93. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_double_x2.c +48 -0
  94. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_UInt_uint_x3.c +51 -0
  95. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_int_DFloat.c +41 -0
  96. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_int_DFloat_x2.c +44 -0
  97. data/ext/numo/gsl/gen/tmpl/m_DFloat_f_int_x2_DFloat_x2.c +46 -0
  98. data/ext/numo/gsl/gen/tmpl/m_Int_f_DFloat.c +36 -0
  99. data/ext/numo/gsl/gen/tmpl/m_Int_f_DFloat_x3.c +42 -0
  100. data/ext/numo/gsl/gen/tmpl/m_Int_f_int_DFloat.c +42 -0
  101. data/ext/numo/gsl/gen/tmpl/m_Int_f_int_DFloat_x2.c +45 -0
  102. data/ext/numo/gsl/gen/tmpl/mod_func_noloop.c +54 -0
  103. data/ext/numo/gsl/gen/tmpl/mod_func_scalar.c +27 -0
  104. data/ext/numo/gsl/gen/tmpl/module.c +9 -0
  105. data/ext/numo/gsl/histogram/depend +17 -0
  106. data/ext/numo/gsl/histogram/erbpp_histogram.rb +109 -0
  107. data/ext/numo/gsl/histogram/extconf.rb +9 -0
  108. data/ext/numo/gsl/histogram/func_def.rb +763 -0
  109. data/ext/numo/gsl/histogram/tmpl/c_DFloat_f_2d_get.c +54 -0
  110. data/ext/numo/gsl/histogram/tmpl/c_DFloat_f_field.c +35 -0
  111. data/ext/numo/gsl/histogram/tmpl/c_DFloat_f_get.c +47 -0
  112. data/ext/numo/gsl/histogram/tmpl/c_DFloat_x2_f_get_range.c +56 -0
  113. data/ext/numo/gsl/histogram/tmpl/c_bool_f_other.c +19 -0
  114. data/ext/numo/gsl/histogram/tmpl/c_bool_f_pdf_init.c +24 -0
  115. data/ext/numo/gsl/histogram/tmpl/c_self_f_2d_set_ranges.c +26 -0
  116. data/ext/numo/gsl/histogram/tmpl/c_self_f_set_ranges.c +21 -0
  117. data/ext/numo/gsl/histogram/tmpl/c_sizet_f_field.c +15 -0
  118. data/ext/numo/gsl/interp/depend +17 -0
  119. data/ext/numo/gsl/interp/erbpp_interp.rb +59 -0
  120. data/ext/numo/gsl/interp/extconf.rb +9 -0
  121. data/ext/numo/gsl/interp/func_def.rb +816 -0
  122. data/ext/numo/gsl/interp/parse_interp.rb +67 -0
  123. data/ext/numo/gsl/interp/tmpl/interp2d_new.c +36 -0
  124. data/ext/numo/gsl/interp/tmpl/interp2d_type_new.c +17 -0
  125. data/ext/numo/gsl/interp/tmpl/interp_bsearch.c +57 -0
  126. data/ext/numo/gsl/interp/tmpl/interp_new.c +29 -0
  127. data/ext/numo/gsl/interp/tmpl/interp_type_new.c +16 -0
  128. data/ext/numo/gsl/interp/tmpl/spline2d_eval.c +61 -0
  129. data/ext/numo/gsl/interp/tmpl/spline_eval.c +55 -0
  130. data/ext/numo/gsl/interp/tmpl/spline_integ.c +56 -0
  131. data/ext/numo/gsl/interp/type_def.rb +9 -0
  132. data/ext/numo/gsl/multifit/depend +17 -0
  133. data/ext/numo/gsl/multifit/erbpp_multifit.rb +99 -0
  134. data/ext/numo/gsl/multifit/extconf.rb +9 -0
  135. data/ext/numo/gsl/multifit/func_2.1.rb +1035 -0
  136. data/ext/numo/gsl/multifit/func_2.2.1.rb +736 -0
  137. data/ext/numo/gsl/multifit/func_2.2.rb +736 -0
  138. data/ext/numo/gsl/multifit/func_2.3.rb +872 -0
  139. data/ext/numo/gsl/multifit/func_def.rb +1012 -0
  140. data/ext/numo/gsl/multifit/tmpl/multifit_linear.c +66 -0
  141. data/ext/numo/gsl/multifit/tmpl/multifit_linear_est.c +48 -0
  142. data/ext/numo/gsl/multifit/tmpl/multifit_linear_residuals.c +47 -0
  143. data/ext/numo/gsl/multifit/tmpl/multifit_wlinear.c +70 -0
  144. data/ext/numo/gsl/multifit/type_def.rb +1 -0
  145. data/ext/numo/gsl/numo_gsl.h +117 -0
  146. data/ext/numo/gsl/pdf/depend +17 -0
  147. data/ext/numo/gsl/pdf/erbpp_pdf.rb +26 -0
  148. data/ext/numo/gsl/pdf/extconf.rb +9 -0
  149. data/ext/numo/gsl/pdf/func_2.2.1.rb +306 -0
  150. data/ext/numo/gsl/pdf/func_2.2.rb +306 -0
  151. data/ext/numo/gsl/pdf/func_2.3.rb +306 -0
  152. data/ext/numo/gsl/pdf/func_def.rb +282 -0
  153. data/ext/numo/gsl/pdf/parse_pdf.rb +42 -0
  154. data/ext/numo/gsl/pdf/tmpl/dirichlet.c +39 -0
  155. data/ext/numo/gsl/pdf/tmpl/multinomial.c +39 -0
  156. data/ext/numo/gsl/poly/depend +17 -0
  157. data/ext/numo/gsl/poly/erbpp_poly.rb +70 -0
  158. data/ext/numo/gsl/poly/extconf.rb +9 -0
  159. data/ext/numo/gsl/poly/func_def.rb +234 -0
  160. data/ext/numo/gsl/poly/tmpl/poly_complex_solve.c +59 -0
  161. data/ext/numo/gsl/poly/tmpl/poly_eval.c +70 -0
  162. data/ext/numo/gsl/poly/tmpl/poly_eval_derivs.c +40 -0
  163. data/ext/numo/gsl/ran/depend +17 -0
  164. data/ext/numo/gsl/ran/erbpp_ran.rb +42 -0
  165. data/ext/numo/gsl/ran/extconf.rb +9 -0
  166. data/ext/numo/gsl/ran/func_2.2.1.rb +1658 -0
  167. data/ext/numo/gsl/ran/func_2.2.rb +1658 -0
  168. data/ext/numo/gsl/ran/func_2.3.rb +1658 -0
  169. data/ext/numo/gsl/ran/func_def.rb +1594 -0
  170. data/ext/numo/gsl/ran/parse_ran.rb +10 -0
  171. data/ext/numo/gsl/rng/depend +17 -0
  172. data/ext/numo/gsl/rng/erbpp_rng.rb +58 -0
  173. data/ext/numo/gsl/rng/extconf.rb +9 -0
  174. data/ext/numo/gsl/rng/func_def.rb +230 -0
  175. data/ext/numo/gsl/rng/parse_rng.rb +125 -0
  176. data/ext/numo/gsl/rng/tmpl/ran.c +40 -0
  177. data/ext/numo/gsl/rng/tmpl/ran_DFloat_f_DFloat.c +28 -0
  178. data/ext/numo/gsl/rng/tmpl/ran_DFloat_x2.c +45 -0
  179. data/ext/numo/gsl/rng/tmpl/ran_DFloat_x3.c +51 -0
  180. data/ext/numo/gsl/rng/tmpl/ran_multinomial.c +32 -0
  181. data/ext/numo/gsl/rng/tmpl/rng_DFloat.c +29 -0
  182. data/ext/numo/gsl/rng/tmpl/rng_UInt.c +44 -0
  183. data/ext/numo/gsl/rng/tmpl/rng_alloc.c +24 -0
  184. data/ext/numo/gsl/rng/tmpl/rng_type_new.c +14 -0
  185. data/ext/numo/gsl/rng/type_def.rb +63 -0
  186. data/ext/numo/gsl/rstat/depend +17 -0
  187. data/ext/numo/gsl/rstat/erbpp_rstat.rb +64 -0
  188. data/ext/numo/gsl/rstat/extconf.rb +9 -0
  189. data/ext/numo/gsl/rstat/func_2.2.1.rb +116 -0
  190. data/ext/numo/gsl/rstat/func_2.2.rb +116 -0
  191. data/ext/numo/gsl/rstat/func_2.3.rb +123 -0
  192. data/ext/numo/gsl/rstat/func_def.rb +102 -0
  193. data/ext/numo/gsl/sf/depend +17 -0
  194. data/ext/numo/gsl/sf/erbpp_sf.rb +51 -0
  195. data/ext/numo/gsl/sf/extconf.rb +9 -0
  196. data/ext/numo/gsl/sf/func_def.rb +4703 -0
  197. data/ext/numo/gsl/sf/parse_sf.rb +277 -0
  198. data/ext/numo/gsl/sf/tmpl/c_DFloat_f_int_x2_DFloat.c +50 -0
  199. data/ext/numo/gsl/sf/tmpl/c_DFloat_f_int_x2_DFloat_x2.c +52 -0
  200. data/ext/numo/gsl/sf/tmpl/c_DFloat_f_int_x3_DFloat_x2.c +55 -0
  201. data/ext/numo/gsl/sf/tmpl/m_DFloat_f_DFloat_mode.c +47 -0
  202. data/ext/numo/gsl/sf/tmpl/m_DFloat_f_lmax_array.c +41 -0
  203. data/ext/numo/gsl/sf/tmpl/m_DFloat_f_nmin_nmax_array.c +49 -0
  204. data/ext/numo/gsl/spmatrix/const_2.2.1.rb +3 -0
  205. data/ext/numo/gsl/spmatrix/const_2.2.rb +3 -0
  206. data/ext/numo/gsl/spmatrix/const_2.3.rb +3 -0
  207. data/ext/numo/gsl/spmatrix/const_def.rb +2 -0
  208. data/ext/numo/gsl/spmatrix/depend +17 -0
  209. data/ext/numo/gsl/spmatrix/erbpp_spmatrix.rb +100 -0
  210. data/ext/numo/gsl/spmatrix/extconf.rb +9 -0
  211. data/ext/numo/gsl/spmatrix/func_2.2.1.rb +297 -0
  212. data/ext/numo/gsl/spmatrix/func_2.2.rb +297 -0
  213. data/ext/numo/gsl/spmatrix/func_2.3.rb +297 -0
  214. data/ext/numo/gsl/spmatrix/func_def.rb +218 -0
  215. data/ext/numo/gsl/spmatrix/parse_spmatrix.rb +70 -0
  216. data/ext/numo/gsl/spmatrix/tmpl/itersolve_iterate.c +47 -0
  217. data/ext/numo/gsl/spmatrix/tmpl/itersolve_new.c +22 -0
  218. data/ext/numo/gsl/spmatrix/tmpl/itersolve_type_new.c +16 -0
  219. data/ext/numo/gsl/spmatrix/tmpl/spblas_dgemm.c +35 -0
  220. data/ext/numo/gsl/spmatrix/tmpl/spblas_dgemv.c +43 -0
  221. data/ext/numo/gsl/spmatrix/tmpl/spmatrix_add.c +22 -0
  222. data/ext/numo/gsl/spmatrix/tmpl/spmatrix_d2sp.c +28 -0
  223. data/ext/numo/gsl/spmatrix/tmpl/spmatrix_new.c +40 -0
  224. data/ext/numo/gsl/spmatrix/tmpl/spmatrix_sp2d.c +25 -0
  225. data/ext/numo/gsl/spmatrix/type_def.rb +1 -0
  226. data/ext/numo/gsl/stats/depend +17 -0
  227. data/ext/numo/gsl/stats/erbpp_stats.rb +29 -0
  228. data/ext/numo/gsl/stats/extconf.rb +9 -0
  229. data/ext/numo/gsl/stats/func_2.2.1.rb +608 -0
  230. data/ext/numo/gsl/stats/func_2.2.rb +608 -0
  231. data/ext/numo/gsl/stats/func_2.3.rb +608 -0
  232. data/ext/numo/gsl/stats/func_def.rb +608 -0
  233. data/ext/numo/gsl/stats/parse_stats.rb +63 -0
  234. data/ext/numo/gsl/stats/tmpl/stats_1a0p.c +37 -0
  235. data/ext/numo/gsl/stats/tmpl/stats_1a0p_index.c +60 -0
  236. data/ext/numo/gsl/stats/tmpl/stats_1a1p.c +41 -0
  237. data/ext/numo/gsl/stats/tmpl/stats_1a2p.c +42 -0
  238. data/ext/numo/gsl/stats/tmpl/stats_2a0p.c +39 -0
  239. data/ext/numo/gsl/stats/tmpl/stats_2a1p.c +43 -0
  240. data/ext/numo/gsl/stats/tmpl/stats_2a2p.c +44 -0
  241. data/ext/numo/gsl/stats/tmpl/stats_minmax.c +37 -0
  242. data/ext/numo/gsl/stats/tmpl/stats_minmax_index.c +67 -0
  243. data/ext/numo/gsl/stats/tmpl/stats_spearman.c +46 -0
  244. data/ext/numo/gsl/sys/const_def.rb +21 -0
  245. data/ext/numo/gsl/sys/depend +17 -0
  246. data/ext/numo/gsl/sys/enum_def.rb +75 -0
  247. data/ext/numo/gsl/sys/erbpp_sys.rb +60 -0
  248. data/ext/numo/gsl/sys/extconf.rb +9 -0
  249. data/ext/numo/gsl/sys/func_def.rb +249 -0
  250. data/ext/numo/gsl/version.h +1 -0
  251. data/ext/numo/gsl/wavelet/depend +17 -0
  252. data/ext/numo/gsl/wavelet/erbpp_wavelet.rb +48 -0
  253. data/ext/numo/gsl/wavelet/extconf.rb +9 -0
  254. data/ext/numo/gsl/wavelet/func_def.rb +337 -0
  255. data/ext/numo/gsl/wavelet/parse_wavelet.rb +47 -0
  256. data/ext/numo/gsl/wavelet/tmpl/wavelet2d_transform.c +56 -0
  257. data/ext/numo/gsl/wavelet/tmpl/wavelet_array_check.c +56 -0
  258. data/ext/numo/gsl/wavelet/tmpl/wavelet_macro.c +1 -0
  259. data/ext/numo/gsl/wavelet/tmpl/wavelet_new.c +20 -0
  260. data/ext/numo/gsl/wavelet/tmpl/wavelet_transform.c +55 -0
  261. data/ext/numo/gsl/wavelet/tmpl/wavelet_transform2.c +22 -0
  262. data/ext/numo/gsl/wavelet/tmpl/wavelet_type_new.c +15 -0
  263. data/ext/numo/gsl/wavelet/type_def.rb +6 -0
  264. data/lib/numo/gsl.rb +17 -0
  265. data/numo-gsl.gemspec +33 -0
  266. metadata +367 -0
@@ -0,0 +1,9 @@
1
+ require_relative '../extconf_gsl.rb'
2
+
3
+ # source file to compile
4
+ srcs = %w(
5
+ gsl_const
6
+ )
7
+ $objs = srcs.collect{|i| i+".o"}
8
+
9
+ create_makefile('numo/gsl/const')
@@ -0,0 +1 @@
1
+ src :
@@ -0,0 +1,22 @@
1
+ #include <ruby.h>
2
+ #include <gsl/gsl_errno.h>
3
+
4
+ VALUE numo_eGslError;
5
+
6
+ static void
7
+ numo_gsl_err_hdl(const char *reason, const char *file, int line, int gsl_errno)
8
+ {
9
+ rb_raise(numo_eGslError,"%s:%d: %s",file,line,reason);
10
+ }
11
+
12
+ void
13
+ Init_err(void)
14
+ {
15
+ VALUE mNumo, mGSL;
16
+
17
+ mNumo = rb_define_module("Numo");
18
+ mGSL = rb_define_module_under(mNumo, "GSL");
19
+ numo_eGslError = rb_define_class_under(mGSL, "GslError", rb_eStandardError);
20
+
21
+ gsl_set_error_handler(&numo_gsl_err_hdl);
22
+ }
@@ -0,0 +1,9 @@
1
+ require_relative '../extconf_gsl.rb'
2
+
3
+ # source file to compile
4
+ srcs = %w(
5
+ err
6
+ )
7
+ $objs = srcs.collect{|i| i+".o"}
8
+
9
+ create_makefile('numo/gsl/err')
@@ -0,0 +1,44 @@
1
+ require 'rbconfig.rb'
2
+ require 'numo/narray'
3
+ require 'mkmf'
4
+
5
+ # configure options: --with-gsl-lib=path
6
+ #dir_config("gsl")
7
+
8
+ # check gsl-config command
9
+ print "checking for gsl-config... "
10
+ begin
11
+ gsl_libs = `gsl-config --libs`
12
+ rescue
13
+ puts "no"
14
+ exit 1
15
+ end
16
+ puts "yes"
17
+
18
+ # parse GSL libs
19
+ libs = []
20
+ gsl_libs.split(/\s+/).each do |x|
21
+ case x
22
+ when /^-L(.+)/
23
+ $LIBPATH.push($1)
24
+ when /^-l(.+)/
25
+ libs.unshift($1)
26
+ end
27
+ end
28
+
29
+ # check library
30
+ libs.each do |x|
31
+ exit 1 unless have_library(x)
32
+ end
33
+
34
+ # GSL include files
35
+ $INCFLAGS = [`gsl-config --cflags`.chomp,$INCFLAGS].join(" ")
36
+
37
+ # check narray.h
38
+ $LOAD_PATH.each do |x|
39
+ if File.exist? File.join(x,'numo','numo/narray.h')
40
+ $INCFLAGS = "-I#{x}/numo " + $INCFLAGS
41
+ break
42
+ end
43
+ end
44
+ exit 1 unless have_header('numo/narray.h')
@@ -0,0 +1,17 @@
1
+ COGEN=ruby erbpp_fit.rb
2
+ GENSRC=gsl_fit.c
3
+ GENDEPS=erbpp_fit.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,74 @@
1
+ require_relative "../gen/func_parser"
2
+ require_relative "../gen/erbpp_gsl"
3
+ require "erbpp/line_number"
4
+
5
+ fit_list = ErbppGsl.read_func
6
+
7
+ class DefFit < DefModule
8
+ def lookup(h)
9
+ h[:func_name].sub(/^gsl_/,"")
10
+ end
11
+ def check_func(h)
12
+ if t = lookup(h)
13
+ if File.exist?("tmpl/#{t}.c")
14
+ m = h[:func_name].sub(/^gsl_#{name}_/,"")
15
+ Fit.new(self, t, name:m, **h)
16
+ return true
17
+ end
18
+ end
19
+ $stderr.puts "skip #{h[:func_name]}"
20
+ end
21
+ end
22
+
23
+ class Fit < DefModuleFunction
24
+ def result
25
+ case func_name
26
+ when /_w?(linear|mul)$/
27
+ cls = (name+"_result").split(/_/).map{|x| x.capitalize}.join("")
28
+ set result_class: cls
29
+ "static VALUE c#{cls};\n"+super
30
+ else
31
+ super
32
+ end
33
+ end
34
+ def init_def
35
+ if get(:result_class)
36
+ super+"
37
+ #{struct_def}"
38
+ else
39
+ super
40
+ end
41
+ end
42
+ def struct_def
43
+ vars = get(:args).select{|a| a[0]=="double *"}
44
+ items = vars.map{|a| "\"#{a[1]}\""}.join(",")
45
+ cls = get(:result_class)
46
+ "/*
47
+ Document-class: Numo::GSL::Fit::#{cls}
48
+ */
49
+ c#{cls} = rb_struct_define_under(#{_mod_var},\"#{cls}\",#{items},NULL);"
50
+ end
51
+ end
52
+
53
+ DefLib.new do
54
+ set erb_dir: %w[tmpl ../gen/tmpl]
55
+ set erb_suffix: ".c"
56
+ set ns_var: "mG"
57
+
58
+ name = "Fit"
59
+ set file_name: "gsl_#{name}.c"
60
+ set include_files: %w[gsl/gsl_fit.h]
61
+ set lib_name: name.downcase
62
+
63
+ DefFit.new(self) do
64
+ set name: name.downcase
65
+ set module_name: name
66
+ set module_var: "m"+name
67
+ set full_module_name: "Numo::GSL::"+name
68
+
69
+ fit_list.each do |h|
70
+ check_func(h)
71
+ end
72
+
73
+ end
74
+ end.write(ARGV[0])
@@ -0,0 +1,9 @@
1
+ require_relative '../extconf_gsl.rb'
2
+
3
+ # source file to compile
4
+ srcs = %w(
5
+ gsl_fit
6
+ )
7
+ $objs = srcs.collect{|i| i+".o"}
8
+
9
+ create_makefile('numo/gsl/fit')
@@ -0,0 +1,129 @@
1
+ [{:func_name=>"gsl_fit_linear",
2
+ :func_type=>"int",
3
+ :args=>
4
+ [["const double *", "x"],
5
+ ["const size_t", "xstride"],
6
+ ["const double *", "y"],
7
+ ["const size_t", "ystride"],
8
+ ["size_t", "n"],
9
+ ["double *", "c0"],
10
+ ["double *", "c1"],
11
+ ["double *", "cov00"],
12
+ ["double *", "cov01"],
13
+ ["double *", "cov11"],
14
+ ["double *", "sumsq"]],
15
+ :desc=>
16
+ "This function computes the best-fit linear regression coefficients\n" +
17
+ "(c0,c1) of the model Y = c_0 + c_1 X for the dataset\n" +
18
+ "(x, y), two vectors of length n with strides\n" +
19
+ "xstride and ystride. The errors on y are assumed unknown so \n" +
20
+ "the variance-covariance matrix for the\n" +
21
+ "parameters (c0, c1) is estimated from the scatter of the\n" +
22
+ "points around the best-fit line and returned via the parameters\n" +
23
+ "(cov00, cov01, cov11). \n" +
24
+ "The sum of squares of the residuals from the best-fit line is returned\n" +
25
+ "in sumsq. Note: the correlation coefficient of the data can be computed using gsl_stats_correlation (Correlation), it does not depend on the fit."},
26
+ {:func_name=>"gsl_fit_wlinear",
27
+ :func_type=>"int",
28
+ :args=>
29
+ [["const double *", "x"],
30
+ ["const size_t", "xstride"],
31
+ ["const double *", "w"],
32
+ ["const size_t", "wstride"],
33
+ ["const double *", "y"],
34
+ ["const size_t", "ystride"],
35
+ ["size_t", "n"],
36
+ ["double *", "c0"],
37
+ ["double *", "c1"],
38
+ ["double *", "cov00"],
39
+ ["double *", "cov01"],
40
+ ["double *", "cov11"],
41
+ ["double *", "chisq"]],
42
+ :desc=>
43
+ "This function computes the best-fit linear regression coefficients\n" +
44
+ "(c0,c1) of the model Y = c_0 + c_1 X for the weighted\n" +
45
+ "dataset (x, y), two vectors of length n with strides\n" +
46
+ "xstride and ystride. The vector w, of length n\n" +
47
+ "and stride wstride, specifies the weight of each datapoint. The\n" +
48
+ "weight is the reciprocal of the variance for each datapoint in y.\n" +
49
+ "\n" +
50
+ "The covariance matrix for the parameters (c0, c1) is\n" +
51
+ "computed using the weights and returned via the parameters\n" +
52
+ "(cov00, cov01, cov11). The weighted sum of squares\n" +
53
+ "of the residuals from the best-fit line, \\chi^2, is returned in\n" +
54
+ "chisq."},
55
+ {:func_name=>"gsl_fit_linear_est",
56
+ :func_type=>"int",
57
+ :args=>
58
+ [["double", "x"],
59
+ ["double", "c0"],
60
+ ["double", "c1"],
61
+ ["double", "cov00"],
62
+ ["double", "cov01"],
63
+ ["double", "cov11"],
64
+ ["double *", "y"],
65
+ ["double *", "y_err"]],
66
+ :desc=>
67
+ "This function uses the best-fit linear regression coefficients\n" +
68
+ "c0, c1 and their covariance\n" +
69
+ "cov00, cov01, cov11 to compute the fitted function\n" +
70
+ "y and its standard deviation y_err for the model Y =\n" +
71
+ "c_0 + c_1 X at the point x."},
72
+ {:func_name=>"gsl_fit_mul",
73
+ :func_type=>"int",
74
+ :args=>
75
+ [["const double *", "x"],
76
+ ["const size_t", "xstride"],
77
+ ["const double *", "y"],
78
+ ["const size_t", "ystride"],
79
+ ["size_t", "n"],
80
+ ["double *", "c1"],
81
+ ["double *", "cov11"],
82
+ ["double *", "sumsq"]],
83
+ :desc=>
84
+ "This function computes the best-fit linear regression coefficient\n" +
85
+ "c1 of the model Y = c_1 X for the datasets (x,\n" +
86
+ "y), two vectors of length n with strides xstride and\n" +
87
+ "ystride. The errors on y are assumed unknown so the \n" +
88
+ "variance of the parameter c1 is estimated from\n" +
89
+ "the scatter of the points around the best-fit line and returned via the\n" +
90
+ "parameter cov11. The sum of squares of the residuals from the\n" +
91
+ "best-fit line is returned in sumsq."},
92
+ {:func_name=>"gsl_fit_wmul",
93
+ :func_type=>"int",
94
+ :args=>
95
+ [["const double *", "x"],
96
+ ["const size_t", "xstride"],
97
+ ["const double *", "w"],
98
+ ["const size_t", "wstride"],
99
+ ["const double *", "y"],
100
+ ["const size_t", "ystride"],
101
+ ["size_t", "n"],
102
+ ["double *", "c1"],
103
+ ["double *", "cov11"],
104
+ ["double *", "sumsq"]],
105
+ :desc=>
106
+ "This function computes the best-fit linear regression coefficient\n" +
107
+ "c1 of the model Y = c_1 X for the weighted datasets\n" +
108
+ "(x, y), two vectors of length n with strides\n" +
109
+ "xstride and ystride. The vector w, of length n\n" +
110
+ "and stride wstride, specifies the weight of each datapoint. The\n" +
111
+ "weight is the reciprocal of the variance for each datapoint in y.\n" +
112
+ "\n" +
113
+ "The variance of the parameter c1 is computed using the weights\n" +
114
+ "and returned via the parameter cov11. The weighted sum of\n" +
115
+ "squares of the residuals from the best-fit line, \\chi^2, is\n" +
116
+ "returned in chisq."},
117
+ {:func_name=>"gsl_fit_mul_est",
118
+ :func_type=>"int",
119
+ :args=>
120
+ [["double", "x"],
121
+ ["double", "c1"],
122
+ ["double", "cov11"],
123
+ ["double *", "y"],
124
+ ["double *", "y_err"]],
125
+ :desc=>
126
+ "This function uses the best-fit linear regression coefficient c1\n" +
127
+ "and its covariance cov11 to compute the fitted function\n" +
128
+ "y and its standard deviation y_err for the model Y =\n" +
129
+ "c_1 X at the point x."}]
@@ -0,0 +1,9 @@
1
+ static void
2
+ check_1d(VALUE v)
3
+ {
4
+ narray_t *na;
5
+ GetNArray(v,na);
6
+ if (NA_NDIM(na) != 1) {
7
+ rb_raise(nary_eShapeError, "argument should be 1-dimensional array");
8
+ }
9
+ }
@@ -0,0 +1,53 @@
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,*p6,*p7,*p8;
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
+ p6 = (double*)GET_PTR(lp,5);
16
+ p7 = (double*)GET_PTR(lp,6);
17
+ p8 = (double*)GET_PTR(lp,7);
18
+
19
+ <%=func_name%>((double*)p1,s1/sizeof(double),
20
+ (double*)p2,s2/sizeof(double),
21
+ n,p3,p4,p5,p6,p7,p8);
22
+ }
23
+
24
+ /*
25
+ @overload <%=name%>(<%=args[0][1]%>,<%=args[2][1]%>)
26
+ @param [DFloat] <%=args[0][1]%> (input array)
27
+ @param [DFloat] <%=args[2][1]%> (input array)
28
+ @return [GSL::Fit::<%=result_class%>] result Struct with members: <%=args[5][1]%>, <%=args[6][1]%>, <%=args[7][1]%>, <%=args[8][1]%>, <%=args[9][1]%>, <%=args[10][1]%>.
29
+
30
+ <%=desc%>
31
+
32
+ */
33
+ static VALUE
34
+ <%=c_func(2)%>(VALUE mod, VALUE v1, VALUE v2)
35
+ {
36
+ VALUE r, result;
37
+ ndfunc_arg_in_t ain[2] = {{cDF,1},{cDF,1}};
38
+ ndfunc_arg_out_t aout[6] = {{cDF,0},{cDF,0},{cDF,0},{cDF,0},{cDF,0},{cDF,0}};
39
+ ndfunc_t ndf = { iter_<%=c_func%>, NO_LOOP|NDF_EXTRACT,
40
+ 2, 6, ain, aout };
41
+ narray_t *x, *y;
42
+
43
+ GetNArray(v1,x);
44
+ GetNArray(v2,y);
45
+ CHECK_GE_1D(x);
46
+ CHECK_GE_1D(y);
47
+ CHECK_SIZE_EQ(VEC_SIZE(x),VEC_SIZE(y),"x size does not match y size");
48
+
49
+ r = na_ndloop(&ndf, 2, v1, v2);
50
+ result = rb_class_new_instance(6, RARRAY_PTR(r), c<%=result_class%>);
51
+ RB_GC_GUARD(r);
52
+ return result;
53
+ }
@@ -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,*p4,*p5,*p6,*p7,*p8;
6
+ ssize_t s1, s2, s3, s4, s5, s6, s7, s8;
7
+ double x,c0,c1,cov00,cov01,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
+ INIT_PTR(lp, 5, p6, s6);
16
+ INIT_PTR(lp, 6, p7, s7);
17
+ INIT_PTR(lp, 7, p8, s8);
18
+
19
+ for (; i--; ) {
20
+ GET_DATA_STRIDE(p1,s1,double,x);
21
+ GET_DATA_STRIDE(p2,s2,double,c0);
22
+ GET_DATA_STRIDE(p3,s3,double,c1);
23
+ GET_DATA_STRIDE(p4,s4,double,cov00);
24
+ GET_DATA_STRIDE(p5,s5,double,cov01);
25
+ GET_DATA_STRIDE(p6,s6,double,cov11);
26
+ <%=func_name%>(x, c0, c1, cov00, cov01, cov11, &y, &ye);
27
+ SET_DATA_STRIDE(p7,s7,double,y);
28
+ SET_DATA_STRIDE(p8,s8,double,ye);
29
+ }
30
+ }
31
+
32
+ /*
33
+ @overload <%=name%>(<%=args[0][1]%>,linear_result)
34
+ @param [DFloat] <%=args[0][1]%>
35
+ @param [(L|Wl)inearResult] linear_result Result of GSL::Fit.linear|wlinear
36
+ @return [[DFloat,DFloat]] array of (<%=args[6][1]%>, <%=args[7][1]%>).
37
+
38
+ <%=desc%>
39
+
40
+ */
41
+ static VALUE
42
+ <%=c_func(2)%>(VALUE mod, VALUE v1, VALUE v2)
43
+ {
44
+ ndfunc_arg_in_t ain[6] = {{cDF,0},{cDF,0},{cDF,0},{cDF,0},{cDF,0},{cDF,0}};
45
+ ndfunc_arg_out_t aout[2] = {{cDF,0},{cDF,0}};
46
+ ndfunc_t ndf = { iter_<%=c_func%>, STRIDE_LOOP_NIP|NDF_EXTRACT,
47
+ 6, 2, ain, aout };
48
+ VALUE c0, c1, cov00, cov01, cov11;
49
+
50
+ c0 = RSTRUCT_GET(v2,0);
51
+ c1 = RSTRUCT_GET(v2,1);
52
+ cov00 = RSTRUCT_GET(v2,2);
53
+ cov01 = RSTRUCT_GET(v2,3);
54
+ cov11 = RSTRUCT_GET(v2,4);
55
+ return na_ndloop(&ndf, 6, v1, c0, c1, cov00, cov01, cov11);
56
+ }