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
@@ -17,7 +17,6 @@ VALUE cgsl_histogram2d;
|
|
17
17
|
VALUE cgsl_histogram2d_view;
|
18
18
|
static VALUE cgsl_histogram2d_integ;
|
19
19
|
|
20
|
-
#ifdef GSL_0_9_4_LATER
|
21
20
|
static VALUE rb_gsl_histogram2d_alloc_uniform(int argc, VALUE *argv, VALUE klass);
|
22
21
|
static VALUE rb_gsl_histogram2d_alloc(int argc, VALUE *argv, VALUE klass)
|
23
22
|
{
|
@@ -78,7 +77,7 @@ static VALUE rb_gsl_histogram2d_alloc_uniform(int argc, VALUE *argv, VALUE klass
|
|
78
77
|
double xmin, xmax, ymin, ymax;
|
79
78
|
switch (argc) {
|
80
79
|
case 4:
|
81
|
-
CHECK_FIXNUM(argv[0]); CHECK_FIXNUM(argv[2]);
|
80
|
+
CHECK_FIXNUM(argv[0]); CHECK_FIXNUM(argv[2]);
|
82
81
|
Check_Type(argv[1], T_ARRAY); Check_Type(argv[3], T_ARRAY);
|
83
82
|
// if (RARRAY(argv[1])->len != 2 || RARRAY(argv[3])->len != 2)
|
84
83
|
if (RARRAY_LEN(argv[1]) != 2 || RARRAY_LEN(argv[3]) != 2)
|
@@ -92,13 +91,13 @@ static VALUE rb_gsl_histogram2d_alloc_uniform(int argc, VALUE *argv, VALUE klass
|
|
92
91
|
return Data_Wrap_Struct(klass, 0, gsl_histogram2d_free, h);
|
93
92
|
break;
|
94
93
|
case 6:
|
95
|
-
CHECK_FIXNUM(argv[0]);
|
94
|
+
CHECK_FIXNUM(argv[0]);
|
96
95
|
Need_Float(argv[1]); Need_Float(argv[2]);
|
97
96
|
CHECK_FIXNUM(argv[3]);
|
98
97
|
Need_Float(argv[4]); Need_Float(argv[5]);
|
99
98
|
h = gsl_histogram2d_alloc(FIX2INT(argv[0]), FIX2INT(argv[3]));
|
100
99
|
gsl_histogram2d_set_ranges_uniform(h, NUM2DBL(argv[1]), NUM2DBL(argv[2]),
|
101
|
-
|
100
|
+
NUM2DBL(argv[4]), NUM2DBL(argv[5]));
|
102
101
|
return Data_Wrap_Struct(klass, 0, gsl_histogram2d_free, h);
|
103
102
|
break;
|
104
103
|
default:
|
@@ -107,7 +106,6 @@ static VALUE rb_gsl_histogram2d_alloc_uniform(int argc, VALUE *argv, VALUE klass
|
|
107
106
|
}
|
108
107
|
return Qnil; /* never reach here */
|
109
108
|
}
|
110
|
-
#endif
|
111
109
|
|
112
110
|
static VALUE rb_gsl_histogram2d_set_ranges(int argc, VALUE *argv, VALUE obj)
|
113
111
|
{
|
@@ -205,7 +203,7 @@ static VALUE rb_gsl_histogram2d_accumulate(int argc, VALUE *argv, VALUE obj)
|
|
205
203
|
n = (size_t) GSL_MIN_INT((int) vx->size, (int) vy->size);
|
206
204
|
for (i = 0; i < n; i++)
|
207
205
|
gsl_histogram2d_accumulate(h, gsl_vector_get(vx, i), gsl_vector_get(vy, i),
|
208
|
-
|
206
|
+
weight);
|
209
207
|
} else {
|
210
208
|
gsl_histogram2d_accumulate(h, NUM2DBL(argv[0]), NUM2DBL(argv[1]), weight);
|
211
209
|
}
|
@@ -215,14 +213,14 @@ static VALUE rb_gsl_histogram2d_accumulate(int argc, VALUE *argv, VALUE obj)
|
|
215
213
|
static VALUE rb_gsl_histogram2d_accumulate2(int argc, VALUE *argv, VALUE obj)
|
216
214
|
{
|
217
215
|
gsl_histogram2d *h = NULL;
|
218
|
-
double x, y, weight=1;
|
216
|
+
double x, y, weight = 1;
|
219
217
|
switch (argc) {
|
220
218
|
case 3:
|
221
219
|
Need_Float(argv[2]);
|
222
220
|
weight = NUM2DBL(argv[2]);
|
223
|
-
|
221
|
+
/* no break */
|
224
222
|
case 2:
|
225
|
-
Need_Float(argv[0]); Need_Float(argv[1]);
|
223
|
+
Need_Float(argv[0]); Need_Float(argv[1]);
|
226
224
|
x = NUM2DBL(argv[0]); y = NUM2DBL(argv[1]);
|
227
225
|
break;
|
228
226
|
default:
|
@@ -254,13 +252,13 @@ static VALUE rb_gsl_histogram2d_get(int argc, VALUE *argv, VALUE obj)
|
|
254
252
|
switch (TYPE(argv[0])) {
|
255
253
|
case T_ARRAY:
|
256
254
|
return rb_float_new(gsl_histogram2d_get(h2, FIX2INT(rb_ary_entry(argv[0], 0)),
|
257
|
-
|
255
|
+
FIX2INT(rb_ary_entry(argv[0], 1))));
|
258
256
|
break;
|
259
257
|
case T_FIXNUM:
|
260
|
-
CHECK_FIXNUM(argv[0]);
|
258
|
+
CHECK_FIXNUM(argv[0]);
|
261
259
|
i = (size_t) FIX2INT(argv[0]);
|
262
260
|
if (i >= h2->ny)
|
263
|
-
|
261
|
+
rb_raise(rb_eIndexError, "wrong index");
|
264
262
|
h1 = ALLOC(mygsl_histogram2d_view);
|
265
263
|
h1->h.n = h2->ny;
|
266
264
|
h1->h.range = h2->yrange;
|
@@ -269,7 +267,7 @@ static VALUE rb_gsl_histogram2d_get(int argc, VALUE *argv, VALUE obj)
|
|
269
267
|
break;
|
270
268
|
default:
|
271
269
|
rb_raise(rb_eTypeError, "wrong argument type %s (Array or Fixnum expected)",
|
272
|
-
|
270
|
+
rb_class2name(CLASS_OF(argv[0])));
|
273
271
|
break;
|
274
272
|
}
|
275
273
|
break;
|
@@ -345,7 +343,7 @@ static VALUE rb_gsl_histogram2d_find(VALUE obj, VALUE x, VALUE y)
|
|
345
343
|
{
|
346
344
|
gsl_histogram2d *h = NULL;
|
347
345
|
size_t i, j;
|
348
|
-
Need_Float(x);Need_Float(y);
|
346
|
+
Need_Float(x); Need_Float(y);
|
349
347
|
Data_Get_Struct(obj, gsl_histogram2d, h);
|
350
348
|
gsl_histogram2d_find(h, NUM2DBL(x), NUM2DBL(y), &i, &j);
|
351
349
|
return rb_ary_new3(2, INT2FIX(i), INT2FIX(j));
|
@@ -383,7 +381,6 @@ static VALUE rb_gsl_histogram2d_min_bin(VALUE obj)
|
|
383
381
|
return rb_ary_new3(2, INT2FIX(i), INT2FIX(j));
|
384
382
|
}
|
385
383
|
|
386
|
-
#ifdef GSL_1_1_LATER
|
387
384
|
static VALUE rb_gsl_histogram2d_xmean(VALUE obj)
|
388
385
|
{
|
389
386
|
gsl_histogram2d *h = NULL;
|
@@ -425,7 +422,6 @@ static VALUE rb_gsl_histogram2d_sum(VALUE obj)
|
|
425
422
|
Data_Get_Struct(obj, gsl_histogram2d, h);
|
426
423
|
return rb_float_new(gsl_histogram2d_sum(h));
|
427
424
|
}
|
428
|
-
#endif
|
429
425
|
|
430
426
|
/* singleton */
|
431
427
|
static VALUE rb_gsl_histogram2d_equal_bins_p(VALUE obj, VALUE hh1, VALUE hh2)
|
@@ -611,7 +607,6 @@ static VALUE rb_gsl_histogram2d_reset(VALUE obj)
|
|
611
607
|
return obj;
|
612
608
|
}
|
613
609
|
|
614
|
-
#ifdef GSL_0_9_4_LATER
|
615
610
|
static VALUE rb_gsl_histogram2d_pdf_alloc(VALUE klass, VALUE nx, VALUE ny)
|
616
611
|
{
|
617
612
|
gsl_histogram2d_pdf *h = NULL;
|
@@ -630,17 +625,6 @@ static VALUE rb_gsl_histogram2d_pdf_init(VALUE obj, VALUE hh)
|
|
630
625
|
gsl_histogram2d_pdf_init(pdf, h);
|
631
626
|
return obj;
|
632
627
|
}
|
633
|
-
#else
|
634
|
-
static VALUE rb_gsl_histogram2d_pdf_alloc(VALUE klass, VALUE hhh)
|
635
|
-
{
|
636
|
-
gsl_histogram2d_pdf *h = NULL;
|
637
|
-
gsl_histogram2d *hh;
|
638
|
-
Data_Get_Struct(hhh, gsl_histogram2d, hh);
|
639
|
-
h = gsl_histogram2d_pdf_alloc(hh);
|
640
|
-
return Data_Wrap_Struct(klass, 0, gsl_histogram2d_pdf_free, h);
|
641
|
-
}
|
642
|
-
|
643
|
-
#endif
|
644
628
|
|
645
629
|
static VALUE rb_gsl_histogram2d_pdf_sample(VALUE obj, VALUE r1, VALUE r2)
|
646
630
|
{
|
@@ -689,7 +673,7 @@ static VALUE rb_gsl_histogram2d_bin(VALUE obj)
|
|
689
673
|
}
|
690
674
|
|
691
675
|
void mygsl_histogram2d_yproject(const gsl_histogram2d *h2, size_t istart,
|
692
|
-
|
676
|
+
size_t iend, gsl_histogram *h)
|
693
677
|
{
|
694
678
|
size_t i, j;
|
695
679
|
double sum;
|
@@ -704,7 +688,7 @@ void mygsl_histogram2d_yproject(const gsl_histogram2d *h2, size_t istart,
|
|
704
688
|
}
|
705
689
|
|
706
690
|
gsl_histogram* mygsl_histogram2d_calloc_yproject(const gsl_histogram2d *h2,
|
707
|
-
|
691
|
+
size_t istart, size_t iend)
|
708
692
|
{
|
709
693
|
gsl_histogram *h;
|
710
694
|
h = gsl_histogram_calloc_range(h2->ny, h2->yrange);
|
@@ -713,7 +697,7 @@ gsl_histogram* mygsl_histogram2d_calloc_yproject(const gsl_histogram2d *h2,
|
|
713
697
|
}
|
714
698
|
|
715
699
|
void mygsl_histogram2d_xproject(const gsl_histogram2d *h2, size_t jstart,
|
716
|
-
|
700
|
+
size_t jend, gsl_histogram *h)
|
717
701
|
{
|
718
702
|
size_t i, j;
|
719
703
|
double sum;
|
@@ -728,7 +712,7 @@ void mygsl_histogram2d_xproject(const gsl_histogram2d *h2, size_t jstart,
|
|
728
712
|
}
|
729
713
|
|
730
714
|
gsl_histogram* mygsl_histogram2d_calloc_xproject(const gsl_histogram2d *h2,
|
731
|
-
|
715
|
+
size_t jstart, size_t jend)
|
732
716
|
{
|
733
717
|
gsl_histogram *h;
|
734
718
|
h = gsl_histogram_calloc_range(h2->nx, h2->xrange);
|
@@ -789,35 +773,35 @@ static VALUE rb_gsl_histogram2d_yproject(int argc, VALUE *argv, VALUE obj)
|
|
789
773
|
}
|
790
774
|
|
791
775
|
static int mygsl_histogram2d_fread2(FILE * stream, gsl_histogram2d * h)
|
792
|
-
{
|
776
|
+
{
|
793
777
|
double xmin, xmax, ymin, ymax;
|
794
778
|
int status;
|
795
779
|
status = gsl_block_raw_fread(stream, &xmin, 1, 1);
|
796
|
-
if (status) return status;
|
780
|
+
if (status) return status;
|
797
781
|
status = gsl_block_raw_fread(stream, &xmax, 1, 1);
|
798
|
-
if (status) return status;
|
782
|
+
if (status) return status;
|
799
783
|
status = gsl_block_raw_fread(stream, &ymin, 1, 1);
|
800
|
-
if (status) return status;
|
784
|
+
if (status) return status;
|
801
785
|
status = gsl_block_raw_fread(stream, &ymax, 1, 1);
|
802
|
-
if (status) return status;
|
786
|
+
if (status) return status;
|
803
787
|
gsl_histogram2d_set_ranges_uniform(h, xmin, xmax, ymin, ymax);
|
804
|
-
status = gsl_block_raw_fread (stream, h->bin, h->nx*h->ny, 1);
|
805
|
-
if (status) return status;
|
788
|
+
status = gsl_block_raw_fread (stream, h->bin, h->nx*h->ny, 1);
|
789
|
+
if (status) return status;
|
806
790
|
return status;
|
807
791
|
}
|
808
792
|
|
809
793
|
static int mygsl_histogram2d_fwrite2(FILE * stream, const gsl_histogram2d * h)
|
810
|
-
{
|
794
|
+
{
|
811
795
|
int status;
|
812
796
|
status = gsl_block_raw_fwrite (stream, h->xrange, 1, 1);
|
813
|
-
if (status) return status;
|
797
|
+
if (status) return status;
|
814
798
|
status = gsl_block_raw_fwrite (stream, h->xrange+h->nx, 1, 1);
|
815
|
-
if (status) return status;
|
799
|
+
if (status) return status;
|
816
800
|
status = gsl_block_raw_fwrite (stream, h->yrange, 1, 1);
|
817
|
-
if (status) return status;
|
801
|
+
if (status) return status;
|
818
802
|
status = gsl_block_raw_fwrite (stream, h->yrange+h->ny, 1, 1);
|
819
|
-
if (status) return status;
|
820
|
-
status = gsl_block_raw_fwrite (stream, h->bin, h->nx*h->ny, 1);
|
803
|
+
if (status) return status;
|
804
|
+
status = gsl_block_raw_fwrite (stream, h->bin, h->nx*h->ny, 1);
|
821
805
|
return status;
|
822
806
|
}
|
823
807
|
|
@@ -846,7 +830,7 @@ static VALUE rb_gsl_histogram2d_fread2(VALUE obj, VALUE io)
|
|
846
830
|
}
|
847
831
|
|
848
832
|
static gsl_histogram2d* mygsl_histogram2d_calloc_integrate(const gsl_histogram2d *h,
|
849
|
-
|
833
|
+
int flag)
|
850
834
|
{
|
851
835
|
gsl_histogram2d *hi;
|
852
836
|
size_t i, j, k;
|
@@ -867,26 +851,26 @@ static gsl_histogram2d* mygsl_histogram2d_calloc_integrate(const gsl_histogram2d
|
|
867
851
|
}
|
868
852
|
for (i = nx-2;; i--) {
|
869
853
|
for (j = ny-2;; j--) {
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
854
|
+
hi->bin[i*ny+j] = ((gsl_histogram2d_get(hi, i+1, j)
|
855
|
+
+ gsl_histogram2d_get(hi, i, j+1))
|
856
|
+
- gsl_histogram2d_get(hi, i+1, j+1))
|
857
|
+
+ gsl_histogram2d_get(h, i, j);
|
858
|
+
if (j == 0) break;
|
875
859
|
}
|
876
860
|
if (i == 0) break;
|
877
861
|
}
|
878
862
|
} else {
|
879
863
|
hi->bin[0] = h->bin[0];
|
880
|
-
for (j = 1; j < ny; j++) hi->bin[j] = gsl_histogram2d_get(hi, 0, j-1)
|
881
|
-
|
864
|
+
for (j = 1; j < ny; j++) hi->bin[j] = gsl_histogram2d_get(hi, 0, j-1)
|
865
|
+
+ gsl_histogram2d_get(h, 0, j);
|
882
866
|
for (i = 1; i < nx; i++) hi->bin[i*ny] = gsl_histogram2d_get(hi, i-1, 0)
|
883
|
-
|
867
|
+
+ gsl_histogram2d_get(h, i, 0);
|
884
868
|
for (i = 1; i < nx; i++) {
|
885
869
|
for (j = 1; j < ny; j++) {
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
870
|
+
hi->bin[i*ny+j] = ((gsl_histogram2d_get(hi, i-1, j)
|
871
|
+
+ gsl_histogram2d_get(hi, i, j-1))
|
872
|
+
- gsl_histogram2d_get(hi, i-1, j-1))
|
873
|
+
+ gsl_histogram2d_get(h, i, j);
|
890
874
|
}
|
891
875
|
}
|
892
876
|
}
|
@@ -940,40 +924,39 @@ void Init_gsl_histogram2d(VALUE module)
|
|
940
924
|
|
941
925
|
cgsl_histogram2d = rb_define_class_under(module, "Histogram2d", cGSL_Object);
|
942
926
|
cgsl_histogram2d_view = rb_define_class_under(cgsl_histogram2d, "View",
|
943
|
-
|
927
|
+
cgsl_histogram);
|
928
|
+
|
929
|
+
cgsl_histogram2d_integ = rb_define_class_under(cgsl_histogram2d, "Integral",
|
930
|
+
cgsl_histogram2d);
|
944
931
|
|
945
|
-
cgsl_histogram2d_integ = rb_define_class_under(cgsl_histogram2d, "Integral",
|
946
|
-
cgsl_histogram2d);
|
947
|
-
#ifdef GSL_0_9_4_LATER
|
948
932
|
/* rb_define_singleton_method(cgsl_histogram2d, "new", rb_gsl_histogram2d_alloc, -1);*/
|
949
933
|
rb_define_singleton_method(cgsl_histogram2d, "alloc", rb_gsl_histogram2d_alloc, -1);
|
950
|
-
rb_define_singleton_method(cgsl_histogram2d, "new_uniform",
|
951
|
-
|
952
|
-
rb_define_singleton_method(cgsl_histogram2d, "alloc_uniform",
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
rb_gsl_histogram2d_memcpy, 2);
|
934
|
+
rb_define_singleton_method(cgsl_histogram2d, "new_uniform",
|
935
|
+
rb_gsl_histogram2d_alloc_uniform, -1);
|
936
|
+
rb_define_singleton_method(cgsl_histogram2d, "alloc_uniform",
|
937
|
+
rb_gsl_histogram2d_alloc_uniform, -1);
|
938
|
+
|
939
|
+
rb_define_singleton_method(cgsl_histogram2d, "equal_bins_p",
|
940
|
+
rb_gsl_histogram2d_equal_bins_p, 2);
|
941
|
+
rb_define_singleton_method(cgsl_histogram2d, "equal_bins_p?",
|
942
|
+
rb_gsl_histogram2d_equal_bins_p2, 2);
|
943
|
+
|
944
|
+
rb_define_method(cgsl_histogram2d, "set_ranges",
|
945
|
+
rb_gsl_histogram2d_set_ranges, -1);
|
946
|
+
rb_define_method(cgsl_histogram2d, "set_ranges_uniform",
|
947
|
+
rb_gsl_histogram2d_set_ranges_uniform, -1);
|
948
|
+
|
949
|
+
rb_define_singleton_method(cgsl_histogram2d, "memcpy",
|
950
|
+
rb_gsl_histogram2d_memcpy, 2);
|
968
951
|
rb_define_method(cgsl_histogram2d, "clone", rb_gsl_histogram2d_clone, 0);
|
969
952
|
rb_define_alias(cgsl_histogram2d, "duplicate", "clone");
|
970
|
-
rb_define_method(cgsl_histogram2d, "increment",
|
971
|
-
|
953
|
+
rb_define_method(cgsl_histogram2d, "increment",
|
954
|
+
rb_gsl_histogram2d_accumulate, -1);
|
972
955
|
rb_define_alias(cgsl_histogram2d, "fill", "increment");
|
973
956
|
rb_define_alias(cgsl_histogram2d, "accumulate", "increment");
|
974
957
|
|
975
|
-
rb_define_method(cgsl_histogram2d, "increment2",
|
976
|
-
|
958
|
+
rb_define_method(cgsl_histogram2d, "increment2",
|
959
|
+
rb_gsl_histogram2d_accumulate2, -1);
|
977
960
|
rb_define_alias(cgsl_histogram2d, "accumulate2", "increment2");
|
978
961
|
rb_define_alias(cgsl_histogram2d, "fill2", "increment2");
|
979
962
|
|
@@ -996,7 +979,6 @@ void Init_gsl_histogram2d(VALUE module)
|
|
996
979
|
rb_define_method(cgsl_histogram2d, "min_val", rb_gsl_histogram2d_min_val, 0);
|
997
980
|
rb_define_method(cgsl_histogram2d, "min_bin", rb_gsl_histogram2d_min_bin, 0);
|
998
981
|
|
999
|
-
#ifdef GSL_1_1_LATER
|
1000
982
|
rb_define_method(cgsl_histogram2d, "xmean", rb_gsl_histogram2d_xmean, 0);
|
1001
983
|
rb_define_method(cgsl_histogram2d, "ymean", rb_gsl_histogram2d_ymean, 0);
|
1002
984
|
rb_define_method(cgsl_histogram2d, "xsigma", rb_gsl_histogram2d_xsigma, 0);
|
@@ -1004,7 +986,6 @@ void Init_gsl_histogram2d(VALUE module)
|
|
1004
986
|
rb_define_method(cgsl_histogram2d, "cov", rb_gsl_histogram2d_cov, 0);
|
1005
987
|
rb_define_method(cgsl_histogram2d, "sum", rb_gsl_histogram2d_sum, 0);
|
1006
988
|
rb_define_alias(cgsl_histogram2d, "integral", "sum");
|
1007
|
-
#endif
|
1008
989
|
|
1009
990
|
rb_define_method(cgsl_histogram2d, "add", rb_gsl_histogram2d_add, 1);
|
1010
991
|
rb_define_alias(cgsl_histogram2d, "+", "add");
|
@@ -1028,18 +1009,12 @@ void Init_gsl_histogram2d(VALUE module)
|
|
1028
1009
|
rb_define_method(cgsl_histogram2d, "fscanf", rb_gsl_histogram2d_fscanf, 3);
|
1029
1010
|
|
1030
1011
|
cgsl_histogram2d_pdf = rb_define_class_under(cgsl_histogram2d, "Pdf", cGSL_Object);
|
1031
|
-
|
1032
|
-
/* rb_define_singleton_method(cgsl_histogram2d_pdf, "new",
|
1012
|
+
|
1013
|
+
/* rb_define_singleton_method(cgsl_histogram2d_pdf, "new",
|
1033
1014
|
rb_gsl_histogram2d_pdf_alloc, 2);*/
|
1034
|
-
rb_define_singleton_method(cgsl_histogram2d_pdf, "alloc",
|
1035
|
-
|
1015
|
+
rb_define_singleton_method(cgsl_histogram2d_pdf, "alloc",
|
1016
|
+
rb_gsl_histogram2d_pdf_alloc, 2);
|
1036
1017
|
rb_define_method(cgsl_histogram2d_pdf, "init", rb_gsl_histogram2d_pdf_init, 1);
|
1037
|
-
#else
|
1038
|
-
/* rb_define_singleton_method(cgsl_histogram2d_pdf, "new",
|
1039
|
-
rb_gsl_histogram2d_pdf_alloc, 1);*/
|
1040
|
-
rb_define_singleton_method(cgsl_histogram2d_pdf, "alloc",
|
1041
|
-
rb_gsl_histogram2d_pdf_alloc, 1);
|
1042
|
-
#endif
|
1043
1018
|
|
1044
1019
|
rb_define_method(cgsl_histogram2d_pdf, "sample", rb_gsl_histogram2d_pdf_sample, 2);
|
1045
1020
|
|
@@ -24,27 +24,27 @@ static VALUE rb_gsl_histogram3d_new(int argc, VALUE *argv, VALUE klass)
|
|
24
24
|
size_t nx, ny, nz;
|
25
25
|
switch (argc) {
|
26
26
|
case 3:
|
27
|
-
if (TYPE(argv[0]) == T_FIXNUM
|
28
|
-
|
29
|
-
h = mygsl_histogram3d_alloc(FIX2INT(argv[0]),
|
30
|
-
|
27
|
+
if (TYPE(argv[0]) == T_FIXNUM
|
28
|
+
&& TYPE(argv[1]) == T_FIXNUM && TYPE(argv[2]) == T_FIXNUM) {
|
29
|
+
h = mygsl_histogram3d_alloc(FIX2INT(argv[0]),
|
30
|
+
FIX2INT(argv[1]), FIX2INT(argv[2]));
|
31
31
|
} else if (VECTOR_P(argv[0]) && VECTOR_P(argv[1]) && VECTOR_P(argv[2])) {
|
32
32
|
Data_Get_Struct(argv[0], gsl_vector, xrange);
|
33
33
|
Data_Get_Struct(argv[1], gsl_vector, yrange);
|
34
34
|
Data_Get_Struct(argv[2], gsl_vector, zrange);
|
35
35
|
h = mygsl_histogram3d_alloc(xrange->size-1, yrange->size-1, zrange->size-1);
|
36
36
|
mygsl_histogram3d_set_ranges(h, xrange->data, xrange->size,
|
37
|
-
|
38
|
-
|
39
|
-
} else if (TYPE(argv[0]) == T_ARRAY
|
40
|
-
|
37
|
+
yrange->data, yrange->size,
|
38
|
+
zrange->data, zrange->size);
|
39
|
+
} else if (TYPE(argv[0]) == T_ARRAY
|
40
|
+
&& TYPE(argv[1]) == T_ARRAY && TYPE(argv[2]) == T_ARRAY) {
|
41
41
|
xrange = make_cvector_from_rarray(argv[0]);
|
42
42
|
yrange = make_cvector_from_rarray(argv[1]);
|
43
43
|
zrange = make_cvector_from_rarray(argv[2]);
|
44
44
|
h = mygsl_histogram3d_alloc(xrange->size-1, yrange->size-1, zrange->size-1);
|
45
45
|
mygsl_histogram3d_set_ranges(h, xrange->data, xrange->size,
|
46
|
-
|
47
|
-
|
46
|
+
yrange->data, yrange->size,
|
47
|
+
zrange->data, zrange->size);
|
48
48
|
gsl_vector_free(zrange);
|
49
49
|
gsl_vector_free(yrange);
|
50
50
|
gsl_vector_free(xrange);
|
@@ -54,7 +54,7 @@ static VALUE rb_gsl_histogram3d_new(int argc, VALUE *argv, VALUE klass)
|
|
54
54
|
break;
|
55
55
|
case 6:
|
56
56
|
CHECK_FIXNUM(argv[0]); CHECK_FIXNUM(argv[2]); CHECK_FIXNUM(argv[4]);
|
57
|
-
Check_Type(argv[1], T_ARRAY); Check_Type(argv[3], T_ARRAY);
|
57
|
+
Check_Type(argv[1], T_ARRAY); Check_Type(argv[3], T_ARRAY);
|
58
58
|
Check_Type(argv[5], T_ARRAY);
|
59
59
|
nx = FIX2INT(argv[0]); ny = FIX2INT(argv[2]); nz = FIX2INT(argv[4]);
|
60
60
|
xmin = NUM2DBL(rb_ary_entry(argv[1], 0));
|
@@ -64,7 +64,7 @@ static VALUE rb_gsl_histogram3d_new(int argc, VALUE *argv, VALUE klass)
|
|
64
64
|
zmin = NUM2DBL(rb_ary_entry(argv[5], 0));
|
65
65
|
zmax = NUM2DBL(rb_ary_entry(argv[5], 1));
|
66
66
|
h = mygsl_histogram3d_calloc_uniform(nx, ny, nz, xmin, xmax, ymin, ymax,
|
67
|
-
|
67
|
+
zmin, zmax);
|
68
68
|
break;
|
69
69
|
case 9:
|
70
70
|
CHECK_FIXNUM(argv[0]); CHECK_FIXNUM(argv[3]); CHECK_FIXNUM(argv[6]);
|
@@ -73,7 +73,7 @@ static VALUE rb_gsl_histogram3d_new(int argc, VALUE *argv, VALUE klass)
|
|
73
73
|
ymin = NUM2DBL(argv[4]); ymax = NUM2DBL(argv[5]);
|
74
74
|
zmin = NUM2DBL(argv[7]); zmax = NUM2DBL(argv[8]);
|
75
75
|
h = mygsl_histogram3d_calloc_uniform(nx, ny, nz, xmin, xmax, ymin, ymax,
|
76
|
-
|
76
|
+
zmin, zmax);
|
77
77
|
break;
|
78
78
|
default:
|
79
79
|
break;
|
@@ -189,37 +189,37 @@ static VALUE rb_gsl_histogram3d_get(int argc, VALUE *argv, VALUE obj)
|
|
189
189
|
// switch (RARRAY(argv[0])->len) {
|
190
190
|
switch (RARRAY_LEN(argv[0])) {
|
191
191
|
case 1:
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
192
|
+
i = FIX2INT(rb_ary_entry(argv[0], 0));
|
193
|
+
h2 = ALLOC(mygsl_histogram3d_view);
|
194
|
+
h2->h.nx = h->ny;
|
195
|
+
h2->h.ny = h->nz;
|
196
|
+
h2->h.xrange = h->yrange;
|
197
|
+
h2->h.yrange = h->zrange;
|
198
|
+
h2->h.bin = h->bin + i*h->ny*h->nz;
|
199
|
+
return Data_Wrap_Struct(cgsl_histogram3d_view, 0, free, h2);
|
200
|
+
break;
|
201
201
|
case 2:
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
202
|
+
i = FIX2INT(rb_ary_entry(argv[0], 0));
|
203
|
+
j = FIX2INT(rb_ary_entry(argv[0], 1));
|
204
|
+
h1 = ALLOC(mygsl_histogram2d_view);
|
205
|
+
h1->h.n = h->nz;
|
206
|
+
h1->h.range = h->zrange;
|
207
|
+
h1->h.bin = h->bin + i*h->ny*h->nz + j*h->nz;
|
208
|
+
return Data_Wrap_Struct(cgsl_histogram2d_view, 0, free, h1);
|
209
|
+
break;
|
210
210
|
case 3:
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
211
|
+
i = FIX2INT(rb_ary_entry(argv[0], 0));
|
212
|
+
j = FIX2INT(rb_ary_entry(argv[0], 1));
|
213
|
+
k = FIX2INT(rb_ary_entry(argv[0], 2));
|
214
|
+
/* do the last line of this function */
|
215
|
+
break;
|
216
216
|
default:
|
217
|
-
|
217
|
+
rb_raise(rb_eRuntimeError, "wrong array size");
|
218
218
|
}
|
219
219
|
break;
|
220
220
|
default:
|
221
221
|
rb_raise(rb_eTypeError, "wrong argument type %s (Fixnum or Array expected)",
|
222
|
-
|
222
|
+
rb_class2name(CLASS_OF(argv[0])));
|
223
223
|
break;
|
224
224
|
}
|
225
225
|
break;
|
@@ -230,7 +230,7 @@ static VALUE rb_gsl_histogram3d_get(int argc, VALUE *argv, VALUE obj)
|
|
230
230
|
h1->h.n = h->nz;
|
231
231
|
h1->h.range = h->zrange;
|
232
232
|
h1->h.bin = h->bin + i*h->ny*h->nz + j*h->nz;
|
233
|
-
return Data_Wrap_Struct(cgsl_histogram2d_view, 0, free, h1);
|
233
|
+
return Data_Wrap_Struct(cgsl_histogram2d_view, 0, free, h1);
|
234
234
|
break;
|
235
235
|
case 3:
|
236
236
|
CHECK_FIXNUM(argv[0]); CHECK_FIXNUM(argv[1]); CHECK_FIXNUM(argv[2]);
|
@@ -251,7 +251,7 @@ static VALUE rb_gsl_histogram3d_increment(int argc, VALUE *argv, VALUE obj)
|
|
251
251
|
case 4:
|
252
252
|
Need_Float(argv[3]);
|
253
253
|
weight = NUM2DBL(argv[3]);
|
254
|
-
|
254
|
+
/* no break */
|
255
255
|
case 3:
|
256
256
|
Need_Float(argv[0]); Need_Float(argv[1]); Need_Float(argv[2]);
|
257
257
|
x = NUM2DBL(argv[0]); y = NUM2DBL(argv[1]); z = NUM2DBL(argv[2]);
|
@@ -273,7 +273,7 @@ static VALUE rb_gsl_histogram3d_increment2(int argc, VALUE *argv, VALUE obj)
|
|
273
273
|
case 4:
|
274
274
|
Need_Float(argv[3]);
|
275
275
|
weight = NUM2DBL(argv[3]);
|
276
|
-
|
276
|
+
/* no break */
|
277
277
|
case 3:
|
278
278
|
Need_Float(argv[0]); Need_Float(argv[1]); Need_Float(argv[2]);
|
279
279
|
x = NUM2DBL(argv[0]); y = NUM2DBL(argv[1]); z = NUM2DBL(argv[2]);
|
@@ -329,7 +329,7 @@ static VALUE rb_gsl_histogram3d_find(VALUE obj, VALUE x, VALUE y, VALUE z)
|
|
329
329
|
size_t i, j, k;
|
330
330
|
Data_Get_Struct(obj, mygsl_histogram3d, h);
|
331
331
|
mygsl_histogram3d_find(h, NUM2DBL(x), NUM2DBL(y), NUM2DBL(z),
|
332
|
-
|
332
|
+
&i, &j, &k);
|
333
333
|
return rb_ary_new3(3, INT2FIX(i), INT2FIX(j), INT2FIX(k));
|
334
334
|
}
|
335
335
|
|
@@ -346,7 +346,7 @@ static VALUE rb_gsl_histogram3d_set_ranges(VALUE obj, VALUE xx, VALUE yy, VALUE
|
|
346
346
|
Data_Get_Struct(xx, gsl_vector, xrange);
|
347
347
|
} else {
|
348
348
|
rb_raise(rb_eTypeError, "wrong argument type %s (Array or Vector expected)",
|
349
|
-
|
349
|
+
rb_class2name(CLASS_OF(xx)));
|
350
350
|
}
|
351
351
|
if (xrange->size != h->nx+1)
|
352
352
|
rb_raise(rb_eIndexError, "xrange length is different");
|
@@ -357,7 +357,7 @@ static VALUE rb_gsl_histogram3d_set_ranges(VALUE obj, VALUE xx, VALUE yy, VALUE
|
|
357
357
|
Data_Get_Struct(yy, gsl_vector, yrange);
|
358
358
|
} else {
|
359
359
|
rb_raise(rb_eTypeError, "wrong argument type %s (Array or Vector expected)",
|
360
|
-
|
360
|
+
rb_class2name(CLASS_OF(yy)));
|
361
361
|
}
|
362
362
|
if (yrange->size != h->ny+1)
|
363
363
|
rb_raise(rb_eIndexError, "yrange length is different");
|
@@ -368,13 +368,13 @@ static VALUE rb_gsl_histogram3d_set_ranges(VALUE obj, VALUE xx, VALUE yy, VALUE
|
|
368
368
|
Data_Get_Struct(zz, gsl_vector, zrange);
|
369
369
|
} else {
|
370
370
|
rb_raise(rb_eTypeError, "wrong argument type %s (Array or Vector expected)",
|
371
|
-
|
371
|
+
rb_class2name(CLASS_OF(zz)));
|
372
372
|
}
|
373
373
|
if (zrange->size != h->nz+1)
|
374
374
|
rb_raise(rb_eIndexError, "zrange length is different");
|
375
375
|
mygsl_histogram3d_set_ranges(h, xrange->data, xrange->size,
|
376
|
-
|
377
|
-
|
376
|
+
yrange->data, yrange->size,
|
377
|
+
zrange->data, zrange->size);
|
378
378
|
if (flagz == 1) gsl_vector_free(zrange);
|
379
379
|
if (flagy == 1) gsl_vector_free(yrange);
|
380
380
|
if (flagx == 1) gsl_vector_free(xrange);
|
@@ -695,7 +695,7 @@ static VALUE rb_gsl_histogram3d_reset(VALUE obj)
|
|
695
695
|
}
|
696
696
|
|
697
697
|
static VALUE rb_gsl_histogram3d_oper(VALUE obj, VALUE hh,
|
698
|
-
|
698
|
+
int (*func)(mygsl_histogram3d *, const mygsl_histogram3d*))
|
699
699
|
{
|
700
700
|
mygsl_histogram3d *h1, *h2, *hnew;
|
701
701
|
CHECK_HISTOGRAM3D(hh);
|
@@ -782,18 +782,18 @@ void Init_gsl_histogram3d(VALUE module)
|
|
782
782
|
{
|
783
783
|
cgsl_histogram3d = rb_define_class_under(module, "Histogram3d", cGSL_Object);
|
784
784
|
cgsl_histogram3d_view = rb_define_class_under(cgsl_histogram3d, "View",
|
785
|
-
|
785
|
+
cgsl_histogram2d);
|
786
786
|
|
787
787
|
/* rb_define_singleton_method(cgsl_histogram3d, "new", rb_gsl_histogram3d_new, -1);*/
|
788
|
-
rb_define_singleton_method(cgsl_histogram3d, "alloc",
|
789
|
-
|
790
|
-
rb_define_singleton_method(cgsl_histogram3d, "memcpy",
|
791
|
-
|
788
|
+
rb_define_singleton_method(cgsl_histogram3d, "alloc",
|
789
|
+
rb_gsl_histogram3d_new, -1);
|
790
|
+
rb_define_singleton_method(cgsl_histogram3d, "memcpy",
|
791
|
+
rb_gsl_histogram3d_memcpy, 2);
|
792
792
|
/******/
|
793
|
-
rb_define_method(cgsl_histogram3d, "set_ranges",
|
794
|
-
|
795
|
-
rb_define_method(cgsl_histogram3d, "set_ranges_uniform",
|
796
|
-
|
793
|
+
rb_define_method(cgsl_histogram3d, "set_ranges",
|
794
|
+
rb_gsl_histogram3d_set_ranges, 3);
|
795
|
+
rb_define_method(cgsl_histogram3d, "set_ranges_uniform",
|
796
|
+
rb_gsl_histogram3d_set_ranges_uniform, -1);
|
797
797
|
|
798
798
|
rb_define_method(cgsl_histogram3d, "nx", rb_gsl_histogram3d_nx, 0);
|
799
799
|
rb_define_method(cgsl_histogram3d, "ny", rb_gsl_histogram3d_ny, 0);
|
@@ -809,22 +809,22 @@ void Init_gsl_histogram3d(VALUE module)
|
|
809
809
|
rb_define_method(cgsl_histogram3d, "get", rb_gsl_histogram3d_get, -1);
|
810
810
|
rb_define_alias(cgsl_histogram3d, "[]", "get");
|
811
811
|
|
812
|
-
rb_define_method(cgsl_histogram3d, "increment",
|
813
|
-
|
812
|
+
rb_define_method(cgsl_histogram3d, "increment",
|
813
|
+
rb_gsl_histogram3d_increment, -1);
|
814
814
|
rb_define_alias(cgsl_histogram3d, "fill", "increment");
|
815
815
|
rb_define_alias(cgsl_histogram3d, "accumulate", "increment");
|
816
816
|
|
817
|
-
rb_define_method(cgsl_histogram3d, "increment2",
|
818
|
-
|
817
|
+
rb_define_method(cgsl_histogram3d, "increment2",
|
818
|
+
rb_gsl_histogram3d_increment2, -1);
|
819
819
|
rb_define_alias(cgsl_histogram3d, "fill2", "increment2");
|
820
820
|
rb_define_alias(cgsl_histogram3d, "accumulate2", "increment2");
|
821
821
|
|
822
|
-
rb_define_method(cgsl_histogram3d, "get_xrange",
|
823
|
-
|
824
|
-
rb_define_method(cgsl_histogram3d, "get_yrange",
|
825
|
-
|
826
|
-
rb_define_method(cgsl_histogram3d, "get_zrange",
|
827
|
-
|
822
|
+
rb_define_method(cgsl_histogram3d, "get_xrange",
|
823
|
+
rb_gsl_histogram3d_get_xrange, 1);
|
824
|
+
rb_define_method(cgsl_histogram3d, "get_yrange",
|
825
|
+
rb_gsl_histogram3d_get_yrange, 1);
|
826
|
+
rb_define_method(cgsl_histogram3d, "get_zrange",
|
827
|
+
rb_gsl_histogram3d_get_zrange, 1);
|
828
828
|
|
829
829
|
rb_define_method(cgsl_histogram3d, "find", rb_gsl_histogram3d_find, 3);
|
830
830
|
|
@@ -835,12 +835,12 @@ void Init_gsl_histogram3d(VALUE module)
|
|
835
835
|
|
836
836
|
/*****/
|
837
837
|
|
838
|
-
rb_define_method(cgsl_histogram3d, "xyproject",
|
839
|
-
|
840
|
-
rb_define_method(cgsl_histogram3d, "xzproject",
|
841
|
-
|
842
|
-
rb_define_method(cgsl_histogram3d, "yzproject",
|
843
|
-
|
838
|
+
rb_define_method(cgsl_histogram3d, "xyproject",
|
839
|
+
rb_gsl_histogram3d_xyproject, -1);
|
840
|
+
rb_define_method(cgsl_histogram3d, "xzproject",
|
841
|
+
rb_gsl_histogram3d_xzproject, -1);
|
842
|
+
rb_define_method(cgsl_histogram3d, "yzproject",
|
843
|
+
rb_gsl_histogram3d_yzproject, -1);
|
844
844
|
|
845
845
|
rb_define_method(cgsl_histogram3d, "scale", rb_gsl_histogram3d_scale, 1);
|
846
846
|
rb_define_method(cgsl_histogram3d, "scale!", rb_gsl_histogram3d_scale_bang, 1);
|