rb-gsl 1.16.0.4 → 1.16.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -0
  3. data/.travis.yml +24 -0
  4. data/AUTHORS +6 -0
  5. data/COPYING +341 -339
  6. data/ChangeLog +608 -587
  7. data/Gemfile +4 -0
  8. data/README.md +77 -0
  9. data/Rakefile +14 -33
  10. data/THANKS +1 -1
  11. data/examples/blas/blas.rb +1 -1
  12. data/examples/bspline.rb +3 -3
  13. data/examples/complex/functions.rb +4 -4
  14. data/examples/complex/mul.rb +1 -1
  15. data/examples/const/physconst.rb +4 -4
  16. data/examples/const/travel.rb +4 -4
  17. data/examples/eigen/nonsymmv.rb +1 -1
  18. data/examples/eigen/qhoscillator.rb +3 -3
  19. data/examples/fft/radix2.rb +1 -1
  20. data/examples/fft/real-halfcomplex.rb +3 -3
  21. data/examples/fft/real-halfcomplex2.rb +3 -3
  22. data/examples/fit/expfit.rb +1 -1
  23. data/examples/fit/multifit.rb +1 -1
  24. data/examples/fit/ndlinear.rb +44 -44
  25. data/examples/fit/nonlinearfit.rb +1 -1
  26. data/examples/fit/wlinear.rb +3 -3
  27. data/examples/function/function.rb +1 -1
  28. data/examples/function/min.rb +1 -1
  29. data/examples/function/synchrotron.rb +2 -2
  30. data/examples/gallery/koch.rb +1 -1
  31. data/examples/histogram/cauchy.rb +2 -2
  32. data/examples/histogram/exponential.rb +1 -1
  33. data/examples/histogram/histo3d.rb +1 -1
  34. data/examples/histogram/histogram-pdf.rb +2 -2
  35. data/examples/histogram/xexp.rb +1 -1
  36. data/examples/integration/ahmed.rb +2 -2
  37. data/examples/integration/cosmology.rb +7 -7
  38. data/examples/integration/friedmann.rb +4 -4
  39. data/examples/integration/qng.rb +1 -1
  40. data/examples/interp/demo.rb +2 -2
  41. data/examples/linalg/LQ_solve.rb +1 -1
  42. data/examples/linalg/LU.rb +1 -1
  43. data/examples/linalg/LU2.rb +1 -1
  44. data/examples/linalg/LU_narray.rb +1 -1
  45. data/examples/linalg/PTLQ.rb +1 -1
  46. data/examples/linalg/QRPT.rb +1 -1
  47. data/examples/linalg/chol.rb +1 -1
  48. data/examples/linalg/chol_narray.rb +1 -1
  49. data/examples/linalg/complex.rb +1 -1
  50. data/examples/math/elementary.rb +1 -1
  51. data/examples/math/functions.rb +1 -1
  52. data/examples/math/inf_nan.rb +1 -1
  53. data/examples/math/minmax.rb +1 -1
  54. data/examples/math/power.rb +1 -1
  55. data/examples/math/test.rb +1 -1
  56. data/examples/min.rb +1 -1
  57. data/examples/multimin/bundle.rb +1 -1
  58. data/examples/multimin/cqp.rb +17 -17
  59. data/examples/multiroot/fsolver3.rb +1 -1
  60. data/examples/odeiv/binarysystem.rb +12 -12
  61. data/examples/odeiv/demo.rb +3 -3
  62. data/examples/odeiv/frei1.rb +7 -7
  63. data/examples/odeiv/frei2.rb +4 -4
  64. data/examples/odeiv/oscillator.rb +1 -1
  65. data/examples/odeiv/sedov.rb +3 -3
  66. data/examples/odeiv/whitedwarf.rb +11 -11
  67. data/examples/permutation/ex1.rb +2 -2
  68. data/examples/permutation/permutation.rb +1 -1
  69. data/examples/poly/demo.rb +1 -1
  70. data/examples/random/diffusion.rb +1 -1
  71. data/examples/random/generator.rb +2 -2
  72. data/examples/random/randomwalk.rb +3 -3
  73. data/examples/random/rng.rb +1 -1
  74. data/examples/roots/bisection.rb +1 -1
  75. data/examples/roots/brent.rb +1 -1
  76. data/examples/roots/demo.rb +1 -1
  77. data/examples/roots/newton.rb +2 -2
  78. data/examples/roots/recombination.gp +0 -1
  79. data/examples/sf/hyperg.rb +1 -1
  80. data/examples/sf/sphbessel.rb +1 -1
  81. data/examples/sort/sort.rb +1 -1
  82. data/examples/tamu_anova.rb +4 -4
  83. data/examples/vector/add.rb +1 -1
  84. data/examples/vector/decimate.rb +1 -1
  85. data/examples/vector/gnuplot.rb +8 -8
  86. data/examples/vector/vector.rb +2 -2
  87. data/examples/wavelet/wavelet1.rb +1 -1
  88. data/ext/{gsl → gsl_native}/alf.c +9 -9
  89. data/ext/{gsl → gsl_native}/array.c +64 -151
  90. data/ext/{gsl → gsl_native}/array_complex.c +61 -63
  91. data/ext/{gsl → gsl_native}/blas.c +0 -0
  92. data/ext/{gsl → gsl_native}/blas1.c +32 -32
  93. data/ext/{gsl → gsl_native}/blas2.c +54 -58
  94. data/ext/{gsl → gsl_native}/blas3.c +54 -54
  95. data/ext/{gsl → gsl_native}/block.c +3 -6
  96. data/ext/{gsl/block_source.c → gsl_native/block_source.h} +109 -111
  97. data/ext/gsl_native/bspline.c +122 -0
  98. data/ext/{gsl → gsl_native}/bundle.c +0 -0
  99. data/ext/{gsl → gsl_native}/cdf.c +76 -88
  100. data/ext/{gsl → gsl_native}/cheb.c +74 -85
  101. data/ext/{gsl → gsl_native}/combination.c +9 -16
  102. data/ext/{gsl → gsl_native}/common.c +7 -37
  103. data/ext/{gsl → gsl_native}/complex.c +113 -115
  104. data/ext/gsl_native/const.c +331 -0
  105. data/ext/{gsl → gsl_native}/const_additional.c +12 -33
  106. data/ext/gsl_native/cqp.c +283 -0
  107. data/ext/{gsl → gsl_native}/deriv.c +22 -30
  108. data/ext/{gsl → gsl_native}/dht.c +20 -28
  109. data/ext/{gsl → gsl_native}/diff.c +23 -25
  110. data/ext/{gsl → gsl_native}/dirac.c +44 -45
  111. data/ext/{gsl → gsl_native}/eigen.c +1031 -1082
  112. data/ext/{gsl → gsl_native}/error.c +13 -13
  113. data/ext/{gsl → gsl_native}/extconf.rb +5 -13
  114. data/ext/{gsl → gsl_native}/fft.c +192 -198
  115. data/ext/{gsl → gsl_native}/fit.c +16 -16
  116. data/ext/gsl_native/fresnel.c +312 -0
  117. data/ext/{gsl → gsl_native}/function.c +29 -35
  118. data/ext/{gsl → gsl_native}/geometry.c +15 -15
  119. data/ext/{gsl → gsl_native}/graph.c +37 -87
  120. data/ext/{gsl → gsl_native}/gsl.c +10 -23
  121. data/ext/{gsl → gsl_native}/gsl_narray.c +15 -24
  122. data/ext/{gsl → gsl_native}/histogram.c +123 -150
  123. data/ext/{gsl → gsl_native}/histogram2d.c +71 -96
  124. data/ext/{gsl → gsl_native}/histogram3d.c +72 -72
  125. data/ext/{gsl → gsl_native}/histogram3d_source.c +195 -196
  126. data/ext/{gsl → gsl_native}/histogram_find.c +31 -33
  127. data/ext/{gsl → gsl_native}/histogram_oper.c +43 -52
  128. data/ext/{gsl → gsl_native}/ieee.c +7 -15
  129. data/ext/{gsl → gsl_native}/include/rb_gsl.h +0 -7
  130. data/ext/{gsl → gsl_native}/include/rb_gsl_array.h +15 -25
  131. data/ext/{gsl → gsl_native}/include/rb_gsl_cheb.h +0 -0
  132. data/ext/{gsl → gsl_native}/include/rb_gsl_common.h +44 -52
  133. data/ext/{gsl → gsl_native}/include/rb_gsl_complex.h +0 -0
  134. data/ext/{gsl → gsl_native}/include/rb_gsl_const.h +0 -5
  135. data/ext/{gsl → gsl_native}/include/rb_gsl_dirac.h +0 -0
  136. data/ext/{gsl → gsl_native}/include/rb_gsl_eigen.h +0 -0
  137. data/ext/{gsl → gsl_native}/include/rb_gsl_fft.h +0 -3
  138. data/ext/{gsl → gsl_native}/include/rb_gsl_fit.h +0 -0
  139. data/ext/{gsl → gsl_native}/include/rb_gsl_function.h +0 -0
  140. data/ext/{gsl → gsl_native}/include/rb_gsl_graph.h +2 -2
  141. data/ext/{gsl → gsl_native}/include/rb_gsl_histogram.h +8 -8
  142. data/ext/{gsl → gsl_native}/include/rb_gsl_histogram3d.h +50 -50
  143. data/ext/{gsl → gsl_native}/include/rb_gsl_integration.h +0 -0
  144. data/ext/{gsl → gsl_native}/include/rb_gsl_interp.h +0 -0
  145. data/ext/{gsl → gsl_native}/include/rb_gsl_linalg.h +0 -1
  146. data/ext/{gsl → gsl_native}/include/rb_gsl_math.h +0 -4
  147. data/ext/{gsl → gsl_native}/include/rb_gsl_odeiv.h +0 -0
  148. data/ext/{gsl → gsl_native}/include/rb_gsl_poly.h +3 -3
  149. data/ext/{gsl → gsl_native}/include/rb_gsl_rational.h +1 -1
  150. data/ext/{gsl → gsl_native}/include/rb_gsl_rng.h +0 -0
  151. data/ext/{gsl → gsl_native}/include/rb_gsl_root.h +0 -0
  152. data/ext/{gsl → gsl_native}/include/rb_gsl_sf.h +39 -43
  153. data/ext/{gsl → gsl_native}/include/rb_gsl_statistics.h +0 -0
  154. data/ext/{gsl → gsl_native}/include/rb_gsl_tensor.h +0 -0
  155. data/ext/{gsl → gsl_native}/include/rb_gsl_with_narray.h +0 -0
  156. data/ext/{gsl → gsl_native}/include/templates_off.h +0 -0
  157. data/ext/{gsl → gsl_native}/include/templates_on.h +1 -1
  158. data/ext/{gsl → gsl_native}/integration.c +160 -183
  159. data/ext/{gsl → gsl_native}/interp.c +23 -31
  160. data/ext/gsl_native/jacobi.c +733 -0
  161. data/ext/{gsl → gsl_native}/linalg.c +448 -576
  162. data/ext/{gsl → gsl_native}/linalg_complex.c +84 -98
  163. data/ext/{gsl → gsl_native}/math.c +45 -63
  164. data/ext/{gsl → gsl_native}/matrix.c +4 -6
  165. data/ext/{gsl → gsl_native}/matrix_complex.c +111 -114
  166. data/ext/{gsl → gsl_native}/matrix_double.c +74 -77
  167. data/ext/{gsl → gsl_native}/matrix_int.c +49 -50
  168. data/ext/{gsl/matrix_source.c → gsl_native/matrix_source.h} +280 -302
  169. data/ext/{gsl → gsl_native}/min.c +43 -74
  170. data/ext/{gsl → gsl_native}/monte.c +45 -59
  171. data/ext/{gsl → gsl_native}/multifit.c +138 -147
  172. data/ext/{gsl → gsl_native}/multimin.c +55 -83
  173. data/ext/{gsl → gsl_native}/multimin_fsdf.c +15 -15
  174. data/ext/{gsl → gsl_native}/multiroots.c +61 -64
  175. data/ext/{gsl → gsl_native}/multiset.c +3 -7
  176. data/ext/{gsl → gsl_native}/ndlinear.c +320 -321
  177. data/ext/{gsl → gsl_native}/nmf.c +11 -11
  178. data/ext/{gsl → gsl_native}/nmf_wrap.c +1 -1
  179. data/ext/{gsl → gsl_native}/ntuple.c +13 -13
  180. data/ext/{gsl → gsl_native}/odeiv.c +95 -106
  181. data/ext/gsl_native/ool.c +879 -0
  182. data/ext/{gsl → gsl_native}/permutation.c +36 -34
  183. data/ext/{gsl → gsl_native}/poly.c +2 -5
  184. data/ext/{gsl → gsl_native}/poly2.c +6 -6
  185. data/ext/{gsl/poly_source.c → gsl_native/poly_source.h} +232 -275
  186. data/ext/{gsl → gsl_native}/qrng.c +6 -17
  187. data/ext/{gsl → gsl_native}/randist.c +218 -243
  188. data/ext/{gsl → gsl_native}/rational.c +9 -9
  189. data/ext/{gsl → gsl_native}/rng.c +29 -45
  190. data/ext/{gsl → gsl_native}/root.c +43 -43
  191. data/ext/{gsl → gsl_native}/sf.c +163 -197
  192. data/ext/{gsl → gsl_native}/sf_airy.c +0 -0
  193. data/ext/{gsl → gsl_native}/sf_bessel.c +6 -6
  194. data/ext/{gsl → gsl_native}/sf_clausen.c +0 -0
  195. data/ext/{gsl → gsl_native}/sf_coulomb.c +39 -39
  196. data/ext/{gsl → gsl_native}/sf_coupling.c +29 -29
  197. data/ext/{gsl → gsl_native}/sf_dawson.c +0 -0
  198. data/ext/{gsl → gsl_native}/sf_debye.c +0 -9
  199. data/ext/{gsl → gsl_native}/sf_dilog.c +0 -0
  200. data/ext/{gsl → gsl_native}/sf_elementary.c +2 -2
  201. data/ext/{gsl → gsl_native}/sf_ellint.c +42 -42
  202. data/ext/{gsl → gsl_native}/sf_elljac.c +2 -2
  203. data/ext/{gsl → gsl_native}/sf_erfc.c +0 -4
  204. data/ext/{gsl → gsl_native}/sf_exp.c +2 -2
  205. data/ext/{gsl → gsl_native}/sf_expint.c +1 -11
  206. data/ext/{gsl → gsl_native}/sf_fermi_dirac.c +0 -0
  207. data/ext/{gsl → gsl_native}/sf_gamma.c +1 -5
  208. data/ext/{gsl → gsl_native}/sf_gegenbauer.c +0 -0
  209. data/ext/{gsl → gsl_native}/sf_hyperg.c +0 -0
  210. data/ext/{gsl → gsl_native}/sf_laguerre.c +3 -3
  211. data/ext/{gsl → gsl_native}/sf_lambert.c +0 -0
  212. data/ext/{gsl → gsl_native}/sf_legendre.c +0 -0
  213. data/ext/{gsl → gsl_native}/sf_log.c +3 -3
  214. data/ext/gsl_native/sf_mathieu.c +235 -0
  215. data/ext/{gsl → gsl_native}/sf_power.c +0 -0
  216. data/ext/{gsl → gsl_native}/sf_psi.c +2 -11
  217. data/ext/{gsl → gsl_native}/sf_synchrotron.c +0 -0
  218. data/ext/{gsl → gsl_native}/sf_transport.c +0 -0
  219. data/ext/{gsl → gsl_native}/sf_trigonometric.c +3 -3
  220. data/ext/{gsl → gsl_native}/sf_zeta.c +0 -4
  221. data/ext/{gsl → gsl_native}/signal.c +60 -64
  222. data/ext/{gsl → gsl_native}/siman.c +36 -40
  223. data/ext/{gsl → gsl_native}/sort.c +3 -4
  224. data/ext/{gsl → gsl_native}/spline.c +25 -43
  225. data/ext/{gsl → gsl_native}/stats.c +102 -115
  226. data/ext/{gsl → gsl_native}/sum.c +32 -32
  227. data/ext/{gsl → gsl_native}/tamu_anova.c +0 -0
  228. data/ext/{gsl → gsl_native}/tensor.c +2 -4
  229. data/ext/{gsl/tensor_source.c → gsl_native/tensor_source.h} +144 -144
  230. data/ext/{gsl → gsl_native}/vector.c +2 -4
  231. data/ext/{gsl → gsl_native}/vector_complex.c +165 -171
  232. data/ext/{gsl → gsl_native}/vector_double.c +167 -174
  233. data/ext/{gsl → gsl_native}/vector_int.c +23 -25
  234. data/ext/{gsl/vector_source.c → gsl_native/vector_source.h} +400 -414
  235. data/ext/{gsl → gsl_native}/wavelet.c +215 -236
  236. data/lib/gsl.rb +1 -7
  237. data/lib/gsl/gnuplot.rb +2 -2
  238. data/lib/gsl/version.rb +1 -3
  239. data/rb-gsl.gemspec +29 -0
  240. data/rdoc/blas.rdoc +3 -3
  241. data/rdoc/bspline.rdoc +7 -7
  242. data/rdoc/cheb.rdoc +8 -8
  243. data/rdoc/cholesky_complex.rdoc +1 -1
  244. data/rdoc/combi.rdoc +9 -9
  245. data/rdoc/complex.rdoc +11 -11
  246. data/rdoc/const.rdoc +20 -20
  247. data/rdoc/dht.rdoc +6 -6
  248. data/rdoc/diff.rdoc +6 -6
  249. data/rdoc/ehandling.rdoc +3 -3
  250. data/rdoc/eigen.rdoc +11 -11
  251. data/rdoc/fft.rdoc +26 -26
  252. data/rdoc/fit.rdoc +18 -18
  253. data/rdoc/graph.rdoc +2 -2
  254. data/rdoc/hist.rdoc +16 -16
  255. data/rdoc/hist2d.rdoc +4 -4
  256. data/rdoc/hist3d.rdoc +3 -3
  257. data/rdoc/integration.rdoc +16 -16
  258. data/rdoc/interp.rdoc +11 -11
  259. data/rdoc/intro.rdoc +3 -3
  260. data/rdoc/linalg.rdoc +20 -20
  261. data/rdoc/linalg_complex.rdoc +1 -1
  262. data/rdoc/math.rdoc +13 -13
  263. data/rdoc/matrix.rdoc +22 -22
  264. data/rdoc/min.rdoc +9 -9
  265. data/rdoc/monte.rdoc +3 -3
  266. data/rdoc/multimin.rdoc +12 -12
  267. data/rdoc/multiroot.rdoc +12 -12
  268. data/rdoc/narray.rdoc +9 -9
  269. data/rdoc/ndlinear.rdoc +4 -4
  270. data/rdoc/nonlinearfit.rdoc +17 -17
  271. data/rdoc/ntuple.rdoc +5 -5
  272. data/rdoc/odeiv.rdoc +12 -12
  273. data/rdoc/perm.rdoc +11 -11
  274. data/rdoc/poly.rdoc +17 -17
  275. data/rdoc/qrng.rdoc +9 -9
  276. data/rdoc/randist.rdoc +10 -10
  277. data/rdoc/ref.rdoc +49 -49
  278. data/rdoc/rng.rdoc +9 -9
  279. data/rdoc/roots.rdoc +12 -12
  280. data/rdoc/sf.rdoc +35 -35
  281. data/rdoc/siman.rdoc +3 -3
  282. data/rdoc/sort.rdoc +6 -6
  283. data/rdoc/start.rdoc +2 -2
  284. data/rdoc/stats.rdoc +13 -13
  285. data/rdoc/sum.rdoc +4 -4
  286. data/rdoc/tensor.rdoc +3 -3
  287. data/rdoc/tut.rdoc +1 -1
  288. data/rdoc/use.rdoc +3 -3
  289. data/rdoc/vector.rdoc +28 -28
  290. data/rdoc/vector_complex.rdoc +6 -6
  291. data/rdoc/wavelet.rdoc +8 -8
  292. data/test/gsl/blas_test.rb +1 -1
  293. data/test/gsl/index_test.rb +61 -0
  294. data/test/gsl/matrix_test.rb +21 -0
  295. data/uncrustify.cfg +1693 -0
  296. metadata +212 -243
  297. data/README +0 -28
  298. data/ext/gsl/bspline.c +0 -130
  299. data/ext/gsl/const.c +0 -672
  300. data/ext/gsl/cqp.c +0 -283
  301. data/ext/gsl/fcmp.c +0 -64
  302. data/ext/gsl/fresnel.c +0 -312
  303. data/ext/gsl/jacobi.c +0 -739
  304. data/ext/gsl/ool.c +0 -879
  305. data/ext/gsl/oper_complex_source.c +0 -251
  306. data/ext/gsl/sf_mathieu.c +0 -238
  307. data/rdoc/index.rdoc +0 -50
