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,139 @@
1
+ #include "rb_gsl.h"
2
+
3
+ /*!
4
+ Counter-clockwise rotation around the X-axis
5
+
6
+ / x' \ / 1 0 0 \ / x \
7
+ | y' | = | 0 cos_th -sin_th | | y |
8
+ \ z' / \ 0 sin_th cos_th / \ z /
9
+
10
+ */
11
+ void vector3_rotateX(const double x[3] /*!< Input */,
12
+ double theta /*!< Rotation angle */,
13
+ double xout[3] /*!< Output */)
14
+ {
15
+ double a, b, c;
16
+ double costheta, sintheta;
17
+
18
+ costheta = cos(theta);
19
+ sintheta = sin(theta);
20
+
21
+ a = x[0];
22
+ b = x[1]*costheta - x[2]*sintheta;
23
+ c = x[1]*sintheta + x[2]*costheta;
24
+
25
+ xout[0] = a;
26
+ xout[1] = b;
27
+ xout[2] = c;
28
+ }
29
+
30
+ /*!
31
+ Counter-clockwise rotation around the Y-axis
32
+ (Note the sign of the matrix element.)
33
+
34
+ / x' \ / cos_th 0 sin_th \ / x \
35
+ | y' | = | 0 1 0 | | y |
36
+ \ z' / \ -sin_th 0 cos_th / \ z /
37
+
38
+ */
39
+ void vector3_rotateY(const double x[3] /*!< Input */,
40
+ double theta /*!< Rotation angle */,
41
+ double xout[3] /*!< Output */)
42
+ {
43
+ double a, b, c;
44
+ double costheta, sintheta;
45
+
46
+ costheta = cos(theta);
47
+ sintheta = sin(theta);
48
+
49
+ a = x[0]*costheta + x[2]*sintheta;
50
+ b = x[1];
51
+ c = -x[0]*sintheta + x[2]*costheta;
52
+
53
+ xout[0] = a;
54
+ xout[1] = b;
55
+ xout[2] = c;
56
+ }
57
+
58
+ /*!
59
+ Counter-clockwise rotation around the Z-axis
60
+
61
+ / x' \ / cos_th -sin_th 0 \ / x \
62
+ | y' | = | sin_th cos_th 0 | | y |
63
+ \ z' / \ 0 0 1 / \ z /
64
+
65
+ */
66
+ void vector3_rotateZ(const double x[3] /*!< Input */,
67
+ double theta /*!< Rotation angle */,
68
+ double xout[3] /*!< Output */)
69
+ {
70
+ double a, b, c;
71
+ double costheta, sintheta;
72
+
73
+ costheta = cos(theta);
74
+ sintheta = sin(theta);
75
+
76
+ a = x[0]*costheta - x[1]*sintheta;
77
+ b = x[0]*sintheta + x[1]*costheta;
78
+ c = x[2];
79
+
80
+ xout[0] = a;
81
+ xout[1] = b;
82
+ xout[2] = c;
83
+ }
84
+
85
+ /*!
86
+ Rotate a 3-vector.
87
+
88
+ If flag != 1, cos/sin values stored in the static variables are used
89
+ for efficiency.
90
+ The input and the output vectors (x, xout) can be the same pointer.
91
+
92
+ / x' \ / cos_phi -sin_phi 0 \ / cos_th 0 sin_th \ / x \
93
+ | y' | = | sin_phi cos_phi 0 | | 0 1 | | y |
94
+ \ z' / \ 0 0 1 / \ -sin_th 0 cos_th / \ z /
95
+
96
+ */
97
+ void vector3_rotate(const double x[3], double theta, double phi,
98
+ double xout[3])
99
+ {
100
+ vector3_rotateY(x, theta,xout);
101
+ vector3_rotateZ(xout, phi, xout);
102
+ }
103
+
104
+ static VALUE rb_gsl_vector_rotateX(VALUE obj, VALUE angle)
105
+ {
106
+ gsl_vector *v;
107
+ Data_Get_Struct(obj, gsl_vector, v);
108
+ vector3_rotateX(v->data, NUM2DBL(angle), v->data);
109
+ return obj;
110
+ }
111
+ static VALUE rb_gsl_vector_rotateY(VALUE obj, VALUE angle)
112
+ {
113
+ gsl_vector *v;
114
+ Data_Get_Struct(obj, gsl_vector, v);
115
+ vector3_rotateY(v->data, NUM2DBL(angle), v->data);
116
+ return obj;
117
+ }
118
+ static VALUE rb_gsl_vector_rotateZ(VALUE obj, VALUE angle)
119
+ {
120
+ gsl_vector *v;
121
+ Data_Get_Struct(obj, gsl_vector, v);
122
+ vector3_rotateZ(v->data, NUM2DBL(angle), v->data);
123
+ return obj;
124
+ }
125
+ static VALUE rb_gsl_vector_rotate(VALUE obj, VALUE theta, VALUE phi)
126
+ {
127
+ gsl_vector *v;
128
+ Data_Get_Struct(obj, gsl_vector, v);
129
+ vector3_rotate(v->data, NUM2DBL(theta), NUM2DBL(phi), v->data);
130
+ return obj;
131
+ }
132
+
133
+ void Init_geometry(VALUE module)
134
+ {
135
+ rb_define_method(cgsl_vector, "rotateX", rb_gsl_vector_rotateX, 1);
136
+ rb_define_method(cgsl_vector, "rotateY", rb_gsl_vector_rotateY, 1);
137
+ rb_define_method(cgsl_vector, "rotateZ", rb_gsl_vector_rotateZ, 1);
138
+ rb_define_method(cgsl_vector, "rotate", rb_gsl_vector_rotate, 2);
139
+ }
@@ -0,0 +1,1640 @@
1
+ /*
2
+ graph.c
3
+ Ruby/GSL: Ruby extension library for GSL (GNU Scientific Library)
4
+ (C) Copyright 2004 by Yoshiki Tsunesada
5
+
6
+ Ruby/GSL is free software: you can redistribute it and/or modify it
7
+ under the terms of the GNU General Public License.
8
+ This library is distributed in the hope that it will be useful, but
9
+ WITHOUT ANY WARRANTY.
10
+ */
11
+ #include "rb_gsl_config.h"
12
+ #include "rb_gsl_graph.h"
13
+
14
+ void make_graphcommand(char *command, VALUE hash)
15
+ {
16
+ VALUE val;
17
+ if (TYPE(hash) == T_STRING) {
18
+ sprintf(command, "graph -T X -g 3 %s", STR2CSTR(hash));
19
+ return;
20
+ }
21
+
22
+ strcpy(command, "graph");
23
+ if (TYPE(hash) != T_HASH) rb_raise(rb_eTypeError,
24
+ "wrong argument type %s (Hash expected)",
25
+ rb_class2name(CLASS_OF(hash)));
26
+ if ((val = rb_hash_aref(hash, rb_str_new2("T"))) != Qnil)
27
+ sprintf(command, "%s -T %s", command, STR2CSTR(val));
28
+ else
29
+ sprintf(command, "%s -T X", command);
30
+
31
+ val = rb_hash_aref(hash, rb_str_new2("C"));
32
+ if (val == Qtrue)
33
+ sprintf(command, "%s -C", command);
34
+
35
+ if ((val = rb_hash_aref(hash, rb_str_new2("g"))) != Qnil)
36
+ sprintf(command, "%s -g %d", command, (int) FIX2INT(val));
37
+ else
38
+ sprintf(command, "%s -g 3", command);
39
+
40
+ if ((val = rb_hash_aref(hash, rb_str_new2("B"))) == Qtrue)
41
+ sprintf(command, "%s -B", command);
42
+ if ((val = rb_hash_aref(hash, rb_str_new2("E"))) != Qnil)
43
+ sprintf(command, "%s -E %s", command, STR2CSTR(val));
44
+ if ((val = rb_hash_aref(hash, rb_str_new2("f"))) != Qnil)
45
+ sprintf(command, "%s -f %f", command, NUM2DBL(val));
46
+ if ((val = rb_hash_aref(hash, rb_str_new2("F"))) != Qnil)
47
+ sprintf(command, "%s -F %s", command, STR2CSTR(val));
48
+
49
+ if ((val = rb_hash_aref(hash, rb_str_new2("h"))) != Qnil)
50
+ sprintf(command, "%s -h %f", command, NUM2DBL(val));
51
+ if ((val = rb_hash_aref(hash, rb_str_new2("k"))) != Qnil)
52
+ sprintf(command, "%s -k %f", command, NUM2DBL(val));
53
+ if ((val = rb_hash_aref(hash, rb_str_new2("K"))) != Qnil)
54
+ sprintf(command, "%s -K %d", command, (int) FIX2INT(val));
55
+ if ((val = rb_hash_aref(hash, rb_str_new2("l"))) != Qnil) {
56
+ if (str_tail_grep(STR2CSTR(val), "xy") || str_tail_grep(STR2CSTR(val), "x/y"))
57
+ sprintf(command, "%s -l x -l y", command);
58
+ else
59
+ sprintf(command, "%s -l %s", command, STR2CSTR(val));
60
+ }
61
+
62
+ if ((val = rb_hash_aref(hash, rb_str_new2("L"))) != Qnil)
63
+ sprintf(command, "%s -L \"%s\"", command, STR2CSTR(val));
64
+ if ((val = rb_hash_aref(hash, rb_str_new2("N"))) != Qnil)
65
+ sprintf(command, "%s -N %s", command, STR2CSTR(val));
66
+ if ((val = rb_hash_aref(hash, rb_str_new2("r"))) != Qnil)
67
+ sprintf(command, "%s -r %f", command, NUM2DBL(val));
68
+ if ((val = rb_hash_aref(hash, rb_str_new2("R"))) != Qnil)
69
+ sprintf(command, "%s -R %s", command, STR2CSTR(val));
70
+ if ((val = rb_hash_aref(hash, rb_str_new2("s"))) == Qtrue)
71
+ sprintf(command, "%s -s", command);
72
+ if ((val = rb_hash_aref(hash, rb_str_new2("t"))) == Qtrue)
73
+ sprintf(command, "%s -t", command);
74
+ if ((val = rb_hash_aref(hash, rb_str_new2("u"))) != Qnil)
75
+ sprintf(command, "%s -u %f", command, NUM2DBL(val));
76
+ if ((val = rb_hash_aref(hash, rb_str_new2("w"))) != Qnil)
77
+ sprintf(command, "%s -w %f", command, NUM2DBL(val));
78
+ if ((val = rb_hash_aref(hash, rb_str_new2("x"))) != Qnil)
79
+ sprintf(command, "%s -x %s", command, STR2CSTR(val));
80
+ if ((val = rb_hash_aref(hash, rb_str_new2("X"))) != Qnil)
81
+ sprintf(command, "%s -X \"%s\"", command, STR2CSTR(val));
82
+ if ((val = rb_hash_aref(hash, rb_str_new2("y"))) != Qnil)
83
+ sprintf(command, "%s -y %s", command, STR2CSTR(val));
84
+ if ((val = rb_hash_aref(hash, rb_str_new2("Y"))) != Qnil)
85
+ sprintf(command, "%s -Y \"%s\"", command, STR2CSTR(val));
86
+ if ((val = rb_hash_aref(hash, rb_str_new2("bg-color"))) != Qnil)
87
+ sprintf(command, "%s --bg-color %s", command, STR2CSTR(val));
88
+ if ((val = rb_hash_aref(hash, rb_str_new2("bitmap-size"))) != Qnil)
89
+ sprintf(command, "%s --bitmap-size %s", command, STR2CSTR(val));
90
+ if ((val = rb_hash_aref(hash, rb_str_new2("frame-color"))) != Qnil)
91
+ sprintf(command, "%s --frame-color %s", command, STR2CSTR(val));
92
+ if ((val = rb_hash_aref(hash, rb_str_new2("frame-line-width"))) != Qnil)
93
+ sprintf(command, "%s --frame-line-width %f", command, NUM2DBL(val));
94
+ if ((val = rb_hash_aref(hash, rb_str_new2("max-line-length"))) != Qnil)
95
+ sprintf(command, "%s --max-line-length %f", command, NUM2DBL(val));
96
+ if ((val = rb_hash_aref(hash, rb_str_new2("page-size"))) != Qnil)
97
+ sprintf(command, "%s --page-size %s", command, STR2CSTR(val));
98
+ if ((val = rb_hash_aref(hash, rb_str_new2("pen-colors"))) != Qnil)
99
+ sprintf(command, "%s --pen-colors %s", command, STR2CSTR(val));
100
+ if ((val = rb_hash_aref(hash, rb_str_new2("rotation"))) != Qnil)
101
+ sprintf(command, "%s --rotation %f", command, NUM2DBL(val));
102
+ if ((val = rb_hash_aref(hash, rb_str_new2("title-font-name"))) != Qnil)
103
+ sprintf(command, "%s --title-font-name %s", command, STR2CSTR(val));
104
+ if ((val = rb_hash_aref(hash, rb_str_new2("title-font-size"))) != Qnil)
105
+ sprintf(command, "%s --title-font-size %f", command, NUM2DBL(val));
106
+
107
+ if ((val = rb_hash_aref(hash, rb_str_new2("toggle-rotate-y-label"))) == Qtrue)
108
+ sprintf(command, "%s --toggle-rotate-y-label", command);
109
+
110
+ if ((val = rb_hash_aref(hash, rb_str_new2("m"))) != Qnil)
111
+ sprintf(command, "%s -m %d", command, (int) FIX2INT(val));
112
+ if ((val = rb_hash_aref(hash, rb_str_new2("S"))) != Qnil)
113
+ sprintf(command, "%s -S %d", command, (int) FIX2INT(val));
114
+ if ((val = rb_hash_aref(hash, rb_str_new2("W"))) != Qnil)
115
+ sprintf(command, "%s -W %f", command, NUM2DBL(val));
116
+ if ((val = rb_hash_aref(hash, rb_str_new2("q"))) != Qnil)
117
+ sprintf(command, "%s -q %f", command, NUM2DBL(val));
118
+
119
+ if ((val = rb_hash_aref(hash, rb_str_new2("symbol-font-name"))) != Qnil)
120
+ sprintf(command, "%s --symbol-font-name %s", command, STR2CSTR(val));
121
+
122
+ if ((val = rb_hash_aref(hash, rb_str_new2("reposition"))) != Qnil)
123
+ sprintf(command, "%s --reposition %s", command, STR2CSTR(val));
124
+ if ((val = rb_hash_aref(hash, rb_str_new2("blankout"))) != Qnil)
125
+ sprintf(command, "%s --blankout %s", command, STR2CSTR(val));
126
+
127
+ if ((val = rb_hash_aref(hash, rb_str_new2("O"))) == Qtrue)
128
+ sprintf(command, "%s -O", command);
129
+ }
130
+
131
+ static void gsl_graph_init(gsl_graph *g);
132
+ gsl_graph* gsl_graph_new()
133
+ {
134
+ gsl_graph *g = NULL;
135
+ g = ALLOC(gsl_graph);
136
+ gsl_graph_init(g);
137
+ return g;
138
+ }
139
+
140
+ static void gsl_graph_init(gsl_graph *g)
141
+ {
142
+ g->xdata = Qnil;
143
+ g->ydata = Qnil;
144
+
145
+ g->T = Qnil;
146
+ g->E = Qnil;
147
+ g->f = Qnil;
148
+ g->F = Qnil;
149
+ g->g = Qnil;
150
+ g->h = Qnil;
151
+ g->k = Qnil;
152
+ g->K = Qnil;
153
+ g->l = Qnil;
154
+ g->L = Qnil;
155
+ g->N = Qnil;
156
+ g->r = Qnil;
157
+ g->R = Qnil;
158
+ g->u = Qnil;
159
+ g->w = Qnil;
160
+ g->x = Qnil;
161
+ g->y = Qnil;
162
+ g->X = Qnil;
163
+ g->Y = Qnil;
164
+
165
+ g->bg = Qnil;
166
+ g->bitmap_size = Qnil;
167
+ g->frame = Qnil;
168
+ g->frame_line_width = Qnil;
169
+ g->max_line_length = Qnil;
170
+ g->page_size = Qnil;
171
+ g->pen_colors = Qnil;
172
+ g->rotation = Qnil;
173
+ g->title_font_size = Qnil;
174
+ g->title_font_name = Qnil;
175
+ g->rotate_y_label = Qfalse;
176
+
177
+ g->I = Qnil;
178
+ g->m = Qnil;
179
+ g->S = Qnil;
180
+ g->W = Qnil;
181
+ g->q = Qnil;
182
+ g->symbol_font_name = Qnil;
183
+ g->reposition = Qnil;
184
+ g->blankout = Qnil;
185
+
186
+ g->s = Qfalse;
187
+ g->t = Qfalse;
188
+
189
+ g->B = Qfalse;
190
+ g->C = Qfalse;
191
+ g->O = Qfalse;
192
+ }
193
+
194
+ static void gsl_graph_mark(gsl_graph *g)
195
+ {
196
+ rb_gc_mark(g->xdata);
197
+ rb_gc_mark(g->ydata);
198
+ rb_gc_mark(g->T);
199
+ rb_gc_mark(g->E);
200
+ rb_gc_mark(g->f);
201
+ rb_gc_mark(g->F);
202
+ rb_gc_mark(g->g);
203
+ rb_gc_mark(g->h);
204
+ rb_gc_mark(g->k);
205
+ rb_gc_mark(g->K);
206
+ rb_gc_mark(g->l);
207
+ rb_gc_mark(g->L);
208
+ rb_gc_mark(g->N);
209
+ rb_gc_mark(g->r);
210
+ rb_gc_mark(g->R);
211
+ rb_gc_mark(g->s);
212
+ rb_gc_mark(g->t);
213
+ rb_gc_mark(g->u);
214
+ rb_gc_mark(g->w);
215
+ rb_gc_mark(g->x);
216
+ rb_gc_mark(g->y);
217
+ rb_gc_mark(g->X);
218
+ rb_gc_mark(g->Y);
219
+ rb_gc_mark(g->bg);
220
+ rb_gc_mark(g->bitmap_size);
221
+ rb_gc_mark(g->frame);
222
+ rb_gc_mark(g->frame_line_width);
223
+ rb_gc_mark(g->max_line_length);
224
+ rb_gc_mark(g->page_size);
225
+ rb_gc_mark(g->pen_colors);
226
+ rb_gc_mark(g->rotation);
227
+ rb_gc_mark(g->title_font_name);
228
+ rb_gc_mark(g->title_font_size);
229
+ rb_gc_mark(g->rotate_y_label);
230
+ rb_gc_mark(g->I);
231
+ rb_gc_mark(g->B);
232
+ rb_gc_mark(g->m);
233
+ rb_gc_mark(g->S);
234
+ rb_gc_mark(g->W);
235
+ rb_gc_mark(g->q);
236
+ rb_gc_mark(g->C);
237
+ rb_gc_mark(g->symbol_font_name);
238
+ rb_gc_mark(g->reposition);
239
+ rb_gc_mark(g->blankout);
240
+ rb_gc_mark(g->O);
241
+ }
242
+
243
+ void gsl_graph_free(gsl_graph *g)
244
+ {
245
+ free((gsl_graph *) g);
246
+ }
247
+
248
+ static VALUE rb_gsl_graph_set_xdata(VALUE obj, VALUE xx);
249
+ static VALUE rb_gsl_graph_set_ydata(VALUE obj, VALUE yy);
250
+ static VALUE rb_gsl_graph_set_xydata(VALUE obj, VALUE xx, VALUE yy);
251
+ static VALUE rb_gsl_graph_new(int argc, VALUE *argv, VALUE klass)
252
+ {
253
+ gsl_graph *g = NULL;
254
+ VALUE obj;
255
+ g = gsl_graph_new();
256
+ obj = Data_Wrap_Struct(klass, gsl_graph_mark, gsl_graph_free, g);
257
+ switch (argc) {
258
+ case 1:
259
+ rb_gsl_graph_set_xdata(obj, argv[0]);
260
+ break;
261
+ case 2:
262
+ rb_gsl_graph_set_xydata(obj, argv[0], argv[1]);
263
+ break;
264
+ }
265
+ return obj;
266
+ }
267
+
268
+ static VALUE rb_gsl_graph_init(VALUE obj)
269
+ {
270
+ gsl_graph *g = NULL;
271
+ Data_Get_Struct(obj, gsl_graph, g);
272
+ gsl_graph_init(g);
273
+ return obj;
274
+ }
275
+
276
+ static VALUE rb_gsl_graph_xdata(VALUE obj)
277
+ {
278
+ gsl_graph *g = NULL;
279
+ Data_Get_Struct(obj, gsl_graph, g);
280
+ return g->xdata;
281
+ }
282
+
283
+ static VALUE rb_gsl_graph_ydata(VALUE obj)
284
+ {
285
+ gsl_graph *g = NULL;
286
+ Data_Get_Struct(obj, gsl_graph, g);
287
+ return g->ydata;
288
+ }
289
+
290
+ static VALUE rb_gsl_graph_xydata(VALUE obj)
291
+ {
292
+ gsl_graph *g = NULL;
293
+ Data_Get_Struct(obj, gsl_graph, g);
294
+ return rb_ary_new3(2, g->xdata, g->ydata);
295
+ }
296
+
297
+ static VALUE rb_gsl_graph_set_xdata(VALUE obj, VALUE xx)
298
+ {
299
+ gsl_graph *g = NULL;
300
+ Data_Get_Struct(obj, gsl_graph, g);
301
+ CHECK_VECTOR(xx);
302
+ g->xdata = xx;
303
+ return obj;
304
+ }
305
+
306
+ static VALUE rb_gsl_graph_set_ydata(VALUE obj, VALUE yy)
307
+ {
308
+ gsl_graph *g = NULL;
309
+ Data_Get_Struct(obj, gsl_graph, g);
310
+ CHECK_VECTOR(yy);
311
+ g->ydata = yy;
312
+ return obj;
313
+ }
314
+
315
+ static VALUE rb_gsl_graph_set_xydata(VALUE obj, VALUE xx, VALUE yy)
316
+ {
317
+ gsl_graph *g = NULL;
318
+ Data_Get_Struct(obj, gsl_graph, g);
319
+ CHECK_VECTOR(xx); CHECK_VECTOR(yy);
320
+ g->xdata = xx;
321
+ g->ydata = yy;
322
+ return obj;
323
+ }
324
+
325
+ static VALUE rb_gsl_graph_set_T(VALUE obj, VALUE T)
326
+ {
327
+ gsl_graph *g = NULL;
328
+ Data_Get_Struct(obj, gsl_graph, g);
329
+ Check_Type(T, T_STRING);
330
+ g->T = T;
331
+ return T;
332
+ }
333
+
334
+ static VALUE rb_gsl_graph_T(VALUE obj)
335
+ {
336
+ gsl_graph *g = NULL;
337
+ Data_Get_Struct(obj, gsl_graph, g);
338
+ return g->T;
339
+ }
340
+
341
+ static VALUE rb_gsl_graph_set_E(VALUE obj, VALUE E)
342
+ {
343
+ gsl_graph *g = NULL;
344
+ Data_Get_Struct(obj, gsl_graph, g);
345
+ Check_Type(E, T_STRING);
346
+ g->E = E;
347
+ return E;
348
+ }
349
+
350
+ static VALUE rb_gsl_graph_E(VALUE obj)
351
+ {
352
+ gsl_graph *g = NULL;
353
+ Data_Get_Struct(obj, gsl_graph, g);
354
+ return g->E;
355
+ }
356
+
357
+ static VALUE rb_gsl_graph_set_f(VALUE obj, VALUE f)
358
+ {
359
+ gsl_graph *g = NULL;
360
+ Data_Get_Struct(obj, gsl_graph, g);
361
+ g->f = f;
362
+ return f;
363
+ }
364
+
365
+ static VALUE rb_gsl_graph_f(VALUE obj)
366
+ {
367
+ gsl_graph *g = NULL;
368
+ Data_Get_Struct(obj, gsl_graph, g);
369
+ return g->f;
370
+ }
371
+
372
+ static VALUE rb_gsl_graph_set_F(VALUE obj, VALUE F)
373
+ {
374
+ gsl_graph *g = NULL;
375
+ Data_Get_Struct(obj, gsl_graph, g);
376
+ g->F = F;
377
+ return F;
378
+ }
379
+
380
+ static VALUE rb_gsl_graph_F(VALUE obj)
381
+ {
382
+ gsl_graph *g = NULL;
383
+ Data_Get_Struct(obj, gsl_graph, g);
384
+ return g->F;
385
+ }
386
+
387
+ static VALUE rb_gsl_graph_set_g(VALUE obj, VALUE gg)
388
+ {
389
+ gsl_graph *g = NULL;
390
+ Data_Get_Struct(obj, gsl_graph, g);
391
+ Check_Type(gg, T_FIXNUM);
392
+ g->g = gg;
393
+ return gg;
394
+ }
395
+
396
+ static VALUE rb_gsl_graph_g(VALUE obj)
397
+ {
398
+ gsl_graph *g = NULL;
399
+ Data_Get_Struct(obj, gsl_graph, g);
400
+ return g->g;
401
+ }
402
+
403
+ static VALUE rb_gsl_graph_set_h(VALUE obj, VALUE h)
404
+ {
405
+ gsl_graph *g = NULL;
406
+ Data_Get_Struct(obj, gsl_graph, g);
407
+ g->h = h;
408
+ return h;
409
+ }
410
+
411
+ static VALUE rb_gsl_graph_h(VALUE obj)
412
+ {
413
+ gsl_graph *g = NULL;
414
+ Data_Get_Struct(obj, gsl_graph, g);
415
+ return g->h;
416
+ }
417
+
418
+ static VALUE rb_gsl_graph_set_k(VALUE obj, VALUE k)
419
+ {
420
+ gsl_graph *g = NULL;
421
+ Data_Get_Struct(obj, gsl_graph, g);
422
+ g->k = k;
423
+ return k;
424
+ }
425
+
426
+ static VALUE rb_gsl_graph_k(VALUE obj)
427
+ {
428
+ gsl_graph *g = NULL;
429
+ Data_Get_Struct(obj, gsl_graph, g);
430
+ return g->k;
431
+ }
432
+
433
+ static VALUE rb_gsl_graph_set_K(VALUE obj, VALUE K)
434
+ {
435
+ gsl_graph *g = NULL;
436
+ Data_Get_Struct(obj, gsl_graph, g);
437
+ g->K = K;
438
+ return K;
439
+ }
440
+
441
+ static VALUE rb_gsl_graph_K(VALUE obj)
442
+ {
443
+ gsl_graph *g = NULL;
444
+ Data_Get_Struct(obj, gsl_graph, g);
445
+ return g->K;
446
+ }
447
+
448
+ static VALUE rb_gsl_graph_set_l(VALUE obj, VALUE l)
449
+ {
450
+ gsl_graph *g = NULL;
451
+ Data_Get_Struct(obj, gsl_graph, g);
452
+ g->l = l;
453
+ return l;
454
+ }
455
+
456
+ static VALUE rb_gsl_graph_l(VALUE obj)
457
+ {
458
+ gsl_graph *g = NULL;
459
+ Data_Get_Struct(obj, gsl_graph, g);
460
+ return g->l;
461
+ }
462
+
463
+ static VALUE rb_gsl_graph_set_L(VALUE obj, VALUE L)
464
+ {
465
+ gsl_graph *g = NULL;
466
+ Data_Get_Struct(obj, gsl_graph, g);
467
+ g->L = L;
468
+ return L;
469
+ }
470
+
471
+ static VALUE rb_gsl_graph_L(VALUE obj)
472
+ {
473
+ gsl_graph *g = NULL;
474
+ Data_Get_Struct(obj, gsl_graph, g);
475
+ return g->L;
476
+ }
477
+
478
+ static VALUE rb_gsl_graph_set_N(VALUE obj, VALUE N)
479
+ {
480
+ gsl_graph *g = NULL;
481
+ Data_Get_Struct(obj, gsl_graph, g);
482
+ g->N = N;
483
+ return N;
484
+ }
485
+
486
+ static VALUE rb_gsl_graph_N(VALUE obj)
487
+ {
488
+ gsl_graph *g = NULL;
489
+ Data_Get_Struct(obj, gsl_graph, g);
490
+ return g->N;
491
+ }
492
+
493
+ static VALUE rb_gsl_graph_set_r(VALUE obj, VALUE r)
494
+ {
495
+ gsl_graph *g = NULL;
496
+ Data_Get_Struct(obj, gsl_graph, g);
497
+ g->r = r;
498
+ return r;
499
+ }
500
+
501
+ static VALUE rb_gsl_graph_r(VALUE obj)
502
+ {
503
+ gsl_graph *g = NULL;
504
+ Data_Get_Struct(obj, gsl_graph, g);
505
+ return g->r;
506
+ }
507
+
508
+ static VALUE rb_gsl_graph_set_R(VALUE obj, VALUE R)
509
+ {
510
+ gsl_graph *g = NULL;
511
+ Data_Get_Struct(obj, gsl_graph, g);
512
+ g->R = R;
513
+ return R;
514
+ }
515
+
516
+ static VALUE rb_gsl_graph_R(VALUE obj)
517
+ {
518
+ gsl_graph *g = NULL;
519
+ Data_Get_Struct(obj, gsl_graph, g);
520
+ return g->R;
521
+ }
522
+
523
+ static VALUE rb_gsl_graph_set_s(VALUE obj, VALUE s)
524
+ {
525
+ gsl_graph *g = NULL;
526
+ Data_Get_Struct(obj, gsl_graph, g);
527
+ g->s = s;
528
+ return s;
529
+ }
530
+
531
+ static VALUE rb_gsl_graph_s(VALUE obj)
532
+ {
533
+ gsl_graph *g = NULL;
534
+ Data_Get_Struct(obj, gsl_graph, g);
535
+ return g->s;
536
+ }
537
+
538
+ static VALUE rb_gsl_graph_set_t(VALUE obj, VALUE t)
539
+ {
540
+ gsl_graph *g = NULL;
541
+ Data_Get_Struct(obj, gsl_graph, g);
542
+ g->t = t;
543
+ return t;
544
+ }
545
+
546
+ static VALUE rb_gsl_graph_t(VALUE obj)
547
+ {
548
+ gsl_graph *g = NULL;
549
+ Data_Get_Struct(obj, gsl_graph, g);
550
+ return g->t;
551
+ }
552
+
553
+ static VALUE rb_gsl_graph_set_u(VALUE obj, VALUE u)
554
+ {
555
+ gsl_graph *g = NULL;
556
+ Data_Get_Struct(obj, gsl_graph, g);
557
+ g->u = u;
558
+ return u;
559
+ }
560
+
561
+ static VALUE rb_gsl_graph_u(VALUE obj)
562
+ {
563
+ gsl_graph *g = NULL;
564
+ Data_Get_Struct(obj, gsl_graph, g);
565
+ return g->u;
566
+ }
567
+
568
+ static VALUE rb_gsl_graph_set_w(VALUE obj, VALUE w)
569
+ {
570
+ gsl_graph *g = NULL;
571
+ Data_Get_Struct(obj, gsl_graph, g);
572
+ g->w = w;
573
+ return w;
574
+ }
575
+
576
+ static VALUE rb_gsl_graph_w(VALUE obj)
577
+ {
578
+ gsl_graph *g = NULL;
579
+ Data_Get_Struct(obj, gsl_graph, g);
580
+ return g->w;
581
+ }
582
+
583
+ static VALUE rb_gsl_graph_set_x(VALUE obj, VALUE x)
584
+ {
585
+ gsl_graph *g = NULL;
586
+ Data_Get_Struct(obj, gsl_graph, g);
587
+ g->x = x;
588
+ return x;
589
+ }
590
+
591
+ static VALUE rb_gsl_graph_x(VALUE obj)
592
+ {
593
+ gsl_graph *g = NULL;
594
+ Data_Get_Struct(obj, gsl_graph, g);
595
+ return g->x;
596
+ }
597
+
598
+ static VALUE rb_gsl_graph_set_y(VALUE obj, VALUE y)
599
+ {
600
+ gsl_graph *g = NULL;
601
+ Data_Get_Struct(obj, gsl_graph, g);
602
+ g->y = y;
603
+ return y;
604
+ }
605
+
606
+ static VALUE rb_gsl_graph_y(VALUE obj)
607
+ {
608
+ gsl_graph *g = NULL;
609
+ Data_Get_Struct(obj, gsl_graph, g);
610
+ return g->y;
611
+ }
612
+ static VALUE rb_gsl_graph_set_X(VALUE obj, VALUE X)
613
+ {
614
+ gsl_graph *g = NULL;
615
+ Data_Get_Struct(obj, gsl_graph, g);
616
+ Check_Type(X, T_STRING);
617
+ g->X = X;
618
+ return X;
619
+ }
620
+
621
+ static VALUE rb_gsl_graph_set_Y(VALUE obj, VALUE Y)
622
+ {
623
+ gsl_graph *g = NULL;
624
+ Data_Get_Struct(obj, gsl_graph, g);
625
+ Check_Type(Y, T_STRING);
626
+ g->Y = Y;
627
+ return Y;
628
+ }
629
+
630
+ static VALUE rb_gsl_graph_X(VALUE obj)
631
+ {
632
+ gsl_graph *g = NULL;
633
+ Data_Get_Struct(obj, gsl_graph, g);
634
+ return g->X;
635
+ }
636
+
637
+ static VALUE rb_gsl_graph_Y(VALUE obj)
638
+ {
639
+ gsl_graph *g = NULL;
640
+ Data_Get_Struct(obj, gsl_graph, g);
641
+ return g->Y;
642
+ }
643
+
644
+ static VALUE rb_gsl_graph_set_bg(VALUE obj, VALUE bg)
645
+ {
646
+ gsl_graph *g = NULL;
647
+ Data_Get_Struct(obj, gsl_graph, g);
648
+ g->bg = bg;
649
+ return bg;
650
+ }
651
+
652
+ static VALUE rb_gsl_graph_bg(VALUE obj)
653
+ {
654
+ gsl_graph *g = NULL;
655
+ Data_Get_Struct(obj, gsl_graph, g);
656
+ return g->bg;
657
+ }
658
+
659
+ static VALUE rb_gsl_graph_set_bitmap_size(VALUE obj, VALUE bitmap_size)
660
+ {
661
+ gsl_graph *g = NULL;
662
+ Data_Get_Struct(obj, gsl_graph, g);
663
+ g->bitmap_size = bitmap_size;
664
+ return bitmap_size;
665
+ }
666
+
667
+ static VALUE rb_gsl_graph_bitmap_size(VALUE obj)
668
+ {
669
+ gsl_graph *g = NULL;
670
+ Data_Get_Struct(obj, gsl_graph, g);
671
+ return g->bitmap_size;
672
+ }
673
+
674
+ static VALUE rb_gsl_graph_set_frame(VALUE obj, VALUE frame)
675
+ {
676
+ gsl_graph *g = NULL;
677
+ Data_Get_Struct(obj, gsl_graph, g);
678
+ g->frame = frame;
679
+ return frame;
680
+ }
681
+
682
+ static VALUE rb_gsl_graph_frame(VALUE obj)
683
+ {
684
+ gsl_graph *g = NULL;
685
+ Data_Get_Struct(obj, gsl_graph, g);
686
+ return g->frame;
687
+ }
688
+
689
+ static VALUE rb_gsl_graph_set_frame_line_width(VALUE obj, VALUE frame_line_width)
690
+ {
691
+ gsl_graph *g = NULL;
692
+ Data_Get_Struct(obj, gsl_graph, g);
693
+ g->frame_line_width = frame_line_width;
694
+ return frame_line_width;
695
+ }
696
+
697
+ static VALUE rb_gsl_graph_frame_line_width(VALUE obj)
698
+ {
699
+ gsl_graph *g = NULL;
700
+ Data_Get_Struct(obj, gsl_graph, g);
701
+ return g->frame_line_width;
702
+ }
703
+
704
+ static VALUE rb_gsl_graph_set_max_line_length(VALUE obj, VALUE max_line_length)
705
+ {
706
+ gsl_graph *g = NULL;
707
+ Data_Get_Struct(obj, gsl_graph, g);
708
+ g->max_line_length = max_line_length;
709
+ return max_line_length;
710
+ }
711
+
712
+ static VALUE rb_gsl_graph_max_line_length(VALUE obj)
713
+ {
714
+ gsl_graph *g = NULL;
715
+ Data_Get_Struct(obj, gsl_graph, g);
716
+ return g->max_line_length;
717
+ }
718
+
719
+ static VALUE rb_gsl_graph_set_page_size(VALUE obj, VALUE page_size)
720
+ {
721
+ gsl_graph *g = NULL;
722
+ Data_Get_Struct(obj, gsl_graph, g);
723
+ g->page_size = page_size;
724
+ return page_size;
725
+ }
726
+
727
+ static VALUE rb_gsl_graph_page_size(VALUE obj)
728
+ {
729
+ gsl_graph *g = NULL;
730
+ Data_Get_Struct(obj, gsl_graph, g);
731
+ return g->page_size;
732
+ }
733
+
734
+ static VALUE rb_gsl_graph_set_pen_colors(VALUE obj, VALUE pen_colors)
735
+ {
736
+ gsl_graph *g = NULL;
737
+ Data_Get_Struct(obj, gsl_graph, g);
738
+ g->pen_colors = pen_colors;
739
+ return pen_colors;
740
+ }
741
+
742
+ static VALUE rb_gsl_graph_pen_colors(VALUE obj)
743
+ {
744
+ gsl_graph *g = NULL;
745
+ Data_Get_Struct(obj, gsl_graph, g);
746
+ return g->pen_colors;
747
+ }
748
+
749
+ static VALUE rb_gsl_graph_set_rotation(VALUE obj, VALUE rotation)
750
+ {
751
+ gsl_graph *g = NULL;
752
+ Data_Get_Struct(obj, gsl_graph, g);
753
+ g->rotation = rotation;
754
+ return rotation;
755
+ }
756
+
757
+ static VALUE rb_gsl_graph_rotation(VALUE obj)
758
+ {
759
+ gsl_graph *g = NULL;
760
+ Data_Get_Struct(obj, gsl_graph, g);
761
+ return g->rotation;
762
+ }
763
+
764
+ static VALUE rb_gsl_graph_set_title_font_name(VALUE obj, VALUE title_font_name)
765
+ {
766
+ gsl_graph *g = NULL;
767
+ Data_Get_Struct(obj, gsl_graph, g);
768
+ g->title_font_name = title_font_name;
769
+ return title_font_name;
770
+ }
771
+
772
+ static VALUE rb_gsl_graph_title_font_name(VALUE obj)
773
+ {
774
+ gsl_graph *g = NULL;
775
+ Data_Get_Struct(obj, gsl_graph, g);
776
+ return g->title_font_name;
777
+ }
778
+
779
+ static VALUE rb_gsl_graph_set_title_font_size(VALUE obj, VALUE title_font_size)
780
+ {
781
+ gsl_graph *g = NULL;
782
+ Data_Get_Struct(obj, gsl_graph, g);
783
+ g->title_font_size = title_font_size;
784
+ return title_font_size;
785
+ }
786
+
787
+ static VALUE rb_gsl_graph_title_font_size(VALUE obj)
788
+ {
789
+ gsl_graph *g = NULL;
790
+ Data_Get_Struct(obj, gsl_graph, g);
791
+ return g->title_font_size;
792
+ }
793
+
794
+ static VALUE rb_gsl_graph_set_rotate_y_label(VALUE obj, VALUE rotate_y_label)
795
+ {
796
+ gsl_graph *g = NULL;
797
+ Data_Get_Struct(obj, gsl_graph, g);
798
+ g->rotate_y_label = rotate_y_label;
799
+ return rotate_y_label;
800
+ }
801
+
802
+ static VALUE rb_gsl_graph_rotate_y_label(VALUE obj)
803
+ {
804
+ gsl_graph *g = NULL;
805
+ Data_Get_Struct(obj, gsl_graph, g);
806
+ return g->rotate_y_label;
807
+ }
808
+
809
+ static VALUE rb_gsl_graph_set_I(VALUE obj, VALUE I)
810
+ {
811
+ gsl_graph *g = NULL;
812
+ Data_Get_Struct(obj, gsl_graph, g);
813
+ g->I = I;
814
+ return I;
815
+ }
816
+
817
+ static VALUE rb_gsl_graph_I(VALUE obj)
818
+ {
819
+ gsl_graph *g = NULL;
820
+ Data_Get_Struct(obj, gsl_graph, g);
821
+ return g->I;
822
+ }
823
+
824
+ static VALUE rb_gsl_graph_set_B(VALUE obj, VALUE B)
825
+ {
826
+ gsl_graph *g = NULL;
827
+ Data_Get_Struct(obj, gsl_graph, g);
828
+ g->B = B;
829
+ return B;
830
+ }
831
+
832
+ static VALUE rb_gsl_graph_B(VALUE obj)
833
+ {
834
+ gsl_graph *g = NULL;
835
+ Data_Get_Struct(obj, gsl_graph, g);
836
+ return g->B;
837
+ }
838
+
839
+ static VALUE rb_gsl_graph_set_m(VALUE obj, VALUE m)
840
+ {
841
+ gsl_graph *g = NULL;
842
+ Data_Get_Struct(obj, gsl_graph, g);
843
+ g->m = m;
844
+ return m;
845
+ }
846
+
847
+ static VALUE rb_gsl_graph_m(VALUE obj)
848
+ {
849
+ gsl_graph *g = NULL;
850
+ Data_Get_Struct(obj, gsl_graph, g);
851
+ return g->m;
852
+ }
853
+
854
+ static VALUE rb_gsl_graph_set_S(VALUE obj, VALUE S)
855
+ {
856
+ gsl_graph *g = NULL;
857
+ Data_Get_Struct(obj, gsl_graph, g);
858
+ g->S = S;
859
+ return S;
860
+ }
861
+
862
+ static VALUE rb_gsl_graph_S(VALUE obj)
863
+ {
864
+ gsl_graph *g = NULL;
865
+ Data_Get_Struct(obj, gsl_graph, g);
866
+ return g->S;
867
+ }
868
+
869
+ static VALUE rb_gsl_graph_set_W(VALUE obj, VALUE W)
870
+ {
871
+ gsl_graph *g = NULL;
872
+ Data_Get_Struct(obj, gsl_graph, g);
873
+ g->W = W;
874
+ return W;
875
+ }
876
+
877
+ static VALUE rb_gsl_graph_W(VALUE obj)
878
+ {
879
+ gsl_graph *g = NULL;
880
+ Data_Get_Struct(obj, gsl_graph, g);
881
+ return g->W;
882
+ }
883
+
884
+ static VALUE rb_gsl_graph_set_q(VALUE obj, VALUE q)
885
+ {
886
+ gsl_graph *g = NULL;
887
+ Data_Get_Struct(obj, gsl_graph, g);
888
+ g->q = q;
889
+ return q;
890
+ }
891
+
892
+ static VALUE rb_gsl_graph_q(VALUE obj)
893
+ {
894
+ gsl_graph *g = NULL;
895
+ Data_Get_Struct(obj, gsl_graph, g);
896
+ return g->q;
897
+ }
898
+
899
+ static VALUE rb_gsl_graph_set_C(VALUE obj, VALUE C)
900
+ {
901
+ gsl_graph *g = NULL;
902
+ Data_Get_Struct(obj, gsl_graph, g);
903
+ g->C = C;
904
+ return C;
905
+ }
906
+
907
+ static VALUE rb_gsl_graph_C(VALUE obj)
908
+ {
909
+ gsl_graph *g = NULL;
910
+ Data_Get_Struct(obj, gsl_graph, g);
911
+ return g->C;
912
+ }
913
+
914
+ static VALUE rb_gsl_graph_set_symbol_font_name(VALUE obj, VALUE symbol_font_name)
915
+ {
916
+ gsl_graph *g = NULL;
917
+ Data_Get_Struct(obj, gsl_graph, g);
918
+ g->symbol_font_name = symbol_font_name;
919
+ return symbol_font_name;
920
+ }
921
+
922
+ static VALUE rb_gsl_graph_symbol_font_name(VALUE obj)
923
+ {
924
+ gsl_graph *g = NULL;
925
+ Data_Get_Struct(obj, gsl_graph, g);
926
+ return g->symbol_font_name;
927
+ }
928
+
929
+ static VALUE rb_gsl_graph_set_reposition(VALUE obj, VALUE r)
930
+ {
931
+ gsl_graph *g = NULL;
932
+ Data_Get_Struct(obj, gsl_graph, g);
933
+ g->reposition = r;
934
+ return r;
935
+ }
936
+
937
+ static VALUE rb_gsl_graph_reposition(VALUE obj)
938
+ {
939
+ gsl_graph *g = NULL;
940
+ Data_Get_Struct(obj, gsl_graph, g);
941
+ return g->reposition;
942
+ }
943
+
944
+ static VALUE rb_gsl_graph_set_blankout(VALUE obj, VALUE r)
945
+ {
946
+ gsl_graph *g = NULL;
947
+ Data_Get_Struct(obj, gsl_graph, g);
948
+ g->blankout = r;
949
+ return r;
950
+ }
951
+
952
+ static VALUE rb_gsl_graph_blankout(VALUE obj)
953
+ {
954
+ gsl_graph *g = NULL;
955
+ Data_Get_Struct(obj, gsl_graph, g);
956
+ return g->blankout;
957
+ }
958
+
959
+ static VALUE rb_gsl_graph_set_O(VALUE obj, VALUE O)
960
+ {
961
+ gsl_graph *g = NULL;
962
+ Data_Get_Struct(obj, gsl_graph, g);
963
+ g->O = O;
964
+ return O;
965
+ }
966
+
967
+ static VALUE rb_gsl_graph_O(VALUE obj)
968
+ {
969
+ gsl_graph *g = NULL;
970
+ Data_Get_Struct(obj, gsl_graph, g);
971
+ return g->O;
972
+ }
973
+
974
+ #ifdef HAVE_GNU_GRAPH
975
+ static void gsl_graph_set_command(gsl_graph *g, char *command)
976
+ {
977
+ char str[256];
978
+ size_t i, len;
979
+ VALUE val;
980
+ strcpy(command, "graph");
981
+ if (g->T == Qnil)
982
+ sprintf(command, "%s -T X", command);
983
+ else
984
+ sprintf(command, "%s -T %s", command, STR2CSTR(g->T));
985
+
986
+ if (TYPE(g->E) == T_STRING) {
987
+ strcpy(str, STR2CSTR(g->E));
988
+ if (strcmp(str, "x") == 0)
989
+ sprintf(command, "%s -E x", command);
990
+ else if (strcmp(str, "y") == 0)
991
+ sprintf(command, "%s -E y", command);
992
+ else if (strcmp(str, "xy")*strcmp(str, "x/y") == 0)
993
+ sprintf(command, "%s -E x -E y", command);
994
+ else
995
+ rb_raise(rb_eRuntimeError, "unrecognized -E option %s", str);
996
+ }
997
+
998
+ if (g->f != Qnil)
999
+ sprintf(command, "%s -f %f", command, NUM2DBL(g->f));
1000
+
1001
+ if (TYPE(g->F) == T_STRING)
1002
+ sprintf(command, "%s -F %s", command, STR2CSTR(g->F));
1003
+
1004
+ if (TYPE(g->g) == T_FIXNUM)
1005
+ sprintf(command, "%s -g %d", command, (int) FIX2INT(g->g));
1006
+
1007
+ if (g->h != Qnil)
1008
+ sprintf(command, "%s -h %f", command, NUM2DBL(g->h));
1009
+
1010
+ if (g->k != Qnil)
1011
+ sprintf(command, "%s -k %f", command, NUM2DBL(g->k));
1012
+
1013
+ if (TYPE(g->K) == T_FIXNUM)
1014
+ sprintf(command, "%s -K %d", command, (int) FIX2INT(g->K));
1015
+
1016
+ if (TYPE(g->l) == T_STRING) {
1017
+ strcpy(str, STR2CSTR(g->l));
1018
+ if (strcmp(str, "x") == 0)
1019
+ sprintf(command, "%s -l x", command);
1020
+ else if (strcmp(str, "y") == 0)
1021
+ sprintf(command, "%s -l y", command);
1022
+ else if (strcmp(str, "xy")*strcmp(str, "x/y") == 0)
1023
+ sprintf(command, "%s -l x -l y", command);
1024
+ else
1025
+ rb_raise(rb_eRuntimeError, "unrecognized -l option %s", str);
1026
+ }
1027
+
1028
+ if (TYPE(g->L) == T_STRING)
1029
+ sprintf(command, "%s -L \"%s\"", command, STR2CSTR(g->L));
1030
+
1031
+ if (TYPE(g->N) == T_STRING) {
1032
+ strcpy(str, STR2CSTR(g->N));
1033
+ if (strcmp(str, "x") == 0)
1034
+ sprintf(command, "%s -N x", command);
1035
+ else if (strcmp(str, "y") == 0)
1036
+ sprintf(command, "%s -N y", command);
1037
+ else if (strcmp(str, "xy")*strcmp(str, "x/y") == 0)
1038
+ sprintf(command, "%s -N x -N y", command);
1039
+ else
1040
+ rb_raise(rb_eRuntimeError, "unrecognized -N option %s", str);
1041
+ }
1042
+
1043
+ if (g->r != Qnil)
1044
+ sprintf(command, "%s -r %f", command, NUM2DBL(g->r));
1045
+
1046
+ if (TYPE(g->R) == T_STRING) {
1047
+ strcpy(str, STR2CSTR(g->R));
1048
+ if (strcmp(str, "x") == 0)
1049
+ sprintf(command, "%s -R x", command);
1050
+ else if (strcmp(str, "y") == 0)
1051
+ sprintf(command, "%s -R y", command);
1052
+ else if (strcmp(str, "xy")*strcmp(str, "x/y") == 0)
1053
+ sprintf(command, "%s -R x -R y", command);
1054
+ else
1055
+ rb_raise(rb_eRuntimeError, "unrecognized -R option %s", str);
1056
+ }
1057
+
1058
+ if (g->u != Qnil)
1059
+ sprintf(command, "%s -u %f", command, NUM2DBL(g->u));
1060
+
1061
+ if (g->w != Qnil)
1062
+ sprintf(command, "%s -w %f", command, NUM2DBL(g->w));
1063
+
1064
+ switch (TYPE(g->x)) {
1065
+ case T_STRING:
1066
+ sprintf(command, "%s -x %s", command, STR2CSTR(g->x));
1067
+ break;
1068
+ case T_ARRAY:
1069
+ sprintf(command, "%s -x", command);
1070
+ // len = RARRAY(g->x)->len;
1071
+ len = RARRAY_LEN(g->x);
1072
+ for (i = 0; i < len; i++) {
1073
+ val = rb_ary_entry(g->x, i);
1074
+ Need_Float(val);
1075
+ sprintf(command, "%s %f", command, NUM2DBL(val));
1076
+ }
1077
+ break;
1078
+ default:
1079
+ /* do nothing */
1080
+ break;
1081
+ }
1082
+
1083
+ switch (TYPE(g->y)) {
1084
+ case T_STRING:
1085
+ sprintf(command, "%s -y %s", command, STR2CSTR(g->y));
1086
+ break;
1087
+ case T_ARRAY:
1088
+ sprintf(command, "%s -y", command);
1089
+ // len = RARRAY(g->y)->len;
1090
+ len = RARRAY_LEN(g->y);
1091
+ for (i = 0; i < len; i++) {
1092
+ val = rb_ary_entry(g->y, i);
1093
+ Need_Float(val);
1094
+ sprintf(command, "%s %f", command, NUM2DBL(val));
1095
+ }
1096
+ break;
1097
+ default:
1098
+ /* do nothing */
1099
+ break;
1100
+ }
1101
+
1102
+ if (g->X != Qnil)
1103
+ sprintf(command, "%s -X \"%s\"", command, STR2CSTR(g->X));
1104
+ if (g->Y != Qnil)
1105
+ sprintf(command, "%s -Y \"%s\"", command, STR2CSTR(g->Y));
1106
+
1107
+ if (TYPE(g->bg) == T_STRING)
1108
+ sprintf(command, "%s --bg-color %s", command, STR2CSTR(g->bg));
1109
+
1110
+ if (TYPE(g->bitmap_size) == T_STRING)
1111
+ sprintf(command, "%s --bitmap-size %s", command, STR2CSTR(g->bitmap_size));
1112
+
1113
+ if (TYPE(g->frame) == T_STRING)
1114
+ sprintf(command, "%s --frame-color %s", command, STR2CSTR(g->frame));
1115
+
1116
+ if (g->frame_line_width != Qnil)
1117
+ sprintf(command, "%s --frame-line-width %f", command, NUM2DBL(g->frame_line_width));
1118
+
1119
+ if (g->max_line_length != Qnil)
1120
+ sprintf(command, "%s --max_line_length %d", command,
1121
+ (int) FIX2INT(g->max_line_length));
1122
+
1123
+ if (g->page_size != Qnil)
1124
+ sprintf(command, "%s --page-size %s", command, STR2CSTR(g->page_size));
1125
+
1126
+ if (g->pen_colors != Qnil)
1127
+ sprintf(command, "%s --pen-colors %s", command, STR2CSTR(g->pen_colors));
1128
+
1129
+ if (g->rotation != Qnil)
1130
+ sprintf(command, "%s --rotation %d", command, (int) FIX2INT(g->rotation));
1131
+
1132
+ if (g->title_font_name != Qnil)
1133
+ sprintf(command, "%s --title-font-name %s", command, STR2CSTR(g->title_font_name)); if (g->title_font_size != Qnil)
1134
+ sprintf(command, "%s --title-font-size %f", command, NUM2DBL(g->title_font_size));
1135
+
1136
+ if (g->rotate_y_label == Qtrue)
1137
+ sprintf(command, "%s --toggle-rotate-y-label", command);
1138
+
1139
+ if (g->I != Qnil)
1140
+ sprintf(command, "%s -I %s", command, STR2CSTR(g->I));
1141
+
1142
+ if (g->s == Qtrue)
1143
+ sprintf(command, "%s -s", command);
1144
+ if (g->t == Qtrue)
1145
+ sprintf(command, "%s -t", command);
1146
+ if (g->B == Qtrue)
1147
+ sprintf(command, "%s -B", command);
1148
+
1149
+ if (g->m != Qnil)
1150
+ sprintf(command, "%s -m %d", command, (int) FIX2INT(g->m));
1151
+
1152
+ switch (TYPE(g->S)) {
1153
+ case T_STRING:
1154
+ sprintf(command, "%s -S %s", command, STR2CSTR(g->S));
1155
+ break;
1156
+ case T_ARRAY:
1157
+ // if (RARRAY(g->S)->len == 2)
1158
+ if (RARRAY_LEN(g->S) == 2)
1159
+ sprintf(command, "%s -S %d %f", command, (int) FIX2INT(rb_ary_entry(g->S, 0)),
1160
+ NUM2DBL(rb_ary_entry(g->S, 1)));
1161
+ break;
1162
+ default:
1163
+ /* do nothing */
1164
+ break;
1165
+ }
1166
+
1167
+ if (g->W != Qnil)
1168
+ sprintf(command, "%s -W %f", command, NUM2DBL(g->W));
1169
+
1170
+ if (g->q != Qnil)
1171
+ sprintf(command, "%s -q %f", command, NUM2DBL(g->q));
1172
+
1173
+ if (g->C == Qtrue)
1174
+ sprintf(command, "%s -C", command);
1175
+
1176
+ if (g->symbol_font_name != Qnil)
1177
+ sprintf(command, "%s --symbol_font_name %s", command, STR2CSTR(g->symbol_font_name));
1178
+
1179
+ switch (TYPE(g->reposition)) {
1180
+ case T_STRING:
1181
+ sprintf(command, "%s --reposition %s", command, STR2CSTR(g->reposition));
1182
+ break;
1183
+ case T_ARRAY:
1184
+ sprintf(command, "%s --reposition", command);
1185
+ // len = RARRAY(g->reposition)->len;
1186
+ len = RARRAY_LEN(g->reposition);
1187
+ for (i = 0; i <len; i++) {
1188
+ val = rb_ary_entry(g->reposition, i);
1189
+ Need_Float(val);
1190
+ sprintf(command, "%s %f", command, NUM2DBL(val));
1191
+ }
1192
+ break;
1193
+ default:
1194
+ /* do nothing */
1195
+ break;
1196
+ }
1197
+
1198
+ if (g->blankout != Qnil)
1199
+ sprintf(command, "%s --blankout %f", command, NUM2DBL(g->blankout));
1200
+
1201
+ if (g->O == Qtrue)
1202
+ sprintf(command, "%s -O", command);
1203
+ }
1204
+ #endif
1205
+
1206
+ static VALUE rb_gsl_graph_graph(int argc, VALUE *argv, VALUE obj)
1207
+ {
1208
+ #ifdef HAVE_GNU_GRAPH
1209
+ gsl_graph *g = NULL;
1210
+ gsl_histogram *h = NULL;
1211
+ gsl_vector *x = NULL, *y = NULL;
1212
+ size_t i, size;
1213
+ FILE *fp;
1214
+ char command[1024];
1215
+ Data_Get_Struct(obj, gsl_graph, g);
1216
+
1217
+ gsl_graph_set_command(g, command);
1218
+ switch (argc) {
1219
+ case 3:
1220
+ Check_Type(argv[2], T_STRING);
1221
+ sprintf(command, "%s %s", command, STR2CSTR(argv[2]));
1222
+ /* no break */
1223
+ case 2:
1224
+ if (TYPE(argv[1]) == T_STRING) {
1225
+ sprintf(command, "%s %s", command, STR2CSTR(argv[1]));
1226
+ } else if (VECTOR_P(argv[1])) {
1227
+ g->ydata = argv[1];
1228
+ } else {
1229
+ rb_raise(rb_eTypeError, "wrong argument type %s (Vector or String expected)",
1230
+ rb_class2name(CLASS_OF(argv[1])));
1231
+ }
1232
+ /* no break */
1233
+ case 1:
1234
+ if (TYPE(argv[0]) == T_STRING) {
1235
+ sprintf(command, "%s %s", command, STR2CSTR(argv[0]));
1236
+ } else if (VECTOR_P(argv[0])) {
1237
+ g->xdata = argv[0];
1238
+ } else if (HISTOGRAM_P(argv[0])) {
1239
+ Data_Get_Struct(argv[0], gsl_histogram, h);
1240
+ } else {
1241
+ rb_raise(rb_eTypeError, "wrong argument type %s (Vector or String expected)",
1242
+ rb_class2name(CLASS_OF(argv[0])));
1243
+ }
1244
+ break;
1245
+ default:
1246
+ rb_raise(rb_eArgError, "wrong number of argumeuts (%d for 1-3)", argc);
1247
+ break;
1248
+ }
1249
+ if (VECTOR_P(g->xdata)) Data_Get_Struct(g->xdata, gsl_vector, x);
1250
+ if (VECTOR_P(g->ydata)) Data_Get_Struct(g->ydata, gsl_vector, y);
1251
+
1252
+ if (x == NULL && h == NULL)
1253
+ rb_raise(rb_eRuntimeError, "data is not given");
1254
+
1255
+ if (h) size = h->n;
1256
+ else size = x->size;
1257
+
1258
+ fp = popen(command, "w");
1259
+ if (fp == NULL) rb_raise(rb_eIOError, "GNU graph not found.");
1260
+ for (i = 0; i < size; i++) {
1261
+ if (h)
1262
+ fprintf(fp, "%g %g\n%g %g\n", h->range[i], h->bin[i], h->range[i+1], h->bin[i]);
1263
+ else if (y == NULL)
1264
+ fprintf(fp, "%d %g\n", (int) i, gsl_vector_get(x, i));
1265
+ else
1266
+ fprintf(fp, "%g %g\n", gsl_vector_get(x, i), gsl_vector_get(y, i));
1267
+ }
1268
+ fflush(fp);
1269
+ pclose(fp);
1270
+ fp = NULL;
1271
+ return Qtrue;
1272
+ #else
1273
+ rb_raise(rb_eNoMethodError, "GNU plotutils required");
1274
+ return Qfalse;
1275
+ #endif
1276
+ }
1277
+
1278
+ static VALUE rb_gsl_graph_step(int argc, VALUE *argv, VALUE obj)
1279
+ {
1280
+ #ifdef HAVE_GNU_GRAPH
1281
+ gsl_graph *g = NULL;
1282
+ gsl_vector *x = NULL, *y = NULL;
1283
+ size_t i, size;
1284
+ FILE *fp;
1285
+ char command[1024];
1286
+ Data_Get_Struct(obj, gsl_graph, g);
1287
+
1288
+ gsl_graph_set_command(g, command);
1289
+ switch (argc) {
1290
+ case 3:
1291
+ Check_Type(argv[2], T_STRING);
1292
+ sprintf(command, "%s %s", command, STR2CSTR(argv[2]));
1293
+ /* no break */
1294
+ case 2:
1295
+ if (TYPE(argv[1]) == T_STRING) {
1296
+ sprintf(command, "%s %s", command, STR2CSTR(argv[1]));
1297
+ } else if (VECTOR_P(argv[1])) {
1298
+ g->ydata = argv[1];
1299
+ } else {
1300
+ rb_raise(rb_eTypeError, "wrong argument type %s (Vector or String expected)",
1301
+ rb_class2name(CLASS_OF(argv[1])));
1302
+ }
1303
+ /* no break */
1304
+ case 1:
1305
+ if (TYPE(argv[0]) == T_STRING) {
1306
+ sprintf(command, "%s %s", command, STR2CSTR(argv[0]));
1307
+ } else if (VECTOR_P(argv[0])) {
1308
+ g->xdata = argv[0];
1309
+ } else {
1310
+ rb_raise(rb_eTypeError, "wrong argument type %s (Vector or String expected)",
1311
+ rb_class2name(CLASS_OF(argv[0])));
1312
+ }
1313
+ break;
1314
+ default:
1315
+ rb_raise(rb_eArgError, "wrong number of argumeuts (%d for 1-3)", argc);
1316
+ break;
1317
+ }
1318
+ if (VECTOR_P(g->xdata)) Data_Get_Struct(g->xdata, gsl_vector, x);
1319
+ if (VECTOR_P(g->ydata)) Data_Get_Struct(g->ydata, gsl_vector, y);
1320
+
1321
+ if (x == NULL)
1322
+ rb_raise(rb_eRuntimeError, "data is not given");
1323
+
1324
+ size = x->size;
1325
+
1326
+ fp = popen(command, "w");
1327
+ if (fp == NULL) rb_raise(rb_eIOError, "GNU graph not found.");
1328
+ for (i = 0; i < size; i++) {
1329
+ if (y == NULL) {
1330
+ fprintf(fp, "%d %g\n%d %g\n", (int) i, gsl_vector_get(x, i),
1331
+ (int) (i+1), gsl_vector_get(x, i));
1332
+ } else {
1333
+ if (i != size-1)
1334
+ fprintf(fp, "%g %g\n%g %g\n", gsl_vector_get(x, i), gsl_vector_get(y, i),
1335
+ gsl_vector_get(x, i+1), gsl_vector_get(y, i));
1336
+ else
1337
+ fprintf(fp, "%g %g\n%g %g", gsl_vector_get(x, i), gsl_vector_get(y, i),
1338
+ 2.0*gsl_vector_get(x, i)-gsl_vector_get(x, i-1), gsl_vector_get(y, i));
1339
+ }
1340
+ }
1341
+ fflush(fp);
1342
+ pclose(fp);
1343
+ fp = NULL;
1344
+ return Qtrue;
1345
+ #else
1346
+ rb_raise(rb_eNoMethodError, "GNU plotutils required");
1347
+ return Qfalse;
1348
+ #endif
1349
+ }
1350
+
1351
+ void Init_gsl_graph(VALUE module)
1352
+ {
1353
+ VALUE cgsl_graph;
1354
+
1355
+ cgsl_graph = rb_define_class_under(module, "Graph", cGSL_Object);
1356
+
1357
+ rb_define_singleton_method(cgsl_graph, "new", rb_gsl_graph_new, -1);
1358
+ rb_define_singleton_method(cgsl_graph, "alloc", rb_gsl_graph_new, -1);
1359
+
1360
+ /*****/
1361
+
1362
+ rb_define_method(cgsl_graph, "init", rb_gsl_graph_init, 0);
1363
+
1364
+ rb_define_method(cgsl_graph, "set_xdata", rb_gsl_graph_set_xdata, 1);
1365
+ rb_define_method(cgsl_graph, "set_ydata", rb_gsl_graph_set_ydata, 1);
1366
+ rb_define_method(cgsl_graph, "set_xydata", rb_gsl_graph_set_xydata, 2);
1367
+
1368
+ rb_define_method(cgsl_graph, "xdata", rb_gsl_graph_xdata, 0);
1369
+ rb_define_method(cgsl_graph, "ydata", rb_gsl_graph_ydata, 0);
1370
+ rb_define_method(cgsl_graph, "xydata", rb_gsl_graph_xydata, 0);
1371
+
1372
+ rb_define_method(cgsl_graph, "graph", rb_gsl_graph_graph, -1);
1373
+ rb_define_alias(cgsl_graph, "draw", "graph");
1374
+ rb_define_alias(cgsl_graph, "plot", "graph");
1375
+
1376
+ rb_define_method(cgsl_graph, "graph_step", rb_gsl_graph_step, -1);
1377
+ rb_define_alias(cgsl_graph, "step", "graph_step");
1378
+
1379
+ /*****/
1380
+ rb_define_method(cgsl_graph, "set_T", rb_gsl_graph_set_T, 1);
1381
+ rb_define_alias(cgsl_graph, "T=", "set_T");
1382
+ rb_define_alias(cgsl_graph, "display_type=", "set_T");
1383
+ rb_define_method(cgsl_graph, "T", rb_gsl_graph_T, 0);
1384
+ rb_define_alias(cgsl_graph, "display_type", "T");
1385
+
1386
+ rb_define_method(cgsl_graph, "set_E", rb_gsl_graph_set_E, 1);
1387
+ rb_define_alias(cgsl_graph, "E=", "set_E");
1388
+ rb_define_alias(cgsl_graph, "axis_end=", "set_E");
1389
+ rb_define_alias(cgsl_graph, "toggle_axis_end=", "set_E");
1390
+ rb_define_method(cgsl_graph, "E", rb_gsl_graph_E, 0);
1391
+ rb_define_alias(cgsl_graph, "axis_end", "E");
1392
+ rb_define_alias(cgsl_graph, "toggle_axis_end", "E");
1393
+
1394
+ rb_define_method(cgsl_graph, "set_f", rb_gsl_graph_set_f, 1);
1395
+ rb_define_alias(cgsl_graph, "f=", "set_f");
1396
+ rb_define_alias(cgsl_graph, "font_size=", "set_f");
1397
+ rb_define_method(cgsl_graph, "f", rb_gsl_graph_f, 0);
1398
+ rb_define_alias(cgsl_graph, "font_size", "f");
1399
+
1400
+ rb_define_method(cgsl_graph, "set_F", rb_gsl_graph_set_F, 1);
1401
+ rb_define_alias(cgsl_graph, "F=", "set_F");
1402
+ rb_define_alias(cgsl_graph, "font_name=", "set_F");
1403
+ rb_define_method(cgsl_graph, "F", rb_gsl_graph_F, 0);
1404
+ rb_define_alias(cgsl_graph, "font_name", "F");
1405
+
1406
+ rb_define_method(cgsl_graph, "set_g", rb_gsl_graph_set_g, 1);
1407
+ rb_define_alias(cgsl_graph, "g=", "set_g");
1408
+ rb_define_alias(cgsl_graph, "grid_style=", "set_g");
1409
+ rb_define_method(cgsl_graph, "g", rb_gsl_graph_g, 0);
1410
+ rb_define_alias(cgsl_graph, "grid_style", "g");
1411
+
1412
+ rb_define_method(cgsl_graph, "set_h", rb_gsl_graph_set_h, 1);
1413
+ rb_define_alias(cgsl_graph, "h=", "set_h");
1414
+ rb_define_alias(cgsl_graph, "height=", "set_h");
1415
+ rb_define_alias(cgsl_graph, "height_of_plot=", "set_h");
1416
+ rb_define_method(cgsl_graph, "h", rb_gsl_graph_h, 0);
1417
+ rb_define_alias(cgsl_graph, "height", "h");
1418
+ rb_define_alias(cgsl_graph, "height_of_plot", "h");
1419
+
1420
+ rb_define_method(cgsl_graph, "set_k", rb_gsl_graph_set_k, 1);
1421
+ rb_define_alias(cgsl_graph, "k=", "set_k");
1422
+ rb_define_alias(cgsl_graph, "tick_size=", "set_k");
1423
+ rb_define_method(cgsl_graph, "k", rb_gsl_graph_k, 0);
1424
+ rb_define_alias(cgsl_graph, "tick_size", "k");
1425
+
1426
+ rb_define_method(cgsl_graph, "set_K", rb_gsl_graph_set_K, 1);
1427
+ rb_define_alias(cgsl_graph, "K=", "set_K");
1428
+ rb_define_alias(cgsl_graph, "clip_mode=", "set_K");
1429
+ rb_define_method(cgsl_graph, "K", rb_gsl_graph_K, 0);
1430
+ rb_define_alias(cgsl_graph, "clip_mode", "K");
1431
+
1432
+ rb_define_method(cgsl_graph, "set_l", rb_gsl_graph_set_l, 1);
1433
+ rb_define_alias(cgsl_graph, "l=", "set_l");
1434
+ rb_define_alias(cgsl_graph, "log_axis=", "set_l");
1435
+ rb_define_alias(cgsl_graph, "toggle_log_axis=", "set_l");
1436
+ rb_define_method(cgsl_graph, "l", rb_gsl_graph_l, 0);
1437
+ rb_define_alias(cgsl_graph, "log_axis", "l");
1438
+ rb_define_alias(cgsl_graph, "toggle_log_axis", "l");
1439
+
1440
+ rb_define_method(cgsl_graph, "set_L", rb_gsl_graph_set_L, 1);
1441
+ rb_define_alias(cgsl_graph, "L=", "set_L");
1442
+ rb_define_alias(cgsl_graph, "top_label=", "set_L");
1443
+ rb_define_method(cgsl_graph, "L", rb_gsl_graph_L, 0);
1444
+ rb_define_alias(cgsl_graph, "top_label", "L");
1445
+
1446
+ rb_define_method(cgsl_graph, "set_N", rb_gsl_graph_set_N, 1);
1447
+ rb_define_alias(cgsl_graph, "N=", "set_N");
1448
+ rb_define_alias(cgsl_graph, "no_tics=", "set_N");
1449
+ rb_define_alias(cgsl_graph, "toggle_no_tics=", "set_N");
1450
+ rb_define_method(cgsl_graph, "N", rb_gsl_graph_N, 0);
1451
+ rb_define_alias(cgsl_graph, "no_tics", "N");
1452
+ rb_define_alias(cgsl_graph, "toggle_no_tics", "N");
1453
+
1454
+ rb_define_method(cgsl_graph, "set_r", rb_gsl_graph_set_r, 1);
1455
+ rb_define_alias(cgsl_graph, "r=", "set_r");
1456
+ rb_define_alias(cgsl_graph, "right_shift=", "set_r");
1457
+ rb_define_method(cgsl_graph, "r", rb_gsl_graph_r, 0);
1458
+ rb_define_alias(cgsl_graph, "right_shift", "r");
1459
+
1460
+ rb_define_method(cgsl_graph, "set_R", rb_gsl_graph_set_R, 1);
1461
+ rb_define_alias(cgsl_graph, "R=", "set_R");
1462
+ rb_define_alias(cgsl_graph, "round-to-next-tick=", "set_R");
1463
+ rb_define_alias(cgsl_graph, "toggle_round-to-next-tick=", "set_R");
1464
+ rb_define_method(cgsl_graph, "R", rb_gsl_graph_R, 0);
1465
+ rb_define_alias(cgsl_graph, "round-to-next-tick", "R");
1466
+ rb_define_alias(cgsl_graph, "toggle_round-to-next-tick", "R");
1467
+
1468
+ rb_define_method(cgsl_graph, "set_s", rb_gsl_graph_set_s, 1);
1469
+ rb_define_alias(cgsl_graph, "s=", "set_s");
1470
+ rb_define_alias(cgsl_graph, "save_screen=", "set_s");
1471
+ rb_define_method(cgsl_graph, "s", rb_gsl_graph_s, 0);
1472
+ rb_define_alias(cgsl_graph, "save_screen", "s");
1473
+
1474
+ rb_define_method(cgsl_graph, "set_t", rb_gsl_graph_set_t, 1);
1475
+ rb_define_alias(cgsl_graph, "t=", "set_t");
1476
+ rb_define_alias(cgsl_graph, "transpose_axes=", "set_t");
1477
+ rb_define_alias(cgsl_graph, "toggle_transpose_axes=", "set_t");
1478
+ rb_define_method(cgsl_graph, "t", rb_gsl_graph_t, 0);
1479
+ rb_define_alias(cgsl_graph, "transpose_axes", "t");
1480
+ rb_define_alias(cgsl_graph, "toggle_transpose_axes", "t");
1481
+
1482
+ rb_define_method(cgsl_graph, "set_u", rb_gsl_graph_set_u, 1);
1483
+ rb_define_alias(cgsl_graph, "u=", "set_u");
1484
+ rb_define_alias(cgsl_graph, "upward_shift=", "set_u");
1485
+ rb_define_method(cgsl_graph, "u", rb_gsl_graph_u, 0);
1486
+ rb_define_alias(cgsl_graph, "upward_shift", "u");
1487
+
1488
+ rb_define_method(cgsl_graph, "set_w", rb_gsl_graph_set_w, 1);
1489
+ rb_define_alias(cgsl_graph, "w=", "set_w");
1490
+ rb_define_alias(cgsl_graph, "width=", "set_w");
1491
+ rb_define_alias(cgsl_graph, "width_of_plot=", "set_w");
1492
+ rb_define_method(cgsl_graph, "w", rb_gsl_graph_w, 0);
1493
+ rb_define_alias(cgsl_graph, "width", "w");
1494
+ rb_define_alias(cgsl_graph, "width_of_plot", "w");
1495
+
1496
+ rb_define_method(cgsl_graph, "set_x", rb_gsl_graph_set_x, 1);
1497
+ rb_define_alias(cgsl_graph, "x=", "set_x");
1498
+ rb_define_alias(cgsl_graph, "x_limits=", "set_x");
1499
+ rb_define_method(cgsl_graph, "x", rb_gsl_graph_x, 0);
1500
+ rb_define_alias(cgsl_graph, "x_limits", "x");
1501
+
1502
+ rb_define_method(cgsl_graph, "set_y", rb_gsl_graph_set_y, 1);
1503
+ rb_define_alias(cgsl_graph, "y=", "set_y");
1504
+ rb_define_alias(cgsl_graph, "y_limits=", "set_y");
1505
+ rb_define_method(cgsl_graph, "y", rb_gsl_graph_y, 0);
1506
+ rb_define_alias(cgsl_graph, "y_limits", "y");
1507
+
1508
+ rb_define_method(cgsl_graph, "set_X", rb_gsl_graph_set_X, 1);
1509
+ rb_define_alias(cgsl_graph, "X=", "set_X");
1510
+ rb_define_alias(cgsl_graph, "x_label=", "set_X");
1511
+ rb_define_method(cgsl_graph, "X", rb_gsl_graph_X, 0);
1512
+ rb_define_alias(cgsl_graph, "x_label", "X");
1513
+ rb_define_method(cgsl_graph, "set_Y", rb_gsl_graph_set_Y, 1);
1514
+ rb_define_alias(cgsl_graph, "Y=", "set_Y");
1515
+ rb_define_alias(cgsl_graph, "y_label=", "set_Y");
1516
+ rb_define_method(cgsl_graph, "Y", rb_gsl_graph_Y, 0);
1517
+ rb_define_alias(cgsl_graph, "y_label", "Y");
1518
+
1519
+ rb_define_method(cgsl_graph, "set_bg", rb_gsl_graph_set_bg, 1);
1520
+ rb_define_alias(cgsl_graph, "bg=", "set_bg");
1521
+ rb_define_alias(cgsl_graph, "bg_color=", "set_bg");
1522
+ rb_define_alias(cgsl_graph, "set_bg_color", "set_bg");
1523
+ rb_define_method(cgsl_graph, "bg", rb_gsl_graph_bg, 0);
1524
+ rb_define_alias(cgsl_graph, "bg_color", "bg");
1525
+
1526
+ rb_define_method(cgsl_graph, "set_bitmap_size", rb_gsl_graph_set_bitmap_size, 1);
1527
+ rb_define_alias(cgsl_graph, "bitmap_size=", "set_bitmap_size");
1528
+ rb_define_alias(cgsl_graph, "set_bitmap_size", "set_bitmap_size");
1529
+ rb_define_method(cgsl_graph, "bitmap_size", rb_gsl_graph_bitmap_size, 0);
1530
+
1531
+ rb_define_method(cgsl_graph, "set_frame", rb_gsl_graph_set_frame, 1);
1532
+ rb_define_alias(cgsl_graph, "frame=", "set_frame");
1533
+ rb_define_alias(cgsl_graph, "frame_color=", "set_frame");
1534
+ rb_define_alias(cgsl_graph, "set_frame_color", "set_frame");
1535
+ rb_define_method(cgsl_graph, "frame", rb_gsl_graph_frame, 0);
1536
+ rb_define_alias(cgsl_graph, "frame_color", "frame");
1537
+
1538
+ rb_define_method(cgsl_graph, "set_frame_line_width", rb_gsl_graph_set_frame_line_width, 1);
1539
+ rb_define_alias(cgsl_graph, "frame_line_width=", "set_frame_line_width");
1540
+ rb_define_method(cgsl_graph, "frame_line_width", rb_gsl_graph_frame_line_width, 0);
1541
+
1542
+ rb_define_method(cgsl_graph, "set_max_line_length", rb_gsl_graph_set_max_line_length, 1);
1543
+ rb_define_alias(cgsl_graph, "max_line_length=", "set_max_line_length");
1544
+ rb_define_method(cgsl_graph, "max_line_length", rb_gsl_graph_max_line_length, 0);
1545
+
1546
+ rb_define_method(cgsl_graph, "set_page_size", rb_gsl_graph_set_page_size, 1);
1547
+ rb_define_alias(cgsl_graph, "page_size=", "set_page_size");
1548
+ rb_define_method(cgsl_graph, "page_size", rb_gsl_graph_page_size, 0);
1549
+
1550
+ rb_define_method(cgsl_graph, "set_pen_colors", rb_gsl_graph_set_pen_colors, 1);
1551
+ rb_define_alias(cgsl_graph, "pen_colors=", "set_pen_colors");
1552
+ rb_define_alias(cgsl_graph, "pen=", "set_pen_colors");
1553
+ rb_define_method(cgsl_graph, "pen_colors", rb_gsl_graph_pen_colors, 0);
1554
+ rb_define_alias(cgsl_graph, "pen", "pen_colors");
1555
+
1556
+ rb_define_method(cgsl_graph, "set_rotation", rb_gsl_graph_set_rotation, 1);
1557
+ rb_define_alias(cgsl_graph, "rotation=", "set_rotation");
1558
+ rb_define_method(cgsl_graph, "rotation", rb_gsl_graph_rotation, 0);
1559
+
1560
+ rb_define_method(cgsl_graph, "set_title_font_name", rb_gsl_graph_set_title_font_name, 1);
1561
+ rb_define_alias(cgsl_graph, "title_font_name=", "set_title_font_name");
1562
+ rb_define_method(cgsl_graph, "title_font_name", rb_gsl_graph_title_font_name, 0);
1563
+
1564
+ rb_define_method(cgsl_graph, "set_title_font_size", rb_gsl_graph_set_title_font_size, 1);
1565
+ rb_define_alias(cgsl_graph, "title_font_size=", "set_title_font_size");
1566
+ rb_define_method(cgsl_graph, "title_font_size", rb_gsl_graph_title_font_size, 0);
1567
+
1568
+ rb_define_method(cgsl_graph, "set_rotate_y_label", rb_gsl_graph_set_rotate_y_label, 1);
1569
+ rb_define_alias(cgsl_graph, "rotate_y_label=", "set_rotate_y_label");
1570
+ rb_define_alias(cgsl_graph, "toggle_rotate_y_label=", "set_rotate_y_label");
1571
+ rb_define_method(cgsl_graph, "rotate_y_label", rb_gsl_graph_rotate_y_label, 0);
1572
+ rb_define_alias(cgsl_graph, "toggle_rotate_y_label", "rotate_y_label");
1573
+
1574
+ rb_define_method(cgsl_graph, "set_B", rb_gsl_graph_set_B, 1);
1575
+ rb_define_alias(cgsl_graph, "B=", "set_B");
1576
+ rb_define_alias(cgsl_graph, "auto_dump=", "set_B");
1577
+ rb_define_alias(cgsl_graph, "toggle_auto_dump=", "set_B");
1578
+ rb_define_method(cgsl_graph, "B", rb_gsl_graph_B, 0);
1579
+ rb_define_alias(cgsl_graph, "auto_dump", "B");
1580
+ rb_define_alias(cgsl_graph, "toggle_auto_dump", "B");
1581
+
1582
+ rb_define_method(cgsl_graph, "set_I", rb_gsl_graph_set_I, 1);
1583
+ rb_define_alias(cgsl_graph, "I=", "set_I");
1584
+ rb_define_alias(cgsl_graph, "input_format=", "set_I");
1585
+ rb_define_method(cgsl_graph, "I", rb_gsl_graph_I, 0);
1586
+ rb_define_alias(cgsl_graph, "input_format", "I");
1587
+
1588
+ rb_define_method(cgsl_graph, "set_m", rb_gsl_graph_set_m, 1);
1589
+ rb_define_alias(cgsl_graph, "m=", "set_m");
1590
+ rb_define_alias(cgsl_graph, "line_mode=", "set_m");
1591
+ rb_define_method(cgsl_graph, "m", rb_gsl_graph_m, 0);
1592
+ rb_define_alias(cgsl_graph, "line_mode", "m");
1593
+
1594
+ rb_define_method(cgsl_graph, "set_S", rb_gsl_graph_set_S, 1);
1595
+ rb_define_alias(cgsl_graph, "S=", "set_S");
1596
+ rb_define_alias(cgsl_graph, "symbol=", "set_S");
1597
+ rb_define_method(cgsl_graph, "S", rb_gsl_graph_S, 0);
1598
+ rb_define_alias(cgsl_graph, "symbol", "S");
1599
+
1600
+ rb_define_method(cgsl_graph, "set_W", rb_gsl_graph_set_W, 1);
1601
+ rb_define_alias(cgsl_graph, "W=", "set_W");
1602
+ rb_define_alias(cgsl_graph, "line_width=", "set_W");
1603
+ rb_define_method(cgsl_graph, "W", rb_gsl_graph_W, 0);
1604
+ rb_define_alias(cgsl_graph, "line_width", "W");
1605
+
1606
+ rb_define_method(cgsl_graph, "set_q", rb_gsl_graph_set_q, 1);
1607
+ rb_define_alias(cgsl_graph, "q=", "set_q");
1608
+ rb_define_alias(cgsl_graph, "fill_fraction=", "set_q");
1609
+ rb_define_method(cgsl_graph, "q", rb_gsl_graph_q, 0);
1610
+ rb_define_alias(cgsl_graph, "fill_fraction", "q");
1611
+
1612
+ rb_define_method(cgsl_graph, "set_C", rb_gsl_graph_set_C, 1);
1613
+ rb_define_alias(cgsl_graph, "C=", "set_C");
1614
+ rb_define_alias(cgsl_graph, "use_color=", "set_C");
1615
+ rb_define_alias(cgsl_graph, "toggle_use_color=", "set_C");
1616
+ rb_define_method(cgsl_graph, "C", rb_gsl_graph_C, 0);
1617
+ rb_define_alias(cgsl_graph, "use_color", "C");
1618
+ rb_define_alias(cgsl_graph, "toggle_use_color", "C");
1619
+
1620
+ rb_define_method(cgsl_graph, "set_symbol_font_name",
1621
+ rb_gsl_graph_set_symbol_font_name, 1);
1622
+ rb_define_alias(cgsl_graph, "symbol_font_name=", "set_symbol_font_name");
1623
+ rb_define_method(cgsl_graph, "symbol_font_name", rb_gsl_graph_symbol_font_name, 0);
1624
+
1625
+ rb_define_method(cgsl_graph, "set_reposition",
1626
+ rb_gsl_graph_set_reposition, 1);
1627
+ rb_define_alias(cgsl_graph, "reposition=", "set_reposition");
1628
+ rb_define_method(cgsl_graph, "reposition", rb_gsl_graph_reposition, 0);
1629
+
1630
+ rb_define_method(cgsl_graph, "set_blankout",
1631
+ rb_gsl_graph_set_blankout, 1);
1632
+ rb_define_alias(cgsl_graph, "blankout=", "set_blankout");
1633
+ rb_define_method(cgsl_graph, "blankout", rb_gsl_graph_blankout, 0);
1634
+
1635
+ rb_define_method(cgsl_graph, "set_O", rb_gsl_graph_set_O, 1);
1636
+ rb_define_alias(cgsl_graph, "O=", "set_O");
1637
+ rb_define_alias(cgsl_graph, "portable_output=", "set_O");
1638
+ rb_define_method(cgsl_graph, "O", rb_gsl_graph_O, 0);
1639
+ rb_define_alias(cgsl_graph, "portable_output", "O");
1640
+ }