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.
- checksums.yaml +4 -4
- data/.gitignore +12 -0
- data/.travis.yml +24 -0
- data/AUTHORS +6 -0
- data/COPYING +341 -339
- data/ChangeLog +608 -587
- data/Gemfile +4 -0
- data/README.md +77 -0
- data/Rakefile +14 -33
- data/THANKS +1 -1
- data/examples/blas/blas.rb +1 -1
- data/examples/bspline.rb +3 -3
- data/examples/complex/functions.rb +4 -4
- data/examples/complex/mul.rb +1 -1
- data/examples/const/physconst.rb +4 -4
- data/examples/const/travel.rb +4 -4
- data/examples/eigen/nonsymmv.rb +1 -1
- data/examples/eigen/qhoscillator.rb +3 -3
- data/examples/fft/radix2.rb +1 -1
- data/examples/fft/real-halfcomplex.rb +3 -3
- data/examples/fft/real-halfcomplex2.rb +3 -3
- data/examples/fit/expfit.rb +1 -1
- data/examples/fit/multifit.rb +1 -1
- data/examples/fit/ndlinear.rb +44 -44
- data/examples/fit/nonlinearfit.rb +1 -1
- data/examples/fit/wlinear.rb +3 -3
- data/examples/function/function.rb +1 -1
- data/examples/function/min.rb +1 -1
- data/examples/function/synchrotron.rb +2 -2
- data/examples/gallery/koch.rb +1 -1
- data/examples/histogram/cauchy.rb +2 -2
- data/examples/histogram/exponential.rb +1 -1
- data/examples/histogram/histo3d.rb +1 -1
- data/examples/histogram/histogram-pdf.rb +2 -2
- data/examples/histogram/xexp.rb +1 -1
- data/examples/integration/ahmed.rb +2 -2
- data/examples/integration/cosmology.rb +7 -7
- data/examples/integration/friedmann.rb +4 -4
- data/examples/integration/qng.rb +1 -1
- data/examples/interp/demo.rb +2 -2
- data/examples/linalg/LQ_solve.rb +1 -1
- data/examples/linalg/LU.rb +1 -1
- data/examples/linalg/LU2.rb +1 -1
- data/examples/linalg/LU_narray.rb +1 -1
- data/examples/linalg/PTLQ.rb +1 -1
- data/examples/linalg/QRPT.rb +1 -1
- data/examples/linalg/chol.rb +1 -1
- data/examples/linalg/chol_narray.rb +1 -1
- data/examples/linalg/complex.rb +1 -1
- data/examples/math/elementary.rb +1 -1
- data/examples/math/functions.rb +1 -1
- data/examples/math/inf_nan.rb +1 -1
- data/examples/math/minmax.rb +1 -1
- data/examples/math/power.rb +1 -1
- data/examples/math/test.rb +1 -1
- data/examples/min.rb +1 -1
- data/examples/multimin/bundle.rb +1 -1
- data/examples/multimin/cqp.rb +17 -17
- data/examples/multiroot/fsolver3.rb +1 -1
- data/examples/odeiv/binarysystem.rb +12 -12
- data/examples/odeiv/demo.rb +3 -3
- data/examples/odeiv/frei1.rb +7 -7
- data/examples/odeiv/frei2.rb +4 -4
- data/examples/odeiv/oscillator.rb +1 -1
- data/examples/odeiv/sedov.rb +3 -3
- data/examples/odeiv/whitedwarf.rb +11 -11
- data/examples/permutation/ex1.rb +2 -2
- data/examples/permutation/permutation.rb +1 -1
- data/examples/poly/demo.rb +1 -1
- data/examples/random/diffusion.rb +1 -1
- data/examples/random/generator.rb +2 -2
- data/examples/random/randomwalk.rb +3 -3
- data/examples/random/rng.rb +1 -1
- data/examples/roots/bisection.rb +1 -1
- data/examples/roots/brent.rb +1 -1
- data/examples/roots/demo.rb +1 -1
- data/examples/roots/newton.rb +2 -2
- data/examples/roots/recombination.gp +0 -1
- data/examples/sf/hyperg.rb +1 -1
- data/examples/sf/sphbessel.rb +1 -1
- data/examples/sort/sort.rb +1 -1
- data/examples/tamu_anova.rb +4 -4
- data/examples/vector/add.rb +1 -1
- data/examples/vector/decimate.rb +1 -1
- data/examples/vector/gnuplot.rb +8 -8
- data/examples/vector/vector.rb +2 -2
- data/examples/wavelet/wavelet1.rb +1 -1
- data/ext/{gsl → gsl_native}/alf.c +9 -9
- data/ext/{gsl → gsl_native}/array.c +64 -151
- data/ext/{gsl → gsl_native}/array_complex.c +61 -63
- data/ext/{gsl → gsl_native}/blas.c +0 -0
- data/ext/{gsl → gsl_native}/blas1.c +32 -32
- data/ext/{gsl → gsl_native}/blas2.c +54 -58
- data/ext/{gsl → gsl_native}/blas3.c +54 -54
- data/ext/{gsl → gsl_native}/block.c +3 -6
- data/ext/{gsl/block_source.c → gsl_native/block_source.h} +109 -111
- data/ext/gsl_native/bspline.c +122 -0
- data/ext/{gsl → gsl_native}/bundle.c +0 -0
- data/ext/{gsl → gsl_native}/cdf.c +76 -88
- data/ext/{gsl → gsl_native}/cheb.c +74 -85
- data/ext/{gsl → gsl_native}/combination.c +9 -16
- data/ext/{gsl → gsl_native}/common.c +7 -37
- data/ext/{gsl → gsl_native}/complex.c +113 -115
- data/ext/gsl_native/const.c +331 -0
- data/ext/{gsl → gsl_native}/const_additional.c +12 -33
- data/ext/gsl_native/cqp.c +283 -0
- data/ext/{gsl → gsl_native}/deriv.c +22 -30
- data/ext/{gsl → gsl_native}/dht.c +20 -28
- data/ext/{gsl → gsl_native}/diff.c +23 -25
- data/ext/{gsl → gsl_native}/dirac.c +44 -45
- data/ext/{gsl → gsl_native}/eigen.c +1031 -1082
- data/ext/{gsl → gsl_native}/error.c +13 -13
- data/ext/{gsl → gsl_native}/extconf.rb +5 -13
- data/ext/{gsl → gsl_native}/fft.c +192 -198
- data/ext/{gsl → gsl_native}/fit.c +16 -16
- data/ext/gsl_native/fresnel.c +312 -0
- data/ext/{gsl → gsl_native}/function.c +29 -35
- data/ext/{gsl → gsl_native}/geometry.c +15 -15
- data/ext/{gsl → gsl_native}/graph.c +37 -87
- data/ext/{gsl → gsl_native}/gsl.c +10 -23
- data/ext/{gsl → gsl_native}/gsl_narray.c +15 -24
- data/ext/{gsl → gsl_native}/histogram.c +123 -150
- data/ext/{gsl → gsl_native}/histogram2d.c +71 -96
- data/ext/{gsl → gsl_native}/histogram3d.c +72 -72
- data/ext/{gsl → gsl_native}/histogram3d_source.c +195 -196
- data/ext/{gsl → gsl_native}/histogram_find.c +31 -33
- data/ext/{gsl → gsl_native}/histogram_oper.c +43 -52
- data/ext/{gsl → gsl_native}/ieee.c +7 -15
- data/ext/{gsl → gsl_native}/include/rb_gsl.h +0 -7
- data/ext/{gsl → gsl_native}/include/rb_gsl_array.h +15 -25
- data/ext/{gsl → gsl_native}/include/rb_gsl_cheb.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_common.h +44 -52
- data/ext/{gsl → gsl_native}/include/rb_gsl_complex.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_const.h +0 -5
- data/ext/{gsl → gsl_native}/include/rb_gsl_dirac.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_eigen.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_fft.h +0 -3
- data/ext/{gsl → gsl_native}/include/rb_gsl_fit.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_function.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_graph.h +2 -2
- data/ext/{gsl → gsl_native}/include/rb_gsl_histogram.h +8 -8
- data/ext/{gsl → gsl_native}/include/rb_gsl_histogram3d.h +50 -50
- data/ext/{gsl → gsl_native}/include/rb_gsl_integration.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_interp.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_linalg.h +0 -1
- data/ext/{gsl → gsl_native}/include/rb_gsl_math.h +0 -4
- data/ext/{gsl → gsl_native}/include/rb_gsl_odeiv.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_poly.h +3 -3
- data/ext/{gsl → gsl_native}/include/rb_gsl_rational.h +1 -1
- data/ext/{gsl → gsl_native}/include/rb_gsl_rng.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_root.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_sf.h +39 -43
- data/ext/{gsl → gsl_native}/include/rb_gsl_statistics.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_tensor.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_with_narray.h +0 -0
- data/ext/{gsl → gsl_native}/include/templates_off.h +0 -0
- data/ext/{gsl → gsl_native}/include/templates_on.h +1 -1
- data/ext/{gsl → gsl_native}/integration.c +160 -183
- data/ext/{gsl → gsl_native}/interp.c +23 -31
- data/ext/gsl_native/jacobi.c +733 -0
- data/ext/{gsl → gsl_native}/linalg.c +448 -576
- data/ext/{gsl → gsl_native}/linalg_complex.c +84 -98
- data/ext/{gsl → gsl_native}/math.c +45 -63
- data/ext/{gsl → gsl_native}/matrix.c +4 -6
- data/ext/{gsl → gsl_native}/matrix_complex.c +111 -114
- data/ext/{gsl → gsl_native}/matrix_double.c +74 -77
- data/ext/{gsl → gsl_native}/matrix_int.c +49 -50
- data/ext/{gsl/matrix_source.c → gsl_native/matrix_source.h} +280 -302
- data/ext/{gsl → gsl_native}/min.c +43 -74
- data/ext/{gsl → gsl_native}/monte.c +45 -59
- data/ext/{gsl → gsl_native}/multifit.c +138 -147
- data/ext/{gsl → gsl_native}/multimin.c +55 -83
- data/ext/{gsl → gsl_native}/multimin_fsdf.c +15 -15
- data/ext/{gsl → gsl_native}/multiroots.c +61 -64
- data/ext/{gsl → gsl_native}/multiset.c +3 -7
- data/ext/{gsl → gsl_native}/ndlinear.c +320 -321
- data/ext/{gsl → gsl_native}/nmf.c +11 -11
- data/ext/{gsl → gsl_native}/nmf_wrap.c +1 -1
- data/ext/{gsl → gsl_native}/ntuple.c +13 -13
- data/ext/{gsl → gsl_native}/odeiv.c +95 -106
- data/ext/gsl_native/ool.c +879 -0
- data/ext/{gsl → gsl_native}/permutation.c +36 -34
- data/ext/{gsl → gsl_native}/poly.c +2 -5
- data/ext/{gsl → gsl_native}/poly2.c +6 -6
- data/ext/{gsl/poly_source.c → gsl_native/poly_source.h} +232 -275
- data/ext/{gsl → gsl_native}/qrng.c +6 -17
- data/ext/{gsl → gsl_native}/randist.c +218 -243
- data/ext/{gsl → gsl_native}/rational.c +9 -9
- data/ext/{gsl → gsl_native}/rng.c +29 -45
- data/ext/{gsl → gsl_native}/root.c +43 -43
- data/ext/{gsl → gsl_native}/sf.c +163 -197
- data/ext/{gsl → gsl_native}/sf_airy.c +0 -0
- data/ext/{gsl → gsl_native}/sf_bessel.c +6 -6
- data/ext/{gsl → gsl_native}/sf_clausen.c +0 -0
- data/ext/{gsl → gsl_native}/sf_coulomb.c +39 -39
- data/ext/{gsl → gsl_native}/sf_coupling.c +29 -29
- data/ext/{gsl → gsl_native}/sf_dawson.c +0 -0
- data/ext/{gsl → gsl_native}/sf_debye.c +0 -9
- data/ext/{gsl → gsl_native}/sf_dilog.c +0 -0
- data/ext/{gsl → gsl_native}/sf_elementary.c +2 -2
- data/ext/{gsl → gsl_native}/sf_ellint.c +42 -42
- data/ext/{gsl → gsl_native}/sf_elljac.c +2 -2
- data/ext/{gsl → gsl_native}/sf_erfc.c +0 -4
- data/ext/{gsl → gsl_native}/sf_exp.c +2 -2
- data/ext/{gsl → gsl_native}/sf_expint.c +1 -11
- data/ext/{gsl → gsl_native}/sf_fermi_dirac.c +0 -0
- data/ext/{gsl → gsl_native}/sf_gamma.c +1 -5
- data/ext/{gsl → gsl_native}/sf_gegenbauer.c +0 -0
- data/ext/{gsl → gsl_native}/sf_hyperg.c +0 -0
- data/ext/{gsl → gsl_native}/sf_laguerre.c +3 -3
- data/ext/{gsl → gsl_native}/sf_lambert.c +0 -0
- data/ext/{gsl → gsl_native}/sf_legendre.c +0 -0
- data/ext/{gsl → gsl_native}/sf_log.c +3 -3
- data/ext/gsl_native/sf_mathieu.c +235 -0
- data/ext/{gsl → gsl_native}/sf_power.c +0 -0
- data/ext/{gsl → gsl_native}/sf_psi.c +2 -11
- data/ext/{gsl → gsl_native}/sf_synchrotron.c +0 -0
- data/ext/{gsl → gsl_native}/sf_transport.c +0 -0
- data/ext/{gsl → gsl_native}/sf_trigonometric.c +3 -3
- data/ext/{gsl → gsl_native}/sf_zeta.c +0 -4
- data/ext/{gsl → gsl_native}/signal.c +60 -64
- data/ext/{gsl → gsl_native}/siman.c +36 -40
- data/ext/{gsl → gsl_native}/sort.c +3 -4
- data/ext/{gsl → gsl_native}/spline.c +25 -43
- data/ext/{gsl → gsl_native}/stats.c +102 -115
- data/ext/{gsl → gsl_native}/sum.c +32 -32
- data/ext/{gsl → gsl_native}/tamu_anova.c +0 -0
- data/ext/{gsl → gsl_native}/tensor.c +2 -4
- data/ext/{gsl/tensor_source.c → gsl_native/tensor_source.h} +144 -144
- data/ext/{gsl → gsl_native}/vector.c +2 -4
- data/ext/{gsl → gsl_native}/vector_complex.c +165 -171
- data/ext/{gsl → gsl_native}/vector_double.c +167 -174
- data/ext/{gsl → gsl_native}/vector_int.c +23 -25
- data/ext/{gsl/vector_source.c → gsl_native/vector_source.h} +400 -414
- data/ext/{gsl → gsl_native}/wavelet.c +215 -236
- data/lib/gsl.rb +1 -7
- data/lib/gsl/gnuplot.rb +2 -2
- data/lib/gsl/version.rb +1 -3
- data/rb-gsl.gemspec +29 -0
- data/rdoc/blas.rdoc +3 -3
- data/rdoc/bspline.rdoc +7 -7
- data/rdoc/cheb.rdoc +8 -8
- data/rdoc/cholesky_complex.rdoc +1 -1
- data/rdoc/combi.rdoc +9 -9
- data/rdoc/complex.rdoc +11 -11
- data/rdoc/const.rdoc +20 -20
- data/rdoc/dht.rdoc +6 -6
- data/rdoc/diff.rdoc +6 -6
- data/rdoc/ehandling.rdoc +3 -3
- data/rdoc/eigen.rdoc +11 -11
- data/rdoc/fft.rdoc +26 -26
- data/rdoc/fit.rdoc +18 -18
- data/rdoc/graph.rdoc +2 -2
- data/rdoc/hist.rdoc +16 -16
- data/rdoc/hist2d.rdoc +4 -4
- data/rdoc/hist3d.rdoc +3 -3
- data/rdoc/integration.rdoc +16 -16
- data/rdoc/interp.rdoc +11 -11
- data/rdoc/intro.rdoc +3 -3
- data/rdoc/linalg.rdoc +20 -20
- data/rdoc/linalg_complex.rdoc +1 -1
- data/rdoc/math.rdoc +13 -13
- data/rdoc/matrix.rdoc +22 -22
- data/rdoc/min.rdoc +9 -9
- data/rdoc/monte.rdoc +3 -3
- data/rdoc/multimin.rdoc +12 -12
- data/rdoc/multiroot.rdoc +12 -12
- data/rdoc/narray.rdoc +9 -9
- data/rdoc/ndlinear.rdoc +4 -4
- data/rdoc/nonlinearfit.rdoc +17 -17
- data/rdoc/ntuple.rdoc +5 -5
- data/rdoc/odeiv.rdoc +12 -12
- data/rdoc/perm.rdoc +11 -11
- data/rdoc/poly.rdoc +17 -17
- data/rdoc/qrng.rdoc +9 -9
- data/rdoc/randist.rdoc +10 -10
- data/rdoc/ref.rdoc +49 -49
- data/rdoc/rng.rdoc +9 -9
- data/rdoc/roots.rdoc +12 -12
- data/rdoc/sf.rdoc +35 -35
- data/rdoc/siman.rdoc +3 -3
- data/rdoc/sort.rdoc +6 -6
- data/rdoc/start.rdoc +2 -2
- data/rdoc/stats.rdoc +13 -13
- data/rdoc/sum.rdoc +4 -4
- data/rdoc/tensor.rdoc +3 -3
- data/rdoc/tut.rdoc +1 -1
- data/rdoc/use.rdoc +3 -3
- data/rdoc/vector.rdoc +28 -28
- data/rdoc/vector_complex.rdoc +6 -6
- data/rdoc/wavelet.rdoc +8 -8
- data/test/gsl/blas_test.rb +1 -1
- data/test/gsl/index_test.rb +61 -0
- data/test/gsl/matrix_test.rb +21 -0
- data/uncrustify.cfg +1693 -0
- metadata +212 -243
- data/README +0 -28
- data/ext/gsl/bspline.c +0 -130
- data/ext/gsl/const.c +0 -672
- data/ext/gsl/cqp.c +0 -283
- data/ext/gsl/fcmp.c +0 -64
- data/ext/gsl/fresnel.c +0 -312
- data/ext/gsl/jacobi.c +0 -739
- data/ext/gsl/ool.c +0 -879
- data/ext/gsl/oper_complex_source.c +0 -251
- data/ext/gsl/sf_mathieu.c +0 -238
- 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])
|
data/examples/odeiv/demo.rb
CHANGED
@@ -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
|
data/examples/odeiv/frei1.rb
CHANGED
@@ -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
|
data/examples/odeiv/frei2.rb
CHANGED
@@ -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
|
data/examples/odeiv/sedov.rb
CHANGED
@@ -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]
|
data/examples/permutation/ex1.rb
CHANGED
@@ -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");
|
data/examples/poly/demo.rb
CHANGED
@@ -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
|
|
@@ -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
|
data/examples/random/rng.rb
CHANGED
data/examples/roots/bisection.rb
CHANGED
@@ -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
|
data/examples/roots/brent.rb
CHANGED
data/examples/roots/demo.rb
CHANGED
@@ -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
|
data/examples/roots/newton.rb
CHANGED
@@ -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
|
data/examples/sf/hyperg.rb
CHANGED
data/examples/sf/sphbessel.rb
CHANGED
@@ -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
|
data/examples/sort/sort.rb
CHANGED
data/examples/tamu_anova.rb
CHANGED
@@ -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
|
|