@@ -19,23 +19,23 @@ void Init_ndlinear(VALUE module);
19
19
  #endif
20
20
 
21
21
  #ifndef CHECK_WORKSPACE
22
- #define CHECK_WORKSPACE(x) if(CLASS_OF(x)!=cgsl_multifit_workspace)\
23
- rb_raise(rb_eTypeError,\
24
- "wrong argument type %s (GSL::MultiFit::Workspace expected)",\
25
- rb_class2name(CLASS_OF(x)));
22
+ #define CHECK_WORKSPACE(x) if(CLASS_OF(x)!=cgsl_multifit_workspace) \
23
+ rb_raise(rb_eTypeError, \
24
+ "wrong argument type %s (GSL::MultiFit::Workspace expected)", \
25
+ rb_class2name(CLASS_OF(x)));
26
26
  #endif
27
27
 
28
28
  #ifndef CHECK_MULTIFIT_FUNCTION_FDF
29
- #define CHECK_MULTIFIT_FUNCTION_FDF(x) if(CLASS_OF(x)!=cgsl_multifit_function_fdf)\
30
- rb_raise(rb_eTypeError,\
31
- "wrong argument type %s (GSL::MultiFit::Workspace expected)",\
32
- rb_class2name(CLASS_OF(x)));
29
+ #define CHECK_MULTIFIT_FUNCTION_FDF(x) if(CLASS_OF(x)!=cgsl_multifit_function_fdf) \
30
+ rb_raise(rb_eTypeError, \
31
+ "wrong argument type %s (GSL::MultiFit::Workspace expected)", \
32
+ rb_class2name(CLASS_OF(x)));
33
33
  #endif
