rb-gsl 1.15.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (660) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS +6 -0
  3. data/COPYING +339 -0
  4. data/ChangeLog +567 -0
  5. data/README +32 -0
  6. data/Rakefile +99 -0
  7. data/THANKS +17 -0
  8. data/VERSION +1 -0
  9. data/examples/alf/alf.gp +15 -0
  10. data/examples/alf/alf.rb +32 -0
  11. data/examples/blas/blas.rb +13 -0
  12. data/examples/blas/dnrm2.rb +16 -0
  13. data/examples/blas/level1.rb +81 -0
  14. data/examples/blas/level2.rb +11 -0
  15. data/examples/blas/level3.rb +12 -0
  16. data/examples/bspline.rb +57 -0
  17. data/examples/cdf.rb +16 -0
  18. data/examples/cheb.rb +21 -0
  19. data/examples/combination.rb +23 -0
  20. data/examples/complex/RC-lpf.rb +47 -0
  21. data/examples/complex/add.rb +36 -0
  22. data/examples/complex/coerce.rb +14 -0
  23. data/examples/complex/complex.rb +25 -0
  24. data/examples/complex/fpmi.rb +70 -0
  25. data/examples/complex/functions.rb +77 -0
  26. data/examples/complex/michelson.rb +36 -0
  27. data/examples/complex/mul.rb +28 -0
  28. data/examples/complex/oscillator.rb +17 -0
  29. data/examples/complex/set.rb +37 -0
  30. data/examples/const/physconst.rb +151 -0
  31. data/examples/const/travel.rb +45 -0
  32. data/examples/deriv/demo.rb +13 -0
  33. data/examples/deriv/deriv.rb +36 -0
  34. data/examples/deriv/diff.rb +35 -0
  35. data/examples/dht.rb +42 -0
  36. data/examples/dirac.rb +56 -0
  37. data/examples/eigen/eigen.rb +34 -0
  38. data/examples/eigen/herm.rb +22 -0
  39. data/examples/eigen/narray.rb +9 -0
  40. data/examples/eigen/nonsymm.rb +37 -0
  41. data/examples/eigen/nonsymmv.rb +43 -0
  42. data/examples/eigen/qhoscillator.gp +35 -0
  43. data/examples/eigen/qhoscillator.rb +90 -0
  44. data/examples/eigen/vander.rb +41 -0
  45. data/examples/fft/fft.rb +17 -0
  46. data/examples/fft/fft2.rb +17 -0
  47. data/examples/fft/forward.rb +25 -0
  48. data/examples/fft/forward2.rb +26 -0
  49. data/examples/fft/radix2.rb +18 -0
  50. data/examples/fft/real-halfcomplex.rb +33 -0
  51. data/examples/fft/real-halfcomplex2.rb +30 -0
  52. data/examples/fft/realradix2.rb +19 -0
  53. data/examples/fft/sunspot.dat +256 -0
  54. data/examples/fft/sunspot.rb +16 -0
  55. data/examples/fit/expdata.dat +20 -0
  56. data/examples/fit/expfit.rb +31 -0
  57. data/examples/fit/gaussfit.rb +29 -0
  58. data/examples/fit/gaussian_2peaks.rb +34 -0
  59. data/examples/fit/hillfit.rb +40 -0
  60. data/examples/fit/lognormal.rb +26 -0
  61. data/examples/fit/lorentzfit.rb +22 -0
  62. data/examples/fit/multifit.rb +72 -0
  63. data/examples/fit/ndlinear.rb +133 -0
  64. data/examples/fit/nonlinearfit.rb +89 -0
  65. data/examples/fit/plot.gp +36 -0
  66. data/examples/fit/polyfit.rb +9 -0
  67. data/examples/fit/powerfit.rb +21 -0
  68. data/examples/fit/sigmoidfit.rb +40 -0
  69. data/examples/fit/sinfit.rb +22 -0
  70. data/examples/fit/wlinear.rb +46 -0
  71. data/examples/fresnel.rb +11 -0
  72. data/examples/function/function.rb +36 -0
  73. data/examples/function/log.rb +7 -0
  74. data/examples/function/min.rb +33 -0
  75. data/examples/function/sin.rb +10 -0
  76. data/examples/function/synchrotron.rb +18 -0
  77. data/examples/gallery/butterfly.rb +7 -0
  78. data/examples/gallery/cayley.rb +12 -0
  79. data/examples/gallery/cornu.rb +23 -0
  80. data/examples/gallery/eight.rb +11 -0
  81. data/examples/gallery/koch.rb +40 -0
  82. data/examples/gallery/lemniscate.rb +11 -0
  83. data/examples/gallery/polar.rb +11 -0
  84. data/examples/gallery/rgplot/cossin.rb +35 -0
  85. data/examples/gallery/rgplot/rgplot.replaced +0 -0
  86. data/examples/gallery/rgplot/roesller.rb +55 -0
  87. data/examples/gallery/roesller.rb +39 -0
  88. data/examples/gallery/scarabaeus.rb +14 -0
  89. data/examples/histogram/cauchy.rb +27 -0
  90. data/examples/histogram/cauchy.sh +2 -0
  91. data/examples/histogram/exponential.rb +19 -0
  92. data/examples/histogram/gauss.rb +16 -0
  93. data/examples/histogram/gsl-histogram.rb +40 -0
  94. data/examples/histogram/histo2d.rb +31 -0
  95. data/examples/histogram/histo3d.rb +34 -0
  96. data/examples/histogram/histogram-pdf.rb +27 -0
  97. data/examples/histogram/histogram.rb +26 -0
  98. data/examples/histogram/integral.rb +28 -0
  99. data/examples/histogram/poisson.rb +27 -0
  100. data/examples/histogram/power.rb +25 -0
  101. data/examples/histogram/rebin.rb +17 -0
  102. data/examples/histogram/smp.dat +5 -0
  103. data/examples/histogram/xexp.rb +21 -0
  104. data/examples/integration/ahmed.rb +21 -0
  105. data/examples/integration/cosmology.rb +75 -0
  106. data/examples/integration/friedmann.gp +16 -0
  107. data/examples/integration/friedmann.rb +35 -0
  108. data/examples/integration/gamma-zeta.rb +35 -0
  109. data/examples/integration/integration.rb +22 -0
  110. data/examples/integration/qag.rb +8 -0
  111. data/examples/integration/qag2.rb +14 -0
  112. data/examples/integration/qag3.rb +8 -0
  113. data/examples/integration/qagi.rb +28 -0
  114. data/examples/integration/qagi2.rb +49 -0
  115. data/examples/integration/qagiu.rb +29 -0
  116. data/examples/integration/qagp.rb +20 -0
  117. data/examples/integration/qags.rb +14 -0
  118. data/examples/integration/qawc.rb +18 -0
  119. data/examples/integration/qawf.rb +41 -0
  120. data/examples/integration/qawo.rb +29 -0
  121. data/examples/integration/qaws.rb +30 -0
  122. data/examples/integration/qng.rb +17 -0
  123. data/examples/interp/demo.gp +20 -0
  124. data/examples/interp/demo.rb +45 -0
  125. data/examples/interp/interp.rb +37 -0
  126. data/examples/interp/points +10 -0
  127. data/examples/interp/spline.rb +20 -0
  128. data/examples/jacobi/deriv.rb +40 -0
  129. data/examples/jacobi/integrate.rb +34 -0
  130. data/examples/jacobi/interp.rb +43 -0
  131. data/examples/jacobi/jacobi.rb +11 -0
  132. data/examples/linalg/HH.rb +15 -0
  133. data/examples/linalg/HH_narray.rb +13 -0
  134. data/examples/linalg/LQ_solve.rb +73 -0
  135. data/examples/linalg/LU.rb +84 -0
  136. data/examples/linalg/LU2.rb +31 -0
  137. data/examples/linalg/LU_narray.rb +24 -0
  138. data/examples/linalg/PTLQ.rb +47 -0
  139. data/examples/linalg/QR.rb +18 -0
  140. data/examples/linalg/QRPT.rb +47 -0
  141. data/examples/linalg/QR_solve.rb +78 -0
  142. data/examples/linalg/QR_solve_narray.rb +13 -0
  143. data/examples/linalg/SV.rb +16 -0
  144. data/examples/linalg/SV_narray.rb +12 -0
  145. data/examples/linalg/SV_solve.rb +49 -0
  146. data/examples/linalg/chol.rb +29 -0
  147. data/examples/linalg/chol_narray.rb +15 -0
  148. data/examples/linalg/complex.rb +57 -0
  149. data/examples/linalg/invert_narray.rb +10 -0
  150. data/examples/math/const.rb +67 -0
  151. data/examples/math/elementary.rb +35 -0
  152. data/examples/math/functions.rb +41 -0
  153. data/examples/math/inf_nan.rb +34 -0
  154. data/examples/math/minmax.rb +22 -0
  155. data/examples/math/power.rb +18 -0
  156. data/examples/math/test.rb +31 -0
  157. data/examples/matrix/a.dat +0 -0
  158. data/examples/matrix/add.rb +45 -0
  159. data/examples/matrix/b.dat +4 -0
  160. data/examples/matrix/cat.rb +31 -0
  161. data/examples/matrix/colvectors.rb +24 -0
  162. data/examples/matrix/complex.rb +41 -0
  163. data/examples/matrix/det.rb +29 -0
  164. data/examples/matrix/diagonal.rb +23 -0
  165. data/examples/matrix/get_all.rb +159 -0
  166. data/examples/matrix/hilbert.rb +31 -0
  167. data/examples/matrix/iterator.rb +19 -0
  168. data/examples/matrix/matrix.rb +57 -0
  169. data/examples/matrix/minmax.rb +53 -0
  170. data/examples/matrix/mul.rb +39 -0
  171. data/examples/matrix/rand.rb +20 -0
  172. data/examples/matrix/read.rb +29 -0
  173. data/examples/matrix/rowcol.rb +47 -0
  174. data/examples/matrix/set.rb +41 -0
  175. data/examples/matrix/set_all.rb +100 -0
  176. data/examples/matrix/view.rb +32 -0
  177. data/examples/matrix/view_all.rb +148 -0
  178. data/examples/matrix/write.rb +23 -0
  179. data/examples/min.rb +29 -0
  180. data/examples/monte/miser.rb +47 -0
  181. data/examples/monte/monte.rb +47 -0
  182. data/examples/monte/plain.rb +47 -0
  183. data/examples/monte/vegas.rb +46 -0
  184. data/examples/multimin/bundle.rb +66 -0
  185. data/examples/multimin/cqp.rb +109 -0
  186. data/examples/multimin/fdfminimizer.rb +40 -0
  187. data/examples/multimin/fminimizer.rb +41 -0
  188. data/examples/multiroot/demo.rb +36 -0
  189. data/examples/multiroot/fdfsolver.rb +50 -0
  190. data/examples/multiroot/fsolver.rb +33 -0
  191. data/examples/multiroot/fsolver2.rb +32 -0
  192. data/examples/multiroot/fsolver3.rb +26 -0
  193. data/examples/narray/histogram.rb +14 -0
  194. data/examples/narray/mandel.rb +27 -0
  195. data/examples/narray/narray.rb +28 -0
  196. data/examples/narray/narray2.rb +44 -0
  197. data/examples/narray/sf.rb +26 -0
  198. data/examples/ntuple/create.rb +17 -0
  199. data/examples/ntuple/project.rb +31 -0
  200. data/examples/odeiv/binarysystem.gp +23 -0
  201. data/examples/odeiv/binarysystem.rb +104 -0
  202. data/examples/odeiv/demo.gp +24 -0
  203. data/examples/odeiv/demo.rb +69 -0
  204. data/examples/odeiv/demo2.gp +26 -0
  205. data/examples/odeiv/duffing.rb +45 -0
  206. data/examples/odeiv/frei1.rb +109 -0
  207. data/examples/odeiv/frei2.rb +76 -0
  208. data/examples/odeiv/legendre.rb +52 -0
  209. data/examples/odeiv/odeiv.rb +32 -0
  210. data/examples/odeiv/odeiv2.rb +45 -0
  211. data/examples/odeiv/oscillator.rb +42 -0
  212. data/examples/odeiv/sedov.rb +97 -0
  213. data/examples/odeiv/whitedwarf.gp +40 -0
  214. data/examples/odeiv/whitedwarf.rb +158 -0
  215. data/examples/ool/conmin.rb +100 -0
  216. data/examples/ool/gencan.rb +99 -0
  217. data/examples/ool/pgrad.rb +100 -0
  218. data/examples/ool/spg.rb +100 -0
  219. data/examples/pdf/bernoulli.rb +5 -0
  220. data/examples/pdf/beta.rb +7 -0
  221. data/examples/pdf/binomiral.rb +10 -0
  222. data/examples/pdf/cauchy.rb +6 -0
  223. data/examples/pdf/chisq.rb +8 -0
  224. data/examples/pdf/exponential.rb +7 -0
  225. data/examples/pdf/exppow.rb +6 -0
  226. data/examples/pdf/fdist.rb +7 -0
  227. data/examples/pdf/flat.rb +7 -0
  228. data/examples/pdf/gamma.rb +8 -0
  229. data/examples/pdf/gauss-tail.rb +5 -0
  230. data/examples/pdf/gauss.rb +6 -0
  231. data/examples/pdf/geometric.rb +5 -0
  232. data/examples/pdf/gumbel.rb +6 -0
  233. data/examples/pdf/hypergeometric.rb +11 -0
  234. data/examples/pdf/landau.rb +5 -0
  235. data/examples/pdf/laplace.rb +7 -0
  236. data/examples/pdf/logarithmic.rb +5 -0
  237. data/examples/pdf/logistic.rb +6 -0
  238. data/examples/pdf/lognormal.rb +6 -0
  239. data/examples/pdf/neg-binomiral.rb +10 -0
  240. data/examples/pdf/pareto.rb +7 -0
  241. data/examples/pdf/pascal.rb +10 -0
  242. data/examples/pdf/poisson.rb +5 -0
  243. data/examples/pdf/rayleigh-tail.rb +6 -0
  244. data/examples/pdf/rayleigh.rb +6 -0
  245. data/examples/pdf/tdist.rb +6 -0
  246. data/examples/pdf/weibull.rb +8 -0
  247. data/examples/permutation/ex1.rb +22 -0
  248. data/examples/permutation/permutation.rb +16 -0
  249. data/examples/poly/bell.rb +6 -0
  250. data/examples/poly/bessel.rb +6 -0
  251. data/examples/poly/cheb.rb +6 -0
  252. data/examples/poly/cheb_II.rb +6 -0
  253. data/examples/poly/cubic.rb +9 -0
  254. data/examples/poly/demo.rb +20 -0
  255. data/examples/poly/eval.rb +28 -0
  256. data/examples/poly/eval_derivs.rb +14 -0
  257. data/examples/poly/fit.rb +21 -0
  258. data/examples/poly/hermite.rb +6 -0
  259. data/examples/poly/poly.rb +13 -0
  260. data/examples/poly/quadratic.rb +25 -0
  261. data/examples/random/diffusion.rb +34 -0
  262. data/examples/random/gaussian.rb +9 -0
  263. data/examples/random/generator.rb +27 -0
  264. data/examples/random/hdsobol.rb +21 -0
  265. data/examples/random/poisson.rb +9 -0
  266. data/examples/random/qrng.rb +19 -0
  267. data/examples/random/randomwalk.rb +37 -0
  268. data/examples/random/randomwalk2d.rb +19 -0
  269. data/examples/random/rayleigh.rb +36 -0
  270. data/examples/random/rng.rb +33 -0
  271. data/examples/random/rngextra.rb +14 -0
  272. data/examples/roots/bisection.rb +25 -0
  273. data/examples/roots/brent.rb +43 -0
  274. data/examples/roots/demo.rb +30 -0
  275. data/examples/roots/newton.rb +46 -0
  276. data/examples/roots/recombination.gp +12 -0
  277. data/examples/roots/recombination.rb +61 -0
  278. data/examples/roots/steffenson.rb +48 -0
  279. data/examples/sf/ShiChi.rb +6 -0
  280. data/examples/sf/SiCi.rb +6 -0
  281. data/examples/sf/airy_Ai.rb +8 -0
  282. data/examples/sf/airy_Bi.rb +8 -0
  283. data/examples/sf/bessel_IK.rb +12 -0
  284. data/examples/sf/bessel_JY.rb +13 -0
  285. data/examples/sf/beta_inc.rb +9 -0
  286. data/examples/sf/clausen.rb +6 -0
  287. data/examples/sf/dawson.rb +5 -0
  288. data/examples/sf/debye.rb +9 -0
  289. data/examples/sf/dilog.rb +6 -0
  290. data/examples/sf/ellint.rb +6 -0
  291. data/examples/sf/expint.rb +8 -0
  292. data/examples/sf/fermi.rb +10 -0
  293. data/examples/sf/gamma_inc_P.rb +9 -0
  294. data/examples/sf/gegenbauer.rb +8 -0
  295. data/examples/sf/hyperg.rb +7 -0
  296. data/examples/sf/laguerre.rb +19 -0
  297. data/examples/sf/lambertW.rb +5 -0
  298. data/examples/sf/legendre_P.rb +10 -0
  299. data/examples/sf/lngamma.rb +5 -0
  300. data/examples/sf/psi.rb +54 -0
  301. data/examples/sf/sphbessel.gp +27 -0
  302. data/examples/sf/sphbessel.rb +30 -0
  303. data/examples/sf/synchrotron.rb +5 -0
  304. data/examples/sf/transport.rb +10 -0
  305. data/examples/sf/zetam1.rb +5 -0
  306. data/examples/siman.rb +44 -0
  307. data/examples/sort/heapsort.rb +23 -0
  308. data/examples/sort/heapsort_vector_complex.rb +21 -0
  309. data/examples/sort/sort.rb +23 -0
  310. data/examples/sort/sort2.rb +16 -0
  311. data/examples/stats/mean.rb +17 -0
  312. data/examples/stats/statistics.rb +18 -0
  313. data/examples/stats/test.rb +9 -0
  314. data/examples/sum.rb +34 -0
  315. data/examples/tamu_anova.rb +18 -0
  316. data/examples/vector/a.dat +0 -0
  317. data/examples/vector/add.rb +56 -0
  318. data/examples/vector/b.dat +4 -0
  319. data/examples/vector/c.dat +3 -0
  320. data/examples/vector/collect.rb +26 -0
  321. data/examples/vector/compare.rb +28 -0
  322. data/examples/vector/complex.rb +51 -0
  323. data/examples/vector/complex_get_all.rb +85 -0
  324. data/examples/vector/complex_set_all.rb +131 -0
  325. data/examples/vector/complex_view_all.rb +77 -0
  326. data/examples/vector/connect.rb +22 -0
  327. data/examples/vector/decimate.rb +38 -0
  328. data/examples/vector/diff.rb +31 -0
  329. data/examples/vector/filescan.rb +17 -0
  330. data/examples/vector/floor.rb +23 -0
  331. data/examples/vector/get_all.rb +82 -0
  332. data/examples/vector/gnuplot.rb +38 -0
  333. data/examples/vector/graph.rb +28 -0
  334. data/examples/vector/histogram.rb +22 -0
  335. data/examples/vector/linspace.rb +24 -0
  336. data/examples/vector/log.rb +17 -0
  337. data/examples/vector/logic.rb +33 -0
  338. data/examples/vector/logspace.rb +25 -0
  339. data/examples/vector/minmax.rb +47 -0
  340. data/examples/vector/mul.rb +49 -0
  341. data/examples/vector/narray.rb +46 -0
  342. data/examples/vector/read.rb +29 -0
  343. data/examples/vector/set.rb +35 -0
  344. data/examples/vector/set_all.rb +121 -0
  345. data/examples/vector/smpv.dat +15 -0
  346. data/examples/vector/test.rb +43 -0
  347. data/examples/vector/test_gslblock.rb +58 -0
  348. data/examples/vector/vector.rb +110 -0
  349. data/examples/vector/view.rb +35 -0
  350. data/examples/vector/view_all.rb +73 -0
  351. data/examples/vector/where.rb +29 -0
  352. data/examples/vector/write.rb +24 -0
  353. data/examples/vector/zip.rb +34 -0
  354. data/examples/wavelet/ecg.dat +256 -0
  355. data/examples/wavelet/wavelet1.rb +50 -0
  356. data/ext/alf.c +206 -0
  357. data/ext/array.c +642 -0
  358. data/ext/array_complex.c +248 -0
  359. data/ext/blas.c +29 -0
  360. data/ext/blas1.c +734 -0
  361. data/ext/blas2.c +1093 -0
  362. data/ext/blas3.c +881 -0
  363. data/ext/block.c +44 -0
  364. data/ext/block_source.c +887 -0
  365. data/ext/bspline.c +130 -0
  366. data/ext/bundle.c +3 -0
  367. data/ext/cdf.c +754 -0
  368. data/ext/cheb.c +542 -0
  369. data/ext/combination.c +283 -0
  370. data/ext/common.c +325 -0
  371. data/ext/complex.c +1004 -0
  372. data/ext/const.c +673 -0
  373. data/ext/const_additional.c +120 -0
  374. data/ext/cqp.c +283 -0
  375. data/ext/deriv.c +195 -0
  376. data/ext/dht.c +361 -0
  377. data/ext/diff.c +166 -0
  378. data/ext/dirac.c +389 -0
  379. data/ext/eigen.c +2373 -0
  380. data/ext/error.c +193 -0
  381. data/ext/extconf.rb +303 -0
  382. data/ext/fcmp.c +66 -0
  383. data/ext/fft.c +1102 -0
  384. data/ext/fit.c +205 -0
  385. data/ext/fresnel.c +312 -0
  386. data/ext/function.c +524 -0
  387. data/ext/geometry.c +139 -0
  388. data/ext/graph.c +1640 -0
  389. data/ext/gsl.c +280 -0
  390. data/ext/gsl_narray.c +804 -0
  391. data/ext/histogram.c +1991 -0
  392. data/ext/histogram2d.c +1068 -0
  393. data/ext/histogram3d.c +884 -0
  394. data/ext/histogram3d_source.c +750 -0
  395. data/ext/histogram_find.c +101 -0
  396. data/ext/histogram_oper.c +159 -0
  397. data/ext/ieee.c +100 -0
  398. data/ext/integration.c +1179 -0
  399. data/ext/interp.c +512 -0
  400. data/ext/jacobi.c +739 -0
  401. data/ext/linalg.c +4042 -0
  402. data/ext/linalg_complex.c +739 -0
  403. data/ext/math.c +725 -0
  404. data/ext/matrix.c +39 -0
  405. data/ext/matrix_complex.c +1737 -0
  406. data/ext/matrix_double.c +560 -0
  407. data/ext/matrix_int.c +256 -0
  408. data/ext/matrix_source.c +2734 -0
  409. data/ext/min.c +250 -0
  410. data/ext/monte.c +992 -0
  411. data/ext/multifit.c +1871 -0
  412. data/ext/multimin.c +806 -0
  413. data/ext/multimin_fsdf.c +156 -0
  414. data/ext/multiroots.c +955 -0
  415. data/ext/multiset.c +214 -0
  416. data/ext/ndlinear.c +321 -0
  417. data/ext/nmf.c +171 -0
  418. data/ext/nmf_wrap.c +75 -0
  419. data/ext/ntuple.c +469 -0
  420. data/ext/odeiv.c +962 -0
  421. data/ext/ool.c +879 -0
  422. data/ext/oper_complex_source.c +253 -0
  423. data/ext/permutation.c +596 -0
  424. data/ext/poly.c +42 -0
  425. data/ext/poly2.c +265 -0
  426. data/ext/poly_source.c +1915 -0
  427. data/ext/qrng.c +171 -0
  428. data/ext/randist.c +1873 -0
  429. data/ext/rational.c +480 -0
  430. data/ext/rng.c +612 -0
  431. data/ext/root.c +408 -0
  432. data/ext/sf.c +1494 -0
  433. data/ext/sf_airy.c +200 -0
  434. data/ext/sf_bessel.c +871 -0
  435. data/ext/sf_clausen.c +28 -0
  436. data/ext/sf_coulomb.c +206 -0
  437. data/ext/sf_coupling.c +121 -0
  438. data/ext/sf_dawson.c +29 -0
  439. data/ext/sf_debye.c +157 -0
  440. data/ext/sf_dilog.c +43 -0
  441. data/ext/sf_elementary.c +46 -0
  442. data/ext/sf_ellint.c +206 -0
  443. data/ext/sf_elljac.c +30 -0
  444. data/ext/sf_erfc.c +93 -0
  445. data/ext/sf_exp.c +169 -0
  446. data/ext/sf_expint.c +211 -0
  447. data/ext/sf_fermi_dirac.c +148 -0
  448. data/ext/sf_gamma.c +347 -0
  449. data/ext/sf_gegenbauer.c +97 -0
  450. data/ext/sf_hyperg.c +203 -0
  451. data/ext/sf_laguerre.c +113 -0
  452. data/ext/sf_lambert.c +47 -0
  453. data/ext/sf_legendre.c +368 -0
  454. data/ext/sf_log.c +105 -0
  455. data/ext/sf_mathieu.c +238 -0
  456. data/ext/sf_power.c +47 -0
  457. data/ext/sf_psi.c +98 -0
  458. data/ext/sf_synchrotron.c +48 -0
  459. data/ext/sf_transport.c +76 -0
  460. data/ext/sf_trigonometric.c +210 -0
  461. data/ext/sf_zeta.c +119 -0
  462. data/ext/signal.c +308 -0
  463. data/ext/siman.c +717 -0
  464. data/ext/sort.c +208 -0
  465. data/ext/spline.c +395 -0
  466. data/ext/stats.c +800 -0
  467. data/ext/sum.c +168 -0
  468. data/ext/tamu_anova.c +56 -0
  469. data/ext/tensor.c +38 -0
  470. data/ext/tensor_source.c +1123 -0
  471. data/ext/vector.c +38 -0
  472. data/ext/vector_complex.c +2246 -0
  473. data/ext/vector_double.c +1438 -0
  474. data/ext/vector_int.c +204 -0
  475. data/ext/vector_source.c +3336 -0
  476. data/ext/wavelet.c +945 -0
  477. data/include/rb_gsl.h +158 -0
  478. data/include/rb_gsl_array.h +238 -0
  479. data/include/rb_gsl_cheb.h +21 -0
  480. data/include/rb_gsl_common.h +348 -0
  481. data/include/rb_gsl_complex.h +25 -0
  482. data/include/rb_gsl_config.h +62 -0
  483. data/include/rb_gsl_const.h +29 -0
  484. data/include/rb_gsl_dirac.h +13 -0
  485. data/include/rb_gsl_eigen.h +17 -0
  486. data/include/rb_gsl_fft.h +62 -0
  487. data/include/rb_gsl_fit.h +25 -0
  488. data/include/rb_gsl_function.h +27 -0
  489. data/include/rb_gsl_graph.h +70 -0
  490. data/include/rb_gsl_histogram.h +63 -0
  491. data/include/rb_gsl_histogram3d.h +97 -0
  492. data/include/rb_gsl_integration.h +17 -0
  493. data/include/rb_gsl_interp.h +46 -0
  494. data/include/rb_gsl_linalg.h +25 -0
  495. data/include/rb_gsl_math.h +26 -0
  496. data/include/rb_gsl_odeiv.h +21 -0
  497. data/include/rb_gsl_poly.h +71 -0
  498. data/include/rb_gsl_rational.h +37 -0
  499. data/include/rb_gsl_rng.h +21 -0
  500. data/include/rb_gsl_root.h +22 -0
  501. data/include/rb_gsl_sf.h +119 -0
  502. data/include/rb_gsl_statistics.h +17 -0
  503. data/include/rb_gsl_tensor.h +45 -0
  504. data/include/rb_gsl_with_narray.h +29 -0
  505. data/include/templates_off.h +87 -0
  506. data/include/templates_on.h +241 -0
  507. data/lib/gsl.rb +3 -0
  508. data/lib/gsl/gnuplot.rb +41 -0
  509. data/lib/gsl/oper.rb +68 -0
  510. data/lib/ool.rb +22 -0
  511. data/lib/ool/conmin.rb +30 -0
  512. data/lib/rbgsl.rb +3 -0
  513. data/rdoc/alf.rdoc +77 -0
  514. data/rdoc/blas.rdoc +269 -0
  515. data/rdoc/bspline.rdoc +42 -0
  516. data/rdoc/changes.rdoc +164 -0
  517. data/rdoc/cheb.rdoc +99 -0
  518. data/rdoc/cholesky_complex.rdoc +46 -0
  519. data/rdoc/combi.rdoc +125 -0
  520. data/rdoc/complex.rdoc +210 -0
  521. data/rdoc/const.rdoc +546 -0
  522. data/rdoc/dht.rdoc +122 -0
  523. data/rdoc/diff.rdoc +133 -0
  524. data/rdoc/ehandling.rdoc +50 -0
  525. data/rdoc/eigen.rdoc +401 -0
  526. data/rdoc/fft.rdoc +535 -0
  527. data/rdoc/fit.rdoc +284 -0
  528. data/rdoc/function.rdoc +94 -0
  529. data/rdoc/graph.rdoc +137 -0
  530. data/rdoc/hist.rdoc +409 -0
  531. data/rdoc/hist2d.rdoc +279 -0
  532. data/rdoc/hist3d.rdoc +112 -0
  533. data/rdoc/index.rdoc +62 -0
  534. data/rdoc/integration.rdoc +398 -0
  535. data/rdoc/interp.rdoc +231 -0
  536. data/rdoc/intro.rdoc +27 -0
  537. data/rdoc/linalg.rdoc +681 -0
  538. data/rdoc/linalg_complex.rdoc +88 -0
  539. data/rdoc/math.rdoc +276 -0
  540. data/rdoc/matrix.rdoc +1093 -0
  541. data/rdoc/min.rdoc +189 -0
  542. data/rdoc/monte.rdoc +234 -0
  543. data/rdoc/multimin.rdoc +312 -0
  544. data/rdoc/multiroot.rdoc +293 -0
  545. data/rdoc/narray.rdoc +177 -0
  546. data/rdoc/ndlinear.rdoc +250 -0
  547. data/rdoc/nonlinearfit.rdoc +348 -0
  548. data/rdoc/ntuple.rdoc +88 -0
  549. data/rdoc/odeiv.rdoc +378 -0
  550. data/rdoc/perm.rdoc +221 -0
  551. data/rdoc/poly.rdoc +335 -0
  552. data/rdoc/qrng.rdoc +90 -0
  553. data/rdoc/randist.rdoc +233 -0
  554. data/rdoc/ref.rdoc +93 -0
  555. data/rdoc/rng.rdoc +203 -0
  556. data/rdoc/rngextra.rdoc +11 -0
  557. data/rdoc/roots.rdoc +305 -0
  558. data/rdoc/screenshot.rdoc +40 -0
  559. data/rdoc/sf.rdoc +1622 -0
  560. data/rdoc/siman.rdoc +89 -0
  561. data/rdoc/sort.rdoc +94 -0
  562. data/rdoc/start.rdoc +16 -0
  563. data/rdoc/stats.rdoc +219 -0
  564. data/rdoc/sum.rdoc +65 -0
  565. data/rdoc/tensor.rdoc +251 -0
  566. data/rdoc/tut.rdoc +5 -0
  567. data/rdoc/use.rdoc +177 -0
  568. data/rdoc/vector.rdoc +1243 -0
  569. data/rdoc/vector_complex.rdoc +347 -0
  570. data/rdoc/wavelet.rdoc +218 -0
  571. data/setup.rb +1585 -0
  572. data/tests/blas/amax.rb +14 -0
  573. data/tests/blas/asum.rb +16 -0
  574. data/tests/blas/axpy.rb +25 -0
  575. data/tests/blas/copy.rb +23 -0
  576. data/tests/blas/dot.rb +23 -0
  577. data/tests/bspline.rb +53 -0
  578. data/tests/cdf.rb +1388 -0
  579. data/tests/cheb.rb +112 -0
  580. data/tests/combination.rb +123 -0
  581. data/tests/complex.rb +17 -0
  582. data/tests/const.rb +24 -0
  583. data/tests/deriv.rb +85 -0
  584. data/tests/dht/dht1.rb +17 -0
  585. data/tests/dht/dht2.rb +23 -0
  586. data/tests/dht/dht3.rb +23 -0
  587. data/tests/dht/dht4.rb +23 -0
  588. data/tests/diff.rb +78 -0
  589. data/tests/eigen/eigen.rb +220 -0
  590. data/tests/eigen/gen.rb +105 -0
  591. data/tests/eigen/genherm.rb +66 -0
  592. data/tests/eigen/gensymm.rb +68 -0
  593. data/tests/eigen/nonsymm.rb +53 -0
  594. data/tests/eigen/nonsymmv.rb +53 -0
  595. data/tests/eigen/symm-herm.rb +74 -0
  596. data/tests/err.rb +58 -0
  597. data/tests/fit.rb +124 -0
  598. data/tests/gsl_test.rb +118 -0
  599. data/tests/gsl_test2.rb +110 -0
  600. data/tests/histo.rb +12 -0
  601. data/tests/integration/integration1.rb +72 -0
  602. data/tests/integration/integration2.rb +71 -0
  603. data/tests/integration/integration3.rb +71 -0
  604. data/tests/integration/integration4.rb +71 -0
  605. data/tests/interp.rb +45 -0
  606. data/tests/linalg/HH.rb +64 -0
  607. data/tests/linalg/LU.rb +47 -0
  608. data/tests/linalg/QR.rb +77 -0
  609. data/tests/linalg/SV.rb +24 -0
  610. data/tests/linalg/TDN.rb +116 -0
  611. data/tests/linalg/TDS.rb +122 -0
  612. data/tests/linalg/bidiag.rb +73 -0
  613. data/tests/linalg/cholesky.rb +20 -0
  614. data/tests/linalg/linalg.rb +158 -0
  615. data/tests/matrix/matrix_complex_test.rb +36 -0
  616. data/tests/matrix/matrix_nmf_test.rb +39 -0
  617. data/tests/matrix/matrix_test.rb +48 -0
  618. data/tests/min.rb +99 -0
  619. data/tests/monte/miser.rb +31 -0
  620. data/tests/monte/vegas.rb +45 -0
  621. data/tests/multifit/test_2dgauss.rb +112 -0
  622. data/tests/multifit/test_brown.rb +90 -0
  623. data/tests/multifit/test_enso.rb +246 -0
  624. data/tests/multifit/test_filip.rb +155 -0
  625. data/tests/multifit/test_gauss.rb +97 -0
  626. data/tests/multifit/test_longley.rb +110 -0
  627. data/tests/multifit/test_multifit.rb +52 -0
  628. data/tests/multimin.rb +139 -0
  629. data/tests/multiroot.rb +131 -0
  630. data/tests/multiset.rb +52 -0
  631. data/tests/narray/blas_dnrm2.rb +20 -0
  632. data/tests/odeiv.rb +353 -0
  633. data/tests/poly/poly.rb +290 -0
  634. data/tests/poly/special.rb +65 -0
  635. data/tests/qrng.rb +131 -0
  636. data/tests/quartic.rb +29 -0
  637. data/tests/randist.rb +134 -0
  638. data/tests/rng.rb +305 -0
  639. data/tests/roots.rb +76 -0
  640. data/tests/run-test.sh +17 -0
  641. data/tests/sf/gsl_test_sf.rb +249 -0
  642. data/tests/sf/test_airy.rb +83 -0
  643. data/tests/sf/test_bessel.rb +306 -0
  644. data/tests/sf/test_coulomb.rb +17 -0
  645. data/tests/sf/test_dilog.rb +25 -0
  646. data/tests/sf/test_gamma.rb +209 -0
  647. data/tests/sf/test_hyperg.rb +356 -0
  648. data/tests/sf/test_legendre.rb +227 -0
  649. data/tests/sf/test_mathieu.rb +59 -0
  650. data/tests/sf/test_mode.rb +19 -0
  651. data/tests/sf/test_sf.rb +839 -0
  652. data/tests/stats.rb +174 -0
  653. data/tests/stats_mt.rb +16 -0
  654. data/tests/sum.rb +98 -0
  655. data/tests/sys.rb +323 -0
  656. data/tests/tensor.rb +419 -0
  657. data/tests/vector/vector_complex_test.rb +101 -0
  658. data/tests/vector/vector_test.rb +141 -0
  659. data/tests/wavelet.rb +142 -0
  660. metadata +789 -0
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env ruby
2
+ #require("gsl")
3
+ #require("../gsl_test2.rb")
4
+ require("./test_multifit.rb")
5
+ include GSL::Test
6
+ include Math
7
+
8
+ Filip_n = 82
9
+ Filip_p = 11
10
+
11
+ Filip_x = GSL::Vector.alloc(-6.860120914, -4.324130045, -4.358625055,
12
+ -4.358426747, -6.955852379, -6.661145254, -6.355462942, -6.118102026,
13
+ -7.115148017, -6.815308569, -6.519993057, -6.204119983, -5.853871964,
14
+ -6.109523091, -5.79832982, -5.482672118, -5.171791386, -4.851705903,
15
+ -4.517126416, -4.143573228, -3.709075441, -3.499489089, -6.300769497,
16
+ -5.953504836, -5.642065153, -5.031376979, -4.680685696, -4.329846955,
17
+ -3.928486195, -8.56735134, -8.363211311, -8.107682739, -7.823908741,
18
+ -7.522878745, -7.218819279, -6.920818754, -6.628932138, -6.323946875,
19
+ -5.991399828, -8.781464495, -8.663140179, -8.473531488, -8.247337057,
20
+ -7.971428747, -7.676129393, -7.352812702, -7.072065318, -6.774174009,
21
+ -6.478861916, -6.159517513, -6.835647144, -6.53165267, -6.224098421,
22
+ -5.910094889, -5.598599459, -5.290645224, -4.974284616, -4.64454848,
23
+ -4.290560426, -3.885055584, -3.408378962, -3.13200249, -8.726767166,
24
+ -8.66695597, -8.511026475, -8.165388579, -7.886056648, -7.588043762,
25
+ -7.283412422, -6.995678626, -6.691862621, -6.392544977, -6.067374056,
26
+ -6.684029655, -6.378719832, -6.065855188, -5.752272167, -5.132414673,
27
+ -4.811352704, -4.098269308, -3.66174277, -3.2644011)
28
+
29
+ Filip_y = GSL::Vector.alloc(0.8116, 0.9072, 0.9052, 0.9039, 0.8053, 0.8377,
30
+ 0.8667, 0.8809, 0.7975, 0.8162, 0.8515, 0.8766, 0.8885, 0.8859,
31
+ 0.8959, 0.8913, 0.8959, 0.8971, 0.9021, 0.909, 0.9139, 0.9199, 0.8692,
32
+ 0.8872, 0.89, 0.891, 0.8977, 0.9035, 0.9078, 0.7675, 0.7705, 0.7713,
33
+ 0.7736, 0.7775, 0.7841, 0.7971, 0.8329, 0.8641, 0.8804, 0.7668,
34
+ 0.7633, 0.7678, 0.7697, 0.77, 0.7749, 0.7796, 0.7897, 0.8131, 0.8498,
35
+ 0.8741, 0.8061, 0.846, 0.8751, 0.8856, 0.8919, 0.8934, 0.894, 0.8957,
36
+ 0.9047, 0.9129, 0.9209, 0.9219, 0.7739, 0.7681, 0.7665, 0.7703,
37
+ 0.7702, 0.7761, 0.7809, 0.7961, 0.8253, 0.8602, 0.8809, 0.8301,
38
+ 0.8664, 0.8834, 0.8898, 0.8964, 0.8963, 0.9074, 0.9119, 0.9228)
39
+
40
+ def test_filip()
41
+ work = GSL::MultiFit::Workspace.alloc(Filip_n, Filip_p)
42
+ expected_c = GSL::Vector.alloc(-1467.48961422980,
43
+ -2772.17959193342,
44
+ -2316.37108160893,
45
+ -1127.97394098372,
46
+ -354.478233703349,
47
+ -75.1242017393757,
48
+ -10.8753180355343,
49
+ -1.06221498588947,
50
+ -0.670191154593408E-01,
51
+ -0.246781078275479E-02,
52
+ -0.402962525080404E-04)
53
+
54
+ expected_sd = GSL::Vector.alloc(298.084530995537,
55
+ 559.779865474950,
56
+ 466.477572127796,
57
+ 227.204274477751,
58
+ 71.6478660875927,
59
+ 15.2897178747400,
60
+ 2.23691159816033,
61
+ 0.221624321934227,
62
+ 0.142363763154724E-01,
63
+ 0.535617408889821E-03,
64
+ 0.896632837373868E-05)
65
+ expected_chisq = 0.795851382172941E-03
66
+
67
+ xx = GSL::Matrix.alloc(Filip_n, Filip_p)
68
+ for i in 0...Filip_n
69
+ for j in 0...Filip_p
70
+ xx.set(i, j, pow(Filip_x[i], j))
71
+ end
72
+ end
73
+ c, cov, chisq, status = GSL::MultiFit.linear(xx, Filip_y, work)
74
+
75
+ test_rel(c[0], expected_c[0], 1e-7, "filip gsl_fit_multilinear c0")
76
+ test_rel(c[1], expected_c[1], 1e-7, "filip gsl_fit_multilinear c1")
77
+ test_rel(c[2], expected_c[2], 1e-7, "filip gsl_fit_multilinear c2")
78
+ test_rel(c[3], expected_c[3], 1e-7, "filip gsl_fit_multilinear c3")
79
+ test_rel(c[4], expected_c[4], 1e-7, "filip gsl_fit_multilinear c4")
80
+ test_rel(c[5], expected_c[5], 1e-7, "filip gsl_fit_multilinear c5")
81
+ test_rel(c[6], expected_c[6], 1e-7, "filip gsl_fit_multilinear c6")
82
+ test_rel(c[7], expected_c[7], 1e-7, "filip gsl_fit_multilinear c7")
83
+ test_rel(c[8], expected_c[8], 1e-7, "filip gsl_fit_multilinear c8")
84
+ test_rel(c[9], expected_c[9], 1e-7, "filip gsl_fit_multilinear c9")
85
+ test_rel(c[10], expected_c[10], 1e-7, "filip gsl_fit_multilinear c10")
86
+
87
+ diag = cov.diagonal
88
+
89
+ test_rel(diag[0], pow(expected_sd[0],2.0), 1e-6,
90
+ "filip gsl_fit_multilinear cov00") ;
91
+ test_rel(diag[1], pow(expected_sd[1],2.0), 1e-6,
92
+ "filip gsl_fit_multilinear cov11") ;
93
+ test_rel(diag[2], pow(expected_sd[2],2.0), 1e-6,
94
+ "filip gsl_fit_multilinear cov22") ;
95
+ test_rel(diag[3], pow(expected_sd[3],2.0), 1e-6,
96
+ "filip gsl_fit_multilinear cov33") ;
97
+ test_rel(diag[4], pow(expected_sd[4],2.0), 1e-6,
98
+ "filip gsl_fit_multilinear cov44") ;
99
+ test_rel(diag[5], pow(expected_sd[5],2.0), 1e-6,
100
+ "filip gsl_fit_multilinear cov55") ;
101
+ test_rel(diag[6], pow(expected_sd[6],2.0), 1e-6,
102
+ "filip gsl_fit_multilinear cov66") ;
103
+ test_rel(diag[7], pow(expected_sd[7],2.0), 1e-6,
104
+ "filip gsl_fit_multilinear cov77") ;
105
+ test_rel(diag[8], pow(expected_sd[8],2.0), 1e-6,
106
+ "filip gsl_fit_multilinear cov88") ;
107
+ test_rel(diag[9], pow(expected_sd[9],2.0), 1e-6,
108
+ "filip gsl_fit_multilinear cov99") ;
109
+ test_rel(diag[10], pow(expected_sd[10],2.0), 1e-6, "filip gsl_fit_multilinear cov1010") ;
110
+
111
+ test_rel(chisq, expected_chisq, 1e-7, "filip gsl_fit_multilinear chisq")
112
+
113
+ expected_c = GSL::Vector.alloc( -1467.48961422980,
114
+ -2772.17959193342,
115
+ -2316.37108160893,
116
+ -1127.97394098372,
117
+ -354.478233703349,
118
+ -75.1242017393757,
119
+ -10.8753180355343,
120
+ -1.06221498588947,
121
+ -0.670191154593408E-01,
122
+ -0.246781078275479E-02,
123
+ -0.402962525080404E-04)
124
+ expected_cov = GSL::Matrix.alloc([ 7.9269341767252183262588583867942e9, 1.4880416622254098343441063389706e10, 1.2385811858111487905481427591107e10, 6.0210784406215266653697715794241e9, 1.8936652526181982747116667336389e9, 4.0274900618493109653998118587093e8, 5.8685468011819735806180092394606e7, 5.7873451475721689084330083708901e6, 3.6982719848703747920663262917032e5, 1.3834818802741350637527054170891e4, 2.301758578713219280719633494302e2 ],
125
+ [ 1.4880416622254098334697515488559e10, 2.7955091668548290835529555438088e10, 2.3286604504243362691678565997033e10, 1.132895006796272983689297219686e10, 3.5657281653312473123348357644683e9, 7.5893300392314445528176646366087e8, 1.1066654886143524811964131660002e8, 1.0921285448484575110763947787775e7, 6.9838139975394769253353547606971e5, 2.6143091775349597218939272614126e4, 4.3523386330348588614289505633539e2 ],
126
+ [ 1.2385811858111487890788272968677e10, 2.3286604504243362677757802422747e10, 1.9412787917766676553608636489674e10, 9.4516246492862131849077729250098e9, 2.9771226694709917550143152097252e9, 6.3413035086730038062129508949859e8, 9.2536164488309401636559552742339e7, 9.1386304643423333815338760248027e6, 5.8479478338916429826337004060941e5, 2.1905933113294737443808429764554e4, 3.6493161325305557266196635180155e2 ], [ 6.0210784406215266545770691532365e9, 1.1328950067962729823273441573365e10, 9.4516246492862131792040001429636e9, 4.6053152992000107509329772255094e9, 1.4517147860312147098138030287038e9, 3.0944988323328589376402579060072e8, 4.5190223822292688669369522708712e7, 4.4660958693678497534529855690752e6, 2.8599340736122198213681258676423e5, 1.0720394998549386596165641244705e4, 1.7870937745661967319298031044424e2 ], [ 1.8936652526181982701620450132636e9, 3.5657281653312473058825073094524e9, 2.9771226694709917514149924058297e9, 1.451714786031214708936087401632e9, 4.5796563896564815123074920050827e8, 9.7693972414561515534525103622773e7, 1.427717861635658545863942948444e7, 1.4120161287735817621354292900338e6, 9.0484361228623960006818614875557e4, 3.394106783764852373199087455398e3, 5.6617406468519495376287407526295e1 ], [ 4.0274900618493109532650887473599e8, 7.589330039231444534478894935778e8, 6.3413035086730037947153564986653e8, 3.09449883233285893390542947998e8, 9.7693972414561515475770399055121e7, 2.0855726248311948992114244257719e7, 3.0501263034740400533872858749566e6, 3.0187475839310308153394428784224e5, 1.9358204633534233524477930175632e4, 7.2662989867560017077361942813911e2, 1.2129002231061036467607394277965e1 ],
127
+ [ 5.868546801181973559370854830868e7, 1.1066654886143524778548044386795e8, 9.2536164488309401413296494869777e7, 4.5190223822292688587853853162072e7, 1.4277178616356585441556046753562e7, 3.050126303474040051574715592746e6, 4.4639982579046340884744460329946e5, 4.4212093985989836047285007760238e4, 2.8371395028774486687625333589972e3, 1.0656694507620102300567296504381e2, 1.7799982046359973175080475654123e0 ], [ 5.7873451475721688839974153925406e6, 1.0921285448484575071271480643397e7, 9.1386304643423333540728480344578e6, 4.4660958693678497427674903565664e6, 1.4120161287735817596182229182587e6, 3.0187475839310308117812257613082e5, 4.4212093985989836021482392757677e4, 4.3818874017028389517560906916315e3, 2.813828775753142855163154605027e2, 1.0576188138416671883232607188969e1, 1.7676976288918295012452853715408e-1 ],
128
+ [ 3.6982719848703747742568351456818e5, 6.9838139975394768959780068745979e5, 5.8479478338916429616547638954781e5, 2.8599340736122198128717796825489e5, 9.0484361228623959793493985226792e4, 1.9358204633534233490579641064343e4, 2.8371395028774486654873647731797e3, 2.8138287757531428535592907878017e2, 1.8081118503579798222896804627964e1, 6.8005074291434681866415478598732e-1, 1.1373581557749643543869665860719e-2 ],
129
+ [ 1.3834818802741350562839757244708e4, 2.614309177534959709397445440919e4, 2.1905933113294737352721470167247e4, 1.0720394998549386558251721913182e4, 3.3941067837648523632905604575131e3, 7.2662989867560016909534954790835e2, 1.0656694507620102282337905013451e2, 1.0576188138416671871337685672492e1, 6.8005074291434681828743281967838e-1, 2.5593857187900736057022477529078e-2, 4.2831487599116264442963102045936e-4 ],
130
+ [ 2.3017585787132192669801658674163e2, 4.3523386330348588381716460685124e2, 3.6493161325305557094116270974735e2, 1.7870937745661967246233792737255e2, 5.6617406468519495180024059284629e1, 1.2129002231061036433003571679329e1, 1.7799982046359973135014027410646e0, 1.7676976288918294983059118597214e-1, 1.137358155774964353146460100337e-2, 4.283148759911626442000316269063e-4, 7.172253875245080423800933453952e-6 ])
131
+
132
+ expected_chisq = 0.795851382172941E-03;
133
+
134
+ for i in 0...Filip_n
135
+ for j in 0...Filip_p
136
+ xx.set(i, j, pow(Filip_x[i], j))
137
+ end
138
+ end
139
+
140
+ w = GSL::Vector.alloc(Filip_n)
141
+ w.set_all(1.0)
142
+
143
+ c, cov, chisq, status = GSL::MultiFit.wlinear(xx, w, Filip_y, work)
144
+ for i in 0...Filip_p
145
+ test_rel(c[i], expected_c[i], 1e-7, "filip gsl_fit_multilinear c#{i}")
146
+ end
147
+ for i in 0...Filip_p
148
+ for j in 0...Filip_p
149
+ test_rel(cov[i,j], expected_cov[i,j], 1e-6,
150
+ "filip gsl_fit_wmultilinear cov(#{i},#{j})")
151
+ end
152
+ end
153
+ end
154
+
155
+ test_filip()
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ # vim: set ts=8 sw=2 sts=2:
3
+ #require("gsl")
4
+ #require("../gsl_test2.rb")
5
+ require("./test_multifit.rb")
6
+ include GSL::Test
7
+ include Math
8
+
9
+ Maxiter = 10
10
+ N = 1000
11
+
12
+ # model: a*exp(-(x-x0)**2/2/sigma**2)
13
+ gauss_p = 3
14
+ gauss_f = Proc.new { |x, t, y, s, f|
15
+ # x: parameters as a Vecor
16
+ # t: observed points as a GSL::Vector
17
+ # y: observed data as a GSL::Vector
18
+ # s: errorbar
19
+ # f: result
20
+ a = x[0]
21
+ x0 = x[1]
22
+ sigma2 = x[2]**2
23
+ y.size.times do |i|
24
+ f.set(i, (a*Math::exp(-(t[i] - x0)**2/2/sigma2) - y[i])/s[i])
25
+ end
26
+ GSL::SUCCESS
27
+ }
28
+
29
+ gauss_df = Proc.new { |x, t, y, s, df|
30
+ a = x[0]
31
+ x0 = x[1]
32
+ sigma = x[2]
33
+ sigma2 = sigma**2
34
+ y.size.times do |i|
35
+ dx = t[i] - x0
36
+ dx2 = dx**2
37
+ f = a*Math::exp(-dx2/2/sigma2)
38
+ df.set(i, 0, f/a/s[i])
39
+ df.set(i, 1, f*dx/sigma2/s[i])
40
+ df.set(i, 2, f*dx2/sigma2/sigma/s[i])
41
+ end
42
+ GSL::SUCCESS
43
+ }
44
+
45
+ # goal
46
+ xgoal = GSL::Vector.alloc([1, 0, 1])
47
+ parname = %w( a x0 si )
48
+
49
+ # data
50
+ t = GSL::Vector.alloc(N) # positions of data
51
+ tmin = -10.0
52
+ tmax = 10.0
53
+ t.size.times do |i|
54
+ t[i] = tmin + (tmax - tmin)*i/(N-1)
55
+ end
56
+ stdev = xgoal[0]*0.1
57
+ s = GSL::Vector.alloc(Array.new(t.size, stdev)) # error bar of each datum
58
+ r = Rng.alloc
59
+ e = GSL::Vector.alloc(t.size)
60
+ t.size.times do |i|
61
+ e[i] = -r.gaussian(stdev) # perturbation to data
62
+ end
63
+ y = GSL::Vector.alloc(t.size)
64
+ n = GSL::Vector.alloc(Array.new(t.size, 1.0))
65
+ gauss_f.call(xgoal, t, e, n, y) # data: y = model - e
66
+
67
+ # fitting
68
+ x = GSL::Vector.alloc([0.5, 0.1, 2]) # initial guess
69
+ fdf = GSL::MultiFit::Function_fdf.alloc(gauss_f, gauss_df, gauss_p)
70
+ fdf.set_data(t, y, s)
71
+
72
+ solver = GSL::MultiFit::FdfSolver.alloc(GSL::MultiFit::FdfSolver::LMSDER, t.size, gauss_p)
73
+ solver.set(fdf, x)
74
+
75
+ solver.print_state(0)
76
+ Maxiter.times do |i|
77
+ solver.iterate
78
+ status = solver.test_delta(1e-6, 1e-6)
79
+ solver.print_state(i+1)
80
+ break unless GSL::CONTINUE == status
81
+ end
82
+
83
+ # results
84
+ covar = solver.covar(0.0)
85
+ xresult = solver.position
86
+ dof = t.size - gauss_p
87
+ chi2 = pow_2(solver.f.dnrm2)
88
+ xsigma = GSL::Vector.alloc(xresult.size)
89
+ xresult.size.times do |i|
90
+ xsigma[i] = Math::sqrt(chi2/dof*covar[i,i]) * 2.0
91
+ # resulting parameters to differ two times than standard error
92
+ end
93
+ puts("a*exp(-(x-x0)**2/2/si**2), chi2/N:%.3g" % (chi2/t.size))
94
+ xresult.size.times do |i|
95
+ test_rel(xresult[i], xgoal[i], xsigma[i], "%-2.2s" % parname[i])
96
+ exit 1 if (xresult[i] - xgoal[i]).abs > xsigma[i]
97
+ end
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env ruby
2
+ require("gsl")
3
+ require("../gsl_test2.rb")
4
+ include GSL::Test
5
+ include Math
6
+
7
+ Longley_n = 16;
8
+ Longley_p = 7;
9
+
10
+
11
+ Longley_x = GSL::Vector.alloc(1, 83.0, 234289, 2356, 1590, 107608, 1947,
12
+ 1, 88.5, 259426, 2325, 1456, 108632, 1948,
13
+ 1, 88.2, 258054, 3682, 1616, 109773, 1949,
14
+ 1, 89.5, 284599, 3351, 1650, 110929, 1950,
15
+ 1, 96.2, 328975, 2099, 3099, 112075, 1951,
16
+ 1, 98.1, 346999, 1932, 3594, 113270, 1952,
17
+ 1, 99.0, 365385, 1870, 3547, 115094, 1953,
18
+ 1, 100.0, 363112, 3578, 3350, 116219, 1954,
19
+ 1, 101.2, 397469, 2904, 3048, 117388, 1955,
20
+ 1, 104.6, 419180, 2822, 2857, 118734, 1956,
21
+ 1, 108.4, 442769, 2936, 2798, 120445, 1957,
22
+ 1, 110.8, 444546, 4681, 2637, 121950, 1958,
23
+ 1, 112.6, 482704, 3813, 2552, 123366, 1959,
24
+ 1, 114.2, 502601, 3931, 2514, 125368, 1960,
25
+ 1, 115.7, 518173, 4806, 2572, 127852, 1961,
26
+ 1, 116.9, 554894, 4007, 2827, 130081, 1962)
27
+
28
+ Longley_y = GSL::Vector.alloc(60323, 61122, 60171, 61187, 63221, 63639, 64989, 63761,
29
+ 66019, 67857, 68169, 66513, 68655, 69564, 69331, 70551)
30
+
31
+ def test_longley()
32
+ work = GSL::MultiFit::Workspace.alloc(Longley_n, Longley_p)
33
+ x = GSL::Matrix.alloc(Longley_x, Longley_n, Longley_p).view
34
+ y = Longley_y.view
35
+ expected_c = GSL::Vector.alloc(-3482258.63459582,
36
+ 15.0618722713733,
37
+ -0.358191792925910E-01,
38
+ -2.02022980381683,
39
+ -1.03322686717359,
40
+ -0.511041056535807E-01,
41
+ 1829.15146461355)
42
+ expected_sd = GSL::Vector.alloc(890420.383607373,
43
+ 84.9149257747669,
44
+ 0.334910077722432E-01,
45
+ 0.488399681651699,
46
+ 0.214274163161675,
47
+ 0.226073200069370,
48
+ 455.478499142212)
49
+ expected_chisq = 836424.055505915
50
+
51
+ c, cov, chisq, status = GSL::MultiFit.linear(x, y, work)
52
+ for i in 0...7
53
+ test_rel(c[i], expected_c[i], 1e-10, "longley gsl_fit_multilinear c#{i}")
54
+ end
55
+ diag = cov.diagonal
56
+ test_rel(diag[0], pow(expected_sd[0],2.0), 1e-10, "longley gsl_fit_multilinear cov00") ;
57
+ test_rel(diag[1], pow(expected_sd[1],2.0), 1e-10, "longley gsl_fit_multilinear cov11") ;
58
+ test_rel(diag[2], pow(expected_sd[2],2.0), 1e-10, "longley gsl_fit_multilinear cov22") ;
59
+ test_rel(diag[3], pow(expected_sd[3],2.0), 1e-10, "longley gsl_fit_multilinear cov33") ;
60
+ test_rel(diag[4], pow(expected_sd[4],2.0), 1e-10, "longley gsl_fit_multilinear cov44") ;
61
+ test_rel(diag[5], pow(expected_sd[5],2.0), 1e-10, "longley gsl_fit_multilinear cov55") ;
62
+ test_rel(diag[6], pow(expected_sd[6],2.0), 1e-10, "longley gsl_fit_multilinear cov66") ;
63
+ test_rel(chisq, expected_chisq, 1e-10, "longley gsl_fit_multilinear chisq")
64
+
65
+ ###################
66
+ expected_cov = GSL::Matrix.alloc([8531122.56783558,
67
+ -166.727799925578, 0.261873708176346, 3.91188317230983,
68
+ 1.1285582054705, -0.889550869422687, -4362.58709870581],
69
+
70
+ [-166.727799925578, 0.0775861253030891, -1.98725210399982e-05,
71
+ -0.000247667096727256, -6.82911920718824e-05, 0.000136160797527761,
72
+ 0.0775255245956248],
73
+
74
+ [0.261873708176346, -1.98725210399982e-05, 1.20690316701888e-08,
75
+ 1.66429546772984e-07, 3.61843600487847e-08, -6.78805814483582e-08,
76
+ -0.00013158719037715],
77
+
78
+ [3.91188317230983, -0.000247667096727256, 1.66429546772984e-07,
79
+ 2.56665052544717e-06, 6.96541409215597e-07, -9.00858307771567e-07,
80
+ -0.00197260370663974],
81
+
82
+ [1.1285582054705, -6.82911920718824e-05, 3.61843600487847e-08,
83
+ 6.96541409215597e-07, 4.94032602583969e-07, -9.8469143760973e-08,
84
+ -0.000576921112208274],
85
+ [-0.889550869422687, 0.000136160797527761, -6.78805814483582e-08,
86
+ -9.00858307771567e-07, -9.8469143760973e-08, 5.49938542664952e-07,
87
+ 0.000430074434198215],
88
+
89
+ [-4362.58709870581, 0.0775255245956248, -0.00013158719037715,
90
+ -0.00197260370663974, -0.000576921112208274, 0.000430074434198215,
91
+ 2.23229587481535 ])
92
+
93
+ expected_chisq = 836424.055505915
94
+ w = GSL::Vector.alloc(Longley_n)
95
+ w.set_all(1.0)
96
+ c, cov, chisq, status = GSL::MultiFit.wlinear(x, w, y, work)
97
+ for i in 0...7
98
+ test_rel(c[i], expected_c[i], 1e-10, "longley gsl_fit_wmultilinear c#{i}") ;
99
+ end
100
+
101
+ for i in 0...Longley_p
102
+ for j in 0...Longley_p
103
+ test_rel(cov[i,j], expected_cov[i,j], 1e-7,
104
+ "longley gsl_fit_wmultilinear cov(#{i},#{j})")
105
+ end
106
+ end
107
+ test_rel(chisq, expected_chisq, 1e-10, "longley gsl_fit_wmultilinear chisq")
108
+ end
109
+
110
+ test_longley()
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+ require("gsl")
3
+ require("../gsl_test2.rb")
4
+ include GSL::Test
5
+ include Math
6
+
7
+ def test_lmder(fdf, x, xx, f, cov)
8
+ s = GSL::MultiFit::FdfSolver.alloc("lmsder", fdf.n, fdf.p)
9
+ s.set(fdf, x)
10
+ iter = 0
11
+ begin
12
+ status = s.iterate
13
+ for i in 0...fdf.p
14
+ test_rel(s.x[i], xx[fdf.p*iter+i], 1e-5, "lmsder, iter=#{iter}, x#{i}")
15
+ end
16
+ test_rel(Blas.dnrm2(s.f), f[iter], 1e-5, "lmsder, iter=#{iter}, f")
17
+ iter += 1
18
+ end while iter < 20
19
+ covar = s.covar(0.0)
20
+ for i in 0...fdf.p
21
+ for j in 0...fdf.p
22
+ test_rel(covar[i,j], cov[i*fdf.p+j], 1e-7,
23
+ "gsl_multifit_covar cov(#{i},#{j})")
24
+ end
25
+ end
26
+ end
27
+
28
+ def test_fdf(name, fdf, x, x_final, f_sumsq, sigma)
29
+ s = GSL::MultiFit::FdfSolver.alloc("lmsder", fdf.n, fdf.p)
30
+ s.set(fdf, x)
31
+ iter = 0
32
+ begin
33
+ status = s.iterate
34
+ # status = GSL::MultiFit::test_delta(s.dx, s.x, 0.0, 1e-7)
35
+ status = s.test_delta(0.0, 1e-7)
36
+ iter += 1
37
+ end while status == GSL::CONTINUE and iter < 1000
38
+ covar = s.covar(0.0)
39
+ for i in 0...fdf.p
40
+ test_rel(s.x[i], x_final[i], 1e-5, "#{name}, lmsder, x#{i}")
41
+ end
42
+ s2 = pow(Blas.dnrm2(s.f), 2.0)
43
+ test_rel(s2, f_sumsq, 1e-5, "#{name}, lmsder, |f|^2")
44
+ for i in 0...fdf.p
45
+ ei = sqrt(s2/(fdf.n-fdf.p))*sqrt(covar[i,i]);
46
+ test_rel(ei, sigma[i], 1e-4, "#{name}, sigma(#{i})")
47
+ end
48
+ end
49
+
50
+ GSL::IEEE::env_setup()
51
+
52
+
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env ruby
2
+ # Ruby/GSL implementation of GSL "multimin/test.c"
3
+ require("gsl")
4
+ require("./gsl_test2.rb")
5
+ include GSL::Test
6
+ include Math
7
+
8
+ def test_fdf(desc, f, initpt, type)
9
+ x = eval("#{initpt}")
10
+ step_size = 0.1*Blas.dnrm2(x)
11
+ s = GSL::MultiMin::FdfMinimizer.alloc(type, f.n)
12
+ s.set(f, x, step_size, 0.1)
13
+ iter = 0
14
+ begin
15
+ iter += 1
16
+ status = s.iterate
17
+ status = GSL::MultiMin.test_gradient(s.gradient, 1e-3)
18
+ end while iter < 5000 and status == GSL::CONTINUE
19
+ status |= s.f.abs > 1e-5 ? 1 : 0
20
+ GSL::Test::test(status, "#{s.name}, on #{desc}: #{iter} iterations, f(x)=#{s.f}")
21
+ end
22
+
23
+ def test_f(desc, f, initpt)
24
+ x = eval("#{initpt}")
25
+ step_size = GSL::Vector.alloc(f.n)
26
+ for i in 0...f.n
27
+ step_size[i] = 1
28
+ end
29
+ s = GSL::MultiMin::FMinimizer.alloc("nmsimplex", f.n)
30
+ s.set(f, x, step_size)
31
+ iter = 0
32
+ begin
33
+ status = s.iterate
34
+ status = GSL::MultiMin.test_size(s.size, 1e-3)
35
+ end while iter < 5000 and status == GSL::CONTINUE
36
+
37
+ status |= s.fval.abs > 1e-5 ? 1 : 0
38
+ GSL::Test::test(status, "#{s.name}, on #{desc}: #{iter} iterations, f(x)=#{s.fval}")
39
+
40
+ s = GSL::MultiMin::FMinimizer.alloc("nmsimplex2rand", f.n)
41
+ s.set(f, x, step_size)
42
+ iter = 0
43
+ begin
44
+ status = s.iterate
45
+ status = GSL::MultiMin.test_size(s.size, 1e-3)
46
+ end while iter < 5000 and status == GSL::CONTINUE
47
+
48
+ status |= s.fval.abs > 1e-5 ? 1 : 0
49
+ GSL::Test::test(status, "#{s.name}, on #{desc}: #{iter} iterations, f(x)=#{s.fval}")
50
+ end
51
+
52
+ def roth_initpt
53
+ return GSL::Vector.alloc(4.5, 3.5)
54
+ end
55
+
56
+ def wood_initpt
57
+ return GSL::Vector.alloc(-3.0, -1.0, -3.0, -1.0)
58
+ end
59
+
60
+ def rosenbrock_initpt
61
+ return GSL::Vector.alloc(-1.2, 1.0)
62
+ end
63
+
64
+ Roth_f = Proc.new { |x|
65
+ u = x[0]
66
+ v = x[1]
67
+ a = -13.0 + u + ((5.0 - v)*v - 2.0)*v;
68
+ b = -29.0 + u + ((v + 1.0)*v - 14.0)*v;
69
+ a * a + b * b;
70
+ }
71
+
72
+ Roth_df = Proc.new { |x, df|
73
+ u = x[0]
74
+ v = x[1]
75
+ a = -13.0 + u + ((5.0 - v)*v - 2.0)*v
76
+ b = -29.0 + u + ((v + 1.0)*v - 14.0)*v
77
+ c = -2 + v * (10 - 3 * v)
78
+ d = -14 + v * (2 + 3 * v)
79
+ df[0] = 2 * a + 2 * b
80
+ df[1] = 2 * a * c + 2 * b * d
81
+ }
82
+
83
+ Wood_f = Proc.new { |x|
84
+ u1 = x[0]; u2 = x[1]; u3 = x[2]; u4 = x[3]
85
+ t1 = u1*u1 - u2
86
+ t2 = u3*u3 - u4
87
+ 100 * t1 * t1 + (1 - u1) * (1 - u1) + 90 * t2 * t2 + (1 - u3) * (1 - u3) + 10.1 * ( (1 - u2) * (1 - u2) + (1 - u4) * (1 - u4) ) + 19.8 * (1 - u2) * (1 - u4)
88
+ }
89
+
90
+ Wood_df = Proc.new { |x, df|
91
+ u1 = x[0]; u2 = x[1]; u3 = x[2]; u4 = x[3]
92
+ t1 = u1*u1 - u2
93
+ t2 = u3*u3 - u4
94
+ df[0] = 400 * u1 * t1 - 2 * (1 - u1)
95
+ df[1] = -200 * t1 - 20.2 * (1 - u2) - 19.8 * (1 - u4)
96
+ df[2] = 360 * u3 * t2 - 2 * (1 - u3)
97
+ df[3] = -180 * t2 - 20.2 * (1 - u4) - 19.8 * (1 - u2)
98
+ }
99
+
100
+ Rosenbrock_f = Proc.new { |x|
101
+ u = x[0]; v = x[1]
102
+ a = u - 1
103
+ b = u*u - v
104
+ a*a + 10.0*b*b
105
+ }
106
+
107
+ Rosenbrock_df = Proc.new { |x, df|
108
+ u = x[0]; v = x[1]
109
+ a = u - 1
110
+ b = u*u - v
111
+ df[0] = 2 * (u - 1) + 40 * u * b
112
+ df[1] = -20 * b
113
+ }
114
+
115
+ if GSL::GSL_VERSION >= "1.8.90"
116
+ fdfminimizers = ["steepest_descent", "conjugate_pr", "conjugate_fr",
117
+ "vector_bfgs", "vector_bfgs2"]
118
+ else
119
+ fdfminimizers = ["steepest_descent", "conjugate_pr", "conjugate_fr",
120
+ "vector_bfgs"]
121
+ end
122
+
123
+ Rothdf = GSL::MultiMin::Function_fdf.alloc(Roth_f, Roth_df, 2)
124
+ Wooddf = GSL::MultiMin::Function_fdf.alloc(Wood_f, Wood_df, 4)
125
+ Rosenbrockdf = GSL::MultiMin::Function_fdf.alloc(Rosenbrock_f, Rosenbrock_df, 2)
126
+ fdfminimizers.each do |t|
127
+ test_fdf("Roth", Rothdf, "roth_initpt", t)
128
+ test_fdf("Wood", Wooddf, "wood_initpt", t)
129
+ test_fdf("Rosenbrock", Rosenbrockdf, "rosenbrock_initpt", t)
130
+ end
131
+
132
+ rothf = GSL::MultiMin::Function.alloc(Roth_f, 2)
133
+ test_f("Roth", rothf, "roth_initpt")
134
+
135
+ woodf = GSL::MultiMin::Function.alloc(Wood_f, 4)
136
+ test_f("Wood", woodf, "wood_initpt")
137
+
138
+ rosenbrockf = GSL::MultiMin::Function.alloc(Rosenbrock_f, 2)
139
+ test_f("Rosenbrock", rosenbrockf, "rosenbrock_initpt")