rb-gsl 1.16.0.4 → 1.16.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -0
  3. data/.travis.yml +24 -0
  4. data/AUTHORS +6 -0
  5. data/COPYING +341 -339
  6. data/ChangeLog +608 -587
  7. data/Gemfile +4 -0
  8. data/README.md +77 -0
  9. data/Rakefile +14 -33
  10. data/THANKS +1 -1
  11. data/examples/blas/blas.rb +1 -1
  12. data/examples/bspline.rb +3 -3
  13. data/examples/complex/functions.rb +4 -4
  14. data/examples/complex/mul.rb +1 -1
  15. data/examples/const/physconst.rb +4 -4
  16. data/examples/const/travel.rb +4 -4
  17. data/examples/eigen/nonsymmv.rb +1 -1
  18. data/examples/eigen/qhoscillator.rb +3 -3
  19. data/examples/fft/radix2.rb +1 -1
  20. data/examples/fft/real-halfcomplex.rb +3 -3
  21. data/examples/fft/real-halfcomplex2.rb +3 -3
  22. data/examples/fit/expfit.rb +1 -1
  23. data/examples/fit/multifit.rb +1 -1
  24. data/examples/fit/ndlinear.rb +44 -44
  25. data/examples/fit/nonlinearfit.rb +1 -1
  26. data/examples/fit/wlinear.rb +3 -3
  27. data/examples/function/function.rb +1 -1
  28. data/examples/function/min.rb +1 -1
  29. data/examples/function/synchrotron.rb +2 -2
  30. data/examples/gallery/koch.rb +1 -1
  31. data/examples/histogram/cauchy.rb +2 -2
  32. data/examples/histogram/exponential.rb +1 -1
  33. data/examples/histogram/histo3d.rb +1 -1
  34. data/examples/histogram/histogram-pdf.rb +2 -2
  35. data/examples/histogram/xexp.rb +1 -1
  36. data/examples/integration/ahmed.rb +2 -2
  37. data/examples/integration/cosmology.rb +7 -7
  38. data/examples/integration/friedmann.rb +4 -4
  39. data/examples/integration/qng.rb +1 -1
  40. data/examples/interp/demo.rb +2 -2
  41. data/examples/linalg/LQ_solve.rb +1 -1
  42. data/examples/linalg/LU.rb +1 -1
  43. data/examples/linalg/LU2.rb +1 -1
  44. data/examples/linalg/LU_narray.rb +1 -1
  45. data/examples/linalg/PTLQ.rb +1 -1
  46. data/examples/linalg/QRPT.rb +1 -1
  47. data/examples/linalg/chol.rb +1 -1
  48. data/examples/linalg/chol_narray.rb +1 -1
  49. data/examples/linalg/complex.rb +1 -1
  50. data/examples/math/elementary.rb +1 -1
  51. data/examples/math/functions.rb +1 -1
  52. data/examples/math/inf_nan.rb +1 -1
  53. data/examples/math/minmax.rb +1 -1
  54. data/examples/math/power.rb +1 -1
  55. data/examples/math/test.rb +1 -1
  56. data/examples/min.rb +1 -1
  57. data/examples/multimin/bundle.rb +1 -1
  58. data/examples/multimin/cqp.rb +17 -17
  59. data/examples/multiroot/fsolver3.rb +1 -1
  60. data/examples/odeiv/binarysystem.rb +12 -12
  61. data/examples/odeiv/demo.rb +3 -3
  62. data/examples/odeiv/frei1.rb +7 -7
  63. data/examples/odeiv/frei2.rb +4 -4
  64. data/examples/odeiv/oscillator.rb +1 -1
  65. data/examples/odeiv/sedov.rb +3 -3
  66. data/examples/odeiv/whitedwarf.rb +11 -11
  67. data/examples/permutation/ex1.rb +2 -2
  68. data/examples/permutation/permutation.rb +1 -1
  69. data/examples/poly/demo.rb +1 -1
  70. data/examples/random/diffusion.rb +1 -1
  71. data/examples/random/generator.rb +2 -2
  72. data/examples/random/randomwalk.rb +3 -3
  73. data/examples/random/rng.rb +1 -1
  74. data/examples/roots/bisection.rb +1 -1
  75. data/examples/roots/brent.rb +1 -1
  76. data/examples/roots/demo.rb +1 -1
  77. data/examples/roots/newton.rb +2 -2
  78. data/examples/roots/recombination.gp +0 -1
  79. data/examples/sf/hyperg.rb +1 -1
  80. data/examples/sf/sphbessel.rb +1 -1
  81. data/examples/sort/sort.rb +1 -1
  82. data/examples/tamu_anova.rb +4 -4
  83. data/examples/vector/add.rb +1 -1
  84. data/examples/vector/decimate.rb +1 -1
  85. data/examples/vector/gnuplot.rb +8 -8
  86. data/examples/vector/vector.rb +2 -2
  87. data/examples/wavelet/wavelet1.rb +1 -1
  88. data/ext/{gsl → gsl_native}/alf.c +9 -9
  89. data/ext/{gsl → gsl_native}/array.c +64 -151
  90. data/ext/{gsl → gsl_native}/array_complex.c +61 -63
  91. data/ext/{gsl → gsl_native}/blas.c +0 -0
  92. data/ext/{gsl → gsl_native}/blas1.c +32 -32
  93. data/ext/{gsl → gsl_native}/blas2.c +54 -58
  94. data/ext/{gsl → gsl_native}/blas3.c +54 -54
  95. data/ext/{gsl → gsl_native}/block.c +3 -6
  96. data/ext/{gsl/block_source.c → gsl_native/block_source.h} +109 -111
  97. data/ext/gsl_native/bspline.c +122 -0
  98. data/ext/{gsl → gsl_native}/bundle.c +0 -0
  99. data/ext/{gsl → gsl_native}/cdf.c +76 -88
  100. data/ext/{gsl → gsl_native}/cheb.c +74 -85
  101. data/ext/{gsl → gsl_native}/combination.c +9 -16
  102. data/ext/{gsl → gsl_native}/common.c +7 -37
  103. data/ext/{gsl → gsl_native}/complex.c +113 -115
  104. data/ext/gsl_native/const.c +331 -0
  105. data/ext/{gsl → gsl_native}/const_additional.c +12 -33
  106. data/ext/gsl_native/cqp.c +283 -0
  107. data/ext/{gsl → gsl_native}/deriv.c +22 -30
  108. data/ext/{gsl → gsl_native}/dht.c +20 -28
  109. data/ext/{gsl → gsl_native}/diff.c +23 -25
  110. data/ext/{gsl → gsl_native}/dirac.c +44 -45
  111. data/ext/{gsl → gsl_native}/eigen.c +1031 -1082
  112. data/ext/{gsl → gsl_native}/error.c +13 -13
  113. data/ext/{gsl → gsl_native}/extconf.rb +5 -13
  114. data/ext/{gsl → gsl_native}/fft.c +192 -198
  115. data/ext/{gsl → gsl_native}/fit.c +16 -16
  116. data/ext/gsl_native/fresnel.c +312 -0
  117. data/ext/{gsl → gsl_native}/function.c +29 -35
  118. data/ext/{gsl → gsl_native}/geometry.c +15 -15
  119. data/ext/{gsl → gsl_native}/graph.c +37 -87
  120. data/ext/{gsl → gsl_native}/gsl.c +10 -23
  121. data/ext/{gsl → gsl_native}/gsl_narray.c +15 -24
  122. data/ext/{gsl → gsl_native}/histogram.c +123 -150
  123. data/ext/{gsl → gsl_native}/histogram2d.c +71 -96
  124. data/ext/{gsl → gsl_native}/histogram3d.c +72 -72
  125. data/ext/{gsl → gsl_native}/histogram3d_source.c +195 -196
  126. data/ext/{gsl → gsl_native}/histogram_find.c +31 -33
  127. data/ext/{gsl → gsl_native}/histogram_oper.c +43 -52
  128. data/ext/{gsl → gsl_native}/ieee.c +7 -15
  129. data/ext/{gsl → gsl_native}/include/rb_gsl.h +0 -7
  130. data/ext/{gsl → gsl_native}/include/rb_gsl_array.h +15 -25
  131. data/ext/{gsl → gsl_native}/include/rb_gsl_cheb.h +0 -0
  132. data/ext/{gsl → gsl_native}/include/rb_gsl_common.h +44 -52
  133. data/ext/{gsl → gsl_native}/include/rb_gsl_complex.h +0 -0
  134. data/ext/{gsl → gsl_native}/include/rb_gsl_const.h +0 -5
  135. data/ext/{gsl → gsl_native}/include/rb_gsl_dirac.h +0 -0
  136. data/ext/{gsl → gsl_native}/include/rb_gsl_eigen.h +0 -0
  137. data/ext/{gsl → gsl_native}/include/rb_gsl_fft.h +0 -3
  138. data/ext/{gsl → gsl_native}/include/rb_gsl_fit.h +0 -0
  139. data/ext/{gsl → gsl_native}/include/rb_gsl_function.h +0 -0
  140. data/ext/{gsl → gsl_native}/include/rb_gsl_graph.h +2 -2
  141. data/ext/{gsl → gsl_native}/include/rb_gsl_histogram.h +8 -8
  142. data/ext/{gsl → gsl_native}/include/rb_gsl_histogram3d.h +50 -50
  143. data/ext/{gsl → gsl_native}/include/rb_gsl_integration.h +0 -0
  144. data/ext/{gsl → gsl_native}/include/rb_gsl_interp.h +0 -0
  145. data/ext/{gsl → gsl_native}/include/rb_gsl_linalg.h +0 -1
  146. data/ext/{gsl → gsl_native}/include/rb_gsl_math.h +0 -4
  147. data/ext/{gsl → gsl_native}/include/rb_gsl_odeiv.h +0 -0
  148. data/ext/{gsl → gsl_native}/include/rb_gsl_poly.h +3 -3
  149. data/ext/{gsl → gsl_native}/include/rb_gsl_rational.h +1 -1
  150. data/ext/{gsl → gsl_native}/include/rb_gsl_rng.h +0 -0
  151. data/ext/{gsl → gsl_native}/include/rb_gsl_root.h +0 -0
  152. data/ext/{gsl → gsl_native}/include/rb_gsl_sf.h +39 -43
  153. data/ext/{gsl → gsl_native}/include/rb_gsl_statistics.h +0 -0
  154. data/ext/{gsl → gsl_native}/include/rb_gsl_tensor.h +0 -0
  155. data/ext/{gsl → gsl_native}/include/rb_gsl_with_narray.h +0 -0
  156. data/ext/{gsl → gsl_native}/include/templates_off.h +0 -0
  157. data/ext/{gsl → gsl_native}/include/templates_on.h +1 -1
  158. data/ext/{gsl → gsl_native}/integration.c +160 -183
  159. data/ext/{gsl → gsl_native}/interp.c +23 -31
  160. data/ext/gsl_native/jacobi.c +733 -0
  161. data/ext/{gsl → gsl_native}/linalg.c +448 -576
  162. data/ext/{gsl → gsl_native}/linalg_complex.c +84 -98
  163. data/ext/{gsl → gsl_native}/math.c +45 -63
  164. data/ext/{gsl → gsl_native}/matrix.c +4 -6
  165. data/ext/{gsl → gsl_native}/matrix_complex.c +111 -114
  166. data/ext/{gsl → gsl_native}/matrix_double.c +74 -77
  167. data/ext/{gsl → gsl_native}/matrix_int.c +49 -50
  168. data/ext/{gsl/matrix_source.c → gsl_native/matrix_source.h} +280 -302
  169. data/ext/{gsl → gsl_native}/min.c +43 -74
  170. data/ext/{gsl → gsl_native}/monte.c +45 -59
  171. data/ext/{gsl → gsl_native}/multifit.c +138 -147
  172. data/ext/{gsl → gsl_native}/multimin.c +55 -83
  173. data/ext/{gsl → gsl_native}/multimin_fsdf.c +15 -15
  174. data/ext/{gsl → gsl_native}/multiroots.c +61 -64
  175. data/ext/{gsl → gsl_native}/multiset.c +3 -7
  176. data/ext/{gsl → gsl_native}/ndlinear.c +320 -321
  177. data/ext/{gsl → gsl_native}/nmf.c +11 -11
  178. data/ext/{gsl → gsl_native}/nmf_wrap.c +1 -1
  179. data/ext/{gsl → gsl_native}/ntuple.c +13 -13
  180. data/ext/{gsl → gsl_native}/odeiv.c +95 -106
  181. data/ext/gsl_native/ool.c +879 -0
  182. data/ext/{gsl → gsl_native}/permutation.c +36 -34
  183. data/ext/{gsl → gsl_native}/poly.c +2 -5
  184. data/ext/{gsl → gsl_native}/poly2.c +6 -6
  185. data/ext/{gsl/poly_source.c → gsl_native/poly_source.h} +232 -275
  186. data/ext/{gsl → gsl_native}/qrng.c +6 -17
  187. data/ext/{gsl → gsl_native}/randist.c +218 -243
  188. data/ext/{gsl → gsl_native}/rational.c +9 -9
  189. data/ext/{gsl → gsl_native}/rng.c +29 -45
  190. data/ext/{gsl → gsl_native}/root.c +43 -43
  191. data/ext/{gsl → gsl_native}/sf.c +163 -197
  192. data/ext/{gsl → gsl_native}/sf_airy.c +0 -0
  193. data/ext/{gsl → gsl_native}/sf_bessel.c +6 -6
  194. data/ext/{gsl → gsl_native}/sf_clausen.c +0 -0
  195. data/ext/{gsl → gsl_native}/sf_coulomb.c +39 -39
  196. data/ext/{gsl → gsl_native}/sf_coupling.c +29 -29
  197. data/ext/{gsl → gsl_native}/sf_dawson.c +0 -0
  198. data/ext/{gsl → gsl_native}/sf_debye.c +0 -9
  199. data/ext/{gsl → gsl_native}/sf_dilog.c +0 -0
  200. data/ext/{gsl → gsl_native}/sf_elementary.c +2 -2
  201. data/ext/{gsl → gsl_native}/sf_ellint.c +42 -42
  202. data/ext/{gsl → gsl_native}/sf_elljac.c +2 -2
  203. data/ext/{gsl → gsl_native}/sf_erfc.c +0 -4
  204. data/ext/{gsl → gsl_native}/sf_exp.c +2 -2
  205. data/ext/{gsl → gsl_native}/sf_expint.c +1 -11
  206. data/ext/{gsl → gsl_native}/sf_fermi_dirac.c +0 -0
  207. data/ext/{gsl → gsl_native}/sf_gamma.c +1 -5
  208. data/ext/{gsl → gsl_native}/sf_gegenbauer.c +0 -0
  209. data/ext/{gsl → gsl_native}/sf_hyperg.c +0 -0
  210. data/ext/{gsl → gsl_native}/sf_laguerre.c +3 -3
  211. data/ext/{gsl → gsl_native}/sf_lambert.c +0 -0
  212. data/ext/{gsl → gsl_native}/sf_legendre.c +0 -0
  213. data/ext/{gsl → gsl_native}/sf_log.c +3 -3
  214. data/ext/gsl_native/sf_mathieu.c +235 -0
  215. data/ext/{gsl → gsl_native}/sf_power.c +0 -0
  216. data/ext/{gsl → gsl_native}/sf_psi.c +2 -11
  217. data/ext/{gsl → gsl_native}/sf_synchrotron.c +0 -0
  218. data/ext/{gsl → gsl_native}/sf_transport.c +0 -0
  219. data/ext/{gsl → gsl_native}/sf_trigonometric.c +3 -3
  220. data/ext/{gsl → gsl_native}/sf_zeta.c +0 -4
  221. data/ext/{gsl → gsl_native}/signal.c +60 -64
  222. data/ext/{gsl → gsl_native}/siman.c +36 -40
  223. data/ext/{gsl → gsl_native}/sort.c +3 -4
  224. data/ext/{gsl → gsl_native}/spline.c +25 -43
  225. data/ext/{gsl → gsl_native}/stats.c +102 -115
  226. data/ext/{gsl → gsl_native}/sum.c +32 -32
  227. data/ext/{gsl → gsl_native}/tamu_anova.c +0 -0
  228. data/ext/{gsl → gsl_native}/tensor.c +2 -4
  229. data/ext/{gsl/tensor_source.c → gsl_native/tensor_source.h} +144 -144
  230. data/ext/{gsl → gsl_native}/vector.c +2 -4
  231. data/ext/{gsl → gsl_native}/vector_complex.c +165 -171
  232. data/ext/{gsl → gsl_native}/vector_double.c +167 -174
  233. data/ext/{gsl → gsl_native}/vector_int.c +23 -25
  234. data/ext/{gsl/vector_source.c → gsl_native/vector_source.h} +400 -414
  235. data/ext/{gsl → gsl_native}/wavelet.c +215 -236
  236. data/lib/gsl.rb +1 -7
  237. data/lib/gsl/gnuplot.rb +2 -2
  238. data/lib/gsl/version.rb +1 -3
  239. data/rb-gsl.gemspec +29 -0
  240. data/rdoc/blas.rdoc +3 -3
  241. data/rdoc/bspline.rdoc +7 -7
  242. data/rdoc/cheb.rdoc +8 -8
  243. data/rdoc/cholesky_complex.rdoc +1 -1
  244. data/rdoc/combi.rdoc +9 -9
  245. data/rdoc/complex.rdoc +11 -11
  246. data/rdoc/const.rdoc +20 -20
  247. data/rdoc/dht.rdoc +6 -6
  248. data/rdoc/diff.rdoc +6 -6
  249. data/rdoc/ehandling.rdoc +3 -3
  250. data/rdoc/eigen.rdoc +11 -11
  251. data/rdoc/fft.rdoc +26 -26
  252. data/rdoc/fit.rdoc +18 -18
  253. data/rdoc/graph.rdoc +2 -2
  254. data/rdoc/hist.rdoc +16 -16
  255. data/rdoc/hist2d.rdoc +4 -4
  256. data/rdoc/hist3d.rdoc +3 -3
  257. data/rdoc/integration.rdoc +16 -16
  258. data/rdoc/interp.rdoc +11 -11
  259. data/rdoc/intro.rdoc +3 -3
  260. data/rdoc/linalg.rdoc +20 -20
  261. data/rdoc/linalg_complex.rdoc +1 -1
  262. data/rdoc/math.rdoc +13 -13
  263. data/rdoc/matrix.rdoc +22 -22
  264. data/rdoc/min.rdoc +9 -9
  265. data/rdoc/monte.rdoc +3 -3
  266. data/rdoc/multimin.rdoc +12 -12
  267. data/rdoc/multiroot.rdoc +12 -12
  268. data/rdoc/narray.rdoc +9 -9
  269. data/rdoc/ndlinear.rdoc +4 -4
  270. data/rdoc/nonlinearfit.rdoc +17 -17
  271. data/rdoc/ntuple.rdoc +5 -5
  272. data/rdoc/odeiv.rdoc +12 -12
  273. data/rdoc/perm.rdoc +11 -11
  274. data/rdoc/poly.rdoc +17 -17
  275. data/rdoc/qrng.rdoc +9 -9
  276. data/rdoc/randist.rdoc +10 -10
  277. data/rdoc/ref.rdoc +49 -49
  278. data/rdoc/rng.rdoc +9 -9
  279. data/rdoc/roots.rdoc +12 -12
  280. data/rdoc/sf.rdoc +35 -35
  281. data/rdoc/siman.rdoc +3 -3
  282. data/rdoc/sort.rdoc +6 -6
  283. data/rdoc/start.rdoc +2 -2
  284. data/rdoc/stats.rdoc +13 -13
  285. data/rdoc/sum.rdoc +4 -4
  286. data/rdoc/tensor.rdoc +3 -3
  287. data/rdoc/tut.rdoc +1 -1
  288. data/rdoc/use.rdoc +3 -3
  289. data/rdoc/vector.rdoc +28 -28
  290. data/rdoc/vector_complex.rdoc +6 -6
  291. data/rdoc/wavelet.rdoc +8 -8
  292. data/test/gsl/blas_test.rb +1 -1
  293. data/test/gsl/index_test.rb +61 -0
  294. data/test/gsl/matrix_test.rb +21 -0
  295. data/uncrustify.cfg +1693 -0
  296. metadata +212 -243
  297. data/README +0 -28
  298. data/ext/gsl/bspline.c +0 -130
  299. data/ext/gsl/const.c +0 -672
  300. data/ext/gsl/cqp.c +0 -283
  301. data/ext/gsl/fcmp.c +0 -64
  302. data/ext/gsl/fresnel.c +0 -312
  303. data/ext/gsl/jacobi.c +0 -739
  304. data/ext/gsl/ool.c +0 -879
  305. data/ext/gsl/oper_complex_source.c +0 -251
  306. data/ext/gsl/sf_mathieu.c +0 -238
  307. data/rdoc/index.rdoc +0 -50