34
34
 
35
35
  static VALUE cgsl_multifit_workspace;
36
36
  static VALUE cgsl_multifit_function_fdf;
37
37
 
38
- enum MultiFit_Solver_Type{
38
+ enum MultiFit_Solver_Type {
39
39
  GSL_MULTIFIT_FDFSOLVER_LMSDER,
40
40
  GSL_MULTIFIT_FDFSOLVER_LMDER,
41
41
  };
@@ -56,7 +56,7 @@ static VALUE rb_gsl_multifit_linear(int argc, VALUE *argv, VALUE obj)
56
56
  double chisq;
57
57
  int status, flag = 0;
58
58
  VALUE vc, vcov;
59
- if (argc != 2 && argc != 3)
59
+ if (argc != 2 && argc != 3)
60
60
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
61
61
  Data_Get_Matrix(argv[0], x);
62
62
  Data_Get_Vector(argv[1], y);
@@ -84,7 +84,7 @@ static VALUE rb_gsl_multifit_wlinear(int argc, VALUE *argv, VALUE obj)
84
84
  double chisq;
85
85
  int status, flag = 0;
86
86
  VALUE vc, vcov;
87
- if (argc != 3 && argc != 4)
87
+ if (argc != 3 && argc != 4)
88
88
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 3 or 4)", argc);
89
89
  Data_Get_Matrix(argv[0], x);
