rb-gsl 1.16.0.4 → 1.16.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +12 -0
- data/.travis.yml +24 -0
- data/AUTHORS +6 -0
- data/COPYING +341 -339
- data/ChangeLog +608 -587
- data/Gemfile +4 -0
- data/README.md +77 -0
- data/Rakefile +14 -33
- data/THANKS +1 -1
- data/examples/blas/blas.rb +1 -1
- data/examples/bspline.rb +3 -3
- data/examples/complex/functions.rb +4 -4
- data/examples/complex/mul.rb +1 -1
- data/examples/const/physconst.rb +4 -4
- data/examples/const/travel.rb +4 -4
- data/examples/eigen/nonsymmv.rb +1 -1
- data/examples/eigen/qhoscillator.rb +3 -3
- data/examples/fft/radix2.rb +1 -1
- data/examples/fft/real-halfcomplex.rb +3 -3
- data/examples/fft/real-halfcomplex2.rb +3 -3
- data/examples/fit/expfit.rb +1 -1
- data/examples/fit/multifit.rb +1 -1
- data/examples/fit/ndlinear.rb +44 -44
- data/examples/fit/nonlinearfit.rb +1 -1
- data/examples/fit/wlinear.rb +3 -3
- data/examples/function/function.rb +1 -1
- data/examples/function/min.rb +1 -1
- data/examples/function/synchrotron.rb +2 -2
- data/examples/gallery/koch.rb +1 -1
- data/examples/histogram/cauchy.rb +2 -2
- data/examples/histogram/exponential.rb +1 -1
- data/examples/histogram/histo3d.rb +1 -1
- data/examples/histogram/histogram-pdf.rb +2 -2
- data/examples/histogram/xexp.rb +1 -1
- data/examples/integration/ahmed.rb +2 -2
- data/examples/integration/cosmology.rb +7 -7
- data/examples/integration/friedmann.rb +4 -4
- data/examples/integration/qng.rb +1 -1
- data/examples/interp/demo.rb +2 -2
- data/examples/linalg/LQ_solve.rb +1 -1
- data/examples/linalg/LU.rb +1 -1
- data/examples/linalg/LU2.rb +1 -1
- data/examples/linalg/LU_narray.rb +1 -1
- data/examples/linalg/PTLQ.rb +1 -1
- data/examples/linalg/QRPT.rb +1 -1
- data/examples/linalg/chol.rb +1 -1
- data/examples/linalg/chol_narray.rb +1 -1
- data/examples/linalg/complex.rb +1 -1
- data/examples/math/elementary.rb +1 -1
- data/examples/math/functions.rb +1 -1
- data/examples/math/inf_nan.rb +1 -1
- data/examples/math/minmax.rb +1 -1
- data/examples/math/power.rb +1 -1
- data/examples/math/test.rb +1 -1
- data/examples/min.rb +1 -1
- data/examples/multimin/bundle.rb +1 -1
- data/examples/multimin/cqp.rb +17 -17
- data/examples/multiroot/fsolver3.rb +1 -1
- data/examples/odeiv/binarysystem.rb +12 -12
- data/examples/odeiv/demo.rb +3 -3
- data/examples/odeiv/frei1.rb +7 -7
- data/examples/odeiv/frei2.rb +4 -4
- data/examples/odeiv/oscillator.rb +1 -1
- data/examples/odeiv/sedov.rb +3 -3
- data/examples/odeiv/whitedwarf.rb +11 -11
- data/examples/permutation/ex1.rb +2 -2
- data/examples/permutation/permutation.rb +1 -1
- data/examples/poly/demo.rb +1 -1
- data/examples/random/diffusion.rb +1 -1
- data/examples/random/generator.rb +2 -2
- data/examples/random/randomwalk.rb +3 -3
- data/examples/random/rng.rb +1 -1
- data/examples/roots/bisection.rb +1 -1
- data/examples/roots/brent.rb +1 -1
- data/examples/roots/demo.rb +1 -1
- data/examples/roots/newton.rb +2 -2
- data/examples/roots/recombination.gp +0 -1
- data/examples/sf/hyperg.rb +1 -1
- data/examples/sf/sphbessel.rb +1 -1
- data/examples/sort/sort.rb +1 -1
- data/examples/tamu_anova.rb +4 -4
- data/examples/vector/add.rb +1 -1
- data/examples/vector/decimate.rb +1 -1
- data/examples/vector/gnuplot.rb +8 -8
- data/examples/vector/vector.rb +2 -2
- data/examples/wavelet/wavelet1.rb +1 -1
- data/ext/{gsl → gsl_native}/alf.c +9 -9
- data/ext/{gsl → gsl_native}/array.c +64 -151
- data/ext/{gsl → gsl_native}/array_complex.c +61 -63
- data/ext/{gsl → gsl_native}/blas.c +0 -0
- data/ext/{gsl → gsl_native}/blas1.c +32 -32
- data/ext/{gsl → gsl_native}/blas2.c +54 -58
- data/ext/{gsl → gsl_native}/blas3.c +54 -54
- data/ext/{gsl → gsl_native}/block.c +3 -6
- data/ext/{gsl/block_source.c → gsl_native/block_source.h} +109 -111
- data/ext/gsl_native/bspline.c +122 -0
- data/ext/{gsl → gsl_native}/bundle.c +0 -0
- data/ext/{gsl → gsl_native}/cdf.c +76 -88
- data/ext/{gsl → gsl_native}/cheb.c +74 -85
- data/ext/{gsl → gsl_native}/combination.c +9 -16
- data/ext/{gsl → gsl_native}/common.c +7 -37
- data/ext/{gsl → gsl_native}/complex.c +113 -115
- data/ext/gsl_native/const.c +331 -0
- data/ext/{gsl → gsl_native}/const_additional.c +12 -33
- data/ext/gsl_native/cqp.c +283 -0
- data/ext/{gsl → gsl_native}/deriv.c +22 -30
- data/ext/{gsl → gsl_native}/dht.c +20 -28
- data/ext/{gsl → gsl_native}/diff.c +23 -25
- data/ext/{gsl → gsl_native}/dirac.c +44 -45
- data/ext/{gsl → gsl_native}/eigen.c +1031 -1082
- data/ext/{gsl → gsl_native}/error.c +13 -13
- data/ext/{gsl → gsl_native}/extconf.rb +5 -13
- data/ext/{gsl → gsl_native}/fft.c +192 -198
- data/ext/{gsl → gsl_native}/fit.c +16 -16
- data/ext/gsl_native/fresnel.c +312 -0
- data/ext/{gsl → gsl_native}/function.c +29 -35
- data/ext/{gsl → gsl_native}/geometry.c +15 -15
- data/ext/{gsl → gsl_native}/graph.c +37 -87
- data/ext/{gsl → gsl_native}/gsl.c +10 -23
- data/ext/{gsl → gsl_native}/gsl_narray.c +15 -24
- data/ext/{gsl → gsl_native}/histogram.c +123 -150
- data/ext/{gsl → gsl_native}/histogram2d.c +71 -96
- data/ext/{gsl → gsl_native}/histogram3d.c +72 -72
- data/ext/{gsl → gsl_native}/histogram3d_source.c +195 -196
- data/ext/{gsl → gsl_native}/histogram_find.c +31 -33
- data/ext/{gsl → gsl_native}/histogram_oper.c +43 -52
- data/ext/{gsl → gsl_native}/ieee.c +7 -15
- data/ext/{gsl → gsl_native}/include/rb_gsl.h +0 -7
- data/ext/{gsl → gsl_native}/include/rb_gsl_array.h +15 -25
- data/ext/{gsl → gsl_native}/include/rb_gsl_cheb.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_common.h +44 -52
- data/ext/{gsl → gsl_native}/include/rb_gsl_complex.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_const.h +0 -5
- data/ext/{gsl → gsl_native}/include/rb_gsl_dirac.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_eigen.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_fft.h +0 -3
- data/ext/{gsl → gsl_native}/include/rb_gsl_fit.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_function.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_graph.h +2 -2
- data/ext/{gsl → gsl_native}/include/rb_gsl_histogram.h +8 -8
- data/ext/{gsl → gsl_native}/include/rb_gsl_histogram3d.h +50 -50
- data/ext/{gsl → gsl_native}/include/rb_gsl_integration.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_interp.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_linalg.h +0 -1
- data/ext/{gsl → gsl_native}/include/rb_gsl_math.h +0 -4
- data/ext/{gsl → gsl_native}/include/rb_gsl_odeiv.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_poly.h +3 -3
- data/ext/{gsl → gsl_native}/include/rb_gsl_rational.h +1 -1
- data/ext/{gsl → gsl_native}/include/rb_gsl_rng.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_root.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_sf.h +39 -43
- data/ext/{gsl → gsl_native}/include/rb_gsl_statistics.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_tensor.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_with_narray.h +0 -0
- data/ext/{gsl → gsl_native}/include/templates_off.h +0 -0
- data/ext/{gsl → gsl_native}/include/templates_on.h +1 -1
- data/ext/{gsl → gsl_native}/integration.c +160 -183
- data/ext/{gsl → gsl_native}/interp.c +23 -31
- data/ext/gsl_native/jacobi.c +733 -0
- data/ext/{gsl → gsl_native}/linalg.c +448 -576
- data/ext/{gsl → gsl_native}/linalg_complex.c +84 -98
- data/ext/{gsl → gsl_native}/math.c +45 -63
- data/ext/{gsl → gsl_native}/matrix.c +4 -6
- data/ext/{gsl → gsl_native}/matrix_complex.c +111 -114
- data/ext/{gsl → gsl_native}/matrix_double.c +74 -77
- data/ext/{gsl → gsl_native}/matrix_int.c +49 -50
- data/ext/{gsl/matrix_source.c → gsl_native/matrix_source.h} +280 -302
- data/ext/{gsl → gsl_native}/min.c +43 -74
- data/ext/{gsl → gsl_native}/monte.c +45 -59
- data/ext/{gsl → gsl_native}/multifit.c +138 -147
- data/ext/{gsl → gsl_native}/multimin.c +55 -83
- data/ext/{gsl → gsl_native}/multimin_fsdf.c +15 -15
- data/ext/{gsl → gsl_native}/multiroots.c +61 -64
- data/ext/{gsl → gsl_native}/multiset.c +3 -7
- data/ext/{gsl → gsl_native}/ndlinear.c +320 -321
- data/ext/{gsl → gsl_native}/nmf.c +11 -11
- data/ext/{gsl → gsl_native}/nmf_wrap.c +1 -1
- data/ext/{gsl → gsl_native}/ntuple.c +13 -13
- data/ext/{gsl → gsl_native}/odeiv.c +95 -106
- data/ext/gsl_native/ool.c +879 -0
- data/ext/{gsl → gsl_native}/permutation.c +36 -34
- data/ext/{gsl → gsl_native}/poly.c +2 -5
- data/ext/{gsl → gsl_native}/poly2.c +6 -6
- data/ext/{gsl/poly_source.c → gsl_native/poly_source.h} +232 -275
- data/ext/{gsl → gsl_native}/qrng.c +6 -17
- data/ext/{gsl → gsl_native}/randist.c +218 -243
- data/ext/{gsl → gsl_native}/rational.c +9 -9
- data/ext/{gsl → gsl_native}/rng.c +29 -45
- data/ext/{gsl → gsl_native}/root.c +43 -43
- data/ext/{gsl → gsl_native}/sf.c +163 -197
- data/ext/{gsl → gsl_native}/sf_airy.c +0 -0
- data/ext/{gsl → gsl_native}/sf_bessel.c +6 -6
- data/ext/{gsl → gsl_native}/sf_clausen.c +0 -0
- data/ext/{gsl → gsl_native}/sf_coulomb.c +39 -39
- data/ext/{gsl → gsl_native}/sf_coupling.c +29 -29
- data/ext/{gsl → gsl_native}/sf_dawson.c +0 -0
- data/ext/{gsl → gsl_native}/sf_debye.c +0 -9
- data/ext/{gsl → gsl_native}/sf_dilog.c +0 -0
- data/ext/{gsl → gsl_native}/sf_elementary.c +2 -2
- data/ext/{gsl → gsl_native}/sf_ellint.c +42 -42
- data/ext/{gsl → gsl_native}/sf_elljac.c +2 -2
- data/ext/{gsl → gsl_native}/sf_erfc.c +0 -4
- data/ext/{gsl → gsl_native}/sf_exp.c +2 -2
- data/ext/{gsl → gsl_native}/sf_expint.c +1 -11
- data/ext/{gsl → gsl_native}/sf_fermi_dirac.c +0 -0
- data/ext/{gsl → gsl_native}/sf_gamma.c +1 -5
- data/ext/{gsl → gsl_native}/sf_gegenbauer.c +0 -0
- data/ext/{gsl → gsl_native}/sf_hyperg.c +0 -0
- data/ext/{gsl → gsl_native}/sf_laguerre.c +3 -3
- data/ext/{gsl → gsl_native}/sf_lambert.c +0 -0
- data/ext/{gsl → gsl_native}/sf_legendre.c +0 -0
- data/ext/{gsl → gsl_native}/sf_log.c +3 -3
- data/ext/gsl_native/sf_mathieu.c +235 -0
- data/ext/{gsl → gsl_native}/sf_power.c +0 -0
- data/ext/{gsl → gsl_native}/sf_psi.c +2 -11
- data/ext/{gsl → gsl_native}/sf_synchrotron.c +0 -0
- data/ext/{gsl → gsl_native}/sf_transport.c +0 -0
- data/ext/{gsl → gsl_native}/sf_trigonometric.c +3 -3
- data/ext/{gsl → gsl_native}/sf_zeta.c +0 -4
- data/ext/{gsl → gsl_native}/signal.c +60 -64
- data/ext/{gsl → gsl_native}/siman.c +36 -40
- data/ext/{gsl → gsl_native}/sort.c +3 -4
- data/ext/{gsl → gsl_native}/spline.c +25 -43
- data/ext/{gsl → gsl_native}/stats.c +102 -115
- data/ext/{gsl → gsl_native}/sum.c +32 -32
- data/ext/{gsl → gsl_native}/tamu_anova.c +0 -0
- data/ext/{gsl → gsl_native}/tensor.c +2 -4
- data/ext/{gsl/tensor_source.c → gsl_native/tensor_source.h} +144 -144
- data/ext/{gsl → gsl_native}/vector.c +2 -4
- data/ext/{gsl → gsl_native}/vector_complex.c +165 -171
- data/ext/{gsl → gsl_native}/vector_double.c +167 -174
- data/ext/{gsl → gsl_native}/vector_int.c +23 -25
- data/ext/{gsl/vector_source.c → gsl_native/vector_source.h} +400 -414
- data/ext/{gsl → gsl_native}/wavelet.c +215 -236
- data/lib/gsl.rb +1 -7
- data/lib/gsl/gnuplot.rb +2 -2
- data/lib/gsl/version.rb +1 -3
- data/rb-gsl.gemspec +29 -0
- data/rdoc/blas.rdoc +3 -3
- data/rdoc/bspline.rdoc +7 -7
- data/rdoc/cheb.rdoc +8 -8
- data/rdoc/cholesky_complex.rdoc +1 -1
- data/rdoc/combi.rdoc +9 -9
- data/rdoc/complex.rdoc +11 -11
- data/rdoc/const.rdoc +20 -20
- data/rdoc/dht.rdoc +6 -6
- data/rdoc/diff.rdoc +6 -6
- data/rdoc/ehandling.rdoc +3 -3
- data/rdoc/eigen.rdoc +11 -11
- data/rdoc/fft.rdoc +26 -26
- data/rdoc/fit.rdoc +18 -18
- data/rdoc/graph.rdoc +2 -2
- data/rdoc/hist.rdoc +16 -16
- data/rdoc/hist2d.rdoc +4 -4
- data/rdoc/hist3d.rdoc +3 -3
- data/rdoc/integration.rdoc +16 -16
- data/rdoc/interp.rdoc +11 -11
- data/rdoc/intro.rdoc +3 -3
- data/rdoc/linalg.rdoc +20 -20
- data/rdoc/linalg_complex.rdoc +1 -1
- data/rdoc/math.rdoc +13 -13
- data/rdoc/matrix.rdoc +22 -22
- data/rdoc/min.rdoc +9 -9
- data/rdoc/monte.rdoc +3 -3
- data/rdoc/multimin.rdoc +12 -12
- data/rdoc/multiroot.rdoc +12 -12
- data/rdoc/narray.rdoc +9 -9
- data/rdoc/ndlinear.rdoc +4 -4
- data/rdoc/nonlinearfit.rdoc +17 -17
- data/rdoc/ntuple.rdoc +5 -5
- data/rdoc/odeiv.rdoc +12 -12
- data/rdoc/perm.rdoc +11 -11
- data/rdoc/poly.rdoc +17 -17
- data/rdoc/qrng.rdoc +9 -9
- data/rdoc/randist.rdoc +10 -10
- data/rdoc/ref.rdoc +49 -49
- data/rdoc/rng.rdoc +9 -9
- data/rdoc/roots.rdoc +12 -12
- data/rdoc/sf.rdoc +35 -35
- data/rdoc/siman.rdoc +3 -3
- data/rdoc/sort.rdoc +6 -6
- data/rdoc/start.rdoc +2 -2
- data/rdoc/stats.rdoc +13 -13
- data/rdoc/sum.rdoc +4 -4
- data/rdoc/tensor.rdoc +3 -3
- data/rdoc/tut.rdoc +1 -1
- data/rdoc/use.rdoc +3 -3
- data/rdoc/vector.rdoc +28 -28
- data/rdoc/vector_complex.rdoc +6 -6
- data/rdoc/wavelet.rdoc +8 -8
- data/test/gsl/blas_test.rb +1 -1
- data/test/gsl/index_test.rb +61 -0
- data/test/gsl/matrix_test.rb +21 -0
- data/uncrustify.cfg +1693 -0
- metadata +212 -243
- data/README +0 -28
- data/ext/gsl/bspline.c +0 -130
- data/ext/gsl/const.c +0 -672
- data/ext/gsl/cqp.c +0 -283
- data/ext/gsl/fcmp.c +0 -64
- data/ext/gsl/fresnel.c +0 -312
- data/ext/gsl/jacobi.c +0 -739
- data/ext/gsl/ool.c +0 -879
- data/ext/gsl/oper_complex_source.c +0 -251
- data/ext/gsl/sf_mathieu.c +0 -238
- data/rdoc/index.rdoc +0 -50
@@ -199,7 +199,7 @@ static VALUE rb_gsl_poly_make_rational(VALUE obj, VALUE other)
|
|
199
199
|
case T_ARRAY:
|
200
200
|
p2 = gsl_vector_alloc(RARRAY_LEN(other));
|
201
201
|
for (i = 0; i < p2->size; i++)
|
202
|
-
|
202
|
+
gsl_vector_set(p2, i, NUM2DBL(rb_ary_entry(other, i)));
|
203
203
|
rnew = gsl_rational_new(p, p2);
|
204
204
|
gsl_vector_free(p2);
|
205
205
|
break;
|
@@ -210,8 +210,8 @@ static VALUE rb_gsl_poly_make_rational(VALUE obj, VALUE other)
|
|
210
210
|
return Data_Wrap_Struct(cgsl_poly, 0, gsl_vector_free, p2);
|
211
211
|
break;
|
212
212
|
default:
|
213
|
-
rb_raise(rb_eTypeError, "wrong argument type %s",
|
214
|
-
|
213
|
+
rb_raise(rb_eTypeError, "wrong argument type %s",
|
214
|
+
rb_class2name(CLASS_OF(other)));
|
215
215
|
break;
|
216
216
|
}
|
217
217
|
}
|
@@ -280,7 +280,7 @@ static VALUE rb_gsl_rational_uminus(VALUE obj)
|
|
280
280
|
if (RATIONAL_P(obj)) {
|
281
281
|
Data_Get_Struct(obj, gsl_rational, r);
|
282
282
|
rnew = gsl_rational_new(r->pnum, r->pden);
|
283
|
-
for (i = 0; i < rnew->pnum->size; i++)
|
283
|
+
for (i = 0; i < rnew->pnum->size; i++)
|
284
284
|
gsl_vector_set(rnew->pnum, i, -gsl_vector_get(r->pnum, i));
|
285
285
|
return Data_Wrap_Struct(cgsl_rational, gsl_rational_mark, gsl_rational_free, rnew);
|
286
286
|
} else {
|
@@ -342,7 +342,7 @@ static VALUE rb_gsl_rational_div(VALUE obj, VALUE other)
|
|
342
342
|
case T_ARRAY:
|
343
343
|
p = gsl_vector_alloc(RARRAY_LEN(other));
|
344
344
|
for (i = 0; i < p->size; i++)
|
345
|
-
|
345
|
+
gsl_vector_set(p, i, NUM2DBL(rb_ary_entry(other, i)));
|
346
346
|
rnew = gsl_rational_div_poly(r, p);
|
347
347
|
gsl_vector_free(p);
|
348
348
|
break;
|
@@ -352,8 +352,8 @@ static VALUE rb_gsl_rational_div(VALUE obj, VALUE other)
|
|
352
352
|
gsl_vector_scale(rnew->pnum, 1.0/NUM2DBL(other));
|
353
353
|
break;
|
354
354
|
default:
|
355
|
-
rb_raise(rb_eTypeError, "wrong argument type %s",
|
356
|
-
|
355
|
+
rb_raise(rb_eTypeError, "wrong argument type %s",
|
356
|
+
rb_class2name(CLASS_OF(other)));
|
357
357
|
break;
|
358
358
|
}
|
359
359
|
}
|
@@ -407,8 +407,8 @@ static VALUE rb_gsl_rational_coerce(VALUE obj, VALUE other)
|
|
407
407
|
ptmp = gsl_vector_alloc(1);
|
408
408
|
gsl_vector_set(ptmp, 0, 1.0);
|
409
409
|
r = gsl_rational_new2(p, ptmp);
|
410
|
-
return rb_ary_new3(2,
|
411
|
-
|
410
|
+
return rb_ary_new3(2,
|
411
|
+
Data_Wrap_Struct(cgsl_rational, gsl_rational_mark, gsl_rational_free, r), obj);
|
412
412
|
}
|
413
413
|
|
414
414
|
static VALUE rb_gsl_rational_zero(VALUE obj)
|
@@ -9,7 +9,7 @@
|
|
9
9
|
WITHOUT ANY WARRANTY.
|
10
10
|
*/
|
11
11
|
|
12
|
-
/*
|
12
|
+
/*
|
13
13
|
Document-class: <i>GSL::Rng</i>
|
14
14
|
Random number generator
|
15
15
|
*/
|
@@ -24,22 +24,22 @@ VALUE cgsl_rng;
|
|
24
24
|
|
25
25
|
enum rb_gsl_rng_generator {
|
26
26
|
GSL_RNG_DEFAULT,
|
27
|
-
GSL_RNG_MT19937, GSL_RNG_MT19937_1999, GSL_RNG_MT19937_1998,
|
28
|
-
GSL_RNG_RANLXS0, GSL_RNG_RANLXS1, GSL_RNG_RANLXS2,
|
29
|
-
GSL_RNG_RANLXD1, GSL_RNG_RANLXD2,
|
27
|
+
GSL_RNG_MT19937, GSL_RNG_MT19937_1999, GSL_RNG_MT19937_1998,
|
28
|
+
GSL_RNG_RANLXS0, GSL_RNG_RANLXS1, GSL_RNG_RANLXS2,
|
29
|
+
GSL_RNG_RANLXD1, GSL_RNG_RANLXD2,
|
30
30
|
GSL_RNG_RANLUX, GSL_RNG_RANLUX389,
|
31
|
-
GSL_RNG_CMRG, GSL_RNG_MRG,
|
31
|
+
GSL_RNG_CMRG, GSL_RNG_MRG,
|
32
32
|
GSL_RNG_TAUS, GSL_RNG_TAUS2, GSL_RNG_TAUS113, GSL_RNG_GFSR4,
|
33
|
-
GSL_RNG_RAND,
|
33
|
+
GSL_RNG_RAND,
|
34
34
|
GSL_RNG_RANDOM_BSD, GSL_RNG_RANDOM_GLIBC2,
|
35
|
-
GSL_RNG_RANDOM8_GLIBC2, GSL_RNG_RANDOM32_GLIBC2, GSL_RNG_RANDOM64_GLIBC2,
|
35
|
+
GSL_RNG_RANDOM8_GLIBC2, GSL_RNG_RANDOM32_GLIBC2, GSL_RNG_RANDOM64_GLIBC2,
|
36
36
|
GSL_RNG_RANDOM128_GLIBC2, GSL_RNG_RANDOM256_GLIBC2,
|
37
|
-
GSL_RNG_RANDOM8_BSD, GSL_RNG_RANDOM32_BSD, GSL_RNG_RANDOM64_BSD,
|
37
|
+
GSL_RNG_RANDOM8_BSD, GSL_RNG_RANDOM32_BSD, GSL_RNG_RANDOM64_BSD,
|
38
38
|
GSL_RNG_RANDOM128_BSD, GSL_RNG_RANDOM256_BSD,
|
39
|
-
GSL_RNG_RANDOM_LIBC5, GSL_RNG_RANDOM8_LIBC5, GSL_RNG_RANDOM32_LIBC5,
|
40
|
-
GSL_RNG_RANDOM64_LIBC5, GSL_RNG_RANDOM128_LIBC5, GSL_RNG_RANDOM256_LIBC5,
|
41
|
-
GSL_RNG_RAND48,
|
42
|
-
GSL_RNG_RAN0, GSL_RNG_RAN1, GSL_RNG_RAN2, GSL_RNG_RAN3,
|
39
|
+
GSL_RNG_RANDOM_LIBC5, GSL_RNG_RANDOM8_LIBC5, GSL_RNG_RANDOM32_LIBC5,
|
40
|
+
GSL_RNG_RANDOM64_LIBC5, GSL_RNG_RANDOM128_LIBC5, GSL_RNG_RANDOM256_LIBC5,
|
41
|
+
GSL_RNG_RAND48,
|
42
|
+
GSL_RNG_RAN0, GSL_RNG_RAN1, GSL_RNG_RAN2, GSL_RNG_RAN3,
|
43
43
|
GSL_RNG_RANF, GSL_RNG_RANMAR, GSL_RNG_R250, GSL_RNG_TT800, GSL_RNG_VAX,
|
44
44
|
GSL_RNG_TRANSPUTER, GSL_RNG_RANDU, GSL_RNG_MINSTD,
|
45
45
|
GSL_RNG_UNI, GSL_RNG_UNI32, GSL_RNG_SLATEC, GSL_RNG_ZUF,
|
@@ -70,16 +70,16 @@ static VALUE rb_gsl_rng_alloc(int argc, VALUE *argv, VALUE klass)
|
|
70
70
|
T = gsl_rng_default;
|
71
71
|
seed = gsl_rng_default_seed;
|
72
72
|
} else {
|
73
|
-
T = get_gsl_rng_type(argv[0]);
|
73
|
+
T = get_gsl_rng_type(argv[0]);
|
74
74
|
if (argc == 1) {
|
75
75
|
seed = gsl_rng_default_seed;
|
76
76
|
} else if (argc == 2) {
|
77
77
|
itype = TYPE(argv[1]);
|
78
78
|
if (itype == T_FIXNUM || itype == T_BIGNUM) {
|
79
|
-
|
79
|
+
seed = FIX2INT(argv[1]);
|
80
80
|
} else {
|
81
|
-
|
82
|
-
|
81
|
+
rb_raise(rb_eArgError,
|
82
|
+
"bad argument 2, seed must be an integer.");
|
83
83
|
}
|
84
84
|
} else {
|
85
85
|
rb_raise(rb_eArgError, "too many arguments (%d for 0 or 1)", argc);
|
@@ -110,7 +110,6 @@ static const gsl_rng_type* get_gsl_rng_type_name(char *name)
|
|
110
110
|
{
|
111
111
|
if (str_tail_grep(name, "default") == 0) return gsl_rng_default;
|
112
112
|
else if (str_tail_grep(name, "mt19937") == 0) return gsl_rng_mt19937;
|
113
|
-
#ifdef GSL_1_1_LATER
|
114
113
|
else if (str_tail_grep(name, "borosh13") == 0) return gsl_rng_borosh13;
|
115
114
|
else if (str_tail_grep(name, "coveyou") == 0) return gsl_rng_coveyou;
|
116
115
|
else if (str_tail_grep(name, "fishman18") == 0) return gsl_rng_fishman18;
|
@@ -120,15 +119,12 @@ static const gsl_rng_type* get_gsl_rng_type_name(char *name)
|
|
120
119
|
else if (str_tail_grep(name, "waterman14") == 0) return gsl_rng_waterman14;
|
121
120
|
else if (str_tail_grep(name, "knuthran") == 0) return gsl_rng_knuthran;
|
122
121
|
else if (str_tail_grep(name, "knuthran2") == 0) return gsl_rng_knuthran2;
|
123
|
-
#endif
|
124
|
-
#ifdef GSL_1_2_LATER
|
125
122
|
else if (str_tail_grep(name, "mt19937_1999") == 0) return gsl_rng_mt19937_1999;
|
126
123
|
else if (str_tail_grep(name, "mt19937-1999") == 0) return gsl_rng_mt19937_1999;
|
127
|
-
else if (str_tail_grep(name, "mt19937_1998") == 0) return gsl_rng_mt19937_1998;
|
128
|
-
else if (str_tail_grep(name, "mt19937-1998") == 0) return gsl_rng_mt19937_1998;
|
124
|
+
else if (str_tail_grep(name, "mt19937_1998") == 0) return gsl_rng_mt19937_1998;
|
125
|
+
else if (str_tail_grep(name, "mt19937-1998") == 0) return gsl_rng_mt19937_1998;
|
129
126
|
else if (str_tail_grep(name, "taus113") == 0) return gsl_rng_taus113;
|
130
127
|
else if (str_tail_grep(name, "taus2") == 0) return gsl_rng_taus2;
|
131
|
-
#endif
|
132
128
|
else if (str_tail_grep(name, "mt19937") == 0) return gsl_rng_mt19937;
|
133
129
|
else if (str_tail_grep(name, "ranlxs0") == 0) return gsl_rng_ranlxs0;
|
134
130
|
else if (str_tail_grep(name, "ranlxs1") == 0) return gsl_rng_ranlxs1;
|
@@ -147,7 +143,7 @@ static const gsl_rng_type* get_gsl_rng_type_name(char *name)
|
|
147
143
|
else if (str_tail_grep(name, "random32_libc5") == 0) return gsl_rng_random32_libc5;
|
148
144
|
else if (str_tail_grep(name, "random64_libc5") == 0) return gsl_rng_random64_libc5;
|
149
145
|
else if (str_tail_grep(name, "random128_libc5") == 0) return gsl_rng_random128_libc5;
|
150
|
-
else if (str_tail_grep(name, "random256_libc5") == 0) return gsl_rng_random256_libc5;
|
146
|
+
else if (str_tail_grep(name, "random256_libc5") == 0) return gsl_rng_random256_libc5;
|
151
147
|
else if (str_tail_grep(name, "random-libc5") == 0) return gsl_rng_random_libc5;
|
152
148
|
else if (str_tail_grep(name, "random8-libc5") == 0) return gsl_rng_random8_libc5;
|
153
149
|
else if (str_tail_grep(name, "random32-libc5") == 0) return gsl_rng_random32_libc5;
|
@@ -201,18 +197,16 @@ static const gsl_rng_type* get_gsl_rng_type_name(char *name)
|
|
201
197
|
else if (str_tail_grep(name, "rngextra-rng1") == 0) return rngextra_rng1;
|
202
198
|
else if (str_tail_grep(name, "rngextra-rng2") == 0) return rngextra_rng2;
|
203
199
|
#else
|
204
|
-
else if (str_tail_grep(name, "rngextra_rng1")*str_tail_grep(name, "rngextra_rng2") == 0)
|
200
|
+
else if (str_tail_grep(name, "rngextra_rng1")*str_tail_grep(name, "rngextra_rng2") == 0)
|
205
201
|
rb_raise(rb_eNotImpError, "Install the rngextra package found at <http://www.network-theory.co.uk/download/rngextra/>.");
|
206
|
-
else if (str_tail_grep(name, "rngextra_rng2")*str_tail_grep(name, "rngextra_rng2") == 0)
|
202
|
+
else if (str_tail_grep(name, "rngextra_rng2")*str_tail_grep(name, "rngextra_rng2") == 0)
|
207
203
|
rb_raise(rb_eNotImpError, "Install the rngextra package found at <http://www.network-theory.co.uk/download/rngextra/>.");
|
208
|
-
else if (str_tail_grep(name, "rngextra-rng1")*str_tail_grep(name, "rngextra_rng2") == 0)
|
204
|
+
else if (str_tail_grep(name, "rngextra-rng1")*str_tail_grep(name, "rngextra_rng2") == 0)
|
209
205
|
rb_raise(rb_eNotImpError, "Install the rngextra package found at <http://www.network-theory.co.uk/download/rngextra/>.");
|
210
|
-
else if (str_tail_grep(name, "rngextra-rng2")*str_tail_grep(name, "rngextra_rng2") == 0)
|
206
|
+
else if (str_tail_grep(name, "rngextra-rng2")*str_tail_grep(name, "rngextra_rng2") == 0)
|
211
207
|
rb_raise(rb_eNotImpError, "Install the rngextra package found at <http://www.network-theory.co.uk/download/rngextra/>.");
|
212
208
|
#endif
|
213
|
-
#ifdef GSL_1_9_LATER
|
214
209
|
else if (str_tail_grep(name, "knuthran2002") == 0) return gsl_rng_knuthran2002;
|
215
|
-
#endif
|
216
210
|
else
|
217
211
|
rb_raise(rb_eArgError, "unknown generator type \"%s\"", name);
|
218
212
|
}
|
@@ -224,12 +218,10 @@ static const gsl_rng_type* get_gsl_rng_type_int(int itype)
|
|
224
218
|
switch (itype) {
|
225
219
|
case GSL_RNG_DEFAULT: T = gsl_rng_default; break;
|
226
220
|
case GSL_RNG_MT19937: T = gsl_rng_mt19937; break; /* default */
|
227
|
-
#ifdef GSL_1_2_LATER
|
228
221
|
case GSL_RNG_MT19937_1999: T = gsl_rng_mt19937_1999; break;
|
229
222
|
case GSL_RNG_MT19937_1998: T = gsl_rng_mt19937_1998; break;
|
230
223
|
case GSL_RNG_TAUS113: T = gsl_rng_taus113; break;
|
231
224
|
case GSL_RNG_TAUS2: T = gsl_rng_taus2; break;
|
232
|
-
#endif
|
233
225
|
case GSL_RNG_RANLXS0: T = gsl_rng_ranlxs0; break;
|
234
226
|
case GSL_RNG_RANLXS1: T = gsl_rng_ranlxs1; break;
|
235
227
|
case GSL_RNG_RANLXS2: T = gsl_rng_ranlxs2; break;
|
@@ -277,7 +269,6 @@ static const gsl_rng_type* get_gsl_rng_type_int(int itype)
|
|
277
269
|
case GSL_RNG_UNI32: T = gsl_rng_uni32; break;
|
278
270
|
case GSL_RNG_SLATEC: T = gsl_rng_slatec; break;
|
279
271
|
case GSL_RNG_ZUF: T = gsl_rng_zuf; break;
|
280
|
-
#ifdef GSL_1_1_LATER
|
281
272
|
case GSL_RNG_BOROSH13: T = gsl_rng_borosh13; break;
|
282
273
|
case GSL_RNG_COVEYOU: T = gsl_rng_coveyou; break;
|
283
274
|
case GSL_RNG_FISHMAN18: T = gsl_rng_fishman18; break;
|
@@ -287,7 +278,6 @@ static const gsl_rng_type* get_gsl_rng_type_int(int itype)
|
|
287
278
|
case GSL_RNG_KNUTHRAN2: T = gsl_rng_knuthran2; break;
|
288
279
|
case GSL_RNG_LECUYER21: T = gsl_rng_lecuyer21; break;
|
289
280
|
case GSL_RNG_WATERMAN14: T = gsl_rng_waterman14; break;
|
290
|
-
#endif
|
291
281
|
#ifdef HAVE_RNGEXTRA_RNGEXTRA_H
|
292
282
|
case GSL_RNGEXTRA_RNG1: T = rngextra_rng1; break;
|
293
283
|
case GSL_RNGEXTRA_RNG2: T = rngextra_rng2; break;
|
@@ -297,14 +287,12 @@ static const gsl_rng_type* get_gsl_rng_type_int(int itype)
|
|
297
287
|
rb_raise(rb_eNotImpError, "Install the rngextra package found at <http://www.network-theory.co.uk/download/rngextra/>.");
|
298
288
|
break;
|
299
289
|
#endif
|
300
|
-
#ifdef GSL_1_9_LATER
|
301
290
|
case GSL_RNG_KNUTHRAN2002: T = gsl_rng_knuthran2002; break;
|
302
|
-
#endif
|
303
291
|
default:
|
304
292
|
rb_raise(rb_eTypeError, "wrong generator type");
|
305
293
|
}
|
306
294
|
|
307
|
-
return
|
295
|
+
return T;
|
308
296
|
}
|
309
297
|
|
310
298
|
static void rb_gsl_rng_define_const_type(VALUE module)
|
@@ -404,10 +392,10 @@ static VALUE rb_gsl_rng_set(VALUE obj, VALUE s)
|
|
404
392
|
|
405
393
|
/*
|
406
394
|
Document-method: <i>GSL::Rng#get</i>
|
407
|
-
Returns a random integer from the generator.
|
408
|
-
The minimum and maximum values depend on the algorithm used,
|
409
|
-
but all integers in the range [min,max] are equally likely.
|
410
|
-
The values of min and max can determined using the auxiliary
|
395
|
+
Returns a random integer from the generator.
|
396
|
+
The minimum and maximum values depend on the algorithm used,
|
397
|
+
but all integers in the range [min,max] are equally likely.
|
398
|
+
The values of min and max can determined using the auxiliary
|
411
399
|
methodss GSL::Rng#max and GSL::Rng#min.
|
412
400
|
*/
|
413
401
|
static VALUE rb_gsl_rng_get(int argc, VALUE *argv, VALUE obj)
|
@@ -533,7 +521,6 @@ static VALUE rb_gsl_rng_print_state(VALUE obj)
|
|
533
521
|
return obj;
|
534
522
|
}
|
535
523
|
|
536
|
-
#ifdef GSL_1_4_LATER
|
537
524
|
static VALUE rb_gsl_rng_fwrite(VALUE obj, VALUE io)
|
538
525
|
{
|
539
526
|
gsl_rng *h = NULL;
|
@@ -557,7 +544,6 @@ static VALUE rb_gsl_rng_fread(VALUE obj, VALUE io)
|
|
557
544
|
if (flag == 1) fclose(f);
|
558
545
|
return INT2FIX(status);
|
559
546
|
}
|
560
|
-
#endif
|
561
547
|
|
562
548
|
static VALUE rb_gsl_rng_memcpy(VALUE obj, VALUE dst, VALUE org)
|
563
549
|
{
|
@@ -574,7 +560,7 @@ void Init_gsl_rng(VALUE module)
|
|
574
560
|
cgsl_rng = rb_define_class_under(module, "Rng", cGSL_Object);
|
575
561
|
|
576
562
|
rb_gsl_rng_define_const_type(module);
|
577
|
-
|
563
|
+
|
578
564
|
rb_define_singleton_method(cgsl_rng, "alloc", rb_gsl_rng_alloc, -1);
|
579
565
|
|
580
566
|
rb_define_singleton_method(cgsl_rng, "default_seed", rb_gsl_rng_default_seed, 0);
|
@@ -603,9 +589,7 @@ void Init_gsl_rng(VALUE module)
|
|
603
589
|
rb_define_alias(cgsl_rng, "duplicate", "clone");
|
604
590
|
rb_define_method(cgsl_rng, "print_state", rb_gsl_rng_print_state, 0);
|
605
591
|
|
606
|
-
#ifdef GSL_1_4_LATER
|
607
592
|
rb_define_method(cgsl_rng, "fwrite", rb_gsl_rng_fwrite, 1);
|
608
593
|
rb_define_method(cgsl_rng, "fread", rb_gsl_rng_fread, 1);
|
609
|
-
#endif
|
610
594
|
rb_define_singleton_method(cgsl_rng, "memcpy", rb_gsl_rng_memcpy, 2);
|
611
595
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
root.c
|
3
3
|
Ruby/GSL: Ruby extension library for GSL (GNU Scientific Library)
|
4
4
|
(C) Copyright 2004 by Yoshiki Tsunesada
|
5
|
-
|
5
|
+
|
6
6
|
Ruby/GSL is free software: you can redistribute it and/or modify it
|
7
7
|
under the terms of the GNU General Public License.
|
8
8
|
This library is distributed in the hope that it will be useful, but
|
@@ -42,8 +42,8 @@ static VALUE rb_gsl_fsolver_new(VALUE klass, VALUE t)
|
|
42
42
|
} else if (!str_tail_grep(name, "brent")) {
|
43
43
|
T = gsl_root_fsolver_brent;
|
44
44
|
} else {
|
45
|
-
rb_raise(rb_eTypeError,
|
46
|
-
|
45
|
+
rb_raise(rb_eTypeError,
|
46
|
+
"type must be \"bisection\" or \"falsepos\", or \"brent\".");
|
47
47
|
}
|
48
48
|
break;
|
49
49
|
case T_FIXNUM:
|
@@ -64,7 +64,7 @@ static VALUE rb_gsl_fsolver_new(VALUE klass, VALUE t)
|
|
64
64
|
break;
|
65
65
|
default:
|
66
66
|
rb_raise(rb_eTypeError, "wrong argument type %s (String or Fixnum expected)",
|
67
|
-
|
67
|
+
rb_class2name(CLASS_OF(t)));
|
68
68
|
break;
|
69
69
|
}
|
70
70
|
s = gsl_root_fsolver_alloc(T);
|
@@ -124,28 +124,28 @@ static VALUE rb_gsl_fsolver_name(VALUE obj)
|
|
124
124
|
static VALUE rb_gsl_fsolver_test_interval(VALUE obj, VALUE eabs, VALUE erel)
|
125
125
|
{
|
126
126
|
gsl_root_fsolver *s = NULL;
|
127
|
-
Need_Float(eabs); Need_Float(erel);
|
127
|
+
Need_Float(eabs); Need_Float(erel);
|
128
128
|
Data_Get_Struct(obj, gsl_root_fsolver, s);
|
129
129
|
return INT2FIX(gsl_root_test_interval(s->x_lower, s->x_upper,
|
130
|
-
|
130
|
+
NUM2DBL(eabs), NUM2DBL(erel)));
|
131
131
|
}
|
132
132
|
|
133
133
|
static VALUE rb_gsl_root_test_interval(VALUE obj, VALUE xl, VALUE xu, VALUE eabs,
|
134
|
-
|
134
|
+
VALUE erel)
|
135
135
|
{
|
136
136
|
Need_Float(xl); Need_Float(xu);
|
137
|
-
Need_Float(eabs); Need_Float(erel);
|
137
|
+
Need_Float(eabs); Need_Float(erel);
|
138
138
|
return INT2FIX(gsl_root_test_interval(NUM2DBL(xl), NUM2DBL(xu),
|
139
|
-
|
139
|
+
NUM2DBL(eabs), NUM2DBL(erel)));
|
140
140
|
}
|
141
141
|
|
142
142
|
static VALUE rb_gsl_root_test_delta(VALUE obj, VALUE xl, VALUE xu, VALUE eabs,
|
143
|
-
|
143
|
+
VALUE erel)
|
144
144
|
{
|
145
145
|
Need_Float(xl); Need_Float(xu);
|
146
|
-
Need_Float(eabs); Need_Float(erel);
|
146
|
+
Need_Float(eabs); Need_Float(erel);
|
147
147
|
return INT2FIX(gsl_root_test_delta(NUM2DBL(xl), NUM2DBL(xu),
|
148
|
-
|
148
|
+
NUM2DBL(eabs), NUM2DBL(erel)));
|
149
149
|
}
|
150
150
|
|
151
151
|
static VALUE rb_gsl_root_test_residual(VALUE obj, VALUE xl,VALUE eabs)
|
@@ -154,7 +154,7 @@ static VALUE rb_gsl_root_test_residual(VALUE obj, VALUE xl,VALUE eabs)
|
|
154
154
|
return INT2FIX(gsl_root_test_residual(NUM2DBL(xl), NUM2DBL(eabs)));
|
155
155
|
}
|
156
156
|
|
157
|
-
static VALUE rb_gsl_fsolver_solve(int argc, VALUE *argv, VALUE
|
157
|
+
static VALUE rb_gsl_fsolver_solve(int argc, VALUE *argv, VALUE obj)
|
158
158
|
{
|
159
159
|
gsl_root_fsolver *s = NULL;
|
160
160
|
gsl_function *F = NULL;
|
@@ -165,15 +165,15 @@ static VALUE rb_gsl_fsolver_solve(int argc, VALUE *argv, VALUE *obj)
|
|
165
165
|
Check_Type(argv[2], T_ARRAY);
|
166
166
|
epsabs = NUM2DBL(rb_ary_entry(argv[2], 0));
|
167
167
|
epsrel = NUM2DBL(rb_ary_entry(argv[2], 1));
|
168
|
-
|
168
|
+
/* no break */
|
169
169
|
case 2:
|
170
170
|
Check_Type(argv[1], T_ARRAY);
|
171
171
|
xl = NUM2DBL(rb_ary_entry(argv[1], 0));
|
172
172
|
xh = NUM2DBL(rb_ary_entry(argv[1], 1));
|
173
173
|
break;
|
174
174
|
default:
|
175
|
-
rb_raise(rb_eArgError,
|
176
|
-
|
175
|
+
rb_raise(rb_eArgError,
|
176
|
+
"Usage: solve(f = Function, range = Array, eps = Array)");
|
177
177
|
break;
|
178
178
|
}
|
179
179
|
CHECK_FUNCTION(argv[0]);
|
@@ -228,7 +228,7 @@ static VALUE rb_gsl_fdfsolver_new(VALUE klass, VALUE t)
|
|
228
228
|
break;
|
229
229
|
default:
|
230
230
|
rb_raise(rb_eTypeError, "wrong argument type %s (String or Fixnum expected)",
|
231
|
-
|
231
|
+
rb_class2name(CLASS_OF(t)));
|
232
232
|
break;
|
233
233
|
}
|
234
234
|
s = gsl_root_fdfsolver_alloc(T);
|
@@ -269,7 +269,7 @@ static VALUE rb_gsl_fdfsolver_name(VALUE obj)
|
|
269
269
|
return rb_str_new2(gsl_root_fdfsolver_name(s));
|
270
270
|
}
|
271
271
|
|
272
|
-
static VALUE rb_gsl_fdfsolver_solve(int argc, VALUE *argv, VALUE
|
272
|
+
static VALUE rb_gsl_fdfsolver_solve(int argc, VALUE *argv, VALUE obj)
|
273
273
|
{
|
274
274
|
gsl_root_fdfsolver *s = NULL;
|
275
275
|
double x = 0.0, x0, epsabs = 0.0, epsrel = 1e-6;
|
@@ -280,7 +280,7 @@ static VALUE rb_gsl_fdfsolver_solve(int argc, VALUE *argv, VALUE *obj)
|
|
280
280
|
Check_Type(argv[2], T_ARRAY);
|
281
281
|
epsabs = NUM2DBL(rb_ary_entry(argv[2], 0));
|
282
282
|
epsrel = NUM2DBL(rb_ary_entry(argv[2], 1));
|
283
|
-
|
283
|
+
/* no break */
|
284
284
|
case 2:
|
285
285
|
Need_Float(argv[1]);
|
286
286
|
x0 = NUM2DBL(argv[1]);
|
@@ -292,7 +292,7 @@ static VALUE rb_gsl_fdfsolver_solve(int argc, VALUE *argv, VALUE *obj)
|
|
292
292
|
CHECK_FUNCTION_FDF(argv[0]);
|
293
293
|
Data_Get_Struct(argv[0], gsl_function_fdf, F);
|
294
294
|
Data_Get_Struct(obj, gsl_root_fdfsolver, s);
|
295
|
-
gsl_root_fdfsolver_set(s, F, x0);
|
295
|
+
gsl_root_fdfsolver_set(s, F, x0);
|
296
296
|
do {
|
297
297
|
iter++;
|
298
298
|
status = gsl_root_fdfsolver_iterate (s);
|
@@ -361,32 +361,32 @@ void Init_gsl_root(VALUE module)
|
|
361
361
|
mgsl_root = rb_define_module_under(module, "Root");
|
362
362
|
|
363
363
|
cgsl_fsolver = rb_define_class_under(mgsl_root, "FSolver", cGSL_Object);
|
364
|
-
rb_define_singleton_method(cgsl_fsolver, "alloc", rb_gsl_fsolver_new, 1);
|
365
|
-
|
366
|
-
rb_define_method(cgsl_fsolver, "set", rb_gsl_fsolver_set, 3);
|
367
|
-
rb_define_method(cgsl_fsolver, "iterate", rb_gsl_fsolver_iterate, 0);
|
368
|
-
rb_define_method(cgsl_fsolver, "root", rb_gsl_fsolver_root, 0);
|
369
|
-
rb_define_method(cgsl_fsolver, "name", rb_gsl_fsolver_name, 0);
|
370
|
-
rb_define_method(cgsl_fsolver, "x_lower", rb_gsl_fsolver_x_lower, 0);
|
371
|
-
rb_define_method(cgsl_fsolver, "x_upper", rb_gsl_fsolver_x_upper, 0);
|
372
|
-
rb_define_method(cgsl_fsolver, "test_interval", rb_gsl_fsolver_test_interval, 2);
|
373
|
-
rb_define_method(cgsl_fsolver, "solve", rb_gsl_fsolver_solve, -1);
|
374
|
-
|
375
|
-
rb_define_singleton_method(mgsl_root, "test_interval",
|
376
|
-
|
377
|
-
rb_define_singleton_method(mgsl_root, "test_delta",
|
378
|
-
|
379
|
-
rb_define_singleton_method(mgsl_root, "test_residual",
|
380
|
-
|
364
|
+
rb_define_singleton_method(cgsl_fsolver, "alloc", rb_gsl_fsolver_new, 1);
|
365
|
+
|
366
|
+
rb_define_method(cgsl_fsolver, "set", rb_gsl_fsolver_set, 3);
|
367
|
+
rb_define_method(cgsl_fsolver, "iterate", rb_gsl_fsolver_iterate, 0);
|
368
|
+
rb_define_method(cgsl_fsolver, "root", rb_gsl_fsolver_root, 0);
|
369
|
+
rb_define_method(cgsl_fsolver, "name", rb_gsl_fsolver_name, 0);
|
370
|
+
rb_define_method(cgsl_fsolver, "x_lower", rb_gsl_fsolver_x_lower, 0);
|
371
|
+
rb_define_method(cgsl_fsolver, "x_upper", rb_gsl_fsolver_x_upper, 0);
|
372
|
+
rb_define_method(cgsl_fsolver, "test_interval", rb_gsl_fsolver_test_interval, 2);
|
373
|
+
rb_define_method(cgsl_fsolver, "solve", rb_gsl_fsolver_solve, -1);
|
374
|
+
|
375
|
+
rb_define_singleton_method(mgsl_root, "test_interval",
|
376
|
+
rb_gsl_root_test_interval, 4);
|
377
|
+
rb_define_singleton_method(mgsl_root, "test_delta",
|
378
|
+
rb_gsl_root_test_delta, 4);
|
379
|
+
rb_define_singleton_method(mgsl_root, "test_residual",
|
380
|
+
rb_gsl_root_test_residual, 2);
|
381
381
|
|
382
382
|
cgsl_fdfsolver = rb_define_class_under(mgsl_root, "FdfSolver", cGSL_Object);
|
383
|
-
rb_define_singleton_method(cgsl_fdfsolver, "alloc", rb_gsl_fdfsolver_new, 1);
|
383
|
+
rb_define_singleton_method(cgsl_fdfsolver, "alloc", rb_gsl_fdfsolver_new, 1);
|
384
384
|
|
385
|
-
rb_define_method(cgsl_fdfsolver, "set", rb_gsl_fdfsolver_set, 2);
|
386
|
-
rb_define_method(cgsl_fdfsolver, "iterate", rb_gsl_fdfsolver_iterate, 0);
|
387
|
-
rb_define_method(cgsl_fdfsolver, "root", rb_gsl_fdfsolver_root, 0);
|
388
|
-
rb_define_method(cgsl_fdfsolver, "name", rb_gsl_fdfsolver_name, 0);
|
389
|
-
rb_define_method(cgsl_fdfsolver, "solve", rb_gsl_fdfsolver_solve, -1);
|
385
|
+
rb_define_method(cgsl_fdfsolver, "set", rb_gsl_fdfsolver_set, 2);
|
386
|
+
rb_define_method(cgsl_fdfsolver, "iterate", rb_gsl_fdfsolver_iterate, 0);
|
387
|
+
rb_define_method(cgsl_fdfsolver, "root", rb_gsl_fdfsolver_root, 0);
|
388
|
+
rb_define_method(cgsl_fdfsolver, "name", rb_gsl_fdfsolver_name, 0);
|
389
|
+
rb_define_method(cgsl_fdfsolver, "solve", rb_gsl_fdfsolver_solve, -1);
|
390
390
|
|
391
391
|
rb_define_method(cgsl_function, "fsolve", rb_gsl_function_rootfinder, -1);
|
392
392
|
rb_define_alias(cgsl_function, "solve", "fsolve");
|
data/ext/{gsl → gsl_native}/sf.c
RENAMED
@@ -12,9 +12,6 @@
|
|
12
12
|
|
13
13
|
#include "include/rb_gsl_array.h"
|
14
14
|
#include "include/rb_gsl_sf.h"
|
15
|
-
#ifdef HAVE_NARRAY_H
|
16
|
-
#include "narray.h"
|
17
|
-
#endif
|
18
15
|
|
19
16
|
VALUE cgsl_sf_result, cgsl_sf_result_e10;
|
20
17
|
|
@@ -154,10 +151,6 @@ VALUE rb_gsl_sf_eval_int_double(double (*func)(int, double), VALUE jj, VALUE arg
|
|
154
151
|
VALUE ary, xx;
|
155
152
|
size_t i, j, k, n;
|
156
153
|
double val;
|
157
|
-
#ifdef HAVE_NARRAY_H
|
158
|
-
double *ptr1, *ptr2;
|
159
|
-
struct NARRAY *na;
|
160
|
-
#endif
|
161
154
|
CHECK_FIXNUM(jj);
|
162
155
|
j = FIX2INT(jj);
|
163
156
|
if (CLASS_OF(argv) == rb_cRange) argv = rb_gsl_range2ary(argv);
|
@@ -181,6 +174,8 @@ VALUE rb_gsl_sf_eval_int_double(double (*func)(int, double), VALUE jj, VALUE arg
|
|
181
174
|
default:
|
182
175
|
#ifdef HAVE_NARRAY_H
|
183
176
|
if (NA_IsNArray(argv)) {
|
177
|
+
double *ptr1, *ptr2;
|
178
|
+
struct NARRAY *na;
|
184
179
|
argv = na_change_type(argv, NA_DFLOAT);
|
185
180
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
186
181
|
GetNArray(argv, na);
|
@@ -195,10 +190,10 @@ VALUE rb_gsl_sf_eval_int_double(double (*func)(int, double), VALUE jj, VALUE arg
|
|
195
190
|
Data_Get_Struct(argv, gsl_matrix, m);
|
196
191
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
197
192
|
for (i = 0; i < m->size1; i++) {
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
193
|
+
for (k = 0; k < m->size2; k++) {
|
194
|
+
val = (*func)(j, gsl_matrix_get(m, i, k));
|
195
|
+
gsl_matrix_set(mnew, i, k, val);
|
196
|
+
}
|
202
197
|
}
|
203
198
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
204
199
|
} else {
|
@@ -207,8 +202,8 @@ VALUE rb_gsl_sf_eval_int_double(double (*func)(int, double), VALUE jj, VALUE arg
|
|
207
202
|
n = v->size;
|
208
203
|
vnew = gsl_vector_alloc(n);
|
209
204
|
for (i = 0; i < n; i++) {
|
210
|
-
|
211
|
-
|
205
|
+
val = (*func)(j, gsl_vector_get(v, i));
|
206
|
+
gsl_vector_set(vnew, i, val);
|
212
207
|
}
|
213
208
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
214
209
|
}
|
@@ -223,10 +218,6 @@ VALUE rb_gsl_sf_eval_double_int(double (*func)(double, int), VALUE argv, VALUE j
|
|
223
218
|
VALUE ary, xx;
|
224
219
|
size_t i, j, k, n;
|
225
220
|
double val;
|
226
|
-
#ifdef HAVE_NARRAY_H
|
227
|
-
double *ptr1, *ptr2;
|
228
|
-
struct NARRAY *na;
|
229
|
-
#endif
|
230
221
|
CHECK_FIXNUM(jj);
|
231
222
|
j = FIX2INT(jj);
|
232
223
|
if (CLASS_OF(argv) == rb_cRange) argv = rb_gsl_range2ary(argv);
|
@@ -250,6 +241,8 @@ VALUE rb_gsl_sf_eval_double_int(double (*func)(double, int), VALUE argv, VALUE j
|
|
250
241
|
default:
|
251
242
|
#ifdef HAVE_NARRAY_H
|
252
243
|
if (NA_IsNArray(argv)) {
|
244
|
+
double *ptr1, *ptr2;
|
245
|
+
struct NARRAY *na;
|
253
246
|
argv = na_change_type(argv, NA_DFLOAT);
|
254
247
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
255
248
|
GetNArray(argv, na);
|
@@ -264,10 +257,10 @@ VALUE rb_gsl_sf_eval_double_int(double (*func)(double, int), VALUE argv, VALUE j
|
|
264
257
|
Data_Get_Struct(argv, gsl_matrix, m);
|
265
258
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
266
259
|
for (i = 0; i < m->size1; i++) {
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
260
|
+
for (k = 0; k < m->size2; k++) {
|
261
|
+
val = (*func)(gsl_matrix_get(m, i, k), j);
|
262
|
+
gsl_matrix_set(mnew, i, k, val);
|
263
|
+
}
|
271
264
|
}
|
272
265
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
273
266
|
} else {
|
@@ -276,8 +269,8 @@ VALUE rb_gsl_sf_eval_double_int(double (*func)(double, int), VALUE argv, VALUE j
|
|
276
269
|
n = v->size;
|
277
270
|
vnew = gsl_vector_alloc(n);
|
278
271
|
for (i = 0; i < n; i++) {
|
279
|
-
|
280
|
-
|
272
|
+
val = (*func)(gsl_vector_get(v, i), j);
|
273
|
+
gsl_vector_set(vnew, i, val);
|
281
274
|
}
|
282
275
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
283
276
|
}
|
@@ -287,17 +280,13 @@ VALUE rb_gsl_sf_eval_double_int(double (*func)(double, int), VALUE argv, VALUE j
|
|
287
280
|
}
|
288
281
|
|
289
282
|
VALUE rb_gsl_sf_eval_int_int_double(double (*func)(int, int, double), VALUE jj,
|
290
|
-
|
283
|
+
VALUE jj2, VALUE argv)
|
291
284
|
{
|
292
285
|
gsl_vector *v = NULL, *vnew = NULL;
|
293
286
|
gsl_matrix *m = NULL, *mnew = NULL;
|
294
287
|
VALUE ary, xx;
|
295
288
|
size_t i, j, k, j2, n;
|
296
289
|
double val;
|
297
|
-
#ifdef HAVE_NARRAY_H
|
298
|
-
double *ptr1, *ptr2;
|
299
|
-
struct NARRAY *na;
|
300
|
-
#endif
|
301
290
|
CHECK_FIXNUM(jj); CHECK_FIXNUM(jj2);
|
302
291
|
j = FIX2INT(jj);
|
303
292
|
j2 = FIX2INT(jj2);
|
@@ -322,6 +311,8 @@ VALUE rb_gsl_sf_eval_int_int_double(double (*func)(int, int, double), VALUE jj,
|
|
322
311
|
default:
|
323
312
|
#ifdef HAVE_NARRAY_H
|
324
313
|
if (NA_IsNArray(argv)) {
|
314
|
+
double *ptr1, *ptr2;
|
315
|
+
struct NARRAY *na;
|
325
316
|
argv = na_change_type(argv, NA_DFLOAT);
|
326
317
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
327
318
|
GetNArray(argv, na);
|
@@ -357,18 +348,14 @@ VALUE rb_gsl_sf_eval_int_int_double(double (*func)(int, int, double), VALUE jj,
|
|
357
348
|
}
|
358
349
|
}
|
359
350
|
|
360
|
-
VALUE rb_gsl_sf_eval_int_double_double(double (*func)(int, double, double), VALUE jj,
|
361
|
-
|
351
|
+
VALUE rb_gsl_sf_eval_int_double_double(double (*func)(int, double, double), VALUE jj,
|
352
|
+
VALUE ff, VALUE argv)
|
362
353
|
{
|
363
354
|
gsl_vector *v = NULL, *vnew = NULL;
|
364
355
|
gsl_matrix *m = NULL, *mnew = NULL;
|
365
356
|
VALUE ary, xx;
|
366
357
|
size_t i, j, k, n;
|
367
358
|
double f, val;
|
368
|
-
#ifdef HAVE_NARRAY_H
|
369
|
-
double *ptr1, *ptr2;
|
370
|
-
struct NARRAY *na;
|
371
|
-
#endif
|
372
359
|
CHECK_FIXNUM(jj);
|
373
360
|
Need_Float(ff);
|
374
361
|
j = FIX2INT(jj);
|
@@ -394,6 +381,8 @@ VALUE rb_gsl_sf_eval_int_double_double(double (*func)(int, double, double), VALU
|
|
394
381
|
default:
|
395
382
|
#ifdef HAVE_NARRAY_H
|
396
383
|
if (NA_IsNArray(argv)) {
|
384
|
+
double *ptr1, *ptr2;
|
385
|
+
struct NARRAY *na;
|
397
386
|
argv = na_change_type(argv, NA_DFLOAT);
|
398
387
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
399
388
|
GetNArray(argv, na);
|
@@ -408,10 +397,10 @@ VALUE rb_gsl_sf_eval_int_double_double(double (*func)(int, double, double), VALU
|
|
408
397
|
Data_Get_Struct(argv, gsl_matrix, m);
|
409
398
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
410
399
|
for (i = 0; i < m->size1; i++) {
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
400
|
+
for (k = 0; k < m->size2; k++) {
|
401
|
+
val = (*func)(j, f, gsl_matrix_get(m, i, k));
|
402
|
+
gsl_matrix_set(mnew, i, k, val);
|
403
|
+
}
|
415
404
|
}
|
416
405
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
417
406
|
} else {
|
@@ -420,8 +409,8 @@ VALUE rb_gsl_sf_eval_int_double_double(double (*func)(int, double, double), VALU
|
|
420
409
|
n = v->size;
|
421
410
|
vnew = gsl_vector_alloc(n);
|
422
411
|
for (i = 0; i < n; i++) {
|
423
|
-
|
424
|
-
|
412
|
+
val = (*func)(j, f, gsl_vector_get(v, i));
|
413
|
+
gsl_vector_set(vnew, i, val);
|
425
414
|
}
|
426
415
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
427
416
|
}
|
@@ -436,10 +425,6 @@ VALUE rb_gsl_sf_eval_double_double(double (*func)(double, double), VALUE ff, VAL
|
|
436
425
|
VALUE ary, xx;
|
437
426
|
size_t i, k, n;
|
438
427
|
double val, f;
|
439
|
-
#ifdef HAVE_NARRAY_H
|
440
|
-
double *ptr1, *ptr2;
|
441
|
-
struct NARRAY *na;
|
442
|
-
#endif
|
443
428
|
Need_Float(ff);
|
444
429
|
f = NUM2DBL(ff);
|
445
430
|
if (CLASS_OF(argv) == rb_cRange) argv = rb_gsl_range2ary(argv);
|
@@ -463,6 +448,8 @@ VALUE rb_gsl_sf_eval_double_double(double (*func)(double, double), VALUE ff, VAL
|
|
463
448
|
default:
|
464
449
|
#ifdef HAVE_NARRAY_H
|
465
450
|
if (NA_IsNArray(argv)) {
|
451
|
+
double *ptr1, *ptr2;
|
452
|
+
struct NARRAY *na;
|
466
453
|
argv = na_change_type(argv, NA_DFLOAT);
|
467
454
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
468
455
|
GetNArray(argv, na);
|
@@ -477,9 +464,9 @@ VALUE rb_gsl_sf_eval_double_double(double (*func)(double, double), VALUE ff, VAL
|
|
477
464
|
Data_Get_Struct(argv, gsl_matrix, m);
|
478
465
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
479
466
|
for (i = 0; i < m->size1; i++) {
|
480
|
-
|
481
|
-
|
482
|
-
|
467
|
+
for (k = 0; k < m->size2; k++) {
|
468
|
+
gsl_matrix_set(mnew, i, k, (*func)(f, gsl_matrix_get(m, i, k)));
|
469
|
+
}
|
483
470
|
}
|
484
471
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
485
472
|
} else {
|
@@ -487,7 +474,7 @@ VALUE rb_gsl_sf_eval_double_double(double (*func)(double, double), VALUE ff, VAL
|
|
487
474
|
Data_Get_Struct(argv, gsl_vector, v);
|
488
475
|
vnew = gsl_vector_alloc(v->size);
|
489
476
|
for (i = 0; i < v->size; i++) {
|
490
|
-
|
477
|
+
gsl_vector_set(vnew, i, (*func)(f, gsl_vector_get(v, i)));
|
491
478
|
}
|
492
479
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
493
480
|
}
|
@@ -495,18 +482,14 @@ VALUE rb_gsl_sf_eval_double_double(double (*func)(double, double), VALUE ff, VAL
|
|
495
482
|
}
|
496
483
|
}
|
497
484
|
|
498
|
-
VALUE rb_gsl_sf_eval_double3(double (*func)(double, double, double),
|
499
|
-
|
485
|
+
VALUE rb_gsl_sf_eval_double3(double (*func)(double, double, double),
|
486
|
+
VALUE ff, VALUE ff2, VALUE argv)
|
500
487
|
{
|
501
488
|
gsl_vector *v = NULL, *vnew = NULL;
|
502
489
|
gsl_matrix *m = NULL, *mnew = NULL;
|
503
490
|
VALUE ary, xx;
|
504
491
|
size_t i, k, n;
|
505
492
|
double val, f, f2;
|
506
|
-
#ifdef HAVE_NARRAY_H
|
507
|
-
double *ptr1, *ptr2;
|
508
|
-
struct NARRAY *na;
|
509
|
-
#endif
|
510
493
|
Need_Float(ff); Need_Float(ff2);
|
511
494
|
f = NUM2DBL(ff);
|
512
495
|
f2 = NUM2DBL(ff2);
|
@@ -531,6 +514,8 @@ VALUE rb_gsl_sf_eval_double3(double (*func)(double, double, double),
|
|
531
514
|
default:
|
532
515
|
#ifdef HAVE_NARRAY_H
|
533
516
|
if (NA_IsNArray(argv)) {
|
517
|
+
double *ptr1, *ptr2;
|
518
|
+
struct NARRAY *na;
|
534
519
|
argv = na_change_type(argv, NA_DFLOAT);
|
535
520
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
536
521
|
GetNArray(argv, na);
|
@@ -545,10 +530,10 @@ VALUE rb_gsl_sf_eval_double3(double (*func)(double, double, double),
|
|
545
530
|
Data_Get_Struct(argv, gsl_matrix, m);
|
546
531
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
547
532
|
for (i = 0; i < m->size1; i++) {
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
533
|
+
for (k = 0; k < m->size2; k++) {
|
534
|
+
val = (*func)(f, f2, gsl_matrix_get(m, i, k));
|
535
|
+
gsl_matrix_set(mnew, i, k, val);
|
536
|
+
}
|
552
537
|
}
|
553
538
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
554
539
|
} else {
|
@@ -557,8 +542,8 @@ VALUE rb_gsl_sf_eval_double3(double (*func)(double, double, double),
|
|
557
542
|
n = v->size;
|
558
543
|
vnew = gsl_vector_alloc(n);
|
559
544
|
for (i = 0; i < n; i++) {
|
560
|
-
|
561
|
-
|
545
|
+
val = (*func)(f, f2, gsl_vector_get(v, i));
|
546
|
+
gsl_vector_set(vnew, i, val);
|
562
547
|
}
|
563
548
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
564
549
|
}
|
@@ -566,18 +551,14 @@ VALUE rb_gsl_sf_eval_double3(double (*func)(double, double, double),
|
|
566
551
|
}
|
567
552
|
}
|
568
553
|
|
569
|
-
VALUE rb_gsl_sf_eval_double4(double (*func)(double, double, double, double),
|
570
|
-
|
554
|
+
VALUE rb_gsl_sf_eval_double4(double (*func)(double, double, double, double),
|
555
|
+
VALUE ff, VALUE ff2, VALUE ff3, VALUE argv)
|
571
556
|
{
|
572
557
|
gsl_vector *v = NULL, *vnew = NULL;
|
573
558
|
gsl_matrix *m = NULL, *mnew = NULL;
|
574
559
|
VALUE ary, xx;
|
575
560
|
size_t i, k, n;
|
576
561
|
double val, f, f2, f3;
|
577
|
-
#ifdef HAVE_NARRAY_H
|
578
|
-
double *ptr1, *ptr2;
|
579
|
-
struct NARRAY *na;
|
580
|
-
#endif
|
581
562
|
Need_Float(ff); Need_Float(ff2); Need_Float(ff3);
|
582
563
|
f = NUM2DBL(ff);
|
583
564
|
f2 = NUM2DBL(ff2);
|
@@ -603,6 +584,8 @@ VALUE rb_gsl_sf_eval_double4(double (*func)(double, double, double, double),
|
|
603
584
|
default:
|
604
585
|
#ifdef HAVE_NARRAY_H
|
605
586
|
if (NA_IsNArray(argv)) {
|
587
|
+
double *ptr1, *ptr2;
|
588
|
+
struct NARRAY *na;
|
606
589
|
argv = na_change_type(argv, NA_DFLOAT);
|
607
590
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
608
591
|
GetNArray(argv, na);
|
@@ -617,10 +600,10 @@ VALUE rb_gsl_sf_eval_double4(double (*func)(double, double, double, double),
|
|
617
600
|
Data_Get_Struct(argv, gsl_matrix, m);
|
618
601
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
619
602
|
for (i = 0; i < m->size1; i++) {
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
603
|
+
for (k = 0; k < m->size2; k++) {
|
604
|
+
val = (*func)(f, f2, f3, gsl_matrix_get(m, i, k));
|
605
|
+
gsl_matrix_set(mnew, i, k, val);
|
606
|
+
}
|
624
607
|
}
|
625
608
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
626
609
|
} else {
|
@@ -629,8 +612,8 @@ VALUE rb_gsl_sf_eval_double4(double (*func)(double, double, double, double),
|
|
629
612
|
n = v->size;
|
630
613
|
vnew = gsl_vector_alloc(n);
|
631
614
|
for (i = 0; i < n; i++) {
|
632
|
-
|
633
|
-
|
615
|
+
val = (*func)(f, f2, f3, gsl_vector_get(v, i));
|
616
|
+
gsl_vector_set(vnew, i, val);
|
634
617
|
}
|
635
618
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
636
619
|
}
|
@@ -645,10 +628,6 @@ VALUE rb_gsl_sf_eval1_int(double (*func)(int), VALUE argv)
|
|
645
628
|
VALUE ary;
|
646
629
|
size_t i, k, n;
|
647
630
|
double val;
|
648
|
-
#ifdef HAVE_NARRAY_H
|
649
|
-
double *ptr1, *ptr2;
|
650
|
-
struct NARRAY *na;
|
651
|
-
#endif
|
652
631
|
if (CLASS_OF(argv) == rb_cRange) argv = rb_gsl_range2ary(argv);
|
653
632
|
switch (TYPE(argv)) {
|
654
633
|
case T_FIXNUM:
|
@@ -668,6 +647,8 @@ VALUE rb_gsl_sf_eval1_int(double (*func)(int), VALUE argv)
|
|
668
647
|
default:
|
669
648
|
#ifdef HAVE_NARRAY_H
|
670
649
|
if (NA_IsNArray(argv)) {
|
650
|
+
double *ptr1, *ptr2;
|
651
|
+
struct NARRAY *na;
|
671
652
|
argv = na_change_type(argv, NA_DFLOAT);
|
672
653
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
673
654
|
GetNArray(argv, na);
|
@@ -682,10 +663,10 @@ VALUE rb_gsl_sf_eval1_int(double (*func)(int), VALUE argv)
|
|
682
663
|
Data_Get_Struct(argv, gsl_matrix, m);
|
683
664
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
684
665
|
for (i = 0; i < m->size1; i++) {
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
666
|
+
for (k = 0; k < m->size2; k++) {
|
667
|
+
val = (*func)((int) gsl_matrix_get(m, i, k));
|
668
|
+
gsl_matrix_set(mnew, i, k, val);
|
669
|
+
}
|
689
670
|
}
|
690
671
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
691
672
|
} else {
|
@@ -694,8 +675,8 @@ VALUE rb_gsl_sf_eval1_int(double (*func)(int), VALUE argv)
|
|
694
675
|
n = v->size;
|
695
676
|
vnew = gsl_vector_alloc(n);
|
696
677
|
for (i = 0; i < n; i++) {
|
697
|
-
|
698
|
-
|
678
|
+
val = (*func)((int) gsl_vector_get(v, i));
|
679
|
+
gsl_vector_set(vnew, i, val);
|
699
680
|
}
|
700
681
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
701
682
|
}
|
@@ -710,10 +691,6 @@ VALUE rb_gsl_sf_eval1_uint(double (*func)(unsigned int), VALUE argv)
|
|
710
691
|
VALUE ary;
|
711
692
|
size_t i, k, n;
|
712
693
|
double val;
|
713
|
-
#ifdef HAVE_NARRAY_H
|
714
|
-
double *ptr1, *ptr2;
|
715
|
-
struct NARRAY *na;
|
716
|
-
#endif
|
717
694
|
if (CLASS_OF(argv) == rb_cRange) argv = rb_gsl_range2ary(argv);
|
718
695
|
switch (TYPE(argv)) {
|
719
696
|
case T_FIXNUM:
|
@@ -733,6 +710,8 @@ VALUE rb_gsl_sf_eval1_uint(double (*func)(unsigned int), VALUE argv)
|
|
733
710
|
default:
|
734
711
|
#ifdef HAVE_NARRAY_H
|
735
712
|
if (NA_IsNArray(argv)) {
|
713
|
+
double *ptr1, *ptr2;
|
714
|
+
struct NARRAY *na;
|
736
715
|
argv = na_change_type(argv, NA_DFLOAT);
|
737
716
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
738
717
|
GetNArray(argv, na);
|
@@ -747,10 +726,10 @@ VALUE rb_gsl_sf_eval1_uint(double (*func)(unsigned int), VALUE argv)
|
|
747
726
|
Data_Get_Struct(argv, gsl_matrix, m);
|
748
727
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
749
728
|
for (i = 0; i < m->size1; i++) {
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
729
|
+
for (k = 0; k < m->size2; k++) {
|
730
|
+
val = (*func)((unsigned int) gsl_matrix_get(m, i, k));
|
731
|
+
gsl_matrix_set(mnew, i, k, val);
|
732
|
+
}
|
754
733
|
}
|
755
734
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
756
735
|
} else {
|
@@ -759,8 +738,8 @@ VALUE rb_gsl_sf_eval1_uint(double (*func)(unsigned int), VALUE argv)
|
|
759
738
|
n = v->size;
|
760
739
|
vnew = gsl_vector_alloc(n);
|
761
740
|
for (i = 0; i < n; i++) {
|
762
|
-
|
763
|
-
|
741
|
+
val = (*func)((unsigned int) gsl_vector_get(v, i));
|
742
|
+
gsl_vector_set(vnew, i, val);
|
764
743
|
}
|
765
744
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
766
745
|
}
|
@@ -777,10 +756,6 @@ VALUE rb_gsl_sf_eval_double_m(double (*func)(double, gsl_mode_t), VALUE argv, VA
|
|
777
756
|
double val;
|
778
757
|
/*gsl_mode_t mode;
|
779
758
|
char c;*/
|
780
|
-
#ifdef HAVE_NARRAY_H
|
781
|
-
double *ptr1, *ptr2;
|
782
|
-
struct NARRAY *na;
|
783
|
-
#endif
|
784
759
|
switch (TYPE(m)) {
|
785
760
|
case T_STRING:
|
786
761
|
/*c = tolower(NUM2CHR(m));
|
@@ -794,7 +769,7 @@ VALUE rb_gsl_sf_eval_double_m(double (*func)(double, gsl_mode_t), VALUE argv, VA
|
|
794
769
|
break;
|
795
770
|
default:
|
796
771
|
rb_raise(rb_eArgError, "wrong type argument %s (String or Fixnum expected)",
|
797
|
-
|
772
|
+
rb_class2name(CLASS_OF(m)));
|
798
773
|
}
|
799
774
|
if (CLASS_OF(argv) == rb_cRange) argv = rb_gsl_range2ary(argv);
|
800
775
|
switch (TYPE(argv)) {
|
@@ -817,6 +792,8 @@ VALUE rb_gsl_sf_eval_double_m(double (*func)(double, gsl_mode_t), VALUE argv, VA
|
|
817
792
|
default:
|
818
793
|
#ifdef HAVE_NARRAY_H
|
819
794
|
if (NA_IsNArray(argv)) {
|
795
|
+
double *ptr1, *ptr2;
|
796
|
+
struct NARRAY *na;
|
820
797
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
821
798
|
GetNArray(argv, na);
|
822
799
|
n = na->total;
|
@@ -830,10 +807,10 @@ VALUE rb_gsl_sf_eval_double_m(double (*func)(double, gsl_mode_t), VALUE argv, VA
|
|
830
807
|
Data_Get_Struct(argv, gsl_matrix, mm);
|
831
808
|
mnew = gsl_matrix_alloc(mm->size1, mm->size2);
|
832
809
|
for (i = 0; i < mm->size1; i++) {
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
810
|
+
for (k = 0; k < mm->size2; k++) {
|
811
|
+
val = (*func)(gsl_matrix_get(mm, i, k), m);
|
812
|
+
gsl_matrix_set(mnew, i, k, val);
|
813
|
+
}
|
837
814
|
}
|
838
815
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
839
816
|
} else {
|
@@ -842,8 +819,8 @@ VALUE rb_gsl_sf_eval_double_m(double (*func)(double, gsl_mode_t), VALUE argv, VA
|
|
842
819
|
n = v->size;
|
843
820
|
vnew = gsl_vector_alloc(n);
|
844
821
|
for (i = 0; i < n; i++) {
|
845
|
-
|
846
|
-
|
822
|
+
val = (*func)(gsl_vector_get(v, i), m);
|
823
|
+
gsl_vector_set(vnew, i, val);
|
847
824
|
}
|
848
825
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
849
826
|
}
|
@@ -851,8 +828,8 @@ VALUE rb_gsl_sf_eval_double_m(double (*func)(double, gsl_mode_t), VALUE argv, VA
|
|
851
828
|
}
|
852
829
|
}
|
853
830
|
|
854
|
-
VALUE rb_gsl_sf_eval_double2_m(double (*func)(double, double, gsl_mode_t),
|
855
|
-
|
831
|
+
VALUE rb_gsl_sf_eval_double2_m(double (*func)(double, double, gsl_mode_t),
|
832
|
+
VALUE argv, VALUE x2, VALUE m)
|
856
833
|
{
|
857
834
|
gsl_vector *v = NULL, *vnew = NULL;
|
858
835
|
gsl_matrix *mm = NULL, *mnew = NULL;
|
@@ -861,10 +838,6 @@ VALUE rb_gsl_sf_eval_double2_m(double (*func)(double, double, gsl_mode_t),
|
|
861
838
|
double val, xx2;
|
862
839
|
/*gsl_mode_t mode;
|
863
840
|
char c;*/
|
864
|
-
#ifdef HAVE_NARRAY_H
|
865
|
-
double *ptr1, *ptr2;
|
866
|
-
struct NARRAY *na;
|
867
|
-
#endif
|
868
841
|
Need_Float(x2);
|
869
842
|
xx2 = NUM2DBL(x2);
|
870
843
|
/*c = tolower(NUM2CHR(m));
|
@@ -893,6 +866,8 @@ VALUE rb_gsl_sf_eval_double2_m(double (*func)(double, double, gsl_mode_t),
|
|
893
866
|
default:
|
894
867
|
#ifdef HAVE_NARRAY_H
|
895
868
|
if (NA_IsNArray(argv)) {
|
869
|
+
double *ptr1, *ptr2;
|
870
|
+
struct NARRAY *na;
|
896
871
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
897
872
|
GetNArray(argv, na);
|
898
873
|
n = na->total;
|
@@ -906,10 +881,10 @@ VALUE rb_gsl_sf_eval_double2_m(double (*func)(double, double, gsl_mode_t),
|
|
906
881
|
Data_Get_Struct(argv, gsl_matrix, mm);
|
907
882
|
mnew = gsl_matrix_alloc(mm->size1, mm->size2);
|
908
883
|
for (i = 0; i < mm->size1; i++) {
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
884
|
+
for (k = 0; k < mm->size2; k++) {
|
885
|
+
val = (*func)(gsl_matrix_get(mm, i, k), xx2, m);
|
886
|
+
gsl_matrix_set(mnew, i, k, val);
|
887
|
+
}
|
913
888
|
}
|
914
889
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
915
890
|
} else {
|
@@ -918,8 +893,8 @@ VALUE rb_gsl_sf_eval_double2_m(double (*func)(double, double, gsl_mode_t),
|
|
918
893
|
n = v->size;
|
919
894
|
vnew = gsl_vector_alloc(n);
|
920
895
|
for (i = 0; i < n; i++) {
|
921
|
-
|
922
|
-
|
896
|
+
val = (*func)(gsl_vector_get(v, i), xx2, m);
|
897
|
+
gsl_vector_set(vnew, i, val);
|
923
898
|
}
|
924
899
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
925
900
|
}
|
@@ -927,8 +902,8 @@ VALUE rb_gsl_sf_eval_double2_m(double (*func)(double, double, gsl_mode_t),
|
|
927
902
|
}
|
928
903
|
}
|
929
904
|
|
930
|
-
VALUE rb_gsl_sf_eval_double3_m(double (*func)(double, double, double, gsl_mode_t),
|
931
|
-
|
905
|
+
VALUE rb_gsl_sf_eval_double3_m(double (*func)(double, double, double, gsl_mode_t),
|
906
|
+
VALUE argv, VALUE x2, VALUE x3, VALUE m)
|
932
907
|
{
|
933
908
|
gsl_vector *v = NULL, *vnew = NULL;
|
934
909
|
gsl_matrix *mm = NULL, *mnew = NULL;
|
@@ -937,10 +912,6 @@ VALUE rb_gsl_sf_eval_double3_m(double (*func)(double, double, double, gsl_mode_t
|
|
937
912
|
double val, xx2, xx3;
|
938
913
|
/*gsl_mode_t mode;
|
939
914
|
char c;*/
|
940
|
-
#ifdef HAVE_NARRAY_H
|
941
|
-
double *ptr1, *ptr2;
|
942
|
-
struct NARRAY *na;
|
943
|
-
#endif
|
944
915
|
Need_Float(x2); Need_Float(x3);
|
945
916
|
xx2 = NUM2DBL(x2);
|
946
917
|
xx3 = NUM2DBL(x3);
|
@@ -970,6 +941,8 @@ VALUE rb_gsl_sf_eval_double3_m(double (*func)(double, double, double, gsl_mode_t
|
|
970
941
|
default:
|
971
942
|
#ifdef HAVE_NARRAY_H
|
972
943
|
if (NA_IsNArray(argv)) {
|
944
|
+
double *ptr1, *ptr2;
|
945
|
+
struct NARRAY *na;
|
973
946
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
974
947
|
GetNArray(argv, na);
|
975
948
|
n = na->total;
|
@@ -983,10 +956,10 @@ VALUE rb_gsl_sf_eval_double3_m(double (*func)(double, double, double, gsl_mode_t
|
|
983
956
|
Data_Get_Struct(argv, gsl_matrix, mm);
|
984
957
|
mnew = gsl_matrix_alloc(mm->size1, mm->size2);
|
985
958
|
for (i = 0; i < mm->size1; i++) {
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
959
|
+
for (k = 0; k < mm->size2; k++) {
|
960
|
+
val = (*func)(gsl_matrix_get(mm, i, k), xx2, xx3, m);
|
961
|
+
gsl_matrix_set(mnew, i, k, val);
|
962
|
+
}
|
990
963
|
}
|
991
964
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
992
965
|
} else {
|
@@ -995,8 +968,8 @@ VALUE rb_gsl_sf_eval_double3_m(double (*func)(double, double, double, gsl_mode_t
|
|
995
968
|
n = v->size;
|
996
969
|
vnew = gsl_vector_alloc(n);
|
997
970
|
for (i = 0; i < n; i++) {
|
998
|
-
|
999
|
-
|
971
|
+
val = (*func)(gsl_vector_get(v, i), xx2, xx3, m);
|
972
|
+
gsl_vector_set(vnew, i, val);
|
1000
973
|
}
|
1001
974
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
1002
975
|
}
|
@@ -1005,8 +978,8 @@ VALUE rb_gsl_sf_eval_double3_m(double (*func)(double, double, double, gsl_mode_t
|
|
1005
978
|
}
|
1006
979
|
|
1007
980
|
VALUE rb_gsl_sf_eval_double4_m(double (*func)(double, double, double, double,
|
1008
|
-
|
1009
|
-
|
981
|
+
gsl_mode_t),
|
982
|
+
VALUE argv, VALUE x2, VALUE x3, VALUE x4, VALUE m)
|
1010
983
|
{
|
1011
984
|
gsl_vector *v = NULL, *vnew = NULL;
|
1012
985
|
gsl_matrix *mm = NULL, *mnew = NULL;
|
@@ -1015,10 +988,6 @@ VALUE rb_gsl_sf_eval_double4_m(double (*func)(double, double, double, double,
|
|
1015
988
|
double val, xx2, xx3, xx4;
|
1016
989
|
/*gsl_mode_t mode;
|
1017
990
|
char c;*/
|
1018
|
-
#ifdef HAVE_NARRAY_H
|
1019
|
-
double *ptr1, *ptr2;
|
1020
|
-
struct NARRAY *na;
|
1021
|
-
#endif
|
1022
991
|
Need_Float(x2); Need_Float(x3); Need_Float(x4);
|
1023
992
|
xx2 = NUM2DBL(x2); xx3 = NUM2DBL(x3); xx4 = NUM2DBL(x4);
|
1024
993
|
/*c = tolower(NUM2CHR(m));
|
@@ -1032,7 +1001,7 @@ VALUE rb_gsl_sf_eval_double4_m(double (*func)(double, double, double, double,
|
|
1032
1001
|
case T_FIXNUM:
|
1033
1002
|
case T_BIGNUM:
|
1034
1003
|
return rb_float_new((*func)(NUM2DBL(argv), NUM2DBL(x2), NUM2DBL(x3),
|
1035
|
-
|
1004
|
+
NUM2DBL(x4), m));
|
1036
1005
|
break;
|
1037
1006
|
case T_ARRAY:
|
1038
1007
|
n = RARRAY_LEN(argv);
|
@@ -1048,6 +1017,8 @@ VALUE rb_gsl_sf_eval_double4_m(double (*func)(double, double, double, double,
|
|
1048
1017
|
default:
|
1049
1018
|
#ifdef HAVE_NARRAY_H
|
1050
1019
|
if (NA_IsNArray(argv)) {
|
1020
|
+
double *ptr1, *ptr2;
|
1021
|
+
struct NARRAY *na;
|
1051
1022
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
1052
1023
|
GetNArray(argv, na);
|
1053
1024
|
n = na->total;
|
@@ -1061,10 +1032,10 @@ VALUE rb_gsl_sf_eval_double4_m(double (*func)(double, double, double, double,
|
|
1061
1032
|
Data_Get_Struct(argv, gsl_matrix, mm);
|
1062
1033
|
mnew = gsl_matrix_alloc(mm->size1, mm->size2);
|
1063
1034
|
for (i = 0; i < mm->size1; i++) {
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1035
|
+
for (k = 0; k < mm->size2; k++) {
|
1036
|
+
val = (*func)(gsl_matrix_get(mm, i, k), xx2, xx3, xx4, m);
|
1037
|
+
gsl_matrix_set(mnew, i, k, val);
|
1038
|
+
}
|
1068
1039
|
}
|
1069
1040
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
1070
1041
|
} else {
|
@@ -1073,8 +1044,8 @@ VALUE rb_gsl_sf_eval_double4_m(double (*func)(double, double, double, double,
|
|
1073
1044
|
n = v->size;
|
1074
1045
|
vnew = gsl_vector_alloc(n);
|
1075
1046
|
for (i = 0; i < n; i++) {
|
1076
|
-
|
1077
|
-
|
1047
|
+
val = (*func)(gsl_vector_get(v, i), xx2, xx3, xx4, m);
|
1048
|
+
gsl_vector_set(vnew, i, val);
|
1078
1049
|
}
|
1079
1050
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
1080
1051
|
}
|
@@ -1111,8 +1082,8 @@ VALUE rb_gsl_sf_eval_e_uint(int (*func)(unsigned int, gsl_sf_result*), VALUE x)
|
|
1111
1082
|
return v;
|
1112
1083
|
}
|
1113
1084
|
|
1114
|
-
VALUE rb_gsl_sf_eval_e_int_uint(int (*func)(int, unsigned int, gsl_sf_result*),
|
1115
|
-
|
1085
|
+
VALUE rb_gsl_sf_eval_e_int_uint(int (*func)(int, unsigned int, gsl_sf_result*),
|
1086
|
+
VALUE n, VALUE x)
|
1116
1087
|
{
|
1117
1088
|
gsl_sf_result *rslt = NULL;
|
1118
1089
|
VALUE v;
|
@@ -1122,8 +1093,8 @@ VALUE rb_gsl_sf_eval_e_int_uint(int (*func)(int, unsigned int, gsl_sf_result*),
|
|
1122
1093
|
return v;
|
1123
1094
|
}
|
1124
1095
|
|
1125
|
-
VALUE rb_gsl_sf_eval_e_double_uint(int (*func)(double, unsigned int, gsl_sf_result*),
|
1126
|
-
|
1096
|
+
VALUE rb_gsl_sf_eval_e_double_uint(int (*func)(double, unsigned int, gsl_sf_result*),
|
1097
|
+
VALUE y, VALUE x)
|
1127
1098
|
{
|
1128
1099
|
gsl_sf_result *rslt = NULL;
|
1129
1100
|
VALUE v;
|
@@ -1133,8 +1104,8 @@ VALUE rb_gsl_sf_eval_e_double_uint(int (*func)(double, unsigned int, gsl_sf_resu
|
|
1133
1104
|
return v;
|
1134
1105
|
}
|
1135
1106
|
|
1136
|
-
VALUE rb_gsl_sf_eval_e_int_double(int (*func)(int, double, gsl_sf_result*),
|
1137
|
-
|
1107
|
+
VALUE rb_gsl_sf_eval_e_int_double(int (*func)(int, double, gsl_sf_result*),
|
1108
|
+
VALUE n, VALUE x)
|
1138
1109
|
{
|
1139
1110
|
gsl_sf_result *rslt = NULL;
|
1140
1111
|
VALUE v;
|
@@ -1145,8 +1116,8 @@ VALUE rb_gsl_sf_eval_e_int_double(int (*func)(int, double, gsl_sf_result*),
|
|
1145
1116
|
return v;
|
1146
1117
|
}
|
1147
1118
|
|
1148
|
-
VALUE rb_gsl_sf_eval_e_int_double2(int (*func)(int, double, double, gsl_sf_result*),
|
1149
|
-
|
1119
|
+
VALUE rb_gsl_sf_eval_e_int_double2(int (*func)(int, double, double, gsl_sf_result*),
|
1120
|
+
VALUE n, VALUE x1, VALUE x2)
|
1150
1121
|
{
|
1151
1122
|
gsl_sf_result *rslt = NULL;
|
1152
1123
|
VALUE v;
|
@@ -1158,8 +1129,8 @@ VALUE rb_gsl_sf_eval_e_int_double2(int (*func)(int, double, double, gsl_sf_resul
|
|
1158
1129
|
}
|
1159
1130
|
|
1160
1131
|
|
1161
|
-
VALUE rb_gsl_sf_eval_e_int_int_double(int (*func)(int, int, double, gsl_sf_result*),
|
1162
|
-
|
1132
|
+
VALUE rb_gsl_sf_eval_e_int_int_double(int (*func)(int, int, double, gsl_sf_result*),
|
1133
|
+
VALUE n1, VALUE n2, VALUE x)
|
1163
1134
|
{
|
1164
1135
|
gsl_sf_result *rslt = NULL;
|
1165
1136
|
VALUE v;
|
@@ -1170,20 +1141,20 @@ VALUE rb_gsl_sf_eval_e_int_int_double(int (*func)(int, int, double, gsl_sf_resul
|
|
1170
1141
|
return v;
|
1171
1142
|
}
|
1172
1143
|
|
1173
|
-
VALUE rb_gsl_sf_eval_e_double2(int (*func)(double, double, gsl_sf_result*),
|
1174
|
-
|
1144
|
+
VALUE rb_gsl_sf_eval_e_double2(int (*func)(double, double, gsl_sf_result*),
|
1145
|
+
VALUE x1, VALUE x2)
|
1175
1146
|
{
|
1176
1147
|
gsl_sf_result *rslt = NULL;
|
1177
1148
|
VALUE v;
|
1178
|
-
Need_Float(x1); Need_Float(x2);
|
1149
|
+
Need_Float(x1); Need_Float(x2);
|
1179
1150
|
v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt);
|
1180
1151
|
(*func)(NUM2DBL(x1), NUM2DBL(x2), rslt);
|
1181
1152
|
return v;
|
1182
1153
|
}
|
1183
1154
|
|
1184
1155
|
|
1185
|
-
VALUE rb_gsl_sf_eval_e_double3(int (*func)(double, double, double, gsl_sf_result*),
|
1186
|
-
|
1156
|
+
VALUE rb_gsl_sf_eval_e_double3(int (*func)(double, double, double, gsl_sf_result*),
|
1157
|
+
VALUE x1, VALUE x2, VALUE x3)
|
1187
1158
|
{
|
1188
1159
|
gsl_sf_result *rslt = NULL;
|
1189
1160
|
VALUE v;
|
@@ -1193,8 +1164,8 @@ VALUE rb_gsl_sf_eval_e_double3(int (*func)(double, double, double, gsl_sf_result
|
|
1193
1164
|
return v;
|
1194
1165
|
}
|
1195
1166
|
|
1196
|
-
VALUE rb_gsl_sf_eval_e_m(int (*func)(double, gsl_mode_t, gsl_sf_result*),
|
1197
|
-
|
1167
|
+
VALUE rb_gsl_sf_eval_e_m(int (*func)(double, gsl_mode_t, gsl_sf_result*),
|
1168
|
+
VALUE x, VALUE m)
|
1198
1169
|
{
|
1199
1170
|
gsl_mode_t mode;
|
1200
1171
|
char c;
|
@@ -1214,7 +1185,7 @@ VALUE rb_gsl_sf_eval_e_m(int (*func)(double, gsl_mode_t, gsl_sf_result*),
|
|
1214
1185
|
break;
|
1215
1186
|
default:
|
1216
1187
|
rb_raise(rb_eArgError, "wrong type argument %s (String or Fixnum expected)",
|
1217
|
-
|
1188
|
+
rb_class2name(CLASS_OF(m)));
|
1218
1189
|
break;
|
1219
1190
|
}
|
1220
1191
|
v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt);
|
@@ -1223,8 +1194,8 @@ VALUE rb_gsl_sf_eval_e_m(int (*func)(double, gsl_mode_t, gsl_sf_result*),
|
|
1223
1194
|
}
|
1224
1195
|
|
1225
1196
|
|
1226
|
-
VALUE rb_gsl_sf_eval_e_double2_m(int (*func)(double, double, gsl_mode_t, gsl_sf_result*),
|
1227
|
-
|
1197
|
+
VALUE rb_gsl_sf_eval_e_double2_m(int (*func)(double, double, gsl_mode_t, gsl_sf_result*),
|
1198
|
+
VALUE x1, VALUE x2, VALUE m)
|
1228
1199
|
{
|
1229
1200
|
gsl_mode_t mode;
|
1230
1201
|
char c;
|
@@ -1244,7 +1215,7 @@ VALUE rb_gsl_sf_eval_e_double2_m(int (*func)(double, double, gsl_mode_t, gsl_sf_
|
|
1244
1215
|
break;
|
1245
1216
|
default:
|
1246
1217
|
rb_raise(rb_eArgError, "wrong type argument %s (String or Fixnum expected)",
|
1247
|
-
|
1218
|
+
rb_class2name(CLASS_OF(m)));
|
1248
1219
|
break;
|
1249
1220
|
}
|
1250
1221
|
v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt);
|
@@ -1252,8 +1223,8 @@ VALUE rb_gsl_sf_eval_e_double2_m(int (*func)(double, double, gsl_mode_t, gsl_sf_
|
|
1252
1223
|
return v;
|
1253
1224
|
}
|
1254
1225
|
|
1255
|
-
VALUE rb_gsl_sf_eval_e_double3_m(int (*func)(double, double, double, gsl_mode_t, gsl_sf_result*),
|
1256
|
-
|
1226
|
+
VALUE rb_gsl_sf_eval_e_double3_m(int (*func)(double, double, double, gsl_mode_t, gsl_sf_result*),
|
1227
|
+
VALUE x1, VALUE x2, VALUE x3, VALUE m)
|
1257
1228
|
{
|
1258
1229
|
gsl_mode_t mode;
|
1259
1230
|
char c;
|
@@ -1273,7 +1244,7 @@ VALUE rb_gsl_sf_eval_e_double3_m(int (*func)(double, double, double, gsl_mode_t,
|
|
1273
1244
|
break;
|
1274
1245
|
default:
|
1275
1246
|
rb_raise(rb_eArgError, "wrong type argument %s (String or Fixnum expected)",
|
1276
|
-
|
1247
|
+
rb_class2name(CLASS_OF(m)));
|
1277
1248
|
break;
|
1278
1249
|
}
|
1279
1250
|
v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt);
|
@@ -1282,8 +1253,8 @@ VALUE rb_gsl_sf_eval_e_double3_m(int (*func)(double, double, double, gsl_mode_t,
|
|
1282
1253
|
}
|
1283
1254
|
|
1284
1255
|
|
1285
|
-
VALUE rb_gsl_sf_eval_e_double4_m(int (*func)(double, double, double, double, gsl_mode_t, gsl_sf_result*),
|
1286
|
-
|
1256
|
+
VALUE rb_gsl_sf_eval_e_double4_m(int (*func)(double, double, double, double, gsl_mode_t, gsl_sf_result*),
|
1257
|
+
VALUE x1, VALUE x2, VALUE x3, VALUE x4, VALUE m)
|
1287
1258
|
{
|
1288
1259
|
gsl_mode_t mode;
|
1289
1260
|
char c;
|
@@ -1303,9 +1274,9 @@ VALUE rb_gsl_sf_eval_e_double4_m(int (*func)(double, double, double, double, gsl
|
|
1303
1274
|
break;
|
1304
1275
|
default:
|
1305
1276
|
rb_raise(rb_eArgError, "wrong type argument %s (String or Fixnum expected)",
|
1306
|
-
|
1277
|
+
rb_class2name(CLASS_OF(m)));
|
1307
1278
|
break;
|
1308
|
-
}
|
1279
|
+
}
|
1309
1280
|
v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt);
|
1310
1281
|
(*func)(NUM2DBL(x1), NUM2DBL(x2),NUM2DBL(x3), NUM2DBL(x4), mode, rslt);
|
1311
1282
|
return v;
|
@@ -1319,10 +1290,6 @@ VALUE eval_sf(double (*func)(double, gsl_mode_t), VALUE argv)
|
|
1319
1290
|
double val;
|
1320
1291
|
gsl_vector *v = NULL, *vnew = NULL;
|
1321
1292
|
gsl_matrix *mm = NULL, *mnew = NULL;
|
1322
|
-
#ifdef HAVE_NARRAY_H
|
1323
|
-
double *ptr1, *ptr2;
|
1324
|
-
struct NARRAY *na;
|
1325
|
-
#endif
|
1326
1293
|
switch (TYPE(argv)) {
|
1327
1294
|
case T_FLOAT:
|
1328
1295
|
case T_FIXNUM:
|
@@ -1343,6 +1310,8 @@ VALUE eval_sf(double (*func)(double, gsl_mode_t), VALUE argv)
|
|
1343
1310
|
default:
|
1344
1311
|
#ifdef HAVE_NARRAY_H
|
1345
1312
|
if (NA_IsNArray(argv)) {
|
1313
|
+
double *ptr1, *ptr2;
|
1314
|
+
struct NARRAY *na;
|
1346
1315
|
ptr1 = NA_PTR_TYPE(argv, double*);
|
1347
1316
|
GetNArray(argv, na);
|
1348
1317
|
n = na->total;
|
@@ -1356,10 +1325,10 @@ VALUE eval_sf(double (*func)(double, gsl_mode_t), VALUE argv)
|
|
1356
1325
|
Data_Get_Struct(argv, gsl_matrix, mm);
|
1357
1326
|
mnew = gsl_matrix_alloc(mm->size1, mm->size2);
|
1358
1327
|
for (i = 0; i < mm->size1; i++) {
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1328
|
+
for (k = 0; k < mm->size2; k++) {
|
1329
|
+
val = (*func)(gsl_matrix_get(mm, i, k), GSL_PREC_DOUBLE);
|
1330
|
+
gsl_matrix_set(mnew, i, k, val);
|
1331
|
+
}
|
1363
1332
|
}
|
1364
1333
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
1365
1334
|
} else {
|
@@ -1368,8 +1337,8 @@ VALUE eval_sf(double (*func)(double, gsl_mode_t), VALUE argv)
|
|
1368
1337
|
n = v->size;
|
1369
1338
|
vnew = gsl_vector_alloc(n);
|
1370
1339
|
for (i = 0; i < n; i++) {
|
1371
|
-
|
1372
|
-
|
1340
|
+
val = (*func)(gsl_vector_get(v, i), GSL_PREC_DOUBLE);
|
1341
|
+
gsl_vector_set(vnew, i, val);
|
1373
1342
|
}
|
1374
1343
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
1375
1344
|
}
|
@@ -1404,18 +1373,18 @@ VALUE rb_gsl_sf_eval_complex(double (*f)(double), VALUE obj)
|
|
1404
1373
|
mnew = gsl_matrix_complex_alloc(m->size1, m->size2);
|
1405
1374
|
for (i = 0; i < m->size1; i++) {
|
1406
1375
|
for (j = 0; j < m->size2; j++) {
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1376
|
+
c = gsl_matrix_complex_get(m, i, j);
|
1377
|
+
GSL_SET_REAL(&c, (*f)(GSL_REAL(c)));
|
1378
|
+
GSL_SET_IMAG(&c, (*f)(GSL_IMAG(c)));
|
1379
|
+
gsl_matrix_complex_set(mnew, i, j, c);
|
1411
1380
|
}
|
1412
1381
|
}
|
1413
1382
|
return Data_Wrap_Struct(cgsl_matrix_complex, 0, gsl_matrix_complex_free, mnew);
|
1414
1383
|
} else {
|
1415
|
-
rb_raise(rb_eTypeError,
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1384
|
+
rb_raise(rb_eTypeError,
|
1385
|
+
"wrong argument type %s "
|
1386
|
+
" (GSL::Complex or GSL::Vector::Complex expected)",
|
1387
|
+
rb_class2name(CLASS_OF(obj)));
|
1419
1388
|
}
|
1420
1389
|
}
|
1421
1390
|
|
@@ -1424,10 +1393,10 @@ void Init_gsl_sf(VALUE module)
|
|
1424
1393
|
VALUE mgsl_sf;
|
1425
1394
|
mgsl_sf = rb_define_module_under(module, "Sf");
|
1426
1395
|
|
1427
|
-
cgsl_sf_result = rb_define_class_under(mgsl_sf, "Result",
|
1428
|
-
|
1396
|
+
cgsl_sf_result = rb_define_class_under(mgsl_sf, "Result",
|
1397
|
+
cGSL_Object);
|
1429
1398
|
rb_define_singleton_method(cgsl_sf_result, "new", rb_gsl_sf_result_new,
|
1430
|
-
|
1399
|
+
0);
|
1431
1400
|
rb_define_method(cgsl_sf_result, "print", rb_gsl_sf_result_print, 0);
|
1432
1401
|
rb_define_method(cgsl_sf_result, "inspect", rb_gsl_sf_result_inspect, 0);
|
1433
1402
|
rb_define_method(cgsl_sf_result, "val", rb_gsl_sf_result_val, 0);
|
@@ -1435,10 +1404,10 @@ void Init_gsl_sf(VALUE module)
|
|
1435
1404
|
rb_define_method(cgsl_sf_result, "to_a", rb_gsl_sf_result_to_a, 0);
|
1436
1405
|
rb_define_method(cgsl_sf_result, "to_s", rb_gsl_sf_result_to_s, 0);
|
1437
1406
|
|
1438
|
-
cgsl_sf_result_e10 = rb_define_class_under(mgsl_sf, "Result_e10",
|
1439
|
-
|
1440
|
-
rb_define_singleton_method(cgsl_sf_result_e10, "new",
|
1441
|
-
|
1407
|
+
cgsl_sf_result_e10 = rb_define_class_under(mgsl_sf, "Result_e10",
|
1408
|
+
cGSL_Object);
|
1409
|
+
rb_define_singleton_method(cgsl_sf_result_e10, "new",
|
1410
|
+
rb_gsl_sf_result_e10_new, 0);
|
1442
1411
|
rb_define_method(cgsl_sf_result_e10, "val", rb_gsl_sf_result_e10_val, 0);
|
1443
1412
|
rb_define_method(cgsl_sf_result_e10, "err", rb_gsl_sf_result_e10_err, 0);
|
1444
1413
|
rb_define_method(cgsl_sf_result_e10, "e10", rb_gsl_sf_result_e10_e10, 0);
|
@@ -1473,8 +1442,5 @@ void Init_gsl_sf(VALUE module)
|
|
1473
1442
|
Init_gsl_sf_transport(mgsl_sf);
|
1474
1443
|
Init_gsl_sf_trigonometric(mgsl_sf);
|
1475
1444
|
Init_gsl_sf_zeta(mgsl_sf);
|
1476
|
-
|
1477
|
-
#ifdef GSL_1_9_LATER
|
1478
|
-
Init_sf_mathieu(mgsl_sf);
|
1479
|
-
#endif
|
1445
|
+
Init_sf_mathieu(mgsl_sf);
|
1480
1446
|
}
|