@@ -9,7 +9,7 @@ func = GSL::MultiRoot::Function.alloc(2) { |x, f|
9
9
  f[0] = -2.0*x0*x0 + 3.0*x0*x1 + 4.0*sin(x1) - 6.0
10
10
  f[1] = 3.0*x0*x0 - 2.0*x0*x1*x1 + 3.0*cos(x0) + 4.0
11
11
  }
12
-
12
+
13
13
  p func.solve([1.0, 2.0].to_gv, 1000, 1e-7, "hybrids")
14
14
  p func.solve([1.0, 2.0].to_gv, 1000, "broyden")
15
15
  p func.solve([1.0, 2.0], "hybrid")
@@ -2,13 +2,13 @@
2
2
  # 19/Apr/2004 by Yoshiki Tsunesada
3
3
  #
4
4
  # This is an example to calculate the orbital evolution of
5
- # a double neutron star (binary) system. General relativity predicts
6
- # that the binary orbital decays by radiating gravitational waves,
7
- # and the two stars will coalesce in time scale of 100-1000 Mega-years.
8
- # The values used here are of the binary system J0730-3039 discovered
9
- # in 2003 (Burgay et al., Nature 2003). The result shows that the two
10
- # neutron stars will merge after about 85 Mega-years. From the age of
11
- # the system 100 Mega-year, the lifetime of the system is estimated
5
+ # a double neutron star (binary) system. General relativity predicts
6
+ # that the binary orbital decays by radiating gravitational waves,
7
+ # and the two stars will coalesce in time scale of 100-1000 Mega-years.
8
+ # The values used here are of the binary system J0730-3039 discovered
9
+ # in 2003 (Burgay et al., Nature 2003). The result shows that the two
10
+ # neutron stars will merge after about 85 Mega-years. From the age of
11
+ # the system 100 Mega-year, the lifetime of the system is estimated
12
12
  # about 185 Mega-years.