90
90
  Data_Get_Vector(argv[1], w);
@@ -139,7 +139,7 @@ static void calc_X_legendre(gsl_matrix *X, gsl_vector *v, size_t order)
139
139
  }
140
140
 
141
141
  static VALUE rb_gsl_multifit_XXXfit(int argc, VALUE *argv, VALUE obj,
142
- void (*fn)(gsl_matrix*, gsl_vector*,size_t))
142
+ void (*fn)(gsl_matrix*, gsl_vector*,size_t))
143
143
  {
144
144
  gsl_multifit_linear_workspace *space = NULL;
145
145
  gsl_matrix *X = NULL, *cov = NULL;
@@ -149,7 +149,7 @@ static VALUE rb_gsl_multifit_XXXfit(int argc, VALUE *argv, VALUE obj,
149
149
  double chisq;
150
150
  int status, flag = 0, flagw = 0;
151
151
  VALUE vc, verr;
152
- if (argc != 3 && argc != 4 && argc != 5)
152
+ if (argc != 3 && argc != 4 && argc != 5)
153
153
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 3 or 4)", argc);
154
154
  x = &xx.vector;
155
155
  w = &ww.vector;
@@ -181,9 +181,8 @@ static VALUE rb_gsl_multifit_XXXfit(int argc, VALUE *argv, VALUE obj,
181
181
  err = gsl_vector_alloc(order + 1);
182
182
  vc = Data_Wrap_Struct(cgsl_poly, 0, gsl_vector_free, c);
183
183
  verr = Data_Wrap_Struct(cgsl_poly, 0, gsl_vector_free, err);
184
- for (i = 0; i < err->size; i++)
184
+ for (i = 0; i < err->size; i++)
185
185
  gsl_vector_set(err, i, sqrt(chisq/((double)x->size-err->size)*gsl_matrix_get(cov, i, i)));
186
-
187
186
  gsl_matrix_free(X);
188
187
  gsl_matrix_free(cov);
189
188
  return rb_ary_new3(4, vc, verr, rb_float_new(chisq), INT2FIX(status));
@@ -213,31 +212,31 @@ static VALUE rb_gsl_multifit_fdfsolver_new(int argc, VALUE *argv, VALUE klass)
213
212
  case T_STRING:
214
213
  strcpy(name, STR2CSTR(argv[0]));
215
214
  if (str_tail_grep(name, "lmsder") == 0) {
216
- T = gsl_multifit_fdfsolver_lmsder;
215
+ T = gsl_multifit_fdfsolver_lmsder;
217
216
  } else if (str_tail_grep(name, "lmder") == 0) {
218
- T = gsl_multifit_fdfsolver_lmder;
217
+ T = gsl_multifit_fdfsolver_lmder;
219
218
  } else {
220
- rb_raise(rb_eTypeError, "unknown solver type %s (lmsder of lmder)",
221
- name);
219
+ rb_raise(rb_eTypeError, "unknown solver type %s (lmsder of lmder)",
220
+ name);
222
221
  }
223
222
  break;
224
223
  case T_FIXNUM:
225
224
  switch (FIX2INT(argv[0])) {
226
225
  case GSL_MULTIFIT_FDFSOLVER_LMSDER:
227
- T = gsl_multifit_fdfsolver_lmsder;
228
- break;
226
+ T = gsl_multifit_fdfsolver_lmsder;
227
+ break;
229
228
  case GSL_MULTIFIT_FDFSOLVER_LMDER:
230
- T = gsl_multifit_fdfsolver_lmder;
231
- break;
229
+ T = gsl_multifit_fdfsolver_lmder;
230
+ break;
232
231
  default:
233
- rb_raise(rb_eTypeError,
234
- "unknown solver type (GSL::MultiFit::FdfSolver::LMSDER or LMDER expected)");
235
- break;
232
+ rb_raise(rb_eTypeError,
233
+ "unknown solver type (GSL::MultiFit::FdfSolver::LMSDER or LMDER expected)");
234
+ break;
236
235
  }
237
236
  break;
238
237
  default:
239
238
  rb_raise(rb_eTypeError, "wrong argument type %s (Fixnum or String)",
240
- rb_class2name(CLASS_OF(argv[0])));
239
+ rb_class2name(CLASS_OF(argv[0])));
241
240
  break;
242
241
  }
243
242
  CHECK_FIXNUM(argv[1]); CHECK_FIXNUM(argv[2]);
@@ -301,8 +300,8 @@ static VALUE rb_gsl_multifit_fdfsolver_print_state(VALUE obj, VALUE i)
301
300
  CHECK_FIXNUM(i);
302
301
  Data_Get_Struct(obj, gsl_multifit_fdfsolver, solver);
303
302
  printf("iter: %d x = %15.8f %15.8f %15.8f |f(x)| = %g\n",
304
- (int) FIX2INT(i), gsl_vector_get(solver->x, 0), gsl_vector_get(solver->x, 1),
305
- gsl_vector_get(solver->x, 2), gsl_blas_dnrm2(solver->f));
303
+ (int) FIX2INT(i), gsl_vector_get(solver->x, 0), gsl_vector_get(solver->x, 1),
304
+ gsl_vector_get(solver->x, 2), gsl_blas_dnrm2(solver->f));
306
305
  return Qtrue;
307
306
  }
308
307
 
@@ -449,15 +448,15 @@ static VALUE rb_gsl_multifit_gradient(int argc, VALUE *argv, VALUE obj)
449
448
  switch (argc) {
450
449
  case 2:
451
450
  Data_Get_Matrix(argv[0], J);
452
- Data_Get_Vector(argv[1], f);
451
+ Data_Get_Vector(argv[1], f);
453
452
  g = gsl_vector_alloc(f->size);
454
453
  /*status =*/ gsl_multifit_gradient(J, f, g);
455
454
  return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, g);
456
- break;
455
+ break;
457
456
  case 3:
458
457
  Data_Get_Matrix(argv[0], J);
459
- Data_Get_Vector(argv[1], f);
460
- Data_Get_Vector(argv[2], g);
458
+ Data_Get_Vector(argv[1], f);
459
+ Data_Get_Vector(argv[2], g);
461
460
  return INT2FIX(gsl_multifit_gradient(J, f, g));
462
461
  break;
463
462
  default:
@@ -496,15 +495,15 @@ static VALUE rb_gsl_multifit_covar(int argc, VALUE *argv, VALUE obj)
496
495
 
497
496
  static void rb_gsl_multifit_define_const(VALUE klass)
498
497
  {
499
- rb_define_const(klass, "LMSDER",
500
- INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMSDER));
501
- rb_define_const(klass, "LMDER",
502
- INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMDER));
498
+ rb_define_const(klass, "LMSDER",
499
+ INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMSDER));
500
+ rb_define_const(klass, "LMDER",
501
+ INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMDER));
503
502
 
504
- rb_define_const(klass, "Lmsder",
505
- INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMSDER));
506
- rb_define_const(klass, "Lmder",
507
- INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMDER));
503
+ rb_define_const(klass, "Lmsder",
504
+ INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMSDER));
505
+ rb_define_const(klass, "Lmder",
506
+ INT2FIX(GSL_MULTIFIT_FDFSOLVER_LMDER));
508
507
  }
509
508
 
510
509
  static void gsl_multifit_function_fdf_free(gsl_multifit_function_fdf *f);
@@ -520,11 +519,11 @@ static void gsl_multifit_function_fdf_mark(gsl_multifit_function_fdf *F)
520
519
  }
521
520
 
522
521
  static int gsl_multifit_function_fdf_f(const gsl_vector *x, void *params,
523
- gsl_vector *f);
522
+ gsl_vector *f);
524
523
  static int gsl_multifit_function_fdf_df(const gsl_vector *x, void *params,
525
- gsl_matrix *J);
524
+ gsl_matrix *J);
526
525
  static int gsl_multifit_function_fdf_fdf(const gsl_vector *x, void *params,
527
- gsl_vector *f, gsl_matrix *J);
526
+ gsl_vector *f, gsl_matrix *J);
528
527
 
