rb-gsl 1.15.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/AUTHORS +6 -0
- data/COPYING +339 -0
- data/ChangeLog +567 -0
- data/README +32 -0
- data/Rakefile +99 -0
- data/THANKS +17 -0
- data/VERSION +1 -0
- data/examples/alf/alf.gp +15 -0
- data/examples/alf/alf.rb +32 -0
- data/examples/blas/blas.rb +13 -0
- data/examples/blas/dnrm2.rb +16 -0
- data/examples/blas/level1.rb +81 -0
- data/examples/blas/level2.rb +11 -0
- data/examples/blas/level3.rb +12 -0
- data/examples/bspline.rb +57 -0
- data/examples/cdf.rb +16 -0
- data/examples/cheb.rb +21 -0
- data/examples/combination.rb +23 -0
- data/examples/complex/RC-lpf.rb +47 -0
- data/examples/complex/add.rb +36 -0
- data/examples/complex/coerce.rb +14 -0
- data/examples/complex/complex.rb +25 -0
- data/examples/complex/fpmi.rb +70 -0
- data/examples/complex/functions.rb +77 -0
- data/examples/complex/michelson.rb +36 -0
- data/examples/complex/mul.rb +28 -0
- data/examples/complex/oscillator.rb +17 -0
- data/examples/complex/set.rb +37 -0
- data/examples/const/physconst.rb +151 -0
- data/examples/const/travel.rb +45 -0
- data/examples/deriv/demo.rb +13 -0
- data/examples/deriv/deriv.rb +36 -0
- data/examples/deriv/diff.rb +35 -0
- data/examples/dht.rb +42 -0
- data/examples/dirac.rb +56 -0
- data/examples/eigen/eigen.rb +34 -0
- data/examples/eigen/herm.rb +22 -0
- data/examples/eigen/narray.rb +9 -0
- data/examples/eigen/nonsymm.rb +37 -0
- data/examples/eigen/nonsymmv.rb +43 -0
- data/examples/eigen/qhoscillator.gp +35 -0
- data/examples/eigen/qhoscillator.rb +90 -0
- data/examples/eigen/vander.rb +41 -0
- data/examples/fft/fft.rb +17 -0
- data/examples/fft/fft2.rb +17 -0
- data/examples/fft/forward.rb +25 -0
- data/examples/fft/forward2.rb +26 -0
- data/examples/fft/radix2.rb +18 -0
- data/examples/fft/real-halfcomplex.rb +33 -0
- data/examples/fft/real-halfcomplex2.rb +30 -0
- data/examples/fft/realradix2.rb +19 -0
- data/examples/fft/sunspot.dat +256 -0
- data/examples/fft/sunspot.rb +16 -0
- data/examples/fit/expdata.dat +20 -0
- data/examples/fit/expfit.rb +31 -0
- data/examples/fit/gaussfit.rb +29 -0
- data/examples/fit/gaussian_2peaks.rb +34 -0
- data/examples/fit/hillfit.rb +40 -0
- data/examples/fit/lognormal.rb +26 -0
- data/examples/fit/lorentzfit.rb +22 -0
- data/examples/fit/multifit.rb +72 -0
- data/examples/fit/ndlinear.rb +133 -0
- data/examples/fit/nonlinearfit.rb +89 -0
- data/examples/fit/plot.gp +36 -0
- data/examples/fit/polyfit.rb +9 -0
- data/examples/fit/powerfit.rb +21 -0
- data/examples/fit/sigmoidfit.rb +40 -0
- data/examples/fit/sinfit.rb +22 -0
- data/examples/fit/wlinear.rb +46 -0
- data/examples/fresnel.rb +11 -0
- data/examples/function/function.rb +36 -0
- data/examples/function/log.rb +7 -0
- data/examples/function/min.rb +33 -0
- data/examples/function/sin.rb +10 -0
- data/examples/function/synchrotron.rb +18 -0
- data/examples/gallery/butterfly.rb +7 -0
- data/examples/gallery/cayley.rb +12 -0
- data/examples/gallery/cornu.rb +23 -0
- data/examples/gallery/eight.rb +11 -0
- data/examples/gallery/koch.rb +40 -0
- data/examples/gallery/lemniscate.rb +11 -0
- data/examples/gallery/polar.rb +11 -0
- data/examples/gallery/rgplot/cossin.rb +35 -0
- data/examples/gallery/rgplot/rgplot.replaced +0 -0
- data/examples/gallery/rgplot/roesller.rb +55 -0
- data/examples/gallery/roesller.rb +39 -0
- data/examples/gallery/scarabaeus.rb +14 -0
- data/examples/histogram/cauchy.rb +27 -0
- data/examples/histogram/cauchy.sh +2 -0
- data/examples/histogram/exponential.rb +19 -0
- data/examples/histogram/gauss.rb +16 -0
- data/examples/histogram/gsl-histogram.rb +40 -0
- data/examples/histogram/histo2d.rb +31 -0
- data/examples/histogram/histo3d.rb +34 -0
- data/examples/histogram/histogram-pdf.rb +27 -0
- data/examples/histogram/histogram.rb +26 -0
- data/examples/histogram/integral.rb +28 -0
- data/examples/histogram/poisson.rb +27 -0
- data/examples/histogram/power.rb +25 -0
- data/examples/histogram/rebin.rb +17 -0
- data/examples/histogram/smp.dat +5 -0
- data/examples/histogram/xexp.rb +21 -0
- data/examples/integration/ahmed.rb +21 -0
- data/examples/integration/cosmology.rb +75 -0
- data/examples/integration/friedmann.gp +16 -0
- data/examples/integration/friedmann.rb +35 -0
- data/examples/integration/gamma-zeta.rb +35 -0
- data/examples/integration/integration.rb +22 -0
- data/examples/integration/qag.rb +8 -0
- data/examples/integration/qag2.rb +14 -0
- data/examples/integration/qag3.rb +8 -0
- data/examples/integration/qagi.rb +28 -0
- data/examples/integration/qagi2.rb +49 -0
- data/examples/integration/qagiu.rb +29 -0
- data/examples/integration/qagp.rb +20 -0
- data/examples/integration/qags.rb +14 -0
- data/examples/integration/qawc.rb +18 -0
- data/examples/integration/qawf.rb +41 -0
- data/examples/integration/qawo.rb +29 -0
- data/examples/integration/qaws.rb +30 -0
- data/examples/integration/qng.rb +17 -0
- data/examples/interp/demo.gp +20 -0
- data/examples/interp/demo.rb +45 -0
- data/examples/interp/interp.rb +37 -0
- data/examples/interp/points +10 -0
- data/examples/interp/spline.rb +20 -0
- data/examples/jacobi/deriv.rb +40 -0
- data/examples/jacobi/integrate.rb +34 -0
- data/examples/jacobi/interp.rb +43 -0
- data/examples/jacobi/jacobi.rb +11 -0
- data/examples/linalg/HH.rb +15 -0
- data/examples/linalg/HH_narray.rb +13 -0
- data/examples/linalg/LQ_solve.rb +73 -0
- data/examples/linalg/LU.rb +84 -0
- data/examples/linalg/LU2.rb +31 -0
- data/examples/linalg/LU_narray.rb +24 -0
- data/examples/linalg/PTLQ.rb +47 -0
- data/examples/linalg/QR.rb +18 -0
- data/examples/linalg/QRPT.rb +47 -0
- data/examples/linalg/QR_solve.rb +78 -0
- data/examples/linalg/QR_solve_narray.rb +13 -0
- data/examples/linalg/SV.rb +16 -0
- data/examples/linalg/SV_narray.rb +12 -0
- data/examples/linalg/SV_solve.rb +49 -0
- data/examples/linalg/chol.rb +29 -0
- data/examples/linalg/chol_narray.rb +15 -0
- data/examples/linalg/complex.rb +57 -0
- data/examples/linalg/invert_narray.rb +10 -0
- data/examples/math/const.rb +67 -0
- data/examples/math/elementary.rb +35 -0
- data/examples/math/functions.rb +41 -0
- data/examples/math/inf_nan.rb +34 -0
- data/examples/math/minmax.rb +22 -0
- data/examples/math/power.rb +18 -0
- data/examples/math/test.rb +31 -0
- data/examples/matrix/a.dat +0 -0
- data/examples/matrix/add.rb +45 -0
- data/examples/matrix/b.dat +4 -0
- data/examples/matrix/cat.rb +31 -0
- data/examples/matrix/colvectors.rb +24 -0
- data/examples/matrix/complex.rb +41 -0
- data/examples/matrix/det.rb +29 -0
- data/examples/matrix/diagonal.rb +23 -0
- data/examples/matrix/get_all.rb +159 -0
- data/examples/matrix/hilbert.rb +31 -0
- data/examples/matrix/iterator.rb +19 -0
- data/examples/matrix/matrix.rb +57 -0
- data/examples/matrix/minmax.rb +53 -0
- data/examples/matrix/mul.rb +39 -0
- data/examples/matrix/rand.rb +20 -0
- data/examples/matrix/read.rb +29 -0
- data/examples/matrix/rowcol.rb +47 -0
- data/examples/matrix/set.rb +41 -0
- data/examples/matrix/set_all.rb +100 -0
- data/examples/matrix/view.rb +32 -0
- data/examples/matrix/view_all.rb +148 -0
- data/examples/matrix/write.rb +23 -0
- data/examples/min.rb +29 -0
- data/examples/monte/miser.rb +47 -0
- data/examples/monte/monte.rb +47 -0
- data/examples/monte/plain.rb +47 -0
- data/examples/monte/vegas.rb +46 -0
- data/examples/multimin/bundle.rb +66 -0
- data/examples/multimin/cqp.rb +109 -0
- data/examples/multimin/fdfminimizer.rb +40 -0
- data/examples/multimin/fminimizer.rb +41 -0
- data/examples/multiroot/demo.rb +36 -0
- data/examples/multiroot/fdfsolver.rb +50 -0
- data/examples/multiroot/fsolver.rb +33 -0
- data/examples/multiroot/fsolver2.rb +32 -0
- data/examples/multiroot/fsolver3.rb +26 -0
- data/examples/narray/histogram.rb +14 -0
- data/examples/narray/mandel.rb +27 -0
- data/examples/narray/narray.rb +28 -0
- data/examples/narray/narray2.rb +44 -0
- data/examples/narray/sf.rb +26 -0
- data/examples/ntuple/create.rb +17 -0
- data/examples/ntuple/project.rb +31 -0
- data/examples/odeiv/binarysystem.gp +23 -0
- data/examples/odeiv/binarysystem.rb +104 -0
- data/examples/odeiv/demo.gp +24 -0
- data/examples/odeiv/demo.rb +69 -0
- data/examples/odeiv/demo2.gp +26 -0
- data/examples/odeiv/duffing.rb +45 -0
- data/examples/odeiv/frei1.rb +109 -0
- data/examples/odeiv/frei2.rb +76 -0
- data/examples/odeiv/legendre.rb +52 -0
- data/examples/odeiv/odeiv.rb +32 -0
- data/examples/odeiv/odeiv2.rb +45 -0
- data/examples/odeiv/oscillator.rb +42 -0
- data/examples/odeiv/sedov.rb +97 -0
- data/examples/odeiv/whitedwarf.gp +40 -0
- data/examples/odeiv/whitedwarf.rb +158 -0
- data/examples/ool/conmin.rb +100 -0
- data/examples/ool/gencan.rb +99 -0
- data/examples/ool/pgrad.rb +100 -0
- data/examples/ool/spg.rb +100 -0
- data/examples/pdf/bernoulli.rb +5 -0
- data/examples/pdf/beta.rb +7 -0
- data/examples/pdf/binomiral.rb +10 -0
- data/examples/pdf/cauchy.rb +6 -0
- data/examples/pdf/chisq.rb +8 -0
- data/examples/pdf/exponential.rb +7 -0
- data/examples/pdf/exppow.rb +6 -0
- data/examples/pdf/fdist.rb +7 -0
- data/examples/pdf/flat.rb +7 -0
- data/examples/pdf/gamma.rb +8 -0
- data/examples/pdf/gauss-tail.rb +5 -0
- data/examples/pdf/gauss.rb +6 -0
- data/examples/pdf/geometric.rb +5 -0
- data/examples/pdf/gumbel.rb +6 -0
- data/examples/pdf/hypergeometric.rb +11 -0
- data/examples/pdf/landau.rb +5 -0
- data/examples/pdf/laplace.rb +7 -0
- data/examples/pdf/logarithmic.rb +5 -0
- data/examples/pdf/logistic.rb +6 -0
- data/examples/pdf/lognormal.rb +6 -0
- data/examples/pdf/neg-binomiral.rb +10 -0
- data/examples/pdf/pareto.rb +7 -0
- data/examples/pdf/pascal.rb +10 -0
- data/examples/pdf/poisson.rb +5 -0
- data/examples/pdf/rayleigh-tail.rb +6 -0
- data/examples/pdf/rayleigh.rb +6 -0
- data/examples/pdf/tdist.rb +6 -0
- data/examples/pdf/weibull.rb +8 -0
- data/examples/permutation/ex1.rb +22 -0
- data/examples/permutation/permutation.rb +16 -0
- data/examples/poly/bell.rb +6 -0
- data/examples/poly/bessel.rb +6 -0
- data/examples/poly/cheb.rb +6 -0
- data/examples/poly/cheb_II.rb +6 -0
- data/examples/poly/cubic.rb +9 -0
- data/examples/poly/demo.rb +20 -0
- data/examples/poly/eval.rb +28 -0
- data/examples/poly/eval_derivs.rb +14 -0
- data/examples/poly/fit.rb +21 -0
- data/examples/poly/hermite.rb +6 -0
- data/examples/poly/poly.rb +13 -0
- data/examples/poly/quadratic.rb +25 -0
- data/examples/random/diffusion.rb +34 -0
- data/examples/random/gaussian.rb +9 -0
- data/examples/random/generator.rb +27 -0
- data/examples/random/hdsobol.rb +21 -0
- data/examples/random/poisson.rb +9 -0
- data/examples/random/qrng.rb +19 -0
- data/examples/random/randomwalk.rb +37 -0
- data/examples/random/randomwalk2d.rb +19 -0
- data/examples/random/rayleigh.rb +36 -0
- data/examples/random/rng.rb +33 -0
- data/examples/random/rngextra.rb +14 -0
- data/examples/roots/bisection.rb +25 -0
- data/examples/roots/brent.rb +43 -0
- data/examples/roots/demo.rb +30 -0
- data/examples/roots/newton.rb +46 -0
- data/examples/roots/recombination.gp +12 -0
- data/examples/roots/recombination.rb +61 -0
- data/examples/roots/steffenson.rb +48 -0
- data/examples/sf/ShiChi.rb +6 -0
- data/examples/sf/SiCi.rb +6 -0
- data/examples/sf/airy_Ai.rb +8 -0
- data/examples/sf/airy_Bi.rb +8 -0
- data/examples/sf/bessel_IK.rb +12 -0
- data/examples/sf/bessel_JY.rb +13 -0
- data/examples/sf/beta_inc.rb +9 -0
- data/examples/sf/clausen.rb +6 -0
- data/examples/sf/dawson.rb +5 -0
- data/examples/sf/debye.rb +9 -0
- data/examples/sf/dilog.rb +6 -0
- data/examples/sf/ellint.rb +6 -0
- data/examples/sf/expint.rb +8 -0
- data/examples/sf/fermi.rb +10 -0
- data/examples/sf/gamma_inc_P.rb +9 -0
- data/examples/sf/gegenbauer.rb +8 -0
- data/examples/sf/hyperg.rb +7 -0
- data/examples/sf/laguerre.rb +19 -0
- data/examples/sf/lambertW.rb +5 -0
- data/examples/sf/legendre_P.rb +10 -0
- data/examples/sf/lngamma.rb +5 -0
- data/examples/sf/psi.rb +54 -0
- data/examples/sf/sphbessel.gp +27 -0
- data/examples/sf/sphbessel.rb +30 -0
- data/examples/sf/synchrotron.rb +5 -0
- data/examples/sf/transport.rb +10 -0
- data/examples/sf/zetam1.rb +5 -0
- data/examples/siman.rb +44 -0
- data/examples/sort/heapsort.rb +23 -0
- data/examples/sort/heapsort_vector_complex.rb +21 -0
- data/examples/sort/sort.rb +23 -0
- data/examples/sort/sort2.rb +16 -0
- data/examples/stats/mean.rb +17 -0
- data/examples/stats/statistics.rb +18 -0
- data/examples/stats/test.rb +9 -0
- data/examples/sum.rb +34 -0
- data/examples/tamu_anova.rb +18 -0
- data/examples/vector/a.dat +0 -0
- data/examples/vector/add.rb +56 -0
- data/examples/vector/b.dat +4 -0
- data/examples/vector/c.dat +3 -0
- data/examples/vector/collect.rb +26 -0
- data/examples/vector/compare.rb +28 -0
- data/examples/vector/complex.rb +51 -0
- data/examples/vector/complex_get_all.rb +85 -0
- data/examples/vector/complex_set_all.rb +131 -0
- data/examples/vector/complex_view_all.rb +77 -0
- data/examples/vector/connect.rb +22 -0
- data/examples/vector/decimate.rb +38 -0
- data/examples/vector/diff.rb +31 -0
- data/examples/vector/filescan.rb +17 -0
- data/examples/vector/floor.rb +23 -0
- data/examples/vector/get_all.rb +82 -0
- data/examples/vector/gnuplot.rb +38 -0
- data/examples/vector/graph.rb +28 -0
- data/examples/vector/histogram.rb +22 -0
- data/examples/vector/linspace.rb +24 -0
- data/examples/vector/log.rb +17 -0
- data/examples/vector/logic.rb +33 -0
- data/examples/vector/logspace.rb +25 -0
- data/examples/vector/minmax.rb +47 -0
- data/examples/vector/mul.rb +49 -0
- data/examples/vector/narray.rb +46 -0
- data/examples/vector/read.rb +29 -0
- data/examples/vector/set.rb +35 -0
- data/examples/vector/set_all.rb +121 -0
- data/examples/vector/smpv.dat +15 -0
- data/examples/vector/test.rb +43 -0
- data/examples/vector/test_gslblock.rb +58 -0
- data/examples/vector/vector.rb +110 -0
- data/examples/vector/view.rb +35 -0
- data/examples/vector/view_all.rb +73 -0
- data/examples/vector/where.rb +29 -0
- data/examples/vector/write.rb +24 -0
- data/examples/vector/zip.rb +34 -0
- data/examples/wavelet/ecg.dat +256 -0
- data/examples/wavelet/wavelet1.rb +50 -0
- data/ext/alf.c +206 -0
- data/ext/array.c +642 -0
- data/ext/array_complex.c +248 -0
- data/ext/blas.c +29 -0
- data/ext/blas1.c +734 -0
- data/ext/blas2.c +1093 -0
- data/ext/blas3.c +881 -0
- data/ext/block.c +44 -0
- data/ext/block_source.c +887 -0
- data/ext/bspline.c +130 -0
- data/ext/bundle.c +3 -0
- data/ext/cdf.c +754 -0
- data/ext/cheb.c +542 -0
- data/ext/combination.c +283 -0
- data/ext/common.c +325 -0
- data/ext/complex.c +1004 -0
- data/ext/const.c +673 -0
- data/ext/const_additional.c +120 -0
- data/ext/cqp.c +283 -0
- data/ext/deriv.c +195 -0
- data/ext/dht.c +361 -0
- data/ext/diff.c +166 -0
- data/ext/dirac.c +389 -0
- data/ext/eigen.c +2373 -0
- data/ext/error.c +193 -0
- data/ext/extconf.rb +303 -0
- data/ext/fcmp.c +66 -0
- data/ext/fft.c +1102 -0
- data/ext/fit.c +205 -0
- data/ext/fresnel.c +312 -0
- data/ext/function.c +524 -0
- data/ext/geometry.c +139 -0
- data/ext/graph.c +1640 -0
- data/ext/gsl.c +280 -0
- data/ext/gsl_narray.c +804 -0
- data/ext/histogram.c +1991 -0
- data/ext/histogram2d.c +1068 -0
- data/ext/histogram3d.c +884 -0
- data/ext/histogram3d_source.c +750 -0
- data/ext/histogram_find.c +101 -0
- data/ext/histogram_oper.c +159 -0
- data/ext/ieee.c +100 -0
- data/ext/integration.c +1179 -0
- data/ext/interp.c +512 -0
- data/ext/jacobi.c +739 -0
- data/ext/linalg.c +4042 -0
- data/ext/linalg_complex.c +739 -0
- data/ext/math.c +725 -0
- data/ext/matrix.c +39 -0
- data/ext/matrix_complex.c +1737 -0
- data/ext/matrix_double.c +560 -0
- data/ext/matrix_int.c +256 -0
- data/ext/matrix_source.c +2734 -0
- data/ext/min.c +250 -0
- data/ext/monte.c +992 -0
- data/ext/multifit.c +1871 -0
- data/ext/multimin.c +806 -0
- data/ext/multimin_fsdf.c +156 -0
- data/ext/multiroots.c +955 -0
- data/ext/multiset.c +214 -0
- data/ext/ndlinear.c +321 -0
- data/ext/nmf.c +171 -0
- data/ext/nmf_wrap.c +75 -0
- data/ext/ntuple.c +469 -0
- data/ext/odeiv.c +962 -0
- data/ext/ool.c +879 -0
- data/ext/oper_complex_source.c +253 -0
- data/ext/permutation.c +596 -0
- data/ext/poly.c +42 -0
- data/ext/poly2.c +265 -0
- data/ext/poly_source.c +1915 -0
- data/ext/qrng.c +171 -0
- data/ext/randist.c +1873 -0
- data/ext/rational.c +480 -0
- data/ext/rng.c +612 -0
- data/ext/root.c +408 -0
- data/ext/sf.c +1494 -0
- data/ext/sf_airy.c +200 -0
- data/ext/sf_bessel.c +871 -0
- data/ext/sf_clausen.c +28 -0
- data/ext/sf_coulomb.c +206 -0
- data/ext/sf_coupling.c +121 -0
- data/ext/sf_dawson.c +29 -0
- data/ext/sf_debye.c +157 -0
- data/ext/sf_dilog.c +43 -0
- data/ext/sf_elementary.c +46 -0
- data/ext/sf_ellint.c +206 -0
- data/ext/sf_elljac.c +30 -0
- data/ext/sf_erfc.c +93 -0
- data/ext/sf_exp.c +169 -0
- data/ext/sf_expint.c +211 -0
- data/ext/sf_fermi_dirac.c +148 -0
- data/ext/sf_gamma.c +347 -0
- data/ext/sf_gegenbauer.c +97 -0
- data/ext/sf_hyperg.c +203 -0
- data/ext/sf_laguerre.c +113 -0
- data/ext/sf_lambert.c +47 -0
- data/ext/sf_legendre.c +368 -0
- data/ext/sf_log.c +105 -0
- data/ext/sf_mathieu.c +238 -0
- data/ext/sf_power.c +47 -0
- data/ext/sf_psi.c +98 -0
- data/ext/sf_synchrotron.c +48 -0
- data/ext/sf_transport.c +76 -0
- data/ext/sf_trigonometric.c +210 -0
- data/ext/sf_zeta.c +119 -0
- data/ext/signal.c +308 -0
- data/ext/siman.c +717 -0
- data/ext/sort.c +208 -0
- data/ext/spline.c +395 -0
- data/ext/stats.c +800 -0
- data/ext/sum.c +168 -0
- data/ext/tamu_anova.c +56 -0
- data/ext/tensor.c +38 -0
- data/ext/tensor_source.c +1123 -0
- data/ext/vector.c +38 -0
- data/ext/vector_complex.c +2246 -0
- data/ext/vector_double.c +1438 -0
- data/ext/vector_int.c +204 -0
- data/ext/vector_source.c +3336 -0
- data/ext/wavelet.c +945 -0
- data/include/rb_gsl.h +158 -0
- data/include/rb_gsl_array.h +238 -0
- data/include/rb_gsl_cheb.h +21 -0
- data/include/rb_gsl_common.h +348 -0
- data/include/rb_gsl_complex.h +25 -0
- data/include/rb_gsl_config.h +62 -0
- data/include/rb_gsl_const.h +29 -0
- data/include/rb_gsl_dirac.h +13 -0
- data/include/rb_gsl_eigen.h +17 -0
- data/include/rb_gsl_fft.h +62 -0
- data/include/rb_gsl_fit.h +25 -0
- data/include/rb_gsl_function.h +27 -0
- data/include/rb_gsl_graph.h +70 -0
- data/include/rb_gsl_histogram.h +63 -0
- data/include/rb_gsl_histogram3d.h +97 -0
- data/include/rb_gsl_integration.h +17 -0
- data/include/rb_gsl_interp.h +46 -0
- data/include/rb_gsl_linalg.h +25 -0
- data/include/rb_gsl_math.h +26 -0
- data/include/rb_gsl_odeiv.h +21 -0
- data/include/rb_gsl_poly.h +71 -0
- data/include/rb_gsl_rational.h +37 -0
- data/include/rb_gsl_rng.h +21 -0
- data/include/rb_gsl_root.h +22 -0
- data/include/rb_gsl_sf.h +119 -0
- data/include/rb_gsl_statistics.h +17 -0
- data/include/rb_gsl_tensor.h +45 -0
- data/include/rb_gsl_with_narray.h +29 -0
- data/include/templates_off.h +87 -0
- data/include/templates_on.h +241 -0
- data/lib/gsl.rb +3 -0
- data/lib/gsl/gnuplot.rb +41 -0
- data/lib/gsl/oper.rb +68 -0
- data/lib/ool.rb +22 -0
- data/lib/ool/conmin.rb +30 -0
- data/lib/rbgsl.rb +3 -0
- data/rdoc/alf.rdoc +77 -0
- data/rdoc/blas.rdoc +269 -0
- data/rdoc/bspline.rdoc +42 -0
- data/rdoc/changes.rdoc +164 -0
- data/rdoc/cheb.rdoc +99 -0
- data/rdoc/cholesky_complex.rdoc +46 -0
- data/rdoc/combi.rdoc +125 -0
- data/rdoc/complex.rdoc +210 -0
- data/rdoc/const.rdoc +546 -0
- data/rdoc/dht.rdoc +122 -0
- data/rdoc/diff.rdoc +133 -0
- data/rdoc/ehandling.rdoc +50 -0
- data/rdoc/eigen.rdoc +401 -0
- data/rdoc/fft.rdoc +535 -0
- data/rdoc/fit.rdoc +284 -0
- data/rdoc/function.rdoc +94 -0
- data/rdoc/graph.rdoc +137 -0
- data/rdoc/hist.rdoc +409 -0
- data/rdoc/hist2d.rdoc +279 -0
- data/rdoc/hist3d.rdoc +112 -0
- data/rdoc/index.rdoc +62 -0
- data/rdoc/integration.rdoc +398 -0
- data/rdoc/interp.rdoc +231 -0
- data/rdoc/intro.rdoc +27 -0
- data/rdoc/linalg.rdoc +681 -0
- data/rdoc/linalg_complex.rdoc +88 -0
- data/rdoc/math.rdoc +276 -0
- data/rdoc/matrix.rdoc +1093 -0
- data/rdoc/min.rdoc +189 -0
- data/rdoc/monte.rdoc +234 -0
- data/rdoc/multimin.rdoc +312 -0
- data/rdoc/multiroot.rdoc +293 -0
- data/rdoc/narray.rdoc +177 -0
- data/rdoc/ndlinear.rdoc +250 -0
- data/rdoc/nonlinearfit.rdoc +348 -0
- data/rdoc/ntuple.rdoc +88 -0
- data/rdoc/odeiv.rdoc +378 -0
- data/rdoc/perm.rdoc +221 -0
- data/rdoc/poly.rdoc +335 -0
- data/rdoc/qrng.rdoc +90 -0
- data/rdoc/randist.rdoc +233 -0
- data/rdoc/ref.rdoc +93 -0
- data/rdoc/rng.rdoc +203 -0
- data/rdoc/rngextra.rdoc +11 -0
- data/rdoc/roots.rdoc +305 -0
- data/rdoc/screenshot.rdoc +40 -0
- data/rdoc/sf.rdoc +1622 -0
- data/rdoc/siman.rdoc +89 -0
- data/rdoc/sort.rdoc +94 -0
- data/rdoc/start.rdoc +16 -0
- data/rdoc/stats.rdoc +219 -0
- data/rdoc/sum.rdoc +65 -0
- data/rdoc/tensor.rdoc +251 -0
- data/rdoc/tut.rdoc +5 -0
- data/rdoc/use.rdoc +177 -0
- data/rdoc/vector.rdoc +1243 -0
- data/rdoc/vector_complex.rdoc +347 -0
- data/rdoc/wavelet.rdoc +218 -0
- data/setup.rb +1585 -0
- data/tests/blas/amax.rb +14 -0
- data/tests/blas/asum.rb +16 -0
- data/tests/blas/axpy.rb +25 -0
- data/tests/blas/copy.rb +23 -0
- data/tests/blas/dot.rb +23 -0
- data/tests/bspline.rb +53 -0
- data/tests/cdf.rb +1388 -0
- data/tests/cheb.rb +112 -0
- data/tests/combination.rb +123 -0
- data/tests/complex.rb +17 -0
- data/tests/const.rb +24 -0
- data/tests/deriv.rb +85 -0
- data/tests/dht/dht1.rb +17 -0
- data/tests/dht/dht2.rb +23 -0
- data/tests/dht/dht3.rb +23 -0
- data/tests/dht/dht4.rb +23 -0
- data/tests/diff.rb +78 -0
- data/tests/eigen/eigen.rb +220 -0
- data/tests/eigen/gen.rb +105 -0
- data/tests/eigen/genherm.rb +66 -0
- data/tests/eigen/gensymm.rb +68 -0
- data/tests/eigen/nonsymm.rb +53 -0
- data/tests/eigen/nonsymmv.rb +53 -0
- data/tests/eigen/symm-herm.rb +74 -0
- data/tests/err.rb +58 -0
- data/tests/fit.rb +124 -0
- data/tests/gsl_test.rb +118 -0
- data/tests/gsl_test2.rb +110 -0
- data/tests/histo.rb +12 -0
- data/tests/integration/integration1.rb +72 -0
- data/tests/integration/integration2.rb +71 -0
- data/tests/integration/integration3.rb +71 -0
- data/tests/integration/integration4.rb +71 -0
- data/tests/interp.rb +45 -0
- data/tests/linalg/HH.rb +64 -0
- data/tests/linalg/LU.rb +47 -0
- data/tests/linalg/QR.rb +77 -0
- data/tests/linalg/SV.rb +24 -0
- data/tests/linalg/TDN.rb +116 -0
- data/tests/linalg/TDS.rb +122 -0
- data/tests/linalg/bidiag.rb +73 -0
- data/tests/linalg/cholesky.rb +20 -0
- data/tests/linalg/linalg.rb +158 -0
- data/tests/matrix/matrix_complex_test.rb +36 -0
- data/tests/matrix/matrix_nmf_test.rb +39 -0
- data/tests/matrix/matrix_test.rb +48 -0
- data/tests/min.rb +99 -0
- data/tests/monte/miser.rb +31 -0
- data/tests/monte/vegas.rb +45 -0
- data/tests/multifit/test_2dgauss.rb +112 -0
- data/tests/multifit/test_brown.rb +90 -0
- data/tests/multifit/test_enso.rb +246 -0
- data/tests/multifit/test_filip.rb +155 -0
- data/tests/multifit/test_gauss.rb +97 -0
- data/tests/multifit/test_longley.rb +110 -0
- data/tests/multifit/test_multifit.rb +52 -0
- data/tests/multimin.rb +139 -0
- data/tests/multiroot.rb +131 -0
- data/tests/multiset.rb +52 -0
- data/tests/narray/blas_dnrm2.rb +20 -0
- data/tests/odeiv.rb +353 -0
- data/tests/poly/poly.rb +290 -0
- data/tests/poly/special.rb +65 -0
- data/tests/qrng.rb +131 -0
- data/tests/quartic.rb +29 -0
- data/tests/randist.rb +134 -0
- data/tests/rng.rb +305 -0
- data/tests/roots.rb +76 -0
- data/tests/run-test.sh +17 -0
- data/tests/sf/gsl_test_sf.rb +249 -0
- data/tests/sf/test_airy.rb +83 -0
- data/tests/sf/test_bessel.rb +306 -0
- data/tests/sf/test_coulomb.rb +17 -0
- data/tests/sf/test_dilog.rb +25 -0
- data/tests/sf/test_gamma.rb +209 -0
- data/tests/sf/test_hyperg.rb +356 -0
- data/tests/sf/test_legendre.rb +227 -0
- data/tests/sf/test_mathieu.rb +59 -0
- data/tests/sf/test_mode.rb +19 -0
- data/tests/sf/test_sf.rb +839 -0
- data/tests/stats.rb +174 -0
- data/tests/stats_mt.rb +16 -0
- data/tests/sum.rb +98 -0
- data/tests/sys.rb +323 -0
- data/tests/tensor.rb +419 -0
- data/tests/vector/vector_complex_test.rb +101 -0
- data/tests/vector/vector_test.rb +141 -0
- data/tests/wavelet.rb +142 -0
- metadata +789 -0
data/ext/odeiv.c
ADDED
@@ -0,0 +1,962 @@
|
|
1
|
+
/*
|
2
|
+
odeiv.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_odeiv.h"
|
13
|
+
#include "rb_gsl_array.h"
|
14
|
+
#include "rb_gsl_function.h"
|
15
|
+
|
16
|
+
#ifndef CHECK_SYSTEM
|
17
|
+
#define CHECK_SYSTEM(x) if(CLASS_OF(x)!=cgsl_odeiv_system)\
|
18
|
+
rb_raise(rb_eTypeError,\
|
19
|
+
"wrong argument type %s (GSL::Odeiv::System expected)",\
|
20
|
+
rb_class2name(CLASS_OF(x)));
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#ifndef CHECK_STEP
|
24
|
+
#define CHECK_STEP(x) if(CLASS_OF(x)!=cgsl_odeiv_step)\
|
25
|
+
rb_raise(rb_eTypeError,\
|
26
|
+
"wrong argument type %s (GSL::Odeiv::Step expected)",\
|
27
|
+
rb_class2name(CLASS_OF(x)));
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#ifndef CHECK_CONTROL
|
31
|
+
#define CHECK_CONTROL(x) if(CLASS_OF(x)!=cgsl_odeiv_control)\
|
32
|
+
rb_raise(rb_eTypeError,\
|
33
|
+
"wrong argument type %s (GSL::Odeiv::Control expected)",\
|
34
|
+
rb_class2name(CLASS_OF(x)));
|
35
|
+
#endif
|
36
|
+
|
37
|
+
#ifndef CHECK_EVOLVE
|
38
|
+
#define CHECK_EVOLVE(x) if(CLASS_OF(x)!=cgsl_odeiv_evolve)\
|
39
|
+
rb_raise(rb_eTypeError,\
|
40
|
+
"wrong argument type %s (GSL::Odeiv::Evolve expected)",\
|
41
|
+
rb_class2name(CLASS_OF(x)));
|
42
|
+
#endif
|
43
|
+
|
44
|
+
#ifndef CHECK_SOLVER
|
45
|
+
#define CHECK_SOLVER(x) if(CLASS_OF(x)!=cgsl_odeiv_solver)\
|
46
|
+
rb_raise(rb_eTypeError,\
|
47
|
+
"wrong argument type %s (GSL::Odeiv::Solver expected)",\
|
48
|
+
rb_class2name(CLASS_OF(x)));
|
49
|
+
#endif
|
50
|
+
|
51
|
+
static VALUE cgsl_odeiv_system;
|
52
|
+
static VALUE cgsl_odeiv_step;
|
53
|
+
static VALUE cgsl_odeiv_control;
|
54
|
+
static VALUE cgsl_odeiv_evolve;
|
55
|
+
static VALUE cgsl_odeiv_solver;
|
56
|
+
|
57
|
+
enum {
|
58
|
+
GSL_ODEIV_STEP_RK2,
|
59
|
+
GSL_ODEIV_STEP_RK4,
|
60
|
+
GSL_ODEIV_STEP_RKF45,
|
61
|
+
GSL_ODEIV_STEP_RKCK,
|
62
|
+
GSL_ODEIV_STEP_RK8PD,
|
63
|
+
GSL_ODEIV_STEP_RK2IMP,
|
64
|
+
GSL_ODEIV_STEP_RK4IMP,
|
65
|
+
GSL_ODEIV_STEP_BSIMP,
|
66
|
+
GSL_ODEIV_STEP_GEAR1,
|
67
|
+
GSL_ODEIV_STEP_GEAR2,
|
68
|
+
GSL_ODEIV_STEP_RK2SIMP,
|
69
|
+
};
|
70
|
+
|
71
|
+
typedef struct __rb_gsl_odeiv_evolve {
|
72
|
+
gsl_odeiv_evolve *e;
|
73
|
+
gsl_odeiv_control *c;
|
74
|
+
gsl_odeiv_step *s;
|
75
|
+
gsl_odeiv_system *sys;
|
76
|
+
} gsl_odeiv_solver;
|
77
|
+
|
78
|
+
static int calc_func(double t, const double y[], double dydt[], void *data);
|
79
|
+
static int calc_jac(double t, const double y[], double *dfdy, double dfdt[], void *data);
|
80
|
+
|
81
|
+
static int calc_func(double t, const double y[], double dydt[], void *data)
|
82
|
+
{
|
83
|
+
VALUE ary, params, proc;
|
84
|
+
// local variable "result" declared and set, but never used
|
85
|
+
//VALUE result;
|
86
|
+
VALUE vy, vdydt;
|
87
|
+
gsl_vector_view ytmp, dydttmp;
|
88
|
+
size_t dim;
|
89
|
+
|
90
|
+
ary = (VALUE) data;
|
91
|
+
proc = rb_ary_entry(ary, 0);
|
92
|
+
dim = FIX2INT(rb_ary_entry(ary, 2));
|
93
|
+
params = rb_ary_entry(ary, 3);
|
94
|
+
|
95
|
+
ytmp.vector.data = (double *) y;
|
96
|
+
ytmp.vector.stride = 1;
|
97
|
+
ytmp.vector.size = dim;
|
98
|
+
dydttmp.vector.data = dydt;
|
99
|
+
dydttmp.vector.stride = 1;
|
100
|
+
dydttmp.vector.size = dim;
|
101
|
+
vy = Data_Wrap_Struct(cgsl_vector_view_ro, 0, NULL, &ytmp);
|
102
|
+
vdydt = Data_Wrap_Struct(cgsl_vector_view, 0, NULL, &dydttmp);
|
103
|
+
|
104
|
+
if (NIL_P(params)) /*result =*/ rb_funcall((VALUE) proc, RBGSL_ID_call, 3, rb_float_new(t),
|
105
|
+
vy, vdydt);
|
106
|
+
else /*result =*/ rb_funcall((VALUE) proc, RBGSL_ID_call, 4, rb_float_new(t), vy, vdydt, params);
|
107
|
+
|
108
|
+
return GSL_SUCCESS;
|
109
|
+
}
|
110
|
+
|
111
|
+
static int calc_jac(double t, const double y[], double *dfdy, double dfdt[], void *data)
|
112
|
+
{
|
113
|
+
VALUE params, proc, ary;
|
114
|
+
VALUE vdfdt;
|
115
|
+
// local variable "result" declared and set, but never used
|
116
|
+
//VALUE result;
|
117
|
+
VALUE vy, vmjac;
|
118
|
+
gsl_vector_view ytmp, dfdttmp;
|
119
|
+
gsl_matrix_view mv;
|
120
|
+
size_t dim;
|
121
|
+
|
122
|
+
ary = (VALUE) data;
|
123
|
+
proc = rb_ary_entry(ary, 1);
|
124
|
+
if (NIL_P(proc)) rb_raise(rb_eRuntimeError, "df function not given");
|
125
|
+
|
126
|
+
dim = FIX2INT(rb_ary_entry(ary, 2));
|
127
|
+
params = rb_ary_entry(ary, 3);
|
128
|
+
|
129
|
+
ytmp.vector.data = (double *) y;
|
130
|
+
ytmp.vector.size = dim;
|
131
|
+
ytmp.vector.stride = 1;
|
132
|
+
dfdttmp.vector.data = dfdt;
|
133
|
+
dfdttmp.vector.size = dim;
|
134
|
+
dfdttmp.vector.stride = 1;
|
135
|
+
mv = gsl_matrix_view_array(dfdy, dim, dim);
|
136
|
+
vy = Data_Wrap_Struct(cgsl_vector_view_ro, 0, NULL, &ytmp);
|
137
|
+
vmjac = Data_Wrap_Struct(cgsl_matrix_view, 0, NULL, &mv);
|
138
|
+
vdfdt = Data_Wrap_Struct(cgsl_vector_view, 0, NULL, &dfdttmp);
|
139
|
+
if (NIL_P(params)) /*result =*/ rb_funcall((VALUE) proc, RBGSL_ID_call, 4, rb_float_new(t),
|
140
|
+
vy, vmjac, vdfdt);
|
141
|
+
else /*result =*/ rb_funcall((VALUE) proc, RBGSL_ID_call, 5, rb_float_new(t),
|
142
|
+
vy, vmjac, vdfdt, params);
|
143
|
+
return GSL_SUCCESS;
|
144
|
+
}
|
145
|
+
|
146
|
+
static void gsl_odeiv_system_mark(gsl_odeiv_system *sys);
|
147
|
+
static void gsl_odeiv_system_mark(gsl_odeiv_system *sys)
|
148
|
+
{
|
149
|
+
rb_gc_mark((VALUE) sys->params);
|
150
|
+
}
|
151
|
+
|
152
|
+
static gsl_odeiv_system* make_sys(int argc, VALUE *argv);
|
153
|
+
static void set_sys(int argc, VALUE *argv, gsl_odeiv_system *sys);
|
154
|
+
static VALUE rb_gsl_odeiv_system_new(int argc, VALUE *argv, VALUE klass)
|
155
|
+
{
|
156
|
+
VALUE obj;
|
157
|
+
gsl_odeiv_system *sys = NULL;
|
158
|
+
sys = make_sys(argc, argv);
|
159
|
+
obj = Data_Wrap_Struct(klass, gsl_odeiv_system_mark, free, sys);
|
160
|
+
return obj;
|
161
|
+
}
|
162
|
+
|
163
|
+
static VALUE rb_gsl_odeiv_system_set(int argc, VALUE *argv, VALUE obj)
|
164
|
+
{
|
165
|
+
gsl_odeiv_system *sys = NULL;
|
166
|
+
Data_Get_Struct(obj, gsl_odeiv_system, sys);
|
167
|
+
set_sys(argc, argv, sys);
|
168
|
+
return obj;
|
169
|
+
}
|
170
|
+
|
171
|
+
static gsl_odeiv_system* make_sys(int argc, VALUE *argv)
|
172
|
+
{
|
173
|
+
gsl_odeiv_system *sys = NULL;
|
174
|
+
sys = ALLOC(gsl_odeiv_system);
|
175
|
+
sys->function = &calc_func;
|
176
|
+
sys->jacobian = &calc_jac;
|
177
|
+
sys->params = NULL;
|
178
|
+
set_sys(argc, argv, sys);
|
179
|
+
return sys;
|
180
|
+
}
|
181
|
+
|
182
|
+
static void set_sys(int argc, VALUE *argv, gsl_odeiv_system *sys)
|
183
|
+
{
|
184
|
+
size_t dimension;
|
185
|
+
VALUE ary, vjac, dim;
|
186
|
+
VALUE vparams;
|
187
|
+
int itmp;
|
188
|
+
size_t i, j;
|
189
|
+
|
190
|
+
if (argc < 2) rb_raise(rb_eArgError, "too few arguments");
|
191
|
+
CHECK_PROC(argv[0]);
|
192
|
+
|
193
|
+
if (sys == NULL) {
|
194
|
+
sys = ALLOC(gsl_odeiv_system);
|
195
|
+
sys->function = &calc_func;
|
196
|
+
sys->jacobian = &calc_jac;
|
197
|
+
}
|
198
|
+
|
199
|
+
if (sys->params == NULL) {
|
200
|
+
ary = rb_ary_new2(4);
|
201
|
+
/* (VALUE) sys->params = ary;*/
|
202
|
+
sys->params = (void *) ary;
|
203
|
+
} else {
|
204
|
+
ary = (VALUE) sys->params;
|
205
|
+
}
|
206
|
+
rb_ary_store(ary, 1, Qnil); /* function to calc J */
|
207
|
+
rb_ary_store(ary, 3, Qnil); /* parameters */
|
208
|
+
|
209
|
+
itmp = 1;
|
210
|
+
if (rb_obj_is_kind_of(argv[1], rb_cProc)) {
|
211
|
+
vjac = argv[1];
|
212
|
+
itmp = 2;
|
213
|
+
} else {
|
214
|
+
vjac = Qnil;
|
215
|
+
}
|
216
|
+
if ((dim =argv[itmp++]) == Qnil) dim = argv[itmp++];
|
217
|
+
switch (argc - itmp) {
|
218
|
+
case 0:
|
219
|
+
vparams = Qnil;
|
220
|
+
break;
|
221
|
+
case 1:
|
222
|
+
vparams = argv[itmp];
|
223
|
+
break;
|
224
|
+
default:
|
225
|
+
vparams = rb_ary_new2(argc-itmp);
|
226
|
+
for (i = itmp, j = 0; i < argc; i++, j++) rb_ary_store(vparams, j, argv[i]);
|
227
|
+
}
|
228
|
+
dimension = FIX2INT(dim);
|
229
|
+
sys->dimension = dimension;
|
230
|
+
rb_ary_store(ary, 0, argv[0]);
|
231
|
+
rb_ary_store(ary, 1, vjac);
|
232
|
+
rb_ary_store(ary, 2, dim);
|
233
|
+
rb_ary_store(ary, 3, vparams);
|
234
|
+
}
|
235
|
+
|
236
|
+
static VALUE rb_gsl_odeiv_system_set_params(int argc, VALUE *argv, VALUE obj);
|
237
|
+
static VALUE rb_gsl_odeiv_system_set_params(int argc, VALUE *argv, VALUE obj)
|
238
|
+
{
|
239
|
+
VALUE vparams, ary;
|
240
|
+
gsl_odeiv_system *sys = NULL;
|
241
|
+
size_t i;
|
242
|
+
Data_Get_Struct(obj, gsl_odeiv_system, sys);
|
243
|
+
|
244
|
+
ary = (VALUE) sys->params;
|
245
|
+
switch (argc) {
|
246
|
+
case 0:
|
247
|
+
vparams = Qnil;
|
248
|
+
break;
|
249
|
+
case 1:
|
250
|
+
vparams = argv[0];
|
251
|
+
break;
|
252
|
+
default:
|
253
|
+
vparams = rb_ary_new2(argc);
|
254
|
+
for (i = 0; i < argc; i++) rb_ary_store(vparams, i, argv[i]);
|
255
|
+
}
|
256
|
+
// rb_ary_delete_at(ary, 3);
|
257
|
+
rb_ary_store(ary, 3, vparams);
|
258
|
+
return obj;
|
259
|
+
}
|
260
|
+
|
261
|
+
static VALUE rb_gsl_odeiv_system_params(VALUE obj)
|
262
|
+
{
|
263
|
+
VALUE ary;
|
264
|
+
gsl_odeiv_system *sys = NULL;
|
265
|
+
Data_Get_Struct(obj, gsl_odeiv_system, sys);
|
266
|
+
ary = (VALUE) sys->params;
|
267
|
+
return rb_ary_entry(ary, 3);
|
268
|
+
}
|
269
|
+
|
270
|
+
static VALUE rb_gsl_odeiv_system_function(VALUE obj)
|
271
|
+
{
|
272
|
+
VALUE ary;
|
273
|
+
gsl_odeiv_system *sys = NULL;
|
274
|
+
Data_Get_Struct(obj, gsl_odeiv_system, sys);
|
275
|
+
ary = (VALUE) sys->params;
|
276
|
+
return rb_ary_entry(ary, 0);
|
277
|
+
}
|
278
|
+
|
279
|
+
static VALUE rb_gsl_odeiv_system_jacobian(VALUE obj)
|
280
|
+
{
|
281
|
+
VALUE ary;
|
282
|
+
gsl_odeiv_system *sys = NULL;
|
283
|
+
Data_Get_Struct(obj, gsl_odeiv_system, sys);
|
284
|
+
ary = (VALUE) sys->params;
|
285
|
+
return rb_ary_entry(ary, 1);
|
286
|
+
}
|
287
|
+
|
288
|
+
static VALUE rb_gsl_odeiv_system_dimension(VALUE obj)
|
289
|
+
{
|
290
|
+
gsl_odeiv_system *sys = NULL;
|
291
|
+
Data_Get_Struct(obj, gsl_odeiv_system, sys);
|
292
|
+
return INT2FIX(sys->dimension);
|
293
|
+
}
|
294
|
+
|
295
|
+
static const gsl_odeiv_step_type* rb_gsl_odeiv_step_type_get(VALUE tt);
|
296
|
+
|
297
|
+
static gsl_odeiv_step* make_step(VALUE tt, VALUE dim);
|
298
|
+
static VALUE rb_gsl_odeiv_step_new(int argc, VALUE *argv, VALUE klass)
|
299
|
+
{
|
300
|
+
VALUE obj;
|
301
|
+
gsl_odeiv_step *s = NULL;
|
302
|
+
switch (argc) {
|
303
|
+
case 1:
|
304
|
+
CHECK_FIXNUM(argv[0]);
|
305
|
+
s = make_step(INT2FIX(GSL_ODEIV_STEP_RKF45), argv[0]);
|
306
|
+
break;
|
307
|
+
case 2:
|
308
|
+
CHECK_FIXNUM(argv[1]);
|
309
|
+
s = make_step(argv[0], argv[1]);
|
310
|
+
break;
|
311
|
+
default:
|
312
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
|
313
|
+
}
|
314
|
+
obj = Data_Wrap_Struct(klass, 0, gsl_odeiv_step_free, s);
|
315
|
+
return obj;
|
316
|
+
}
|
317
|
+
|
318
|
+
static gsl_odeiv_step* make_step(VALUE tt, VALUE dim)
|
319
|
+
{
|
320
|
+
const gsl_odeiv_step_type *T;
|
321
|
+
T = rb_gsl_odeiv_step_type_get(tt);
|
322
|
+
return gsl_odeiv_step_alloc(T, FIX2INT(dim));
|
323
|
+
}
|
324
|
+
|
325
|
+
static const gsl_odeiv_step_type* rb_gsl_odeiv_step_type_get(VALUE tt)
|
326
|
+
{
|
327
|
+
const gsl_odeiv_step_type *T;
|
328
|
+
int type;
|
329
|
+
char name[64];
|
330
|
+
switch (TYPE(tt)) {
|
331
|
+
case T_FIXNUM:
|
332
|
+
type = FIX2INT(tt);
|
333
|
+
switch (type) {
|
334
|
+
case GSL_ODEIV_STEP_RK2: T = gsl_odeiv_step_rk2; break;
|
335
|
+
case GSL_ODEIV_STEP_RK4: T = gsl_odeiv_step_rk4; break;
|
336
|
+
case GSL_ODEIV_STEP_RKF45: T = gsl_odeiv_step_rkf45; break;
|
337
|
+
case GSL_ODEIV_STEP_RKCK: T = gsl_odeiv_step_rkck; break;
|
338
|
+
case GSL_ODEIV_STEP_RK8PD: T = gsl_odeiv_step_rk8pd; break;
|
339
|
+
case GSL_ODEIV_STEP_RK2IMP: T = gsl_odeiv_step_rk2imp; break;
|
340
|
+
case GSL_ODEIV_STEP_RK4IMP: T = gsl_odeiv_step_rk4imp; break;
|
341
|
+
case GSL_ODEIV_STEP_BSIMP: T = gsl_odeiv_step_bsimp; break;
|
342
|
+
case GSL_ODEIV_STEP_GEAR1: T = gsl_odeiv_step_gear1; break;
|
343
|
+
case GSL_ODEIV_STEP_GEAR2: T = gsl_odeiv_step_gear2; break;
|
344
|
+
#ifdef GSL_1_6_LATER
|
345
|
+
case GSL_ODEIV_STEP_RK2SIMP: T = gsl_odeiv_step_rk2simp; break;
|
346
|
+
#endif
|
347
|
+
default:
|
348
|
+
rb_raise(rb_eArgError, "wrong argument type (Fixnum expected)");
|
349
|
+
break;
|
350
|
+
}
|
351
|
+
break;
|
352
|
+
case T_STRING:
|
353
|
+
strcpy(name, STR2CSTR(tt));
|
354
|
+
if (str_tail_grep(name, "rk2") == 0) T = gsl_odeiv_step_rk2;
|
355
|
+
else if (str_tail_grep(name, "rk4") == 0) T = gsl_odeiv_step_rk4;
|
356
|
+
else if (str_tail_grep(name, "rkf45") == 0) T = gsl_odeiv_step_rkf45;
|
357
|
+
else if (str_tail_grep(name, "rkck") == 0) T = gsl_odeiv_step_rkck;
|
358
|
+
else if (str_tail_grep(name, "rk8pd") == 0) T = gsl_odeiv_step_rk8pd;
|
359
|
+
else if (str_tail_grep(name, "rk2imp") == 0) T = gsl_odeiv_step_rk2imp;
|
360
|
+
else if (str_tail_grep(name, "rk4imp") == 0) T = gsl_odeiv_step_rk4imp;
|
361
|
+
else if (str_tail_grep(name, "bsimp") == 0) T = gsl_odeiv_step_bsimp;
|
362
|
+
else if (str_tail_grep(name, "gear1") == 0) T = gsl_odeiv_step_gear1;
|
363
|
+
else if (str_tail_grep(name, "gear2") == 0) T = gsl_odeiv_step_gear2;
|
364
|
+
#ifdef GSL_1_6_LATER
|
365
|
+
else if (str_tail_grep(name, "rk2simp") == 0) T = gsl_odeiv_step_rk2simp;
|
366
|
+
#endif
|
367
|
+
else {
|
368
|
+
rb_raise(rb_eArgError, "wrong argument type %s", name);
|
369
|
+
}
|
370
|
+
break;
|
371
|
+
default:
|
372
|
+
rb_raise(rb_eArgError, "wrong argument type %s (String or Fixnum expected)",
|
373
|
+
rb_class2name(CLASS_OF(tt)));
|
374
|
+
break;
|
375
|
+
}
|
376
|
+
return T;
|
377
|
+
}
|
378
|
+
|
379
|
+
static VALUE rb_gsl_odeiv_step_reset(VALUE obj)
|
380
|
+
{
|
381
|
+
gsl_odeiv_step *s = NULL;
|
382
|
+
Data_Get_Struct(obj, gsl_odeiv_step, s);
|
383
|
+
return INT2FIX(gsl_odeiv_step_reset(s));
|
384
|
+
}
|
385
|
+
|
386
|
+
static VALUE rb_gsl_odeiv_step_name(VALUE obj)
|
387
|
+
{
|
388
|
+
gsl_odeiv_step *s = NULL;
|
389
|
+
Data_Get_Struct(obj, gsl_odeiv_step, s);
|
390
|
+
return rb_str_new2(gsl_odeiv_step_name(s));
|
391
|
+
}
|
392
|
+
|
393
|
+
static VALUE rb_gsl_odeiv_step_order(VALUE obj)
|
394
|
+
{
|
395
|
+
gsl_odeiv_step *s = NULL;
|
396
|
+
Data_Get_Struct(obj, gsl_odeiv_step, s);
|
397
|
+
return INT2FIX(gsl_odeiv_step_order(s));
|
398
|
+
}
|
399
|
+
|
400
|
+
static VALUE rb_gsl_odeiv_step_dimension(VALUE obj)
|
401
|
+
{
|
402
|
+
gsl_odeiv_step *s = NULL;
|
403
|
+
Data_Get_Struct(obj, gsl_odeiv_step, s);
|
404
|
+
return INT2FIX(s->dimension);
|
405
|
+
}
|
406
|
+
|
407
|
+
static VALUE rb_gsl_odeiv_step_apply(int argc, VALUE *argv, VALUE obj)
|
408
|
+
{
|
409
|
+
gsl_odeiv_step *s = NULL;
|
410
|
+
gsl_odeiv_system *sys = NULL;
|
411
|
+
gsl_vector *y = NULL, *yerr = NULL;
|
412
|
+
gsl_vector *vtmp1 = NULL, *vtmp2 = NULL;
|
413
|
+
double *dydt_in = NULL, *dydt_out = NULL;
|
414
|
+
double t, h;
|
415
|
+
switch (argc) {
|
416
|
+
case 5:
|
417
|
+
break;
|
418
|
+
case 7:
|
419
|
+
if (VECTOR_P(argv[5])) {
|
420
|
+
Data_Get_Struct(argv[5], gsl_vector, vtmp2);
|
421
|
+
if (vtmp2) dydt_out = vtmp2->data;
|
422
|
+
}
|
423
|
+
/* no break */
|
424
|
+
case 6:
|
425
|
+
if (VECTOR_P(argv[4])) {
|
426
|
+
Data_Get_Struct(argv[4], gsl_vector, vtmp1);
|
427
|
+
if (vtmp1) dydt_in = vtmp1->data;
|
428
|
+
}
|
429
|
+
break;
|
430
|
+
default:
|
431
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 5, 6 or 7)", argc);
|
432
|
+
break;
|
433
|
+
}
|
434
|
+
Need_Float(argv[0]); Need_Float(argv[1]);
|
435
|
+
CHECK_VECTOR(argv[2]); CHECK_VECTOR(argv[3]);
|
436
|
+
CHECK_SYSTEM(argv[argc-1]);
|
437
|
+
Data_Get_Struct(obj, gsl_odeiv_step, s);
|
438
|
+
t = NUM2DBL(argv[0]);
|
439
|
+
h = NUM2DBL(argv[1]);
|
440
|
+
Data_Get_Struct(argv[2], gsl_vector, y);
|
441
|
+
Data_Get_Struct(argv[3], gsl_vector, yerr);
|
442
|
+
Data_Get_Struct(argv[argc-1], gsl_odeiv_system, sys);
|
443
|
+
return INT2FIX(gsl_odeiv_step_apply(s, t, h, y->data, yerr->data,
|
444
|
+
dydt_in, dydt_out, sys));
|
445
|
+
}
|
446
|
+
|
447
|
+
static VALUE rb_gsl_odeiv_step_info(VALUE obj)
|
448
|
+
{
|
449
|
+
gsl_odeiv_step *s;
|
450
|
+
char buf[256];
|
451
|
+
Data_Get_Struct(obj, gsl_odeiv_step, s);
|
452
|
+
sprintf(buf, "Class: %s\n", rb_class2name(CLASS_OF(obj)));
|
453
|
+
#ifdef RUBY_1_9_LATER
|
454
|
+
sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS_SUPER(CLASS_OF(obj))));
|
455
|
+
#else
|
456
|
+
sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS(CLASS_OF(obj))->super));
|
457
|
+
#endif
|
458
|
+
sprintf(buf, "%sType: %s\n", buf, gsl_odeiv_step_name(s));
|
459
|
+
sprintf(buf, "%sDimension: %d\n", buf, (int) s->dimension);
|
460
|
+
return rb_str_new2(buf);
|
461
|
+
}
|
462
|
+
|
463
|
+
static gsl_odeiv_control* make_control_standard(VALUE epsabs,
|
464
|
+
VALUE epsrel,
|
465
|
+
VALUE ay, VALUE adydt);
|
466
|
+
static gsl_odeiv_control* make_control_y(VALUE epsabs, VALUE epsrel);
|
467
|
+
static VALUE rb_gsl_odeiv_control_standard_new(VALUE klass, VALUE epsabs,
|
468
|
+
VALUE epsrel,
|
469
|
+
VALUE ay, VALUE adydt)
|
470
|
+
{
|
471
|
+
gsl_odeiv_control *c = NULL;
|
472
|
+
c = make_control_standard(epsabs, epsrel, ay, adydt);
|
473
|
+
return Data_Wrap_Struct(klass, 0, gsl_odeiv_control_free, c);
|
474
|
+
}
|
475
|
+
|
476
|
+
static gsl_odeiv_control* make_control_standard(VALUE epsabs,
|
477
|
+
VALUE epsrel,
|
478
|
+
VALUE ay, VALUE adydt)
|
479
|
+
{
|
480
|
+
Need_Float(epsabs); Need_Float(epsrel);
|
481
|
+
Need_Float(ay); Need_Float(adydt);
|
482
|
+
return gsl_odeiv_control_standard_new(NUM2DBL(epsabs), NUM2DBL(epsrel),
|
483
|
+
NUM2DBL(ay), NUM2DBL(adydt));
|
484
|
+
}
|
485
|
+
|
486
|
+
static gsl_odeiv_control* make_control_y(VALUE epsabs, VALUE epsrel)
|
487
|
+
{
|
488
|
+
Need_Float(epsabs); Need_Float(epsrel);
|
489
|
+
return gsl_odeiv_control_y_new(NUM2DBL(epsabs), NUM2DBL(epsrel));
|
490
|
+
}
|
491
|
+
|
492
|
+
static VALUE rb_gsl_odeiv_control_y_new(VALUE klass, VALUE epsabs,
|
493
|
+
VALUE epsrel)
|
494
|
+
{
|
495
|
+
gsl_odeiv_control *c = NULL;
|
496
|
+
c = make_control_y(epsabs, epsrel);
|
497
|
+
return Data_Wrap_Struct(klass, 0, gsl_odeiv_control_free, c);
|
498
|
+
}
|
499
|
+
|
500
|
+
static VALUE rb_gsl_odeiv_control_yp_new(VALUE klass, VALUE epsabs,
|
501
|
+
VALUE epsrel)
|
502
|
+
{
|
503
|
+
gsl_odeiv_control *c = NULL;
|
504
|
+
Need_Float(epsabs); Need_Float(epsrel);
|
505
|
+
c = gsl_odeiv_control_yp_new(NUM2DBL(epsabs), NUM2DBL(epsrel));
|
506
|
+
return Data_Wrap_Struct(klass, 0, gsl_odeiv_control_free, c);
|
507
|
+
}
|
508
|
+
|
509
|
+
#ifdef GSL_1_2_LATER
|
510
|
+
static VALUE rb_gsl_odeiv_control_scaled_new(VALUE klass, VALUE epsabs,
|
511
|
+
VALUE epsrel,
|
512
|
+
VALUE ay, VALUE adydt,
|
513
|
+
VALUE sc, VALUE dd)
|
514
|
+
{
|
515
|
+
gsl_odeiv_control *c = NULL;
|
516
|
+
gsl_vector *v = NULL;
|
517
|
+
Need_Float(epsabs); Need_Float(epsrel);
|
518
|
+
Need_Float(ay); Need_Float(adydt);
|
519
|
+
CHECK_FIXNUM(dd);
|
520
|
+
CHECK_VECTOR(sc);
|
521
|
+
Data_Get_Struct(sc, gsl_vector, v);
|
522
|
+
c = gsl_odeiv_control_scaled_new(NUM2DBL(epsabs), NUM2DBL(epsrel),
|
523
|
+
NUM2DBL(ay), NUM2DBL(adydt), v->data,
|
524
|
+
FIX2INT(dd));
|
525
|
+
return Data_Wrap_Struct(klass, 0, gsl_odeiv_control_free, c);
|
526
|
+
}
|
527
|
+
#endif
|
528
|
+
|
529
|
+
static VALUE rb_gsl_odeiv_control_init(VALUE obj, VALUE epsabs,
|
530
|
+
VALUE epsrel,
|
531
|
+
VALUE ay, VALUE adydt)
|
532
|
+
{
|
533
|
+
gsl_odeiv_control *c = NULL;
|
534
|
+
Need_Float(epsabs); Need_Float(epsrel);
|
535
|
+
Need_Float(ay); Need_Float(adydt);
|
536
|
+
Data_Get_Struct(obj, gsl_odeiv_control, c);
|
537
|
+
gsl_odeiv_control_init(c, NUM2DBL(epsabs), NUM2DBL(epsrel),
|
538
|
+
NUM2DBL(ay), NUM2DBL(adydt));
|
539
|
+
return obj;
|
540
|
+
}
|
541
|
+
|
542
|
+
static VALUE rb_gsl_odeiv_control_name(VALUE obj)
|
543
|
+
{
|
544
|
+
gsl_odeiv_control *c = NULL;
|
545
|
+
Data_Get_Struct(obj, gsl_odeiv_control, c);
|
546
|
+
return rb_str_new2(gsl_odeiv_control_name(c));
|
547
|
+
}
|
548
|
+
|
549
|
+
static VALUE rb_gsl_odeiv_control_hadjust(VALUE obj, VALUE ss, VALUE yy0,
|
550
|
+
VALUE yyerr, VALUE ddydt, VALUE hh)
|
551
|
+
{
|
552
|
+
gsl_odeiv_control *c = NULL;
|
553
|
+
gsl_odeiv_step *s = NULL;
|
554
|
+
gsl_vector *y0 = NULL, *yerr = NULL, *dydt = NULL;
|
555
|
+
double h;
|
556
|
+
int status;
|
557
|
+
CHECK_VECTOR(yy0);
|
558
|
+
CHECK_VECTOR(yyerr);
|
559
|
+
CHECK_VECTOR(ddydt);
|
560
|
+
Data_Get_Struct(obj, gsl_odeiv_control, c);
|
561
|
+
Data_Get_Struct(ss, gsl_odeiv_step, s);
|
562
|
+
Data_Get_Struct(yy0, gsl_vector, y0);
|
563
|
+
Data_Get_Struct(yyerr, gsl_vector, yerr);
|
564
|
+
Data_Get_Struct(ddydt, gsl_vector, dydt);
|
565
|
+
h = NUM2DBL(hh);
|
566
|
+
status = gsl_odeiv_control_hadjust(c, s, y0->data, yerr->data,
|
567
|
+
dydt->data, &h);
|
568
|
+
return rb_ary_new3(2, rb_float_new(h), INT2FIX(status));
|
569
|
+
}
|
570
|
+
|
571
|
+
static gsl_odeiv_evolve* make_evolve(VALUE dim);
|
572
|
+
static VALUE rb_gsl_odeiv_evolve_new(VALUE klass, VALUE dim)
|
573
|
+
{
|
574
|
+
gsl_odeiv_evolve *e = NULL;
|
575
|
+
e = make_evolve(dim);
|
576
|
+
return Data_Wrap_Struct(klass, 0, gsl_odeiv_evolve_free, e);
|
577
|
+
}
|
578
|
+
|
579
|
+
static gsl_odeiv_evolve* make_evolve(VALUE dim)
|
580
|
+
{
|
581
|
+
return gsl_odeiv_evolve_alloc(FIX2INT(dim));
|
582
|
+
}
|
583
|
+
|
584
|
+
static VALUE rb_gsl_odeiv_evolve_reset(VALUE obj)
|
585
|
+
{
|
586
|
+
gsl_odeiv_evolve *e = NULL;
|
587
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
588
|
+
return INT2FIX(gsl_odeiv_evolve_reset(e));
|
589
|
+
}
|
590
|
+
|
591
|
+
static VALUE rb_gsl_odeiv_evolve_count(VALUE obj)
|
592
|
+
{
|
593
|
+
gsl_odeiv_evolve *e = NULL;
|
594
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
595
|
+
return INT2FIX(e->count);
|
596
|
+
}
|
597
|
+
|
598
|
+
static VALUE rb_gsl_odeiv_evolve_dimension(VALUE obj)
|
599
|
+
{
|
600
|
+
gsl_odeiv_evolve *e = NULL;
|
601
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
602
|
+
return INT2FIX(e->dimension);
|
603
|
+
}
|
604
|
+
|
605
|
+
static VALUE rb_gsl_odeiv_evolve_failed_steps(VALUE obj)
|
606
|
+
{
|
607
|
+
gsl_odeiv_evolve *e = NULL;
|
608
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
609
|
+
return INT2FIX(e->failed_steps);
|
610
|
+
}
|
611
|
+
|
612
|
+
static VALUE rb_gsl_odeiv_evolve_last_step(VALUE obj)
|
613
|
+
{
|
614
|
+
gsl_odeiv_evolve *e = NULL;
|
615
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
616
|
+
return rb_float_new(e->last_step);
|
617
|
+
}
|
618
|
+
|
619
|
+
static VALUE rb_gsl_odeiv_evolve_y0(VALUE obj)
|
620
|
+
{
|
621
|
+
gsl_odeiv_evolve *e = NULL;
|
622
|
+
gsl_vector_view *v = NULL;
|
623
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
624
|
+
v = gsl_vector_view_alloc();
|
625
|
+
v->vector.data = e->y0;
|
626
|
+
v->vector.size = e->dimension;
|
627
|
+
v->vector.stride = 1;
|
628
|
+
v->vector.owner = 0;
|
629
|
+
return Data_Wrap_Struct(cgsl_vector_view_ro, 0, gsl_vector_view_free, v);
|
630
|
+
}
|
631
|
+
|
632
|
+
static VALUE rb_gsl_odeiv_evolve_yerr(VALUE obj)
|
633
|
+
{
|
634
|
+
gsl_odeiv_evolve *e = NULL;
|
635
|
+
gsl_vector_view *v = NULL;
|
636
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
637
|
+
v = gsl_vector_view_alloc();
|
638
|
+
v->vector.data = e->yerr;
|
639
|
+
v->vector.size = e->dimension;
|
640
|
+
v->vector.stride = 1;
|
641
|
+
v->vector.owner = 0;
|
642
|
+
return Data_Wrap_Struct(cgsl_vector_view_ro, 0, gsl_vector_view_free, v);
|
643
|
+
}
|
644
|
+
|
645
|
+
static VALUE rb_gsl_odeiv_evolve_apply(VALUE obj, VALUE cc, VALUE ss, VALUE sss,
|
646
|
+
VALUE tt, VALUE tt1, VALUE hh, VALUE yy)
|
647
|
+
{
|
648
|
+
gsl_odeiv_evolve *e = NULL;
|
649
|
+
gsl_odeiv_control *c = NULL;
|
650
|
+
gsl_odeiv_step *s = NULL;
|
651
|
+
gsl_odeiv_system *sys = NULL;
|
652
|
+
gsl_vector *y = NULL;
|
653
|
+
double t, h;
|
654
|
+
int status;
|
655
|
+
CHECK_STEP(ss); CHECK_SYSTEM(sss);
|
656
|
+
CHECK_VECTOR(yy);
|
657
|
+
Data_Get_Struct(obj, gsl_odeiv_evolve, e);
|
658
|
+
if (NIL_P(cc)) {
|
659
|
+
c = NULL;
|
660
|
+
} else {
|
661
|
+
CHECK_CONTROL(cc);
|
662
|
+
Data_Get_Struct(cc, gsl_odeiv_control, c);
|
663
|
+
}
|
664
|
+
Data_Get_Struct(ss, gsl_odeiv_step, s);
|
665
|
+
Data_Get_Struct(sss, gsl_odeiv_system, sys);
|
666
|
+
Data_Get_Struct(yy, gsl_vector, y);
|
667
|
+
/* if (TYPE(tt) != T_FLOAT) rb_raise(rb_eTypeError, "argument 4 Float expected");
|
668
|
+
if (TYPE(hh) != T_FLOAT) rb_raise(rb_eTypeError, "argument 6 Float expected");*/
|
669
|
+
t = NUM2DBL(tt);
|
670
|
+
h = NUM2DBL(hh);
|
671
|
+
status = gsl_odeiv_evolve_apply(e, c, s, sys, &t, NUM2DBL(tt1), &h, y->data);
|
672
|
+
/* RFLOAT(tt)->value = t;
|
673
|
+
RFLOAT(hh)->value = h;*/
|
674
|
+
return rb_ary_new3(3, rb_float_new(t), rb_float_new(h), INT2FIX(status));
|
675
|
+
}
|
676
|
+
|
677
|
+
static void rb_gsl_odeiv_solver_free(gsl_odeiv_solver *gde);
|
678
|
+
static void gsl_odeiv_solver_mark(gsl_odeiv_solver *gos);
|
679
|
+
static VALUE rb_gsl_odeiv_solver_new(int argc, VALUE *argv, VALUE klass)
|
680
|
+
{
|
681
|
+
gsl_odeiv_solver *gos = NULL;
|
682
|
+
VALUE epsabs, epsrel, ay, adydt;
|
683
|
+
VALUE dim;
|
684
|
+
if (argc < 4) rb_raise(rb_eArgError, "too few arguments");
|
685
|
+
Check_Type(argv[1], T_ARRAY);
|
686
|
+
CHECK_PROC(argv[2]);
|
687
|
+
if (rb_obj_is_kind_of(argv[3], rb_cProc) || NIL_P(argv[3])) {
|
688
|
+
dim = argv[4];
|
689
|
+
} else {
|
690
|
+
dim = argv[3];
|
691
|
+
}
|
692
|
+
gos = ALLOC(gsl_odeiv_solver);
|
693
|
+
gos->s = make_step(argv[0], dim);
|
694
|
+
// switch (RARRAY(argv[1])->len) {
|
695
|
+
switch (RARRAY_LEN(argv[1])) {
|
696
|
+
case 2:
|
697
|
+
epsabs = rb_ary_entry(argv[1], 0);
|
698
|
+
epsrel = rb_ary_entry(argv[1], 1);
|
699
|
+
gos->c = make_control_y(epsabs, epsrel);
|
700
|
+
break;
|
701
|
+
case 4:
|
702
|
+
epsabs = rb_ary_entry(argv[1], 0);
|
703
|
+
epsrel = rb_ary_entry(argv[1], 1);
|
704
|
+
ay = rb_ary_entry(argv[1], 2);
|
705
|
+
adydt = rb_ary_entry(argv[1], 3);
|
706
|
+
gos->c = make_control_standard(epsabs, epsrel, ay, adydt);
|
707
|
+
break;
|
708
|
+
default:
|
709
|
+
rb_raise(rb_eArgError, "size of the argument 1 must be 2 or 4");
|
710
|
+
break;
|
711
|
+
}
|
712
|
+
gos->sys = make_sys(argc - 2, argv + 2);
|
713
|
+
gos->e = make_evolve(dim);
|
714
|
+
return Data_Wrap_Struct(klass, gsl_odeiv_solver_mark, rb_gsl_odeiv_solver_free, gos);
|
715
|
+
// return Data_Wrap_Struct(klass, 0, rb_gsl_odeiv_solver_free, gos);
|
716
|
+
}
|
717
|
+
|
718
|
+
static void gsl_odeiv_solver_mark(gsl_odeiv_solver *gos)
|
719
|
+
{
|
720
|
+
rb_gc_mark((VALUE) gos->sys->params);
|
721
|
+
}
|
722
|
+
|
723
|
+
static VALUE rb_gsl_odeiv_solver_evolve(VALUE obj)
|
724
|
+
{
|
725
|
+
gsl_odeiv_solver *gos = NULL;
|
726
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
727
|
+
return Data_Wrap_Struct(cgsl_odeiv_evolve, 0, NULL, gos->e);
|
728
|
+
}
|
729
|
+
|
730
|
+
static VALUE rb_gsl_odeiv_solver_set_evolve(VALUE obj, VALUE ee)
|
731
|
+
{
|
732
|
+
gsl_odeiv_solver *gos = NULL;
|
733
|
+
gsl_odeiv_evolve *e = NULL;
|
734
|
+
CHECK_EVOLVE(ee);
|
735
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
736
|
+
Data_Get_Struct(ee, gsl_odeiv_evolve, e);
|
737
|
+
gos->e = e;
|
738
|
+
return obj;
|
739
|
+
}
|
740
|
+
|
741
|
+
static VALUE rb_gsl_odeiv_solver_step(VALUE obj)
|
742
|
+
{
|
743
|
+
gsl_odeiv_solver *gos = NULL;
|
744
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
745
|
+
return Data_Wrap_Struct(cgsl_odeiv_step, 0, NULL,gos->s);
|
746
|
+
}
|
747
|
+
|
748
|
+
static VALUE rb_gsl_odeiv_solver_set_step(VALUE obj, VALUE ss)
|
749
|
+
{
|
750
|
+
gsl_odeiv_solver *gos = NULL;
|
751
|
+
gsl_odeiv_step *s = NULL;
|
752
|
+
CHECK_STEP(ss);
|
753
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
754
|
+
Data_Get_Struct(ss, gsl_odeiv_step, s);
|
755
|
+
gos->s = s;
|
756
|
+
return obj;
|
757
|
+
}
|
758
|
+
|
759
|
+
static VALUE rb_gsl_odeiv_solver_control(VALUE obj)
|
760
|
+
{
|
761
|
+
gsl_odeiv_solver *gos = NULL;
|
762
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
763
|
+
return Data_Wrap_Struct(cgsl_odeiv_control, 0, NULL, gos->c);
|
764
|
+
}
|
765
|
+
|
766
|
+
static VALUE rb_gsl_odeiv_solver_set_control(VALUE obj, VALUE cc)
|
767
|
+
{
|
768
|
+
gsl_odeiv_solver *gos = NULL;
|
769
|
+
gsl_odeiv_control *c = NULL;
|
770
|
+
CHECK_CONTROL(cc);
|
771
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
772
|
+
Data_Get_Struct(cc, gsl_odeiv_control, c);
|
773
|
+
gos->c = c;
|
774
|
+
return obj;
|
775
|
+
}
|
776
|
+
|
777
|
+
static VALUE rb_gsl_odeiv_solver_sys(VALUE obj)
|
778
|
+
{
|
779
|
+
gsl_odeiv_solver *gos = NULL;
|
780
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
781
|
+
return Data_Wrap_Struct(cgsl_odeiv_system, 0, NULL, gos->sys);
|
782
|
+
}
|
783
|
+
|
784
|
+
static VALUE rb_gsl_odeiv_solver_set_sys(VALUE obj, VALUE ss)
|
785
|
+
{
|
786
|
+
gsl_odeiv_solver *gos = NULL;
|
787
|
+
gsl_odeiv_system *sys = NULL;
|
788
|
+
CHECK_SYSTEM(ss);
|
789
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
790
|
+
Data_Get_Struct(ss, gsl_odeiv_system, sys);
|
791
|
+
gos->sys = sys;
|
792
|
+
return obj;
|
793
|
+
}
|
794
|
+
|
795
|
+
static VALUE rb_gsl_odeiv_solver_apply(VALUE obj, VALUE tt, VALUE tt1, VALUE hh,
|
796
|
+
VALUE yy)
|
797
|
+
{
|
798
|
+
gsl_odeiv_solver *gos = NULL;
|
799
|
+
gsl_vector *y = NULL;
|
800
|
+
double t, h;
|
801
|
+
int status;
|
802
|
+
CHECK_VECTOR(yy);
|
803
|
+
Need_Float(tt1);
|
804
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
805
|
+
Data_Get_Struct(yy, gsl_vector, y);
|
806
|
+
/* if (TYPE(tt) != T_FLOAT) rb_raise(rb_eTypeError, "argument 0 Float expected");
|
807
|
+
if (TYPE(hh) != T_FLOAT) rb_raise(rb_eTypeError, "argument 2 Float expected");*/
|
808
|
+
t = NUM2DBL(tt);
|
809
|
+
h = NUM2DBL(hh);
|
810
|
+
status = gsl_odeiv_evolve_apply(gos->e, gos->c, gos->s,
|
811
|
+
gos->sys, &t, NUM2DBL(tt1), &h, y->data);
|
812
|
+
/* RFLOAT(tt)->value = t;
|
813
|
+
RFLOAT(hh)->value = h;
|
814
|
+
return INT2FIX(status);*/
|
815
|
+
return rb_ary_new3(3, rb_float_new(t), rb_float_new(h), INT2FIX(status));
|
816
|
+
}
|
817
|
+
|
818
|
+
static void rb_gsl_odeiv_solver_free(gsl_odeiv_solver *gos)
|
819
|
+
{
|
820
|
+
free((gsl_odeiv_solver *) gos);
|
821
|
+
}
|
822
|
+
|
823
|
+
static VALUE rb_gsl_odeiv_solver_reset(VALUE obj)
|
824
|
+
{
|
825
|
+
gsl_odeiv_solver *gos = NULL;
|
826
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
827
|
+
gsl_odeiv_step_reset(gos->s);
|
828
|
+
gsl_odeiv_evolve_reset(gos->e);
|
829
|
+
return obj;
|
830
|
+
}
|
831
|
+
|
832
|
+
static VALUE rb_gsl_odeiv_solver_dim(VALUE obj)
|
833
|
+
{
|
834
|
+
gsl_odeiv_solver *gos = NULL;
|
835
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
836
|
+
return INT2FIX(gos->sys->dimension);
|
837
|
+
}
|
838
|
+
|
839
|
+
static VALUE rb_gsl_odeiv_solver_set_params(int argc, VALUE *argv, VALUE obj)
|
840
|
+
{
|
841
|
+
gsl_odeiv_solver *gos = NULL;
|
842
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, gos);
|
843
|
+
rb_gsl_odeiv_system_set_params(argc, argv,
|
844
|
+
Data_Wrap_Struct(cgsl_odeiv_system, 0, NULL, gos->sys));
|
845
|
+
return obj;
|
846
|
+
}
|
847
|
+
|
848
|
+
static VALUE rb_gsl_odeiv_solver_params(VALUE obj)
|
849
|
+
{
|
850
|
+
VALUE ary;
|
851
|
+
gsl_odeiv_solver *solver = NULL;
|
852
|
+
Data_Get_Struct(obj, gsl_odeiv_solver, solver);
|
853
|
+
ary = (VALUE) solver->sys->params;
|
854
|
+
return rb_ary_entry(ary, 3);
|
855
|
+
}
|
856
|
+
|
857
|
+
void Init_gsl_odeiv(VALUE module)
|
858
|
+
{
|
859
|
+
VALUE mgsl_odeiv;
|
860
|
+
mgsl_odeiv = rb_define_module_under(module, "Odeiv");
|
861
|
+
rb_define_const(mgsl_odeiv, "HADJ_DEC", INT2FIX(GSL_ODEIV_HADJ_DEC));
|
862
|
+
rb_define_const(mgsl_odeiv, "HADJ_INC", INT2FIX(GSL_ODEIV_HADJ_INC));
|
863
|
+
rb_define_const(mgsl_odeiv, "HADJ_NIL", INT2FIX(GSL_ODEIV_HADJ_NIL));
|
864
|
+
cgsl_odeiv_step = rb_define_class_under(mgsl_odeiv, "Step",
|
865
|
+
cGSL_Object);
|
866
|
+
rb_define_singleton_method(cgsl_odeiv_step, "alloc", rb_gsl_odeiv_step_new, -1);
|
867
|
+
|
868
|
+
/*****/
|
869
|
+
rb_define_const(cgsl_odeiv_step, "RK2", INT2FIX(GSL_ODEIV_STEP_RK2));
|
870
|
+
rb_define_const(cgsl_odeiv_step, "RK4", INT2FIX(GSL_ODEIV_STEP_RK4));
|
871
|
+
rb_define_const(cgsl_odeiv_step, "RKF45", INT2FIX(GSL_ODEIV_STEP_RKF45));
|
872
|
+
rb_define_const(cgsl_odeiv_step, "RKCK", INT2FIX(GSL_ODEIV_STEP_RKCK));
|
873
|
+
rb_define_const(cgsl_odeiv_step, "RK8PD", INT2FIX(GSL_ODEIV_STEP_RK8PD));
|
874
|
+
rb_define_const(cgsl_odeiv_step, "RK2IMP", INT2FIX(GSL_ODEIV_STEP_RK2IMP));
|
875
|
+
rb_define_const(cgsl_odeiv_step, "RK4IMP", INT2FIX(GSL_ODEIV_STEP_RK4IMP));
|
876
|
+
rb_define_const(cgsl_odeiv_step, "BSIMP", INT2FIX(GSL_ODEIV_STEP_BSIMP));
|
877
|
+
rb_define_const(cgsl_odeiv_step, "GEAR1", INT2FIX(GSL_ODEIV_STEP_GEAR1));
|
878
|
+
rb_define_const(cgsl_odeiv_step, "GEAR2", INT2FIX(GSL_ODEIV_STEP_GEAR2));
|
879
|
+
rb_define_const(cgsl_odeiv_step, "RK2SIMP", INT2FIX(GSL_ODEIV_STEP_RK2SIMP));
|
880
|
+
/*****/
|
881
|
+
|
882
|
+
rb_define_method(cgsl_odeiv_step, "reset", rb_gsl_odeiv_step_reset, 0);
|
883
|
+
rb_define_method(cgsl_odeiv_step, "name", rb_gsl_odeiv_step_name, 0);
|
884
|
+
rb_define_method(cgsl_odeiv_step, "order", rb_gsl_odeiv_step_order, 0);
|
885
|
+
rb_define_method(cgsl_odeiv_step, "dimension", rb_gsl_odeiv_step_dimension, 0);
|
886
|
+
rb_define_alias(cgsl_odeiv_step, "dim", "dimension");
|
887
|
+
rb_define_method(cgsl_odeiv_step, "apply", rb_gsl_odeiv_step_apply, -1);
|
888
|
+
rb_define_method(cgsl_odeiv_step, "info", rb_gsl_odeiv_step_info, 0);
|
889
|
+
|
890
|
+
/****/
|
891
|
+
|
892
|
+
cgsl_odeiv_control = rb_define_class_under(mgsl_odeiv, "Control",
|
893
|
+
cGSL_Object);
|
894
|
+
rb_define_singleton_method(cgsl_odeiv_control, "alloc", rb_gsl_odeiv_control_standard_new, 4);
|
895
|
+
rb_define_singleton_method(cgsl_odeiv_control, "standard_alloc", rb_gsl_odeiv_control_standard_new, 4);
|
896
|
+
rb_define_singleton_method(cgsl_odeiv_control, "y_new", rb_gsl_odeiv_control_y_new, 2);
|
897
|
+
rb_define_singleton_method(cgsl_odeiv_control, "yp_new", rb_gsl_odeiv_control_yp_new, 2);
|
898
|
+
#ifdef GSL_1_2_LATER
|
899
|
+
rb_define_singleton_method(cgsl_odeiv_control, "scaled_alloc", rb_gsl_odeiv_control_scaled_new, 5);
|
900
|
+
#endif
|
901
|
+
|
902
|
+
rb_define_method(cgsl_odeiv_control, "init", rb_gsl_odeiv_control_init, 4);
|
903
|
+
rb_define_method(cgsl_odeiv_control, "name", rb_gsl_odeiv_control_name, 0);
|
904
|
+
rb_define_method(cgsl_odeiv_control, "hadjust", rb_gsl_odeiv_control_hadjust, 5);
|
905
|
+
|
906
|
+
/****/
|
907
|
+
cgsl_odeiv_evolve = rb_define_class_under(mgsl_odeiv, "Evolve",
|
908
|
+
cGSL_Object);
|
909
|
+
rb_define_singleton_method(cgsl_odeiv_evolve, "alloc", rb_gsl_odeiv_evolve_new, 1);
|
910
|
+
|
911
|
+
rb_define_method(cgsl_odeiv_evolve, "reset", rb_gsl_odeiv_evolve_reset, 0);
|
912
|
+
rb_define_method(cgsl_odeiv_evolve, "apply", rb_gsl_odeiv_evolve_apply, 7);
|
913
|
+
rb_define_method(cgsl_odeiv_evolve, "count", rb_gsl_odeiv_evolve_count, 0);
|
914
|
+
rb_define_method(cgsl_odeiv_evolve, "dimension", rb_gsl_odeiv_evolve_dimension, 0);
|
915
|
+
rb_define_method(cgsl_odeiv_evolve, "failed_steps", rb_gsl_odeiv_evolve_failed_steps, 0);
|
916
|
+
rb_define_method(cgsl_odeiv_evolve, "last_step", rb_gsl_odeiv_evolve_last_step, 0);
|
917
|
+
rb_define_method(cgsl_odeiv_evolve, "y0", rb_gsl_odeiv_evolve_y0, 0);
|
918
|
+
rb_define_method(cgsl_odeiv_evolve, "yerr", rb_gsl_odeiv_evolve_yerr, 0);
|
919
|
+
/*****/
|
920
|
+
|
921
|
+
cgsl_odeiv_system = rb_define_class_under(mgsl_odeiv, "System",
|
922
|
+
cGSL_Object);
|
923
|
+
rb_define_singleton_method(cgsl_odeiv_system, "alloc", rb_gsl_odeiv_system_new, -1);
|
924
|
+
rb_define_method(cgsl_odeiv_system, "set", rb_gsl_odeiv_system_set, -1);
|
925
|
+
rb_define_method(cgsl_odeiv_system, "set_params",
|
926
|
+
rb_gsl_odeiv_system_set_params, -1);
|
927
|
+
rb_define_method(cgsl_odeiv_system, "params",
|
928
|
+
rb_gsl_odeiv_system_params, 0);
|
929
|
+
rb_define_method(cgsl_odeiv_system, "function",
|
930
|
+
rb_gsl_odeiv_system_function, 0);
|
931
|
+
rb_define_alias(cgsl_odeiv_system, "func", "function");
|
932
|
+
rb_define_method(cgsl_odeiv_system, "jacobian",
|
933
|
+
rb_gsl_odeiv_system_jacobian, 0);
|
934
|
+
rb_define_alias(cgsl_odeiv_system, "jac", "jacobian");
|
935
|
+
rb_define_method(cgsl_odeiv_system, "dimension", rb_gsl_odeiv_system_dimension, 0);
|
936
|
+
rb_define_alias(cgsl_odeiv_system, "dim", "dimension");
|
937
|
+
|
938
|
+
/*****/
|
939
|
+
cgsl_odeiv_solver = rb_define_class_under(mgsl_odeiv, "Solver", cGSL_Object);
|
940
|
+
rb_define_singleton_method(cgsl_odeiv_solver, "alloc", rb_gsl_odeiv_solver_new, -1);
|
941
|
+
rb_define_method(cgsl_odeiv_solver, "step", rb_gsl_odeiv_solver_step, 0);
|
942
|
+
rb_define_method(cgsl_odeiv_solver, "control", rb_gsl_odeiv_solver_control, 0);
|
943
|
+
rb_define_method(cgsl_odeiv_solver, "evolve", rb_gsl_odeiv_solver_evolve, 0);
|
944
|
+
rb_define_method(cgsl_odeiv_solver, "sys", rb_gsl_odeiv_solver_sys, 0);
|
945
|
+
rb_define_method(cgsl_odeiv_solver, "apply", rb_gsl_odeiv_solver_apply, 4);
|
946
|
+
|
947
|
+
rb_define_method(cgsl_odeiv_solver, "set_evolve", rb_gsl_odeiv_solver_set_evolve, 1);
|
948
|
+
rb_define_method(cgsl_odeiv_solver, "set_step", rb_gsl_odeiv_solver_set_step, 1);
|
949
|
+
rb_define_method(cgsl_odeiv_solver, "set_control", rb_gsl_odeiv_solver_set_control, 1);
|
950
|
+
rb_define_method(cgsl_odeiv_solver, "set_system", rb_gsl_odeiv_solver_set_sys, 1);
|
951
|
+
rb_define_method(cgsl_odeiv_solver, "reset", rb_gsl_odeiv_solver_reset, 0);
|
952
|
+
rb_define_method(cgsl_odeiv_solver, "dim", rb_gsl_odeiv_solver_dim, 0);
|
953
|
+
rb_define_alias(cgsl_odeiv_solver, "dimension", "dim");
|
954
|
+
rb_define_method(cgsl_odeiv_solver, "set_params", rb_gsl_odeiv_solver_set_params, -1);
|
955
|
+
rb_define_method(cgsl_odeiv_solver, "params", rb_gsl_odeiv_solver_params, 0);
|
956
|
+
}
|
957
|
+
|
958
|
+
#undef CHECK_SOLVER
|
959
|
+
#undef CHECK_EVOLVE
|
960
|
+
#undef CHECK_CONTROL
|
961
|
+
#undef CHECK_STEP
|
962
|
+
#undef CHECK_SYSTEM
|