numo-gsl 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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_poly
6
+ )
7
+ $objs = srcs.collect{|i| i+".o"}
8
+
9
+ create_makefile('numo/gsl/poly')
@@ -0,0 +1,234 @@
1
+ [{:func_name=>"gsl_poly_eval",
2
+ :func_type=>"double",
3
+ :args=>
4
+ [["const double", "c[]"], ["const int", "len"], ["const double", "x"]],
5
+ :desc=>
6
+ "This function evaluates a polynomial with real coefficients for the real variable x."},
7
+ {:func_name=>"gsl_poly_complex_eval",
8
+ :func_type=>"gsl_complex",
9
+ :args=>
10
+ [["const double", "c[]"], ["const int", "len"], ["const gsl_complex", "z"]],
11
+ :desc=>
12
+ "This function evaluates a polynomial with real coefficients for the complex variable z."},
13
+ {:func_name=>"gsl_complex_poly_complex_eval",
14
+ :func_type=>"gsl_complex",
15
+ :args=>
16
+ [["const gsl_complex", "c[]"],
17
+ ["const int", "len"],
18
+ ["const gsl_complex", "z"]],
19
+ :desc=>
20
+ "This function evaluates a polynomial with complex coefficients for the complex variable z."},
21
+ {:func_name=>"gsl_poly_eval_derivs",
22
+ :func_type=>"int",
23
+ :args=>
24
+ [["const double", "c[]"],
25
+ ["const size_t", "lenc"],
26
+ ["const double", "x"],
27
+ ["double", "res[]"],
28
+ ["const size_t", "lenres"]],
29
+ :desc=>
30
+ "This function evaluates a polynomial and its derivatives storing the\n" +
31
+ "results in the array res of size lenres. The output array\n" +
32
+ "contains the values of d^k P/d x^k for the specified value of\n" +
33
+ "x starting with k = 0."},
34
+ {:func_name=>"gsl_poly_dd_init",
35
+ :func_type=>"int",
36
+ :args=>
37
+ [["double", "dd[]"],
38
+ ["const double", "xa[]"],
39
+ ["const double", "ya[]"],
40
+ ["size_t", "size"]],
41
+ :desc=>
42
+ "This function computes a divided-difference representation of the\n" +
43
+ "interpolating polynomial for the points (x, y) stored in\n" +
44
+ "the arrays xa and ya of length size. On output the\n" +
45
+ "divided-differences of (xa,ya) are stored in the array\n" +
46
+ "dd, also of length size. Using the notation above,\n" +
47
+ "dd[k] = [x_0,x_1,...,x_k]."},
48
+ {:func_name=>"gsl_poly_dd_eval",
49
+ :func_type=>"double",
50
+ :args=>
51
+ [["const double", "dd[]"],
52
+ ["const double", "xa[]"],
53
+ ["const size_t", "size"],
54
+ ["const double", "x"]],
55
+ :desc=>
56
+ "This function evaluates the polynomial stored in divided-difference form\n" +
57
+ "in the arrays dd and xa of length size at the point\n" +
58
+ "x. "},
59
+ {:func_name=>"gsl_poly_dd_taylor",
60
+ :func_type=>"int",
61
+ :args=>
62
+ [["double", "c[]"],
63
+ ["double", "xp"],
64
+ ["const double", "dd[]"],
65
+ ["const double", "xa[]"],
66
+ ["size_t", "size"],
67
+ ["double", "w[]"]],
68
+ :desc=>
69
+ "This function converts the divided-difference representation of a\n" +
70
+ "polynomial to a Taylor expansion. The divided-difference representation\n" +
71
+ "is supplied in the arrays dd and xa of length size.\n" +
72
+ "On output the Taylor coefficients of the polynomial expanded about the\n" +
73
+ "point xp are stored in the array c also of length\n" +
74
+ "size. A workspace of length size must be provided in the\n" +
75
+ "array w."},
76
+ {:func_name=>"gsl_poly_dd_hermite_init",
77
+ :func_type=>"int",
78
+ :args=>
79
+ [["double", "dd[]"],
80
+ ["double", "za[]"],
81
+ ["const double", "xa[]"],
82
+ ["const double", "ya[]"],
83
+ ["const double", "dya[]"],
84
+ ["const size_t", "size"]],
85
+ :desc=>
86
+ "This function computes a divided-difference representation of the\n" +
87
+ "interpolating Hermite polynomial for the points (x, y) stored in\n" +
88
+ "the arrays xa and ya of length size. Hermite interpolation\n" +
89
+ "constructs polynomials which also match first derivatives dy/dx which are\n" +
90
+ "provided in the array dya also of length size. The first derivatives can be\n" +
91
+ "incorported into the usual divided-difference algorithm by forming a new\n" +
92
+ "dataset z = \\{x_0,x_0,x_1,x_1,...\\}, which is stored in the array\n" +
93
+ "za of length 2*size on output. On output the\n" +
94
+ "divided-differences of the Hermite representation are stored in the array\n" +
95
+ "dd, also of length 2*size. Using the notation above,\n" +
96
+ "dd[k] = [z_0,z_1,...,z_k]. The resulting Hermite polynomial\n" +
97
+ "can be evaluated by calling gsl_poly_dd_eval and using\n" +
98
+ "za for the input argument xa."},
99
+ {:func_name=>"gsl_poly_solve_quadratic",
100
+ :func_type=>"int",
101
+ :args=>
102
+ [["double", "a"],
103
+ ["double", "b"],
104
+ ["double", "c"],
105
+ ["double *", "x0"],
106
+ ["double *", "x1"]],
107
+ :desc=>
108
+ "This function finds the real roots of the quadratic equation,\n" +
109
+ "\n" +
110
+ "a x^2 + b x + c = 0\n" +
111
+ "\n" +
112
+ "The number of real roots (either zero, one or two) is returned, and\n" +
113
+ "their locations are stored in x0 and x1. If no real roots\n" +
114
+ "are found then x0 and x1 are not modified. If one real root\n" +
115
+ "is found (i.e. if a=0) then it is stored in x0. When two\n" +
116
+ "real roots are found they are stored in x0 and x1 in\n" +
117
+ "ascending order. The case of coincident roots is not considered\n" +
118
+ "special. For example (x-1)^2=0 will have two roots, which happen\n" +
119
+ "to have exactly equal values.\n" +
120
+ "\n" +
121
+ "The number of roots found depends on the sign of the discriminant\n" +
122
+ "b^2 - 4 a c. This will be subject to rounding and cancellation\n" +
123
+ "errors when computed in double precision, and will also be subject to\n" +
124
+ "errors if the coefficients of the polynomial are inexact. These errors\n" +
125
+ "may cause a discrete change in the number of roots. However, for\n" +
126
+ "polynomials with small integer coefficients the discriminant can always\n" +
127
+ "be computed exactly.\n"},
128
+ {:func_name=>"gsl_poly_complex_solve_quadratic",
129
+ :func_type=>"int",
130
+ :args=>
131
+ [["double", "a"],
132
+ ["double", "b"],
133
+ ["double", "c"],
134
+ ["gsl_complex *", "z0"],
135
+ ["gsl_complex *", "z1"]],
136
+ :desc=>
137
+ "\n" +
138
+ "This function finds the complex roots of the quadratic equation,\n" +
139
+ "\n" +
140
+ "a z^2 + b z + c = 0\n" +
141
+ "\n" +
142
+ "The number of complex roots is returned (either one or two) and the\n" +
143
+ "locations of the roots are stored in z0 and z1. The roots\n" +
144
+ "are returned in ascending order, sorted first by their real components\n" +
145
+ "and then by their imaginary components. If only one real root is found\n" +
146
+ "(i.e. if a=0) then it is stored in z0.\n"},
147
+ {:func_name=>"gsl_poly_solve_cubic",
148
+ :func_type=>"int",
149
+ :args=>
150
+ [["double", "a"],
151
+ ["double", "b"],
152
+ ["double", "c"],
153
+ ["double *", "x0"],
154
+ ["double *", "x1"],
155
+ ["double *", "x2"]],
156
+ :desc=>
157
+ "\n" +
158
+ "This function finds the real roots of the cubic equation,\n" +
159
+ "\n" +
160
+ "x^3 + a x^2 + b x + c = 0\n" +
161
+ "\n" +
162
+ "with a leading coefficient of unity. The number of real roots (either\n" +
163
+ "one or three) is returned, and their locations are stored in x0,\n" +
164
+ "x1 and x2. If one real root is found then only x0\n" +
165
+ "is modified. When three real roots are found they are stored in\n" +
166
+ "x0, x1 and x2 in ascending order. The case of\n" +
167
+ "coincident roots is not considered special. For example, the equation\n" +
168
+ "(x-1)^3=0 will have three roots with exactly equal values. As\n" +
169
+ "in the quadratic case, finite precision may cause equal or\n" +
170
+ "closely-spaced real roots to move off the real axis into the complex\n" +
171
+ "plane, leading to a discrete change in the number of real roots."},
172
+ {:func_name=>"gsl_poly_complex_solve_cubic",
173
+ :func_type=>"int",
174
+ :args=>
175
+ [["double", "a"],
176
+ ["double", "b"],
177
+ ["double", "c"],
178
+ ["gsl_complex *", "z0"],
179
+ ["gsl_complex *", "z1"],
180
+ ["gsl_complex *", "z2"]],
181
+ :desc=>
182
+ "\n" +
183
+ "This function finds the complex roots of the cubic equation,\n" +
184
+ "\n" +
185
+ "z^3 + a z^2 + b z + c = 0\n" +
186
+ "\n" +
187
+ "The number of complex roots is returned (always three) and the locations\n" +
188
+ "of the roots are stored in z0, z1 and z2. The roots\n" +
189
+ "are returned in ascending order, sorted first by their real components\n" +
190
+ "and then by their imaginary components.\n"},
191
+ {:func_name=>"gsl_poly_complex_workspace_alloc",
192
+ :func_type=>"gsl_poly_complex_workspace *",
193
+ :args=>[["size_t", "n"]],
194
+ :desc=>
195
+ "This function allocates space for a gsl_poly_complex_workspace\n" +
196
+ "struct and a workspace suitable for solving a polynomial with n\n" +
197
+ "coefficients using the routine gsl_poly_complex_solve.\n" +
198
+ "\n" +
199
+ "The function returns a pointer to the newly allocated\n" +
200
+ "gsl_poly_complex_workspace if no errors were detected, and a null\n" +
201
+ "pointer in the case of error."},
202
+ {:func_name=>"gsl_poly_complex_workspace_free",
203
+ :func_type=>"void",
204
+ :args=>[["gsl_poly_complex_workspace *", "w"]],
205
+ :desc=>
206
+ "This function frees all the memory associated with the workspace\n" +
207
+ "w."},
208
+ {:func_name=>"gsl_poly_complex_solve",
209
+ :func_type=>"int",
210
+ :args=>
211
+ [["const double *", "a"],
212
+ ["size_t", "n"],
213
+ ["gsl_poly_complex_workspace *", "w"],
214
+ ["gsl_complex_packed_ptr", "z"]],
215
+ :desc=>
216
+ "This function computes the roots of the general polynomial \n" +
217
+ "$P(x) = a_0 + a_1 x + a_2 x^2 + ... + a_{n-1} x^{n-1}$ \n" +
218
+ "P(x) = a_0 + a_1 x + a_2 x^2 + ... + a_@{n-1@} x^@{n-1@} using \n" +
219
+ "balanced-QR reduction of the companion matrix. The parameter n\n" +
220
+ "specifies the length of the coefficient array. The coefficient of the\n" +
221
+ "highest order term must be non-zero. The function requires a workspace\n" +
222
+ "w of the appropriate size. The n-1 roots are returned in\n" +
223
+ "the packed complex array z of length 2(n-1), alternating\n" +
224
+ "real and imaginary parts.\n" +
225
+ "\n" +
226
+ "The function returns GSL_SUCCESS if all the roots are found. If\n" +
227
+ "the QR reduction does not converge, the error handler is invoked with\n" +
228
+ "an error code of GSL_EFAILED. Note that due to finite precision,\n" +
229
+ "roots of higher multiplicity are returned as a cluster of simple roots\n" +
230
+ "with reduced accuracy. The solution of polynomials with higher-order\n" +
231
+ "roots requires specialized algorithms that take the multiplicity\n" +
232
+ "structure into account (see e.g. Z. Zeng, Algorithm 835, ACM\n" +
233
+ "Transactions on Mathematical Software, Volume 30, Issue 2 (2004), pp\n" +
234
+ "218--236)."}]
@@ -0,0 +1,59 @@
1
+ static void
2
+ iter_<%=c_func%>(na_loop_t *const lp)
3
+ {
4
+ size_t n;
5
+ double *a;
6
+ gsl_complex_packed_ptr z;
7
+ void **opts;
8
+ gsl_poly_complex_workspace *w;
9
+
10
+ opts = (void **)(lp->opt_ptr);
11
+ w = (gsl_poly_complex_workspace*)(opts[0]);
12
+
13
+ n = lp->args[0].shape[0];
14
+ a = (double*)(lp->args[0].ptr + lp->args[0].iter[0].pos);
15
+ z = (gsl_complex_packed_ptr)(lp->args[1].ptr + lp->args[1].iter[0].pos);
16
+ <%=func_name%>(a, n, w, z);
17
+ }
18
+
19
+ /*
20
+ @overload <%=name%>(<%=args[0][1]%>)
21
+ @param [Numo::DFloat] <%=args[0][1]%>
22
+ @return [Numo::DComplex] <%=args[3][1]%> result
23
+
24
+ <%= description %>
25
+
26
+ */
27
+ static VALUE
28
+ <%=c_func(1)%>(VALUE mod, VALUE v1)
29
+ {
30
+ size_t shape[0];
31
+ ndfunc_arg_in_t ain[1] = {{cDF,1}};
32
+ ndfunc_arg_out_t aout[1] = {{cDC,1,shape}};
33
+ ndfunc_t ndf = {iter_<%=c_func%>, NO_LOOP, 1,1, ain,aout};
34
+ gsl_poly_complex_workspace *w;
35
+ void *opts[1];
36
+ VALUE vz, vws;
37
+ size_t n;
38
+ narray_t *na;
39
+
40
+ v1 = rb_funcall(cDF, rb_intern("cast"), 1, v1);
41
+ GetNArray(v1,na);
42
+ if (na->ndim == 0) {
43
+ rb_raise(nary_eDimensionError,"ndim(=%d) should >= %d", na->ndim, 0);
44
+ }
45
+ if (na->shape[na->ndim-1] < 2) {
46
+ rb_raise(nary_eShapeError, "last axis size must be >= 2");
47
+ }
48
+ n = na->shape[na->ndim-1];
49
+ shape[0] = n-1;
50
+
51
+ vws = poly_complex_workspace_s_new(cComplexWorkspace, SIZET2NUM(n));
52
+ TypedData_Get_Struct(vws, gsl_poly_complex_workspace, &poly_complex_workspace_data_type, w);
53
+ opts[0] = w;
54
+
55
+ vz = na_ndloop3(&ndf, opts, 1, v1);
56
+ RB_GC_GUARD(vws);
57
+ RB_GC_GUARD(v1);
58
+ return vz;
59
+ }
@@ -0,0 +1,70 @@
1
+ static inline int is_complex_nary(VALUE v)
2
+ {
3
+ VALUE c = CLASS_OF(v);
4
+ if (c == numo_cDComplex || c == numo_cSComplex || c == rb_cComplex)
5
+ return 1;
6
+ else
7
+ return 0;
8
+ }
9
+ <%
10
+ dbl="double"
11
+ cmp="gsl_complex"
12
+ cDF="cDF"
13
+ cDC="cDC"
14
+ [
15
+ [dbl,dbl,dbl,cDF,cDF,cDF,"ff","gsl_poly_eval"],
16
+ [dbl,cmp,cmp,cDF,cDC,cDC,"fc","gsl_poly_complex_eval"],
17
+ [cmp,cmp,cmp,cDC,cDC,cDC,"cc","gsl_complex_poly_complex_eval"],
18
+ ].each do |tp0,tp1,tp2,cv0,cv1,cv2,fn,gfn|
19
+ %>
20
+ static void
21
+ iter_<%=fn%>(na_loop_t *const lp)
22
+ {
23
+ size_t n;
24
+ <%=tp0%> *c;
25
+ <%=tp1%> x;
26
+ <%=tp2%> y;
27
+
28
+ assert(lp->args[0].ndim == 1);
29
+ n = lp->args[0].shape[0];
30
+ c = (<%=tp0%>*)GET_PTR(lp,0);
31
+ x = *(<%=tp1%>*)GET_PTR(lp,1);
32
+ y = <%=gfn%>(c,n,x);
33
+ *(<%=tp2%>*)GET_PTR(lp,2) = y;
34
+ }
35
+
36
+ static VALUE
37
+ poly_eval_<%=fn%>(VALUE v0, VALUE v1)
38
+ {
39
+ ndfunc_arg_in_t ain[2] = {{<%=cv0%>,1},{<%=cv1%>,0}};
40
+ ndfunc_arg_out_t aout[1] = {{<%=cv2%>,0}};
41
+ ndfunc_t ndf = {iter_<%=fn%>,NO_LOOP|NDF_INPLACE|NDF_EXTRACT,2,1,ain,aout};
42
+ return na_ndloop(&ndf,2,v0,v1);
43
+ }
44
+ <% end %>
45
+
46
+ /*
47
+ @overload <%=name%>(c,x)
48
+
49
+ @param [Numo::DFloat or DComplex] c
50
+ @param [Numo::DFloat or DComplex] x
51
+ @return [Numo::DFloat or DComplex]
52
+
53
+ This function calls gsl_poly_eval or gsl_poly_complex_eval
54
+ or gsl_complex_poly_complex_eval according to
55
+ whether argument is complex or not.
56
+
57
+ <%= description %>
58
+
59
+ */
60
+ static VALUE
61
+ <%=c_func(2)%>(VALUE mod, VALUE v0, VALUE v1)
62
+ {
63
+ if (is_complex_nary(v0)) {
64
+ return poly_eval_cc(v0,v1);
65
+ } else if (is_complex_nary(v1)) {
66
+ return poly_eval_fc(v0,v1);
67
+ } else {
68
+ return poly_eval_ff(v0,v1);
69
+ }
70
+ }
@@ -0,0 +1,40 @@
1
+ static void
2
+ iter_<%=c_func%>(na_loop_t *const lp)
3
+ {
4
+ size_t lenc, lenres;
5
+ double *c;
6
+ double x;
7
+ double *r;
8
+
9
+ assert(lp->args[0].ndim == 1);
10
+ assert(lp->args[2].ndim == 1);
11
+ lenc = lp->args[0].shape[0];
12
+ lenres = lp->args[2].shape[0];
13
+ c = (double*)GET_PTR(lp,0);
14
+ x = *(double*)GET_PTR(lp,1);
15
+ r = (double*)GET_PTR(lp,2);
16
+ <%=func_name%>(c,lenc,x,r,lenres);
17
+ }
18
+
19
+ /*
20
+ @overload <%=name%>(c,x,lenres)
21
+
22
+ @param [Numo::DFloat] c
23
+ @param [Numo::DFloat] x
24
+ @param [Integer] lenres
25
+ @return [Numo::DFloat]
26
+
27
+ <%= description %>
28
+
29
+ */
30
+ static VALUE
31
+ <%=c_func(3)%>(VALUE mod, VALUE v0, VALUE v1, VALUE v2)
32
+ {
33
+ size_t shape[1];
34
+ ndfunc_arg_in_t ain[2] = {{cDF,1},{cDF,0}};
35
+ ndfunc_arg_out_t aout[1] = {{cDF,1,shape}};
36
+ ndfunc_t ndf = {iter_<%=c_func%>,NO_LOOP|NDF_INPLACE|NDF_EXTRACT,2,1,ain,aout};
37
+
38
+ shape[0] = NUM2SIZET(v2);
39
+ return na_ndloop(&ndf,2,v0,v1);
40
+ }
@@ -0,0 +1,17 @@
1
+ COGEN=ruby erbpp_ran.rb
2
+ GENSRC=gsl_ran.c
3
+ GENDEPS=erbpp_ran.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,42 @@
1
+ require_relative "parse_ran"
2
+ require "erbpp/line_number"
3
+
4
+ ErbppGsl.read_func_pattern(
5
+ [ /^gsl_ran_discrete_(\w+)$/, disc_list=[]],
6
+ [ /^gsl_ran_(\w+)_pdf$/, ran_list=[]],
7
+ )
8
+
9
+ DefLib.new do
10
+ set erb_dir: %w[tmpl ../gen/tmpl]
11
+ set erb_suffix: ".c"
12
+ set ns_var: "mG"
13
+
14
+ name = "Ran"
15
+ base = name.downcase
16
+ set file_name: "gsl_#{name}.c"
17
+ set include_files: ["gsl/gsl_randist.h"]
18
+ set lib_name: "ran"
19
+
20
+ def_module do
21
+ set name: base
22
+ set module_name: name
23
+ set module_var: "m"+name
24
+ set full_module_name: "Numo::GSL::"+name
25
+ end
26
+
27
+ DefDiscrete.new(self) do
28
+ name = "Discrete"
29
+ base = name.downcase
30
+ set ns_var: "mRan"
31
+ set name: "ran_"+base
32
+ set class_name: name
33
+ set class_var: "c"+name
34
+ set full_class_name: "Numo::GSL::Ran::"+name
35
+ set struct: "gsl_ran_discrete_t"
36
+
37
+ disc_list.each do |h|
38
+ check_func(h)
39
+ end
40
+ end
41
+
42
+ end.run