529
528
  static VALUE rb_gsl_multifit_function_fdf_set_procs(int argc, VALUE *argv, VALUE obj);
530
529
 
@@ -551,7 +550,7 @@ static VALUE rb_gsl_multifit_function_fdf_new(int argc, VALUE *argv, VALUE klass
551
550
  break;
552
551
  }
553
552
  return obj;
554
- }
553
+ }
555
554
 
556
555
  static VALUE rb_gsl_multifit_function_fdf_set_procs(int argc, VALUE *argv, VALUE obj)
557
556
  {
@@ -568,8 +567,8 @@ static VALUE rb_gsl_multifit_function_fdf_set_procs(int argc, VALUE *argv, VALUE
568
567
  rb_ary_store(ary, 0, argv[0]);
569
568
  rb_ary_store(ary, 1, argv[1]);
570
569
  switch (argc) {
571
- case 2:
572
- break;
570
+ case 2:
571
+ break;
573
572
  case 3:
574
573
  if (TYPE(argv[2]) == T_FIXNUM) {
575
574
  func->p = FIX2INT(argv[2]);
@@ -621,7 +620,7 @@ static VALUE rb_gsl_multifit_function_fdf_set_data(int argc, VALUE *argv, VALUE
621
620
  }
622
621
 
623
622
  static int gsl_multifit_function_fdf_f(const gsl_vector *x, void *params,
624
- gsl_vector *f)
623
+ gsl_vector *f)
625
624
  {
626
625
  VALUE vt_y_sigma, vt, vy, vsigma, vf, vx, proc, ary;
627
626
  ary = (VALUE) params;
@@ -643,13 +642,13 @@ static int gsl_multifit_function_fdf_f(const gsl_vector *x, void *params,
643
642
  break;
644
643
  default:
645
644
  rb_raise(rb_eArgError, "bad argument");
646
- break;
645
+ break;
647
646
  }
648
647
  return GSL_SUCCESS;
649
648
  }
650
649
 
651
650
  static int gsl_multifit_function_fdf_df(const gsl_vector *x, void *params,
652
- gsl_matrix *J)
651
+ gsl_matrix *J)
653
652
  {
654
653
  VALUE vt_y_sigma, vt, vy, vsigma, vJ, vx, proc, ary;
655
654
  ary = (VALUE) params;
@@ -671,13 +670,13 @@ static int gsl_multifit_function_fdf_df(const gsl_vector *x, void *params,
671
670
  break;
672
671
  default:
673
672
  rb_raise(rb_eArgError, "bad argument");
674
- break;
673
+ break;
675
674
  }
676
675
  return GSL_SUCCESS;
677
676
  }
678
677
 
679
678
  static int gsl_multifit_function_fdf_fdf(const gsl_vector *x, void *params,
680
- gsl_vector *f, gsl_matrix *J)
679
+ gsl_vector *f, gsl_matrix *J)
681
680
  {
682
681
  VALUE vt_y_sigma, vt, vy, vsigma, vf, vJ, vx, proc_f, proc_df, proc_fdf;
683
682
  VALUE ary;
@@ -696,7 +695,7 @@ static int gsl_multifit_function_fdf_fdf(const gsl_vector *x, void *params,
696
695
  if (NIL_P(proc_fdf)) {
697
696
  rb_funcall(proc_f, RBGSL_ID_call, 4, vx, vt, vy, vf);
698
697
  rb_funcall(proc_df, RBGSL_ID_call, 4, vx, vt, vy, vJ);
699
- } else
698
+ } else
700
699
  rb_funcall(proc_fdf, RBGSL_ID_call, 5, vx, vt, vy, vf, vJ);
701
700
  break;
702
701
  case 3:
@@ -706,12 +705,12 @@ static int gsl_multifit_function_fdf_fdf(const gsl_vector *x, void *params,
706
705
  if (NIL_P(proc_fdf)) {
707
706
  rb_funcall(proc_f, RBGSL_ID_call, 5, vx, vt, vy, vsigma, vf);
708
707
  rb_funcall(proc_df, RBGSL_ID_call, 5, vx, vt, vy, vsigma, vJ);
709
- } else
708
+ } else
710
709
  rb_funcall(proc_fdf, RBGSL_ID_call, 6, vx, vt, vy, vsigma, vf, vJ);
711
710
  break;
712
711
  default:
713
712
  rb_raise(rb_eArgError, "bad argument");
714
- break;
713
+ break;
715
714
  }
716
715
  return GSL_SUCCESS;
717
716
  }
@@ -750,7 +749,7 @@ struct fitting_xydata {
750
749
  gsl_vector *x, *y, *w;
751
750
  };
752
751
 