13
13
  #
14
14
  # References:
@@ -16,7 +16,7 @@
16
16
  # 2. Shapiro & Teukolsky, "Black holes, white dwarfs and neutron stars"
17
17
  # John Wiley and Sans (1983)
18
18
  #
19
-
19
+
20
20
  require("gsl")
21
21
  include Math
22
22
 
@@ -33,7 +33,7 @@ GMsolarC3 = 4.925490947e-6
33
33
  MegaYear = 3600*24*365*1e6
34
34
 
35
35
  # Time evolution of the binary orbital period and the eccentricity
36
- # due to gravitational radiation.
36
+ # due to gravitational radiation.
37
37
  # The calculation is based on general relativity (See e.g. Ref.2).
38
38
  # y[0]: orbital period (pb)
39
39
  # y[1]: eccentricity (e)
@@ -45,7 +45,7 @@ deriv = Proc.new { |t, y, dydt, binary|
45
45
  e = y[1] # eccentricity
46
46
  m1 = binary.m1 # neutron star masses
47
47
  m2 = binary.m2
48
- totalM = m1 + m2 # total mass
48
+ totalM = m1 + m2 # total mass
49
49
  mu = m1*m2/totalM # reduced mass
50
50
  mm = mu*GSL::pow(totalM, 2.0/3.0)
51
51
  f_e = GSL::pow(1.0 - e*e, -3.5)*(1.0 + (73.0/24.0 + 37.0/96.0*e*e)*e*e);
@@ -85,8 +85,8 @@ tend = 2500*MegaYear
85
85
  h = 1.0*MegaYear
86
86
 
87
87
  begin
88
- file = File.open("binarysystem.dat", "w")
89
- while t < tend
88
+ file = File.open("binarysystem.dat", "w")
89
+ while t < tend
90
90
  t, h, status = solver.apply(t, tend, h, y)
91
91
  break if status != GSL::SUCCESS
92
92
  break if GSL::isnan?(y[0])
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # Solve
2
+ # Solve
3
3
  # dydt = -2y ---> y(t) = exp(-2t)
4
4
 
5
5
  require("gsl")
@@ -40,11 +40,11 @@ def odeiv_compare_algorithm(solver, steptype, t0, tend, h0, y0, outfile)
40
40
  end
41
41
 
42
42
  if GSL::VERSION >= "1.5.90"
43
- ALGORITHMS = ["rk2", "rk4", "rkf45", "rkck", "rk8pd", "rk2imp", "rk4imp",
43
+ ALGORITHMS = ["rk2", "rk4", "rkf45", "rkck", "rk8pd", "rk2imp", "rk4imp",
44
44
  "bsimp", "gear1", "gear2", "rk2simp"]
45
45
  gpfile = "demo2.gp"
46
46
  else
47
- ALGORITHMS = ["rk2", "rk4", "rkf45", "rkck", "rk8pd", "rk2imp", "rk4imp",
47
+ ALGORITHMS = ["rk2", "rk4", "rkf45", "rkck", "rk8pd", "rk2imp", "rk4imp",
48
48
  "bsimp", "gear1", "gear2"]
49
49
  gpfile = "demo.gp"
50
50
  end
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Solve Schroedinger equation
3
3
  #
4
- # This example is taken from frei1.cpp
4
+ # This example is taken from frei1.cpp
5
5
  # in "Numerische Physik" p201-204 (Springer),
6
6
  # which simulates the time evolution of a probability density.
7
7
  #
8
8
  # Name: frei1.cpp
9
- # Zweck: Simuliert ein quantenmechanisches freies Teilchen
10
- # Gleichung: Schroedingergleichung ohne Potential verwendete
9
+ # Zweck: Simuliert ein quantenmechanisches freies Teilchen
10
+ # Gleichung: Schroedingergleichung ohne Potential verwendete
11
11
  # Bibiliothek: GSL
12
12
  #
13
13
  # Reference:
@@ -20,7 +20,7 @@ require("gsl")
20
20
  #NMAX = 8192
21
21
  NMAX = 256
22
22
 
23
- # The wave equation:
23
+ # The wave equation:
24
24
  # calculate time derivative of the wave function.
25
25
  # The second spatial derivative is approximated by
26
26
  # d2_psi/dx2 ~ (psi[n+1] - 2*psi[n] + pxi[n-1])/(dx*dx)
@@ -68,7 +68,7 @@ sum = 0.0
68
68
  for n in 0...NMAX do
69
69
  x = (n-NMAX/2) * $dx
70
70
  psi[n] = Math::exp(-GSL::pow_2(x/alpha)/2)
71
- sum += GSL::pow_2(psi[n])
71
+ sum += GSL::pow_2(psi[n])
72
72
  end
73
73
  sum = 1.0/Math::sqrt(sum)
74
74
 
@@ -89,12 +89,12 @@ IO.popen("graph -T X -C -g 3", "w") do |io|
89
89
  c = GSL::Odeiv::Control.y_new(atol, rtol)
90
90
  evolve = GSL::Odeiv::Evolve.alloc(2*NMAX)
91
91
  sys = GSL::Odeiv::System.alloc(f, 2*NMAX)
92
-
92
+
93
93
  t = 0.0
94
94
  for n in 1..n_out do
95
95
  t1 = n*dt
96
96
  STDOUT.printf("t = %2.1f (%2d/%2d)\n", t1-dt, n, n_out)
97
- while t < t1
97
+ while t < t1
98
98
  t, h, status = evolve.apply(c, step, sys, t, t1, h, psi)
99
99
  break if status != GSL::SUCCESS
100
100
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # This example is taken from frei2.cpp
2
+ # This example is taken from frei2.cpp
3
3
  # in "Numerische Physik" p205-206 (Springer).
4
4
  #
5
5
  # Reference:
@@ -45,10 +45,10 @@ IO.popen("graph -T X -C -g 3", "w") do |io|
45
45
  io.printf("%e %e\n", x, psi[n1].abs)
46
46
  end
47
47
  io.printf("\n")
48
-
48
+
49
49
  psi_p.radix2_forward!
50
-
51
-
50
+
51
+
52
52
  t = 0.0
53
53
  for n in 1..n_out do
54
54
  t1 = n*dt
@@ -5,7 +5,7 @@
5
5
  # b: resist
6
6
  # f: external force
7
7
 
8
- require("gsl")
8
+ require("gsl")
9
9
 
10
10
  dim = 2
11
11
 
@@ -18,16 +18,16 @@ include Math
18
18
  Sedov = Proc.new { |logx, y, dydlogx, sh|
19
19
  a = -5.0*(6.0*y[2] - 15.0*y[2]*y[0]*sh + 2.0*y[0]*y[1] - 7.0*y[0]*y[0]*y[1] + 5.0*GSL::pow_3(y[0])*y[1])
20
20
  b = -25.0*y[2]*sh + 4.0*y[1] - 20.0*y[0]*y[1] + 25.0*y[0]*y[0]*y[1]
21
- dydlogx[0] = a/b
21
+ dydlogx[0] = a/b
22
22
 
23
23
  bb = -5.0*(6.0*y[2] - 15.0*y[2]*y[0]*sh + 2.0*y[0]*y[1] - 7.0*y[0]*y[0]*y[1])
24
24
 
25
25
  a = -5.0*(-30.0*y[2]*y[1] + 2.0*y[0]*y[1]*y[1] - 25.0*GSL::pow_2(y[0]*y[1]) + 50.0*GSL::pow_3(y[0])*GSL::pow_2(y[1]))
26
26
  bb = (-2.0 + 5.0*y[0])*(-25.0*y[2]*sh + 4.0*y[1] - 20.0*y[0]*y[1] + 25.0*y[0]*y[0]*y[1])
27
- dydlogx[1] = a/bb
27
+ dydlogx[1] = a/bb
28
28
 
29
29
  a = -5.0*y[2]*(-10.0*y[2]*sh + 4.0*y[1] - 14.0*y[0]*y[1] + 10.0*y[0]*y[0]*y[1] - y[0]*sh*y[1] + 10.0*y[0]*y[0]*sh*y[1])
30
- dydlogx[2] = a/b
30
+ dydlogx[2] = a/b
31
31
  }
32
32
 
33
33
  DIM = 3
@@ -15,8 +15,8 @@ module Degenerate
15
15
  hbar = PLANCKS_CONSTANT_HBAR # Planck's constant
16
16
  me = MASS_ELECTRON # Electron mass
17
17
  mn = MASS_NEUTRON # Neutron mass
18
- mu = UNIFIED_ATOMIC_MASS
19
- c = SPEED_OF_LIGHT
18
+ mu = UNIFIED_ATOMIC_MASS
19
+ c = SPEED_OF_LIGHT
20
20
  ELambda = hbar/me/c # Compton length of electron
21
21
  NLambda = hbar/mn/c
22
22
  MeC2 = me*c*c # Electron rest mass energy
@@ -29,24 +29,24 @@ module Degenerate
29
29
  tmp = sqrt(1.0 + x*x)
30
30
  (x*tmp*(2.0*x*x/3.0 - 1.0) + log(x + tmp))/8/PI/PI
31
31
  end
32
-
32
+
33
33
  def chi(x)
34
34
  tmp = sqrt(1.0 + x*x)
35
35
  (x*tmp*(1.0 + 2*x*x) - log(x + tmp))/8/PI/PI
36
36
  end
37
-
37
+
38
38
  def xe_rho_mue(rho, mue)
39
39
  Factor_xe*GSL::pow(rho/mue, 1.0/3.0)
40
40
  end
41
-
41
+
42
42
  def xn_rho(rho)
43
43
  Factor_xn*GSL::pow(rho, 1.0/3.0)
44
44
  end
45
-
45
+
46
46
  end
47
47
 
48
48
  # Polytrope gas sphere
49
- module Polytrope
49
+ module Polytrope
50
50
 
51
51
  # Lane-Emden equation
52
52
  # n: polytrope index
@@ -59,7 +59,7 @@ module Polytrope
59
59
  dim = 2
60
60
  y = GSL::Vector[1.0, 0.0]
61
61
  dydx = GSL::Vector.alloc(dim)
62
-
62
+
63
63
  solver = Solver.alloc(Step::RKF45, [1e-6, 0], EmdenEq, dim)
64
64
  solver.set_params(n)
65
65
  solver.reset
@@ -71,7 +71,7 @@ module Polytrope
71
71
  x = 0.0001
72
72
  xend = 10.0
73
73
  h = 1e-6
74
-
74
+
75
75
  file = File.open("polytrope.dat", "w")
76
76
  i = 0
77
77
  while x < xend
@@ -94,10 +94,10 @@ module Polytrope
94
94
  vdy2 = vdy.subvector(0, i)
95
95
  spline = GSL::Spline.alloc(GSL::Interp::AKIMA, i)
96
96
  spline.init(vy2.reverse, vx2.reverse)
97
-
97
+
98
98
  # Find star surface:
99
99
  # Star sufrace is defined as the zero point of density structure function
100
- x1 = spline.eval(0.0)
100
+ x1 = spline.eval(0.0)
101
101
  spline.init(vx2, vdy2)
102
102
  yx2 = spline.eval(x1).abs
103
103
  return [x1, yx2*x1*x1]
@@ -11,12 +11,12 @@ pp.init
11
11
  pp.fprintf(STDOUT, " %u")
12
12
  printf("\n")
13
13
 
14
- puts(" random permutation:");
14
+ puts(" random permutation:");
15
15
  r.shuffle(pp)
16
16
  pp.fprintf(STDOUT, " %u")
17
17
  printf("\n");
18
18
 
19
- puts("inverse permutation:");
19
+ puts("inverse permutation:");
20
20
  q = pp.inverse
21
21
  q.fprintf(STDOUT, " %u")
22
22
  printf ("\n");
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require("gsl")
2
+ require("gsl")
3
3
 
4
4
  p = GSL::Permutation::alloc(10)
5
5
  p.init
@@ -6,7 +6,7 @@ include GSL
6
6
  poly = Poly[1.5, -1.25, -3.75, 0, 1]
7
7
  # Solve the equation p(x) == 0
8
8
  root = poly.solve # Vector::Complex
9
- # Extract only the real parts
9
+ # Extract only the real parts
10
10
  # (imaginary parts are zero for this case)
11
11
  re = root.real # Vector::View
12
12
 
@@ -19,7 +19,7 @@ h[2] = GSL::Histogram.alloc(61, -30, 30)
19
19
 
20
20
  i = 0
21
21
  for n in [6, 50, 100] do
22
- M.times do
22
+ M.times do
23
23
  s = 0
24
24
  n.times do
25
25
  ds = rng.get%2 == 0 ? 1 : -1
@@ -7,8 +7,8 @@ names = ["default", "mt19937", "mt19937_1999", "mt19937_1998", "ranlxs0", "ranlx
7
7
  "gfsr4", "rand", "random_bsd", "random8_bsd", "random32_bsd", "random64_bsd",
8
8
  "random128_bsd", "random256_bsd", "random_libc5", "random_glibc2", "rand48", "ran0",
9
9
  "ran1", "ran2", "ran3", "ranf", "ranmar", "r250", "tt800", "vax", "transputer",
10
- "randu", "minstd", "uni", "uni32", "slatec", "zuf", "borosh13", "coveyou",
11
- "fishman18", "fishman20", "fishman2x", "knuthran2", "knuthran", "lecuyer21",
10
+ "randu", "minstd", "uni", "uni32", "slatec", "zuf", "borosh13", "coveyou",
11
+ "fishman18", "fishman20", "fishman2x", "knuthran2", "knuthran", "lecuyer21",
12
12
  "waterman14"]
13
13
 
14
14
  names.each do |name|
@@ -17,7 +17,7 @@ sigma = Math::sqrt(N).to_i
17
17
 
18
18
  h = GSL::Histogram.alloc(8*sigma+1, [-4*sigma-0.5, 4*sigma+0.5])
19
19
 
20
- M.times do
20
+ M.times do
21
21
  s = 0
22
22
  N.times do
23
23
  ds = rng.get%2 == 0 ? 1 : -1
@@ -27,8 +27,8 @@ M.times do
27
27
  end
28
28
 
29
29
  x = GSL::Vector.linspace(-40, 40, 80)
30
- y = GSL::Ran::gaussian_pdf(x, sigma)*M*2
31
- # Factor 2 is not important, but necessary
30
+ y = GSL::Ran::gaussian_pdf(x, sigma)*M*2
31
+ # Factor 2 is not important, but necessary
32
32
  # because only the even ranges are filled:
33
33
  # a + b = N a: positive steps, b: negative steps
34
34
  # a - b = s s: the end point after the N steps
@@ -18,7 +18,7 @@ p r.max
18
18
  p r.get
19
19
  p r.get
20
20
 
21
- r2 = GSL::Random::Rng.alloc
21
+ r2 = GSL::Random::Rng.alloc
22
22
  p r2.uniform
23
23
  p r2.uniform
24
24
 
@@ -8,7 +8,7 @@ f = GSL::Function.alloc { |x, params|
8
8
  }
9
9
  f.set_params(1, 0, -5)
10
10
  expected = Math::sqrt(5.0)
11
- printf("%5s [%9s, %9s] %9s %10s %9s\n",
11
+ printf("%5s [%9s, %9s] %9s %10s %9s\n",
12
12
  "iter", "lower", "upper", "root", "err", "err(est)")
13
13
  solver.set(f, 0.0, 5.0)
14
14
  iter = 0
@@ -19,7 +19,7 @@ f.set_params(1, 0, -5)
19
19
  expected = sqrt(5.0)
20
20
 
21
21
  printf("%5s [%9s, %9s] %9s %10s %9s\n",
22
- "iter", "lower", "upper", "root",
22
+ "iter", "lower", "upper", "root",
23
23
  "err", "err(est)")
24
24
 
25
25
  solver.set(f, 0.0, 5.0)
@@ -7,7 +7,7 @@ f = GSL::Function.alloc { |x, params|
7
7
  }
8
8
  f.set_params(1, 0, -5)
9
9
  expected = Math::sqrt(5.0)
10
- printf("%5s [%9s, %9s] %9s %10s %9s\n", "iter",
10
+ printf("%5s [%9s, %9s] %9s %10s %9s\n", "iter",
11
11
  "lower", "upper", "root", "err", "err(est)")
12
12
  solver.set(f, 0.0, 5.0)
13
13
  iter = 0; status = nil
@@ -2,14 +2,14 @@
2
2
  require("gsl")
3
3
  include Math
4
4
 
5
- f = Proc.new { |x, params|
5
+ f = Proc.new { |x, params|
6
6
  a = params[0]
7
7
  b = params[1]
8
8
  c = params[2]
9
9
  (a*x + b)*x + c
10
10
  }
11
11
 
12
- df = Proc.new { |x, params|
12
+ df = Proc.new { |x, params|
13
13
  a = params[0]
14
14
  b = params[1]
15
15
  2.0*a*x + b
@@ -9,4 +9,3 @@ set ylabel 'Fractional ionization'
9
9
  set x2label 'Temperature of the Universe [K]'
10
10
  set grid
11
11
  plot 'recombination.dat' u 2:3 title '' w l lw 3, 1 title ''
12
-
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require("gsl")
2
+ require("gsl")
3
3
 
4
4
  p GSL::Sf.hyperg_0F1(2, 3)
5
5
  r = GSL::Sf.hyperg_0F1_e(2, 3)
@@ -19,7 +19,7 @@ File.open("sphbessel.dat", "w") do |file|
19
19
  k0 = bessel_k0_scaled(x)
20
20
  k1 = bessel_k1_scaled(x)
21
21
  k2 = bessel_k2_scaled(x)
22
- file.printf("%e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
22
+ file.printf("%e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
23
23
  x, j0, j1, j2, j3, y0, y1, y2, i0, i1, i2, k0, k1, k2)
24
24
  x += 0.1
25
25
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require("gsl")
2
+ require("gsl")
3
3
 
4
4
  N = 100000
5
5
  k = 5
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
  require("gsl")
3
3
 
4
- data = GSL::Vector[88.60,73.20,91.40,68.00,75.20,63.00,53.90,69.20,
5
- 50.10,71.50,44.90,59.50,40.20,56.30,38.70,31.00,
4
+ data = GSL::Vector[88.60,73.20,91.40,68.00,75.20,63.00,53.90,69.20,
5
+ 50.10,71.50,44.90,59.50,40.20,56.30,38.70,31.00,
6
6
  39.60,45.30,25.20,22.70]
7
7
  factor = GSL::Vector::Int[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4]
8
8
 
9
9
  table = GSL::TAMU_ANOVA::Table.oneway(data, factor, 4)
10
10
  table.print
11
11
 
12
- data = GSL::Vector[45.50,45.30,45.40,44.40,44.60,43.90,44.60,44.00,44.20,
13
- 43.90,44.70,44.20,44.00,43.80,44.60,43.10,46.00,45.90,
12
+ data = GSL::Vector[45.50,45.30,45.40,44.40,44.60,43.90,44.60,44.00,44.20,
13
+ 43.90,44.70,44.20,44.00,43.80,44.60,43.10,46.00,45.90,
14
14
  44.80,46.20,45.10,45.50]
15
15
  factor = GSL::Vector::Int[1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3]
16
16
 
@@ -23,7 +23,7 @@ a += b
23
23
  a
24
24
 
25
25
  # Subtract b from a
26
- a -= b
26
+ a -= b
27
27
 
28
28
  # Show a
29
29
  a