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
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
include GSL::CONST::MKSA
|
5
|
+
puts("In MKSA unit")
|
6
|
+
|
7
|
+
c = SPEED_OF_LIGHT;
|
8
|
+
au = ASTRONOMICAL_UNIT;
|
9
|
+
minutes = MINUTE;
|
10
|
+
|
11
|
+
# distance stored in meters
|
12
|
+
r_earth = 1.00 * au;
|
13
|
+
r_mars = 1.52 * au;
|
14
|
+
|
15
|
+
t_min = (r_mars - r_earth) / c;
|
16
|
+
t_max = (r_mars + r_earth) / c;
|
17
|
+
|
18
|
+
printf("light travel time from Earth to Mars:\n");
|
19
|
+
printf("c = %e [m/s]\n", c)
|
20
|
+
printf("AU = %e [m]\n", au)
|
21
|
+
printf("minutes = %e [s]\n", minutes)
|
22
|
+
printf("minimum = %.1f minutes\n", t_min / minutes);
|
23
|
+
printf("maximum = %.1f minutes\n\n", t_max / minutes);
|
24
|
+
|
25
|
+
|
26
|
+
include GSL::CONST::CGSM
|
27
|
+
puts("In CGSM unit")
|
28
|
+
|
29
|
+
c = SPEED_OF_LIGHT;
|
30
|
+
au = ASTRONOMICAL_UNIT;
|
31
|
+
minutes = MINUTE;
|
32
|
+
|
33
|
+
# distance stored in meters
|
34
|
+
r_earth = 1.00 * au;
|
35
|
+
r_mars = 1.52 * au;
|
36
|
+
|
37
|
+
t_min = (r_mars - r_earth) / c;
|
38
|
+
t_max = (r_mars + r_earth) / c;
|
39
|
+
|
40
|
+
printf("light travel time from Earth to Mars:\n");
|
41
|
+
printf("c = %e [cm/s]\n", c)
|
42
|
+
printf("AU = %e [cm]\n", au)
|
43
|
+
printf("minutes = %e [s]\n", minutes)
|
44
|
+
printf("minimum = %.1f minutes\n", t_min / minutes);
|
45
|
+
printf("maximum = %.1f minutes\n", t_max / minutes);
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
f = GSL::Function.alloc { |x| Math::exp(-x) }
|
5
|
+
|
6
|
+
puts("f(x) = exp(-x)");
|
7
|
+
puts("Derivative: -exp(-x)")
|
8
|
+
|
9
|
+
h = 1e-8
|
10
|
+
x = GSL::Vector.linspace(0, 5, 50)
|
11
|
+
y = f.eval(x)
|
12
|
+
dy, derr = f.deriv_central(x, h)
|
13
|
+
GSL::graph(x, y, dy, "-T X -C -g 3 -X x -L 'f(x) = exp(-x), and its derivative'")
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
f = GSL::Function.alloc { |x|
|
5
|
+
GSL::pow(x, 1.5)
|
6
|
+
}
|
7
|
+
|
8
|
+
printf("f(x) = x^(3/2)\n");
|
9
|
+
|
10
|
+
x = 2.0
|
11
|
+
h = 1e-8
|
12
|
+
result, abserr, status = f.deriv_central(x, h)
|
13
|
+
printf("x = 2.0\n");
|
14
|
+
printf("f'(x) = %.10f +/- %.10f\n", result, abserr);
|
15
|
+
printf("exact = %.10f\n\n", 1.5 * Math::sqrt(2.0));
|
16
|
+
|
17
|
+
x = 0.0
|
18
|
+
result, abserr, status = GSL::Deriv.forward(f, x, h)
|
19
|
+
printf("x = 0.0\n");
|
20
|
+
printf("f'(x) = %.10f +/- %.10f\n", result, abserr);
|
21
|
+
printf("exact = %.10f\n", 0.0);
|
22
|
+
|
23
|
+
f2 = GSL::Function.alloc { |x, a| Math::exp(a*x) }
|
24
|
+
|
25
|
+
f2.set_params(2)
|
26
|
+
p f2.deriv_central(0)
|
27
|
+
|
28
|
+
f2.set_params(3)
|
29
|
+
p f2.deriv_central(0)
|
30
|
+
|
31
|
+
f2.set_params(123)
|
32
|
+
p f2.deriv_central(0, h)
|
33
|
+
|
34
|
+
p GSL::Deriv.central(f2, 0)
|
35
|
+
p GSL::Deriv.forward(f2, 0)
|
36
|
+
p GSL::Deriv.backward(f2, 0)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
f = GSL::Function.alloc { |x|
|
5
|
+
GSL::pow(x, 1.5)
|
6
|
+
}
|
7
|
+
|
8
|
+
printf("f(x) = x^(3/2)\n");
|
9
|
+
|
10
|
+
x = 2.0
|
11
|
+
result, abserr,status = f.diff_central(x)
|
12
|
+
printf("x = 2.0\n");
|
13
|
+
printf("f'(x) = %.10f +/- %.5f\n", result, abserr);
|
14
|
+
printf("exact = %.10f\n\n", 1.5 * Math::sqrt(2.0));
|
15
|
+
|
16
|
+
x = 0.0
|
17
|
+
result, abserr, status = f.diff_forward(x)
|
18
|
+
printf("x = 0.0\n");
|
19
|
+
printf("f'(x) = %.10f +/- %.5f\n", result, abserr);
|
20
|
+
printf("exact = %.10f\n", 0.0);
|
21
|
+
|
22
|
+
f2 = GSL::Function.alloc { |x, a| Math::exp(a*x) }
|
23
|
+
|
24
|
+
f2.set_params(2)
|
25
|
+
p f2.diff_central(0)
|
26
|
+
|
27
|
+
f2.set_params(3)
|
28
|
+
p f2.diff_central(0)
|
29
|
+
|
30
|
+
f2.set_params(123)
|
31
|
+
p f2.diff_central(0)
|
32
|
+
|
33
|
+
p GSL::Diff.central(f2, 0)
|
34
|
+
p GSL::Diff.forward(f2, 0)
|
35
|
+
p GSL::Diff.backward(f2, 0)
|
data/examples/dht.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
include Math
|
4
|
+
|
5
|
+
# Function to be expanded
|
6
|
+
G = GSL::Function.alloc { |x| exp(-x*x) }
|
7
|
+
#G = Function.alloc { |x| sin(-x*x) }
|
8
|
+
|
9
|
+
# Sampling points
|
10
|
+
XMIN = 0.0
|
11
|
+
XMAX = 3.0
|
12
|
+
SIZE = 20
|
13
|
+
|
14
|
+
x = GSL::Vector.linspace(XMIN, XMAX, SIZE)
|
15
|
+
sample = G.eval(x)
|
16
|
+
|
17
|
+
# Discrete Hankel transform with the Bessel function J0
|
18
|
+
dht = GSL::Dht.alloc(SIZE, 0, XMAX)
|
19
|
+
g = dht.apply(sample)
|
20
|
+
|
21
|
+
num = dht.num
|
22
|
+
den = dht.den
|
23
|
+
coef = dht.coef
|
24
|
+
|
25
|
+
# Reconstruction
|
26
|
+
y = GSL::Vector[SIZE]
|
27
|
+
for n in 0...SIZE do
|
28
|
+
val = 0.0
|
29
|
+
for m in 0...SIZE do
|
30
|
+
a = GSL::Sf::bessel_J0(dht.sample(n, m))
|
31
|
+
val += (2.0/XMAX/XMAX)*a/den[m]*g[m]
|
32
|
+
# val += (2.0/XMAX/XMAX)*num[n][m]/den[m]*g[m]
|
33
|
+
# val += coef[n][m]*g[m]
|
34
|
+
end
|
35
|
+
y[n] = val
|
36
|
+
end
|
37
|
+
|
38
|
+
x0 = GSL::Vector.linspace(XMIN, XMAX, 100)
|
39
|
+
y0 = G.eval(x0)
|
40
|
+
|
41
|
+
GSL::graph([x0, y0], [x, sample], [x, y], "-T X -C -g 3 -X t -Y 'f(t)' --toggle-rotate-y-label -L 'Red: f(t), Green: sample, Blue: DHT of size #{SIZE}'")
|
42
|
+
|
data/examples/dirac.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
include GSL::Dirac
|
4
|
+
|
5
|
+
I = GSL::Complex[0, 1]
|
6
|
+
|
7
|
+
p Pauli1
|
8
|
+
p Pauli2
|
9
|
+
p Pauli3
|
10
|
+
|
11
|
+
p (Pauli1*Pauli2 - Pauli2*Pauli1)/I/2
|
12
|
+
|
13
|
+
p Dirac.anticommute(Pauli1, Pauli1)
|
14
|
+
p Dirac.anticommute(Pauli1, Pauli2)
|
15
|
+
|
16
|
+
#p Eye2
|
17
|
+
#p Eye4
|
18
|
+
|
19
|
+
p Beta
|
20
|
+
|
21
|
+
p Alpha1
|
22
|
+
p Alpha2
|
23
|
+
p Alpha3
|
24
|
+
|
25
|
+
p Alpha1*Alpha1
|
26
|
+
p Alpha2*Alpha2
|
27
|
+
p Alpha3*Alpha3
|
28
|
+
|
29
|
+
p GSL::Dirac.anticommute(Alpha1, Alpha1)
|
30
|
+
p GSL::Dirac.anticommute(Alpha1, Alpha2)
|
31
|
+
|
32
|
+
p GSL::Dirac.anticommute(Gamma0, Gamma0)
|
33
|
+
p GSL::Dirac.anticommute(Gamma1, Gamma1)
|
34
|
+
p GSL::Dirac.anticommute(Gamma2, Gamma2)
|
35
|
+
p GSL::Dirac.anticommute(Gamma3, Gamma3)
|
36
|
+
p GSL::Dirac.anticommute(Gamma3, Gamma0)
|
37
|
+
|
38
|
+
p IEye4*Gamma0*Gamma1*Gamma2*Gamma3
|
39
|
+
|
40
|
+
p Pauli2
|
41
|
+
p Pauli2.conjugate
|
42
|
+
p Pauli2
|
43
|
+
p Pauli3
|
44
|
+
p Pauli3.dagger
|
45
|
+
|
46
|
+
p Lambda1
|
47
|
+
p Lambda2
|
48
|
+
p Lambda3
|
49
|
+
p Lambda4
|
50
|
+
p Lambda5
|
51
|
+
p Lambda6
|
52
|
+
p Lambda7
|
53
|
+
p Lambda8
|
54
|
+
|
55
|
+
|
56
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
m = GSL::Matrix[[1.0, 1/2.0, 1/3.0, 1/4.0], [1/2.0, 1/3.0, 1/4.0, 1/5.0],
|
5
|
+
[1/3.0, 1/4.0, 1/5.0, 1/6.0], [1/4.0, 1/5.0, 1/6.0, 1/7.0]]
|
6
|
+
|
7
|
+
eigval = m.eigen_symm
|
8
|
+
p eigval
|
9
|
+
|
10
|
+
eigval, eigvec = m.eigen_symmv
|
11
|
+
|
12
|
+
p eigval == GSL::Eigen.symm(m)
|
13
|
+
val, vec = GSL::Eigen.symmv(m)
|
14
|
+
p vec
|
15
|
+
|
16
|
+
i = 0
|
17
|
+
vec.each_col do |v|
|
18
|
+
a = (m*v)/v
|
19
|
+
if a != val[i]
|
20
|
+
puts("error")
|
21
|
+
end
|
22
|
+
i += 1
|
23
|
+
end
|
24
|
+
|
25
|
+
# Diagonalization
|
26
|
+
b = eigvec.inv*m*eigvec
|
27
|
+
b.clean!(1e-10)
|
28
|
+
p b
|
29
|
+
d = b.diagonal
|
30
|
+
p d == eigval
|
31
|
+
|
32
|
+
prod = eigval.prod
|
33
|
+
p GSL.equal?(prod, m.det, 1e-10)
|
34
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
include GSL::Eigen
|
5
|
+
|
6
|
+
m = GSL::Matrix::Complex.alloc(2, 2)
|
7
|
+
m.set(0, 1, [0, -1])
|
8
|
+
m.set(1, 0, [0, 1])
|
9
|
+
p m
|
10
|
+
|
11
|
+
val, vec = m.eigen_hermv
|
12
|
+
p val
|
13
|
+
p vec.unpack
|
14
|
+
|
15
|
+
m2 = GSL::Matrix.alloc([1, 0, 0], [0, 0, 1], [0, 1, 0])
|
16
|
+
val, vec = m2.eigen_symmv
|
17
|
+
p val
|
18
|
+
p vec.unpack
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
m = GSL::Matrix[[1, 2], [3, 4]]
|
5
|
+
|
6
|
+
w = GSL::Eigen::Nonsymm::Workspace.alloc(2)
|
7
|
+
v = GSL::Vector::Complex.alloc(2)
|
8
|
+
|
9
|
+
#w.params(0, 1)
|
10
|
+
|
11
|
+
#p GSL::Eigen.nonsymm(m)
|
12
|
+
#p GSL::Eigen.nonsymm(m, v, w)
|
13
|
+
|
14
|
+
p m.eigen_nonsymm
|
15
|
+
#p m.eigen_nonsymm(v, w)
|
16
|
+
|
17
|
+
#p m.eigen_nonsymm_Z
|
18
|
+
#p m
|
19
|
+
|
20
|
+
|
21
|
+
=begin
|
22
|
+
Octave result:
|
23
|
+
|
24
|
+
octave:1> m = [1 2; 3 4]
|
25
|
+
m =
|
26
|
+
|
27
|
+
1 2
|
28
|
+
3 4
|
29
|
+
|
30
|
+
octave:2> eig(m)
|
31
|
+
ans =
|
32
|
+
|
33
|
+
-0.37228
|
34
|
+
5.37228
|
35
|
+
|
36
|
+
|
37
|
+
=end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require("gsl")
|
3
|
+
|
4
|
+
m = GSL::Matrix[[1, 2, 3], [4, 5, 0], [6, 0, 0]]
|
5
|
+
evec, eval = m.eigen_nonsymmv
|
6
|
+
p evec
|
7
|
+
p eval
|
8
|
+
|
9
|
+
m = GSL::Matrix.vandermonde([-1, -2, 3, 4])
|
10
|
+
w = GSL::Eigen::Nonsymmv.alloc(4)
|
11
|
+
eval, evec = GSL::Eigen::nonsymmv(m, w)
|
12
|
+
p eval
|
13
|
+
p evec
|
14
|
+
|
15
|
+
=begin
|
16
|
+
This can be compared with the corresponding output from GNU OCTAVE,
|
17
|
+
|
18
|
+
octave> [v,d] = eig(vander([-1 -2 3 4]));
|
19
|
+
octave> diag(d)
|
20
|
+
ans =
|
21
|
+
|
22
|
+
-6.4139 + 0.0000i
|
23
|
+
5.5456 + 3.0854i
|
24
|
+
5.5456 - 3.0854i
|
25
|
+
2.3228 + 0.0000i
|
26
|
+
|
27
|
+
octave> v
|
28
|
+
v =
|
29
|
+
|
30
|
+
Columns 1 through 3:
|
31
|
+
|
32
|
+
-0.09988 + 0.00000i -0.04350 - 0.00755i -0.04350 + 0.00755i
|
33
|
+
-0.11125 + 0.00000i 0.06399 - 0.14224i 0.06399 + 0.14224i
|
34
|
+
0.29250 + 0.00000i -0.51518 + 0.04142i -0.51518 - 0.04142i
|
35
|
+
0.94451 + 0.00000i -0.84059 + 0.00000i -0.84059 - 0.00000i
|
36
|
+
|
37
|
+
Column 4:
|
38
|
+
|
39
|
+
-0.14493 + 0.00000i
|
40
|
+
0.35660 + 0.00000i
|
41
|
+
0.91937 + 0.00000i
|
42
|
+
0.08118 + 0.00000i
|
43
|
+
=end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
set multiplot
|
2
|
+
set size 0.5, 0.5
|
3
|
+
set grid
|
4
|
+
set key box
|
5
|
+
set xrange [-5.5:5.5]
|
6
|
+
|
7
|
+
# Hermite Polynomials
|
8
|
+
H0(x) = 1
|
9
|
+
H1(x) = 2*x
|
10
|
+
H2(x) = 4*x*x-2
|
11
|
+
H10(x) = -30240 + x*(0 + x*(302400 + x*(0 + x*(-403200 + x*(0 + x*(161280 + x*(0 + x*(-23040 + x*(0 + x*1024)))))))))
|
12
|
+
|
13
|
+
# Normalization constant
|
14
|
+
coef(n) = sqrt(1.0/2**n/gamma(n+1)/sqrt(pi))
|
15
|
+
|
16
|
+
psi0(x) = coef(0)*exp(-x*x/2)*H0(x)
|
17
|
+
psi1(x) = coef(1)*exp(-x*x/2)*H1(x)
|
18
|
+
psi2(x) = coef(2)*exp(-x*x/2)*H2(x)
|
19
|
+
psi10(x) = coef(10)*exp(-x*x/2)*H10(x)
|
20
|
+
|
21
|
+
set ylabel 'psi(x)'
|
22
|
+
|
23
|
+
set pointsize 1
|
24
|
+
|
25
|
+
set origin 0, 0.5
|
26
|
+
plot psi0(x) title 'Exact: n = 0', "qhoscillator.dat" u 1:2 pt 7 title 'Numerical'
|
27
|
+
|
28
|
+
set origin 0.5, 0.5
|
29
|
+
plot psi1(x) title 'Exact: n = 1', "qhoscillator.dat" u 1:3 pt 7 title 'Numerical'
|
30
|
+
|
31
|
+
set origin 0, 0
|
32
|
+
plot psi2(x) title 'Exact: n = 2', "qhoscillator.dat" u 1:4 pt 7title 'Numerical'
|
33
|
+
|
34
|
+
set origin 0.5, 0
|
35
|
+
plot psi10(x) title 'Exact: n = 10', "qhoscillator.dat" u 1:5 pt 7 title 'Numerical'
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Harmonic oscillator in quantum mechanics
|
3
|
+
#
|
4
|
+
# This example is taken from "eigen1.cpp"
|
5
|
+
# in "Numerische Physik" p214-216 (Springer).
|
6
|
+
#
|
7
|
+
# Reference:
|
8
|
+
# "Numerische Physik", by Harald Wiedemann, Springer (2004)
|
9
|
+
# ISBN: 3-540-40774-X
|
10
|
+
# http://www.springeronline.com/sgw/cda/frontpage/0,10735,1-102-22-22345455-0,00.html
|
11
|
+
require("gsl")
|
12
|
+
|
13
|
+
STDERR.puts("Harmonic oscillator in quantum mechanics:")
|
14
|
+
|
15
|
+
# Values used in the book:
|
16
|
+
#NMAX = 512
|
17
|
+
#dx = 0.02
|
18
|
+
|
19
|
+
# These are much faster:
|
20
|
+
NMAX = 64
|
21
|
+
dx = 0.16
|
22
|
+
|
23
|
+
# Potential
|
24
|
+
V = GSL::Vector[NMAX]
|
25
|
+
for n in 0...NMAX do
|
26
|
+
x = (n - NMAX/2)*dx
|
27
|
+
V[n] = 0.5*x*x
|
28
|
+
end
|
29
|
+
|
30
|
+
# Hamiltonian
|
31
|
+
H = GSL::Matrix.calloc(NMAX, NMAX)
|
32
|
+
H.set_diagonal(1.0/dx/dx + V)
|
33
|
+
tmp = -0.5/dx/dx
|
34
|
+
for n1 in 1...NMAX do
|
35
|
+
H[n1-1,n1] = tmp
|
36
|
+
H[n1,n1-1] = tmp
|
37
|
+
end
|
38
|
+
for n1 in 0...(NMAX-1) do
|
39
|
+
H[n1+1,n1] = tmp
|
40
|
+
H[n1,n1+1] = tmp
|
41
|
+
end
|
42
|
+
|
43
|
+
# Calculate eigen values and eigen vectors
|
44
|
+
STDERR.print(" Solving the eigen system of #{NMAX}X#{NMAX} dimensions...")
|
45
|
+
STDERR.flush
|
46
|
+
eval, evec = H.eigen_symmv
|
47
|
+
GSL::Eigen.symmv_sort(eval, evec, GSL::Eigen::SORT_VAL_ASC)
|
48
|
+
STDERR.puts("OK")
|
49
|
+
STDERR.flush
|
50
|
+
|
51
|
+
x2 = GSL::Vector[NMAX]
|
52
|
+
for n1 in 0...NMAX do
|
53
|
+
x2[n1] = 0
|
54
|
+
for n2 in 0...NMAX do
|
55
|
+
x = (n2 - NMAX/2)*dx
|
56
|
+
x2[n1] += GSL::pow_2(evec[n2,n1]*x)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Energy eigen values, see p217 "Tabelle 5.1"
|
61
|
+
# The differences with Tabelle 5.1 are from NMAX and dx.
|
62
|
+
# If we use NMAX=512 and dx=0.02, we obtain the same results (but much slower).
|
63
|
+
STDERR.puts(" Eigen values:")
|
64
|
+
STDERR.printf(" %2s Exact %5s %10s | %2s Exact %5s %10s\n",
|
65
|
+
"n", "E", "err\(\%\)", "n", "E", "err\(\%\)")
|
66
|
+
STDERR.print(" -----------------------------------------------------\n")
|
67
|
+
for n1 in 0..6 do
|
68
|
+
exact1 = n1 + 0.5
|
69
|
+
exact2 = n1 + 7 + 0.5
|
70
|
+
STDERR.printf(" %2d %4.1f %8.5f %+7.5f | %2d %4.1f %8.5f %+7.5f\n",
|
71
|
+
n1, exact1, eval[n1], (exact1 - eval[n1])/exact1*100,
|
72
|
+
n1+7, exact2, eval[n1+7], (exact2-eval[n1+7])/exact2*100)
|
73
|
+
end
|
74
|
+
STDERR.flush
|
75
|
+
|
76
|
+
# Eigen vectors of n = 0, 1, 2, 10. See p217 "Abb 5.3"
|
77
|
+
c = Math::sqrt(1.0/dx)
|
78
|
+
vec0 = evec.col(0).scale(c)
|
79
|
+
vec1 = evec.col(1).scale(c)
|
80
|
+
vec2 = evec.col(2).scale(c)
|
81
|
+
vec10 = evec.col(10).scale(c)
|
82
|
+
File.open("qhoscillator.dat", "w") do |fp|
|
83
|
+
for i in 0...NMAX do
|
84
|
+
x = (i - NMAX/2)*dx
|
85
|
+
fp.printf("%e %e %e %e %e\n", x, -vec0[i], vec1[i], -vec2[i], -vec10[i])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
system("gnuplot -persist qhoscillator.gp")
|
89
|
+
File.delete("qhoscillator.dat")
|
90
|
+
|