753
- /* Gaussian fit
752
+ /* Gaussian fit
754
753
  y = y0 + A exp(-(x-x0/sigma)^2)
755
754
  v[0] = y0
756
755
  v[1] = A
@@ -807,14 +806,14 @@ static int Gaussian_df(const gsl_vector *v, void *data, gsl_matrix *J)
807
806
  }
808
807
 
809
808
  static int Gaussian_fdf(const gsl_vector *v, void *data,
810
- gsl_vector *f, gsl_matrix *J)
809
+ gsl_vector *f, gsl_matrix *J)
811
810
  {
812
811
  Gaussian_f(v, data, f);
813
812
  Gaussian_df(v, data, J);
814
813
  return GSL_SUCCESS;
815
814
  }
816
815
 
817
- /* 2 Gaussian fit
816
+ /* 2 Gaussian fit
818
817
  y = y0 + A1 exp(-(x-x01/sigma1)^2) + A2 exp(-(x-x02/sigma2)^2)
819
818
  v[0] = y0
820
819
  v[1] = A1
@@ -885,14 +884,14 @@ static int Gaussian_2peaks_df(const gsl_vector *v, void *data, gsl_matrix *J)
885
884
  }
886
885
 
887
886
  static int Gaussian_2peaks_fdf(const gsl_vector *v, void *data,
888
- gsl_vector *f, gsl_matrix *J)
887
+ gsl_vector *f, gsl_matrix *J)
889
888
  {
890
889
  Gaussian_2peaks_f(v, data, f);
891
890
  Gaussian_2peaks_df(v, data, J);
892
891
  return GSL_SUCCESS;
893
892
  }
894
893
 
895
- /* Exponential fit
894
+ /* Exponential fit
896
895
  y = y0 + A exp(-bx)
897
896
  v[0] = y0
898
897
  v[1] = A
@@ -938,14 +937,14 @@ static int Exponential_df(const gsl_vector *v, void *data, gsl_matrix *J)
938
937
  else wi = 1.0;
939
938
  yy = exp(-xi*b);
940
939
  gsl_matrix_set(J, i, 0, 1.0*wi);
941
- gsl_matrix_set(J, i, 1, yy*wi);
940
+ gsl_matrix_set(J, i, 1, yy*wi);
942
941
  gsl_matrix_set(J, i, 2, -A*yy*xi*wi);
943
942
  }
944
943
  return GSL_SUCCESS;
945
944
  }
946
945
 
947
946
  static int Exponential_fdf(const gsl_vector *v, void *data,
948
- gsl_vector *f, gsl_matrix *J)
947
+ gsl_vector *f, gsl_matrix *J)
949
948
  {
950
949
  Exponential_f(v, data, f);
951
950
  Exponential_df(v, data, J);
@@ -953,7 +952,7 @@ static int Exponential_fdf(const gsl_vector *v, void *data,
953
952
  }
954
953
 
955
954
 
956
- /* Double Exponential fit
955
+ /* Double Exponential fit
957
956
  y = y0 + A1 exp(-b1 x) + A2 exp(-b2 x)
958
957
  v[0] = y0
959
958
  v[1] = A1
@@ -1006,23 +1005,23 @@ static int DblExponential_df(const gsl_vector *v, void *data, gsl_matrix *J)
1006
1005
  yy1 = exp(-xi*b1);
1007
1006
  yy2 = exp(-xi*b2);
1008
1007
  gsl_matrix_set(J, i, 0, 1.0*wi);
1009
- gsl_matrix_set(J, i, 1, yy1*wi);
1008
+ gsl_matrix_set(J, i, 1, yy1*wi);
1010
1009
  gsl_matrix_set(J, i, 2, -A1*yy1*xi*wi);
1011
- gsl_matrix_set(J, i, 3, yy2*wi);
1010
+ gsl_matrix_set(J, i, 3, yy2*wi);
1012
1011
  gsl_matrix_set(J, i, 4, -A2*yy2*xi*wi);
1013
1012
  }
1014
1013
  return GSL_SUCCESS;
1015
1014
  }
1016
1015
 
1017
1016
  static int DblExponential_fdf(const gsl_vector *v, void *data,
1018
- gsl_vector *f, gsl_matrix *J)
1017
+ gsl_vector *f, gsl_matrix *J)
1019
1018
  {
1020
1019
  DblExponential_f(v, data, f);
1021
1020
  DblExponential_df(v, data, J);
1022
1021
  return GSL_SUCCESS;
1023
1022
  }
1024
1023
 
1025
- /* Lorentzian fit
1024
+ /* Lorentzian fit
1026
1025
  y = y0 + A/((x-x0)^2 + B)
1027
1026
  v[0] = y0
1028
1027
  v[1] = A
@@ -1071,7 +1070,7 @@ static int Lorentzian_df(const gsl_vector *v, void *data, gsl_matrix *J)
1071
1070
  else wi = 1.0;
1072
1071
  yy = gsl_pow_2(xi-x0)+B;
1073
1072
  gsl_matrix_set(J, i, 0, 1.0*wi);
1074
- gsl_matrix_set(J, i, 1, 1.0/yy*wi);
1073
+ gsl_matrix_set(J, i, 1, 1.0/yy*wi);
1075
1074
  gsl_matrix_set(J, i, 2, 2.0*A*(xi-x0)/yy/yy*wi);
1076
1075
  gsl_matrix_set(J, i, 3, -A/yy/yy*wi);
1077
1076
  }
@@ -1079,7 +1078,7 @@ static int Lorentzian_df(const gsl_vector *v, void *data, gsl_matrix *J)
1079
1078
  }
1080
1079
 
1081
1080
  static int Lorentzian_fdf(const gsl_vector *v, void *data,
1082
- gsl_vector *f, gsl_matrix *J)
1081
+ gsl_vector *f, gsl_matrix *J)
1083
1082
  {
1084
1083
  Lorentzian_f(v, data, f);
1085
1084
  Lorentzian_df(v, data, J);
@@ -1136,7 +1135,7 @@ static int Sin_df(const gsl_vector *v, void *data, gsl_matrix *J)
1136
1135
  ys = sin(fc*xi + phi);
1137
1136
  yc = cos(fc*xi + phi);
1138
1137
  gsl_matrix_set(J, i, 0, 1.0*wi);
1139
- gsl_matrix_set(J, i, 1, ys*wi);
1138
+ gsl_matrix_set(J, i, 1, ys*wi);
1140
1139
  gsl_matrix_set(J, i, 2, A*yc*xi*wi);
1141
1140
  gsl_matrix_set(J, i, 3, A*yc*wi);
1142
1141
  }
@@ -1144,7 +1143,7 @@ static int Sin_df(const gsl_vector *v, void *data, gsl_matrix *J)
1144
1143
  }
1145
1144
 
1146
1145
  static int Sin_fdf(const gsl_vector *v, void *data,
1147
- gsl_vector *f, gsl_matrix *J)
1146
+ gsl_vector *f, gsl_matrix *J)
1148
1147
  {
1149
1148
  Sin_f(v, data, f);
1150
1149
  Sin_df(v, data, J);
@@ -1202,7 +1201,7 @@ static int Hill_df(const gsl_vector *v, void *data, gsl_matrix *J)
1202
1201
  a = pow(xhalf/xi, r);
1203
1202
  yy = (1.0 + a);
1204
1203
  gsl_matrix_set(J, i, 0, (1.0 - 1.0/yy)*wi);
1205
- gsl_matrix_set(J, i, 1, 1.0/yy*wi);
1204
+ gsl_matrix_set(J, i, 1, 1.0/yy*wi);
1206
1205
  gsl_matrix_set(J, i, 2, -(m-y0)*r/xhalf*a/yy/yy*wi);
1207
1206
  gsl_matrix_set(J, i, 3, -(m-y0)/yy/yy*a*log(xhalf/xi)*wi);
1208
1207
  }
@@ -1210,7 +1209,7 @@ static int Hill_df(const gsl_vector *v, void *data, gsl_matrix *J)
1210
1209
  }
1211
1210
 
1212
1211
  static int Hill_fdf(const gsl_vector *v, void *data,
1213
- gsl_vector *f, gsl_matrix *J)
1212
+ gsl_vector *f, gsl_matrix *J)
1214
1213
  {
1215
1214
  Hill_f(v, data, f);
1216
1215
  Hill_df(v, data, J);
@@ -1267,7 +1266,7 @@ static int Sigmoid_df(const gsl_vector *v, void *data, gsl_matrix *J)
1267
1266
  a = exp((x0 - xi)/r);
1268
1267
  yy = 1.0 + a;
1269
1268
  gsl_matrix_set(J, i, 0, wi);
1270
- gsl_matrix_set(J, i, 1, 1.0/yy*wi);
1269
+ gsl_matrix_set(J, i, 1, 1.0/yy*wi);
1271
1270
  gsl_matrix_set(J, i, 2, -m*a/r/yy/yy*wi);
1272
1271
  gsl_matrix_set(J, i, 3, m*a*(x0-xi)/r/r/yy/yy*wi);
1273
1272
  }
@@ -1275,7 +1274,7 @@ static int Sigmoid_df(const gsl_vector *v, void *data, gsl_matrix *J)
1275
1274
  }
1276
1275
 
1277
1276
  static int Sigmoid_fdf(const gsl_vector *v, void *data,
1278
- gsl_vector *f, gsl_matrix *J)
1277
+ gsl_vector *f, gsl_matrix *J)
1279
1278
  {
1280
1279
  Sigmoid_f(v, data, f);
1281
1280
  Sigmoid_df(v, data, J);
@@ -1329,15 +1328,15 @@ static int Power_df(const gsl_vector *v, void *data, gsl_matrix *J)
1329
1328
  else wi = 1.0;
1330
1329
  a = pow(xi, r);
1331
1330
  gsl_matrix_set(J, i, 0, wi);
1332
- gsl_matrix_set(J, i, 1, a*wi);
1331
+ gsl_matrix_set(J, i, 1, a*wi);
1333
1332
  gsl_matrix_set(J, i, 2, A*a*log(xi)*wi);
1334
-
1333
+
1335
1334
  }
1336
1335
  return GSL_SUCCESS;
1337
1336
  }
1338
1337
 
1339
1338
  static int Power_fdf(const gsl_vector *v, void *data,
1340
- gsl_vector *f, gsl_matrix *J)
1339
+ gsl_vector *f, gsl_matrix *J)
1341
1340
  {
1342
1341
  Power_f(v, data, f);
1343
1342
  Power_df(v, data, J);
@@ -1395,7 +1394,7 @@ static int Lognormal_df(const gsl_vector *v, void *data, gsl_matrix *J)
1395
1394
  a = log(xi/x0)/width;
1396
1395
  b = exp(-a*a);
1397
1396
  gsl_matrix_set(J, i, 0, wi);
1398
- gsl_matrix_set(J, i, 1, b*wi);
1397
+ gsl_matrix_set(J, i, 1, b*wi);
1399
1398
  gsl_matrix_set(J, i, 2, 2.0*A*b*a*a*a/width/x0*wi);
1400
1399
  gsl_matrix_set(J, i, 3, 2.0*A*b*a*a*a*a/width*wi);
1401
1400
  }
@@ -1403,14 +1402,14 @@ static int Lognormal_df(const gsl_vector *v, void *data, gsl_matrix *J)
1403
1402
  }
1404
1403
 
1405
1404
  static int Lognormal_fdf(const gsl_vector *v, void *data,
1406
- gsl_vector *f, gsl_matrix *J)
1405
+ gsl_vector *f, gsl_matrix *J)
1407
1406
  {
1408
1407
  Lognormal_f(v, data, f);
1409
1408
  Lognormal_df(v, data, J);
1410
1409
  return GSL_SUCCESS;
1411
1410
  }
1412
1411
 
1413
- /* Rayleigh fit
1412
+ /* Rayleigh fit
1414
1413
  y = A exp(-x*x/2/var)
1415
1414
  v[0] = A
1416
1415
  v[1] = var = sigma^2
@@ -1460,7 +1459,7 @@ static int Rayleigh_df(const gsl_vector *v, void *data, gsl_matrix *J)
1460
1459
  }
1461
1460
 
1462
1461
  static int Rayleigh_fdf(const gsl_vector *v, void *data,
1463
- gsl_vector *f, gsl_matrix *J)
1462
+ gsl_vector *f, gsl_matrix *J)
1464
1463
  {
1465
1464
  Rayleigh_f(v, data, f);
1466
1465
  Rayleigh_df(v, data, J);
@@ -1507,10 +1506,10 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1507
1506
  *v = gsl_vector_alloc(*p);
1508
1507
  gsl_vector_set(*v, 0, 0); /* y0 = 0 */
1509
1508
  gsl_vector_set(*v, 1, 1); /* A = 1 */
1510
- gsl_vector_set(*v, 2, 1);
1509
+ gsl_vector_set(*v, 2, 1);
1511
1510
  *flag = 1;
1512
1511
  }
1513
- } else if (str_head_grep(fittype, "rayleigh") == 0) {
1512
+ } else if (str_head_grep(fittype, "rayleigh") == 0) {
1514
1513
  f->f = Rayleigh_f;
1515
1514
  f->df = Rayleigh_df;
1516
1515
  f->fdf = Rayleigh_fdf;
@@ -1530,9 +1529,9 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1530
1529
  *v = gsl_vector_alloc(*p);
1531
1530
  gsl_vector_set(*v, 0, 0); /* y0 = 0 */
1532
1531
  gsl_vector_set(*v, 1, 1); /* A = 1 */
1533
- gsl_vector_set(*v, 2, 1);
1532
+ gsl_vector_set(*v, 2, 1);
1534
1533
  gsl_vector_set(*v, 3, 1); /* A = 1 */
1535
- gsl_vector_set(*v, 4, 1);
1534
+ gsl_vector_set(*v, 4, 1);
1536
1535
  *flag = 1;
1537
1536
  }
1538
1537
  } else if (str_head_grep(fittype, "lor") == 0) {
@@ -1542,10 +1541,10 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1542
1541
  *p = 4;
1543
1542
  if (*v == NULL) {
1544
1543
  *v = gsl_vector_alloc(*p);
1545
- gsl_vector_set(*v, 0, 0);
1544
+ gsl_vector_set(*v, 0, 0);
1546
1545
  gsl_vector_set(*v, 1, 1);
1547
- gsl_vector_set(*v, 2, 0);
1548
- gsl_vector_set(*v, 3, 1);
1546
+ gsl_vector_set(*v, 2, 0);
1547
+ gsl_vector_set(*v, 3, 1);
1549
1548
  *flag = 1;
1550
1549
  }
1551
1550
  } else if (str_head_grep(fittype, "sin") == 0) {
@@ -1555,10 +1554,10 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1555
1554
  *p = 4;
1556
1555
  if (*v == NULL) {
1557
1556
  *v = gsl_vector_alloc(*p);
1558
- gsl_vector_set(*v, 0, 0);
1557
+ gsl_vector_set(*v, 0, 0);
1559
1558
  gsl_vector_set(*v, 1, 1);
1560
- gsl_vector_set(*v, 2, 1);
1561
- gsl_vector_set(*v, 3, 0);
1559
+ gsl_vector_set(*v, 2, 1);
1560
+ gsl_vector_set(*v, 3, 0);
1562
1561
  *flag = 1;
1563
1562
  }
1564
1563
  } else if (str_head_grep(fittype, "hill") == 0) {
@@ -1568,10 +1567,10 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1568
1567
  *p = 4;
1569
1568
  if (*v == NULL) {
1570
1569
  *v = gsl_vector_alloc(*p);
1571
- gsl_vector_set(*v, 0, 0);
1570
+ gsl_vector_set(*v, 0, 0);
1572
1571
  gsl_vector_set(*v, 1, 1);
1573
- gsl_vector_set(*v, 2, 1);
1574
- gsl_vector_set(*v, 3, 1);
1572
+ gsl_vector_set(*v, 2, 1);
1573
+ gsl_vector_set(*v, 3, 1);
1575
1574
  *flag = 1;
1576
1575
  }
1577
1576
  } else if (str_head_grep(fittype, "sigmoid") == 0 || str_head_grep(fittype, "fermi") == 0) {
@@ -1581,10 +1580,10 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1581
1580
  *p = 4;
1582
1581
  if (*v == NULL) {
1583
1582
  *v = gsl_vector_alloc(*p);
1584
- gsl_vector_set(*v, 0, 0);
1583
+ gsl_vector_set(*v, 0, 0);
1585
1584
  gsl_vector_set(*v, 1, 1);
1586
- gsl_vector_set(*v, 2, 0);
1587
- gsl_vector_set(*v, 3, 1);
1585
+ gsl_vector_set(*v, 2, 0);
1586
+ gsl_vector_set(*v, 3, 1);
1588
1587
  *flag = 1;
1589
1588
  }
1590
1589
  } else if (str_head_grep(fittype, "power") == 0) {
@@ -1594,9 +1593,9 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1594
1593
  *p = 3;
1595
1594
  if (*v == NULL) {
1596
1595
  *v = gsl_vector_alloc(*p);
1597
- gsl_vector_set(*v, 0, 0);
1596
+ gsl_vector_set(*v, 0, 0);
1598
1597
  gsl_vector_set(*v, 1, 1);
1599
- gsl_vector_set(*v, 2, -1);
1598
+ gsl_vector_set(*v, 2, -1);
1600
1599
  *flag = 1;
1601
1600
  }
1602
1601
  } else if (str_head_grep(fittype, "lognormal") == 0) {
@@ -1606,16 +1605,15 @@ static void set_fittype(gsl_multifit_function_fdf *f, const char *fittype, size_
1606
1605
  *p = 4;
1607
1606
  if (*v == NULL) {
1608
1607
  *v = gsl_vector_alloc(*p);
1609
- gsl_vector_set(*v, 0, 0);
1608
+ gsl_vector_set(*v, 0, 0);
1610
1609
  gsl_vector_set(*v, 1, 1);
1611
- gsl_vector_set(*v, 2, 1);
1612
- gsl_vector_set(*v, 3, 1);
1610
+ gsl_vector_set(*v, 2, 1);
1611
+ gsl_vector_set(*v, 3, 1);
1613
1612
  *flag = 1;
1614
1613
  }
1615
1614
  } else {
1616
1615
  rb_raise(rb_eRuntimeError, "Unknown fit type (gaussian expected)");
1617
1616
  }
1618
-
1619
1617
  }
1620
1618
 
1621
1619
  /* Singleton method */
@@ -1708,12 +1706,11 @@ static VALUE rb_gsl_multifit_fit(int argc, VALUE *argv, VALUE klass)
1708
1706
  if (flag == 1) gsl_vector_free(v);
1709
1707
  gsl_multifit_fdfsolver_free(solver);
1710
1708
  return rb_ary_new3(4,
1711
- Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vout),
1712
- Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, verr),
1713
- rb_float_new(chi2), INT2FIX(dof));
1709
+ Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vout),
1710
+ Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, verr),
1711
+ rb_float_new(chi2), INT2FIX(dof));
1714
1712
  }
1715
1713
 
1716
- #ifdef GSL_1_8_LATER
1717
1714
  static VALUE rb_gsl_multifit_linear_est(VALUE module, VALUE xx, VALUE cc, VALUE ccov)
1718
1715
  {
1719
1716
  gsl_vector *x, *c;
@@ -1726,8 +1723,7 @@ static VALUE rb_gsl_multifit_linear_est(VALUE module, VALUE xx, VALUE cc, VALUE
1726
1723
  gsl_multifit_linear_est(x, c, cov, &y, &y_err);
1727
1724
  return rb_ary_new3(2, rb_float_new(y), rb_float_new(y_err));
1728
1725
  }
1729
- #endif
1730
- #ifdef GSL_1_11_LATER
1726
+
1731
1727
  static VALUE rb_gsl_multifit_linear_residuals(int argc, VALUE argv[], VALUE module)
1732
1728
  {
1733
1729
  gsl_vector *y, *c, *r;
@@ -1755,8 +1751,6 @@ static VALUE rb_gsl_multifit_linear_residuals(int argc, VALUE argv[], VALUE modu
1755
1751
  return ret;
1756
1752
  }
1757
1753
 
1758
- #endif
1759
-
1760
1754
  void Init_gsl_multifit(VALUE module)
1761
1755
  {
1762
1756
  VALUE mgsl_multifit;
@@ -1765,34 +1759,34 @@ void Init_gsl_multifit(VALUE module)
1765
1759
 
1766
1760
  mgsl_multifit = rb_define_module_under(module, "MultiFit");
1767
1761
 
1768
- cgsl_multifit_workspace = rb_define_class_under(mgsl_multifit, "Workspace",
1769
- cGSL_Object);
1770
- rb_define_singleton_method(cgsl_multifit_workspace, "new",
1771
- rb_gsl_multifit_workspace_new, 2);
1772
- rb_define_singleton_method(cgsl_multifit_workspace, "alloc",
1773
- rb_gsl_multifit_workspace_new, 2);
1774
- rb_define_singleton_method(mgsl_multifit, "alloc",
1775
- rb_gsl_multifit_workspace_new, 2);
1762
+ cgsl_multifit_workspace = rb_define_class_under(mgsl_multifit, "Workspace",
1763
+ cGSL_Object);
1764
+ rb_define_singleton_method(cgsl_multifit_workspace, "new",
1765
+ rb_gsl_multifit_workspace_new, 2);
1766
+ rb_define_singleton_method(cgsl_multifit_workspace, "alloc",
1767
+ rb_gsl_multifit_workspace_new, 2);
1768
+ rb_define_singleton_method(mgsl_multifit, "alloc",
1769
+ rb_gsl_multifit_workspace_new, 2);
1776
1770
  rb_define_module_function(mgsl_multifit, "linear", rb_gsl_multifit_linear, -1);
1777
1771
  rb_define_module_function(mgsl_multifit, "wlinear", rb_gsl_multifit_wlinear, -1);
1778
1772
 
1779
1773
  cgsl_multifit_solver = rb_define_class_under(mgsl_multifit, "Solver", cGSL_Object);
1780
- cgsl_multifit_fdfsolver = rb_define_class_under(mgsl_multifit, "FdfSolver",
1781
- cgsl_multifit_solver);
1774
+ cgsl_multifit_fdfsolver = rb_define_class_under(mgsl_multifit, "FdfSolver",
1775
+ cgsl_multifit_solver);
1782
1776
  cgsl_multifit_function_fdf = rb_define_class_under(mgsl_multifit, "Function_fdf",
1783
- cGSL_Object);
1777
+ cGSL_Object);
1784
1778
 
1785
1779
  /*****/
1786
1780
 
1787
- rb_define_singleton_method(cgsl_multifit_fdfsolver, "new",
1788
- rb_gsl_multifit_fdfsolver_new, -1);
1789
- rb_define_singleton_method(cgsl_multifit_fdfsolver, "alloc",
1790
- rb_gsl_multifit_fdfsolver_new, -1);
1781
+ rb_define_singleton_method(cgsl_multifit_fdfsolver, "new",
1782
+ rb_gsl_multifit_fdfsolver_new, -1);
1783
+ rb_define_singleton_method(cgsl_multifit_fdfsolver, "alloc",
1784
+ rb_gsl_multifit_fdfsolver_new, -1);
1791
1785
 
1792
- rb_define_singleton_method(cgsl_multifit_function_fdf, "new",
1793
- rb_gsl_multifit_function_fdf_new, -1);
1794
- rb_define_singleton_method(cgsl_multifit_function_fdf, "alloc",
1795
- rb_gsl_multifit_function_fdf_new, -1);
1786
+ rb_define_singleton_method(cgsl_multifit_function_fdf, "new",
1787
+ rb_gsl_multifit_function_fdf_new, -1);
1788
+ rb_define_singleton_method(cgsl_multifit_function_fdf, "alloc",
1789
+ rb_gsl_multifit_function_fdf_new, -1);
1796
1790
 
1797
1791
  /*****/
1798
1792
 
@@ -1827,35 +1821,32 @@ void Init_gsl_multifit(VALUE module)
1827
1821
 
1828
1822
  rb_gsl_multifit_define_const(cgsl_multifit_fdfsolver);
1829
1823
 
1830
- rb_define_method(cgsl_multifit_function_fdf, "set_procs",
1831
- rb_gsl_multifit_function_fdf_set_procs, -1);
1832
- rb_define_method(cgsl_multifit_function_fdf, "set_data",
1833
- rb_gsl_multifit_function_fdf_set_data, -1);
1834
- rb_define_method(cgsl_multifit_function_fdf, "params",
1835
- rb_gsl_multifit_function_fdf_params, 0);
1824
+ rb_define_method(cgsl_multifit_function_fdf, "set_procs",
1825
+ rb_gsl_multifit_function_fdf_set_procs, -1);
1826
+ rb_define_method(cgsl_multifit_function_fdf, "set_data",
1827
+ rb_gsl_multifit_function_fdf_set_data, -1);
1828
+ rb_define_method(cgsl_multifit_function_fdf, "params",
1829
+ rb_gsl_multifit_function_fdf_params, 0);
1836
1830
  rb_define_alias(cgsl_multifit_function_fdf, "param", "params");
1837
1831
 
1838
- rb_define_method(cgsl_multifit_function_fdf, "n",
1839
- rb_gsl_multifit_function_fdf_n, 0);
1840
- rb_define_method(cgsl_multifit_function_fdf, "set_n",
1841
- rb_gsl_multifit_function_fdf_set_n, 1);
1832
+ rb_define_method(cgsl_multifit_function_fdf, "n",
1833
+ rb_gsl_multifit_function_fdf_n, 0);
1834
+ rb_define_method(cgsl_multifit_function_fdf, "set_n",
1835
+ rb_gsl_multifit_function_fdf_set_n, 1);
1842
1836
  rb_define_alias(cgsl_multifit_function_fdf, "n=", "set_n");
1843
- rb_define_method(cgsl_multifit_function_fdf, "p",
1844
- rb_gsl_multifit_function_fdf_p, 0);
1837
+ rb_define_method(cgsl_multifit_function_fdf, "p",
1838
+ rb_gsl_multifit_function_fdf_p, 0);
1845
1839
  rb_define_alias(cgsl_multifit_function_fdf, "np", "p");
1846
1840
 
1847
1841
  /*****/
1848
1842
  rb_define_singleton_method(cgsl_multifit_fdfsolver, "fit", rb_gsl_multifit_fit, -1);
1849
1843
 
1850
1844
  /***/
1851
- #ifdef GSL_1_8_LATER
1852
1845
  rb_define_module_function(mgsl_multifit, "linear_est", rb_gsl_multifit_linear_est, 3);
1853
1846
  rb_define_module_function(module, "multifit_linear_est", rb_gsl_multifit_linear_est, 3);
1854
- #endif
1855
- #ifdef GSL_1_11_LATER
1847
+
1856
1848
  rb_define_module_function(mgsl_multifit, "linear_residuals", rb_gsl_multifit_linear_residuals, -1);
1857
1849
  rb_define_module_function(module, "multifit_linear_residuals", rb_gsl_multifit_linear_residuals, -1);
1858
- #endif
1859
1850
 
1860
1851
  #ifdef HAVE_NDLINEAR_GSL_MULTIFIT_NDLINEAR_H
1861
1852
  Init_ndlinear(mgsl_multifit);