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
@@ -16,17 +16,17 @@ static VALUE rb_gsl_sum_accel(VALUE obj)
|
|
16
16
|
{
|
17
17
|
gsl_sum_levin_u_workspace *w = NULL;
|
18
18
|
double sum, err, sum_plain, *ptr;
|
19
|
-
size_t terms_used, n, stride;
|
19
|
+
size_t terms_used, n, stride;
|
20
20
|
ptr = get_vector_ptr(obj, &stride, &n);
|
21
21
|
w = gsl_sum_levin_u_alloc(n);
|
22
22
|
gsl_sum_levin_u_accel(ptr, n, w, &sum, &err);
|
23
23
|
sum_plain = w->sum_plain;
|
24
24
|
terms_used = w->terms_used;
|
25
25
|
gsl_sum_levin_u_free(w);
|
26
|
-
|
27
|
-
|
26
|
+
return rb_ary_new3(4, rb_float_new(sum), rb_float_new(err),
|
27
|
+
rb_float_new(sum_plain), INT2FIX(terms_used));
|
28
28
|
}
|
29
|
-
|
29
|
+
|
30
30
|
static VALUE rb_gsl_utrunc_accel(VALUE obj)
|
31
31
|
{
|
32
32
|
gsl_sum_levin_utrunc_workspace *w = NULL;
|
@@ -38,8 +38,8 @@ static VALUE rb_gsl_utrunc_accel(VALUE obj)
|
|
38
38
|
sum_plain = w->sum_plain;
|
39
39
|
terms_used = w->terms_used;
|
40
40
|
gsl_sum_levin_utrunc_free(w);
|
41
|
-
return rb_ary_new3(4, rb_float_new(sum), rb_float_new(err),
|
42
|
-
|
41
|
+
return rb_ary_new3(4, rb_float_new(sum), rb_float_new(err),
|
42
|
+
rb_float_new(sum_plain), INT2FIX(terms_used));
|
43
43
|
}
|
44
44
|
|
45
45
|
static VALUE rb_gsl_sum_levin_u_new(VALUE klass, VALUE nn)
|
@@ -71,8 +71,8 @@ static VALUE rb_gsl_sum_levin_u_accel2(VALUE obj, VALUE vv)
|
|
71
71
|
sum_plain = w->sum_plain;
|
72
72
|
terms_used = w->terms_used;
|
73
73
|
gsl_sum_levin_u_free(w);
|
74
|
-
return rb_ary_new3(4, rb_float_new(sum), rb_float_new(err),
|
75
|
-
|
74
|
+
return rb_ary_new3(4, rb_float_new(sum), rb_float_new(err),
|
75
|
+
rb_float_new(sum_plain), INT2FIX(terms_used));
|
76
76
|
}
|
77
77
|
|
78
78
|
static VALUE rb_gsl_sum_levin_utrunc_accel2(VALUE obj, VALUE vv)
|
@@ -87,8 +87,8 @@ static VALUE rb_gsl_sum_levin_utrunc_accel2(VALUE obj, VALUE vv)
|
|
87
87
|
sum_plain = w->sum_plain;
|
88
88
|
terms_used = w->terms_used;
|
89
89
|
gsl_sum_levin_utrunc_free(w);
|
90
|
-
return rb_ary_new3(4, rb_float_new(sum), rb_float_new(err),
|
91
|
-
|
90
|
+
return rb_ary_new3(4, rb_float_new(sum), rb_float_new(err),
|
91
|
+
rb_float_new(sum_plain), INT2FIX(terms_used));
|
92
92
|
}
|
93
93
|
|
94
94
|
static VALUE rb_gsl_sum_levin_u_sum_plain(VALUE obj)
|
@@ -119,39 +119,39 @@ static VALUE rb_gsl_sum_levin_utrunc_terms_used(VALUE obj)
|
|
119
119
|
return INT2FIX(w->terms_used);
|
120
120
|
}
|
121
121
|
|
122
|
-
void Init_gsl_sum(VALUE module)
|
122
|
+
void Init_gsl_sum(VALUE module)
|
123
123
|
{
|
124
124
|
VALUE mgsl_sum;
|
125
125
|
VALUE cgsl_sum_levin_u, cgsl_sum_levin_utrunc;
|
126
126
|
|
127
127
|
mgsl_sum = rb_define_module_under(module, "Sum");
|
128
|
-
cgsl_sum_levin_u = rb_define_class_under(mgsl_sum,
|
129
|
-
|
130
|
-
cgsl_sum_levin_utrunc = rb_define_class_under(mgsl_sum,
|
131
|
-
|
128
|
+
cgsl_sum_levin_u = rb_define_class_under(mgsl_sum,
|
129
|
+
"Levin_u", cGSL_Object);
|
130
|
+
cgsl_sum_levin_utrunc = rb_define_class_under(mgsl_sum,
|
131
|
+
"Levin_utrunc", cGSL_Object);
|
132
132
|
|
133
133
|
rb_define_singleton_method(cgsl_sum_levin_u, "new", rb_gsl_sum_levin_u_new, 1);
|
134
134
|
rb_define_singleton_method(cgsl_sum_levin_u, "alloc", rb_gsl_sum_levin_u_new, 1);
|
135
|
-
rb_define_singleton_method(cgsl_sum_levin_utrunc, "new",
|
136
|
-
|
137
|
-
rb_define_singleton_method(cgsl_sum_levin_utrunc, "alloc",
|
138
|
-
|
139
|
-
rb_define_singleton_method(cgsl_sum_levin_u, "accel",
|
140
|
-
|
141
|
-
|
142
|
-
rb_define_singleton_method(cgsl_sum_levin_utrunc, "accel",
|
143
|
-
|
135
|
+
rb_define_singleton_method(cgsl_sum_levin_utrunc, "new",
|
136
|
+
rb_gsl_sum_levin_utrunc_new, 1);
|
137
|
+
rb_define_singleton_method(cgsl_sum_levin_utrunc, "alloc",
|
138
|
+
rb_gsl_sum_levin_utrunc_new, 1);
|
139
|
+
rb_define_singleton_method(cgsl_sum_levin_u, "accel",
|
140
|
+
rb_gsl_sum_levin_u_accel2, 1);
|
141
|
+
|
142
|
+
rb_define_singleton_method(cgsl_sum_levin_utrunc, "accel",
|
143
|
+
rb_gsl_sum_levin_utrunc_accel2, 1);
|
144
144
|
rb_define_method(cgsl_sum_levin_u, "accel", rb_gsl_sum_levin_u_accel2, 1);
|
145
|
-
rb_define_method(cgsl_sum_levin_utrunc, "accel",
|
146
|
-
|
145
|
+
rb_define_method(cgsl_sum_levin_utrunc, "accel",
|
146
|
+
rb_gsl_sum_levin_utrunc_accel2, 1);
|
147
147
|
|
148
148
|
rb_define_method(cgsl_sum_levin_u, "sum_plain", rb_gsl_sum_levin_u_sum_plain, 0);
|
149
|
-
rb_define_method(cgsl_sum_levin_u, "terms_used",
|
150
|
-
|
151
|
-
rb_define_method(cgsl_sum_levin_utrunc, "sum_plain",
|
152
|
-
|
153
|
-
rb_define_method(cgsl_sum_levin_utrunc, "terms_used",
|
154
|
-
|
149
|
+
rb_define_method(cgsl_sum_levin_u, "terms_used",
|
150
|
+
rb_gsl_sum_levin_u_terms_used, 0);
|
151
|
+
rb_define_method(cgsl_sum_levin_utrunc, "sum_plain",
|
152
|
+
rb_gsl_sum_levin_utrunc_sum_plain, 0);
|
153
|
+
rb_define_method(cgsl_sum_levin_utrunc, "terms_used",
|
154
|
+
rb_gsl_sum_levin_utrunc_terms_used, 0);
|
155
155
|
/***/
|
156
156
|
|
157
157
|
rb_define_method(cgsl_vector, "accel_sum", rb_gsl_sum_accel, 0);
|
File without changes
|
@@ -18,19 +18,17 @@
|
|
18
18
|
|
19
19
|
#include "include/rb_gsl_tensor.h"
|
20
20
|
|
21
|
-
#ifdef HAVE_NARRAY_H
|
22
21
|
#include "include/rb_gsl_with_narray.h"
|
23
|
-
#endif
|
24
22
|
|
25
23
|
#define BASE_DOUBLE
|
26
24
|
#include "include/templates_on.h"
|
27
|
-
#include "tensor_source.
|
25
|
+
#include "tensor_source.h"
|
28
26
|
#include "include/templates_off.h"
|
29
27
|
#undef BASE_DOUBLE
|
30
28
|
|
31
29
|
#define BASE_INT
|
32
30
|
#include "include/templates_on.h"
|
33
|
-
#include "tensor_source.
|
31
|
+
#include "tensor_source.h"
|
34
32
|
#include "include/templates_off.h"
|
35
33
|
#undef BASE_INT
|
36
34
|
|
@@ -38,26 +38,26 @@ VALUE cgsl_tensor_view, cgsl_tensor_int_view;
|
|
38
38
|
#define MAT_P(x) MATRIX_INT_P(x)
|
39
39
|
#endif
|
40
40
|
|
41
|
-
GSL_TYPE(rbgsl_tensor)* FUNCTION(rbgsl_tensor,alloc)(const unsigned int rank,
|
42
|
-
|
41
|
+
GSL_TYPE(rbgsl_tensor)* FUNCTION(rbgsl_tensor,alloc)(const unsigned int rank,
|
42
|
+
const size_t dimension)
|
43
43
|
{
|
44
44
|
GSL_TYPE(rbgsl_tensor) *t;
|
45
45
|
t = ALLOC(GSL_TYPE(rbgsl_tensor));
|
46
46
|
t->tensor = FUNCTION(tensor,alloc)(rank, dimension);
|
47
|
-
if (rank == 0)
|
47
|
+
if (rank == 0)
|
48
48
|
t->indices = gsl_permutation_alloc(1);
|
49
49
|
else
|
50
50
|
t->indices = gsl_permutation_alloc(rank);
|
51
51
|
return t;
|
52
52
|
}
|
53
53
|
|
54
|
-
GSL_TYPE(rbgsl_tensor)* FUNCTION(rbgsl_tensor,calloc)(const unsigned int rank,
|
55
|
-
|
54
|
+
GSL_TYPE(rbgsl_tensor)* FUNCTION(rbgsl_tensor,calloc)(const unsigned int rank,
|
55
|
+
const size_t dimension)
|
56
56
|
{
|
57
57
|
GSL_TYPE(rbgsl_tensor) *t;
|
58
58
|
t = ALLOC(GSL_TYPE(rbgsl_tensor));
|
59
59
|
t->tensor = FUNCTION(tensor,calloc)(rank, dimension);
|
60
|
-
if (rank == 0)
|
60
|
+
if (rank == 0)
|
61
61
|
t->indices = gsl_permutation_alloc(1);
|
62
62
|
else
|
63
63
|
t->indices = gsl_permutation_alloc(rank);
|
@@ -68,7 +68,7 @@ GSL_TYPE(rbgsl_tensor)* FUNCTION(rbgsl_tensor,copy)(const GSL_TYPE(rbgsl_tensor)
|
|
68
68
|
{
|
69
69
|
GSL_TYPE(rbgsl_tensor) *tnew;
|
70
70
|
tnew = ALLOC(GSL_TYPE(rbgsl_tensor));
|
71
|
-
if (t->tensor->rank == 0)
|
71
|
+
if (t->tensor->rank == 0)
|
72
72
|
tnew->indices = gsl_permutation_alloc(1);
|
73
73
|
else
|
74
74
|
tnew->indices = gsl_permutation_alloc(t->tensor->rank);
|
@@ -80,14 +80,14 @@ void FUNCTION(rbgsl_tensor,free)(GSL_TYPE(rbgsl_tensor) *t)
|
|
80
80
|
{
|
81
81
|
gsl_permutation_free(t->indices);
|
82
82
|
FUNCTION(tensor,free)(t->tensor);
|
83
|
-
free((GSL_TYPE(rbgsl_tensor) *)
|
83
|
+
free((GSL_TYPE(rbgsl_tensor) *)t);
|
84
84
|
}
|
85
85
|
|
86
86
|
void FUNCTION(rbgsl_tensor,free2)(GSL_TYPE(rbgsl_tensor) *t)
|
87
87
|
{
|
88
88
|
gsl_permutation_free(t->indices);
|
89
|
-
free((GSL_TYPE(tensor)*)
|
90
|
-
free((GSL_TYPE(rbgsl_tensor) *)
|
89
|
+
free((GSL_TYPE(tensor)*)t->tensor);
|
90
|
+
free((GSL_TYPE(rbgsl_tensor) *)t);
|
91
91
|
}
|
92
92
|
|
93
93
|
/* singleton methods */
|
@@ -104,7 +104,7 @@ static VALUE FUNCTION(rb_tensor,new)(int argc, VALUE *argv, VALUE klass)
|
|
104
104
|
break;
|
105
105
|
default:
|
106
106
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2, rank and dimension)",
|
107
|
-
|
107
|
+
argc);
|
108
108
|
break;
|
109
109
|
}
|
110
110
|
return Data_Wrap_Struct(GSL_TYPE(cgsl_tensor), 0, FUNCTION(rbgsl_tensor,free), t);
|
@@ -175,8 +175,8 @@ static VALUE FUNCTION(rb_tensor,set_all)(VALUE obj, VALUE xx)
|
|
175
175
|
}
|
176
176
|
|
177
177
|
static void rb_tensor_get_indices_array(tensor_indices *v, VALUE ary);
|
178
|
-
static void rbgsl_tensor_get_indices(int argc, VALUE *argv, tensor_indices *indices,
|
179
|
-
|
178
|
+
static void rbgsl_tensor_get_indices(int argc, VALUE *argv, tensor_indices *indices,
|
179
|
+
size_t *n);
|
180
180
|
#ifdef BASE_DOUBLE
|
181
181
|
static void rb_tensor_get_indices_array(tensor_indices *v, VALUE ary)
|
182
182
|
{
|
@@ -187,8 +187,8 @@ static void rb_tensor_get_indices_array(tensor_indices *v, VALUE ary)
|
|
187
187
|
v->data[i] = FIX2UINT(rb_ary_entry(ary, i));
|
188
188
|
}
|
189
189
|
|
190
|
-
static void rbgsl_tensor_get_indices(int argc, VALUE *argv,
|
191
|
-
|
190
|
+
static void rbgsl_tensor_get_indices(int argc, VALUE *argv,
|
191
|
+
tensor_indices *indices, size_t *n)
|
192
192
|
{
|
193
193
|
size_t i;
|
194
194
|
for (i = 0; i < indices->size; i++) indices->data[i] = 0;
|
@@ -206,7 +206,7 @@ static void rbgsl_tensor_get_indices(int argc, VALUE *argv,
|
|
206
206
|
break;
|
207
207
|
default:
|
208
208
|
rb_raise(rb_eTypeError, "wrong argument type %s (Array expected)",
|
209
|
-
|
209
|
+
rb_class2name(CLASS_OF(argv[0])));
|
210
210
|
break;
|
211
211
|
}
|
212
212
|
break;
|
@@ -222,13 +222,13 @@ static void rbgsl_tensor_get_indices(int argc, VALUE *argv,
|
|
222
222
|
#endif
|
223
223
|
|
224
224
|
size_t FUNCTION(tensor,position)(const size_t * indices,
|
225
|
-
|
225
|
+
const GSL_TYPE(tensor) * t);
|
226
226
|
static VALUE FUNCTION(rb_tensor,position)(int argc, VALUE *argv, VALUE obj)
|
227
227
|
{
|
228
228
|
GSL_TYPE(rbgsl_tensor) *t = NULL;
|
229
229
|
size_t n, position;
|
230
|
-
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
231
|
-
rbgsl_tensor_get_indices(argc, argv, t->indices, &n);
|
230
|
+
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
231
|
+
rbgsl_tensor_get_indices(argc, argv, t->indices, &n);
|
232
232
|
position = (size_t) FUNCTION(tensor,position)(t->indices->data,t->tensor);
|
233
233
|
return INT2FIX(position);
|
234
234
|
}
|
@@ -238,8 +238,8 @@ static VALUE FUNCTION(rb_tensor,get)(int argc, VALUE *argv, VALUE obj)
|
|
238
238
|
GSL_TYPE(rbgsl_tensor) *t = NULL;
|
239
239
|
BASE x;
|
240
240
|
size_t n;
|
241
|
-
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
242
|
-
rbgsl_tensor_get_indices(argc, argv, t->indices, &n);
|
241
|
+
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
242
|
+
rbgsl_tensor_get_indices(argc, argv, t->indices, &n);
|
243
243
|
if (n < t->tensor->rank) {
|
244
244
|
return FUNCTION(rb_tensor,subtensor)(argc, argv, obj);
|
245
245
|
} else {
|
@@ -254,9 +254,9 @@ static VALUE FUNCTION(rb_tensor,set)(int argc, VALUE *argv, VALUE obj)
|
|
254
254
|
GSL_TYPE(rbgsl_tensor) *t = NULL;
|
255
255
|
size_t n;
|
256
256
|
BASE x;
|
257
|
-
if (argc < 2)
|
257
|
+
if (argc < 2)
|
258
258
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for >= 2)", argc);
|
259
|
-
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
259
|
+
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
260
260
|
rbgsl_tensor_get_indices(argc-1, argv, t->indices, &n);
|
261
261
|
x = NUMCONV(argv[argc-1]);
|
262
262
|
FUNCTION(tensor,set)(t->tensor, t->indices->data, x);
|
@@ -292,7 +292,7 @@ static VALUE FUNCTION(rb_tensor,fprintf)(int argc, VALUE *argv, VALUE obj)
|
|
292
292
|
GSL_TYPE(rbgsl_tensor) *h = NULL;
|
293
293
|
FILE *fp = NULL;
|
294
294
|
int status, flag = 0;
|
295
|
-
if (argc != 1 && argc != 2)
|
295
|
+
if (argc != 1 && argc != 2)
|
296
296
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
|
297
297
|
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), h);
|
298
298
|
fp = rb_gsl_open_writefile(argv[0], &flag);
|
@@ -317,7 +317,7 @@ static VALUE FUNCTION(rb_tensor,printf)(int argc, VALUE *argv, VALUE obj)
|
|
317
317
|
int status;
|
318
318
|
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), h);
|
319
319
|
if (argc == 1) {
|
320
|
-
if (TYPE(argv[0]) != T_STRING)
|
320
|
+
if (TYPE(argv[0]) != T_STRING)
|
321
321
|
rb_raise(rb_eTypeError, "String expected");
|
322
322
|
else
|
323
323
|
status = FUNCTION(tensor,fprintf)(stdout, h->tensor, STR2CSTR(argv[0]));
|
@@ -344,7 +344,7 @@ static VALUE FUNCTION(rb_tensor,swap_indices)(VALUE obj, VALUE ii, VALUE jj)
|
|
344
344
|
GSL_TYPE(rbgsl_tensor) *t, *tnew;
|
345
345
|
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
346
346
|
tnew = ALLOC(GSL_TYPE(rbgsl_tensor));
|
347
|
-
if (t->tensor->rank == 0)
|
347
|
+
if (t->tensor->rank == 0)
|
348
348
|
tnew->indices = gsl_permutation_alloc(1);
|
349
349
|
else
|
350
350
|
tnew->indices = gsl_permutation_alloc(t->tensor->rank);
|
@@ -405,8 +405,8 @@ static VALUE FUNCTION(rb_tensor,minmax_index)(VALUE obj)
|
|
405
405
|
}
|
406
406
|
FUNCTION(tensor,minmax_index)(t->tensor, min->data, max->data);
|
407
407
|
return rb_ary_new3(2,
|
408
|
-
|
409
|
-
|
408
|
+
Data_Wrap_Struct(cgsl_index, 0, gsl_permutation_free, min),
|
409
|
+
Data_Wrap_Struct(cgsl_index, 0, gsl_permutation_free, max));
|
410
410
|
}
|
411
411
|
|
412
412
|
static VALUE FUNCTION(rb_tensor,isnull)(VALUE obj)
|
@@ -427,7 +427,7 @@ static VALUE FUNCTION(rb_tensor,isnull2)(VALUE obj)
|
|
427
427
|
}
|
428
428
|
|
429
429
|
static VALUE FUNCTION(rb_tensor,oper)(VALUE obj, VALUE bb,
|
430
|
-
|
430
|
+
int flag)
|
431
431
|
{
|
432
432
|
GSL_TYPE(rbgsl_tensor) *a, *b, *anew;
|
433
433
|
BASE x;
|
@@ -443,28 +443,28 @@ static VALUE FUNCTION(rb_tensor,oper)(VALUE obj, VALUE bb,
|
|
443
443
|
case TENSOR_MUL_ELEMENTS: f = FUNCTION(&tensor,mul_elements); break;
|
444
444
|
case TENSOR_DIV_ELEMENTS: f = FUNCTION(&tensor,div_elements); break;
|
445
445
|
default: rb_raise(rb_eRuntimeError, "unknown operation"); break;
|
446
|
-
}
|
446
|
+
}
|
447
447
|
(*f)(anew->tensor, b->tensor);
|
448
448
|
} else {
|
449
449
|
switch (flag) {
|
450
450
|
case TENSOR_ADD:
|
451
|
-
case TENSOR_ADD_CONSTANT:
|
451
|
+
case TENSOR_ADD_CONSTANT:
|
452
452
|
x = NUMCONV(bb);
|
453
|
-
f2 = FUNCTION(&tensor,add_constant);
|
453
|
+
f2 = FUNCTION(&tensor,add_constant);
|
454
454
|
break;
|
455
455
|
case TENSOR_SUB:
|
456
456
|
x = -NUMCONV(bb);
|
457
|
-
f2 = FUNCTION(&tensor,add_constant);
|
457
|
+
f2 = FUNCTION(&tensor,add_constant);
|
458
458
|
break;
|
459
459
|
case TENSOR_ADD_DIAGONAL: f2 = FUNCTION(&tensor,add_diagonal); break;
|
460
460
|
case TENSOR_MUL_ELEMENTS:
|
461
461
|
case TENSOR_SCALE:
|
462
|
-
x = NUMCONV(bb);
|
463
|
-
f2 = FUNCTION(&tensor,scale);
|
462
|
+
x = NUMCONV(bb);
|
463
|
+
f2 = FUNCTION(&tensor,scale);
|
464
464
|
break;
|
465
|
-
case TENSOR_DIV_ELEMENTS:
|
466
|
-
x = 1.0/NUMCONV(bb);
|
467
|
-
f2 = FUNCTION(&tensor,scale);
|
465
|
+
case TENSOR_DIV_ELEMENTS:
|
466
|
+
x = 1.0/NUMCONV(bb);
|
467
|
+
f2 = FUNCTION(&tensor,scale);
|
468
468
|
break;
|
469
469
|
default: rb_raise(rb_eRuntimeError, "unknown operation"); break;
|
470
470
|
}
|
@@ -489,28 +489,28 @@ static VALUE FUNCTION(rb_tensor,oper_bang)(VALUE obj, VALUE bb, int flag)
|
|
489
489
|
case TENSOR_MUL_ELEMENTS: f = FUNCTION(&tensor,mul_elements); break;
|
490
490
|
case TENSOR_DIV_ELEMENTS: f = FUNCTION(&tensor,div_elements); break;
|
491
491
|
default: rb_raise(rb_eRuntimeError, "unknown operation"); break;
|
492
|
-
}
|
492
|
+
}
|
493
493
|
(*f)(a->tensor, b->tensor);
|
494
494
|
} else {
|
495
495
|
switch (flag) {
|
496
496
|
case TENSOR_ADD:
|
497
|
-
case TENSOR_ADD_CONSTANT:
|
497
|
+
case TENSOR_ADD_CONSTANT:
|
498
498
|
x = NUMCONV(bb);
|
499
|
-
f2 = FUNCTION(&tensor,add_constant);
|
499
|
+
f2 = FUNCTION(&tensor,add_constant);
|
500
500
|
break;
|
501
501
|
case TENSOR_SUB:
|
502
502
|
x = -NUMCONV(bb);
|
503
|
-
f2 = FUNCTION(&tensor,add_constant);
|
503
|
+
f2 = FUNCTION(&tensor,add_constant);
|
504
504
|
break;
|
505
505
|
case TENSOR_ADD_DIAGONAL: f2 = FUNCTION(&tensor,add_diagonal); break;
|
506
506
|
case TENSOR_MUL_ELEMENTS:
|
507
507
|
case TENSOR_SCALE:
|
508
|
-
x = NUMCONV(bb);
|
509
|
-
f2 = FUNCTION(&tensor,scale);
|
508
|
+
x = NUMCONV(bb);
|
509
|
+
f2 = FUNCTION(&tensor,scale);
|
510
510
|
break;
|
511
|
-
case TENSOR_DIV_ELEMENTS:
|
512
|
-
x = 1.0/NUMCONV(bb);
|
513
|
-
f2 = FUNCTION(&tensor,scale);
|
511
|
+
case TENSOR_DIV_ELEMENTS:
|
512
|
+
x = 1.0/NUMCONV(bb);
|
513
|
+
f2 = FUNCTION(&tensor,scale);
|
514
514
|
break;
|
515
515
|
default: rb_raise(rb_eRuntimeError, "unknown operation"); break;
|
516
516
|
}
|
@@ -688,7 +688,7 @@ static VALUE FUNCTION(rb_tensor,2matrix)(VALUE obj)
|
|
688
688
|
GSL_TYPE(rbgsl_tensor) *t;
|
689
689
|
GSL_TYPE(gsl_matrix) *m = NULL;
|
690
690
|
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
691
|
-
m = (GSL_TYPE(gsl_matrix)*)
|
691
|
+
m = (GSL_TYPE(gsl_matrix)*)FUNCTION(tensor,2matrix)(t->tensor);
|
692
692
|
return Data_Wrap_Struct(QUALIFIED_VIEW(cgsl_matrix,view), 0, FUNCTION(gsl_matrix,free), m);
|
693
693
|
}
|
694
694
|
|
@@ -697,7 +697,7 @@ static VALUE FUNCTION(rb_tensor,2vector)(VALUE obj)
|
|
697
697
|
GSL_TYPE(rbgsl_tensor) *t;
|
698
698
|
GSL_TYPE(gsl_vector) *v = NULL;
|
699
699
|
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
700
|
-
v = (GSL_TYPE(gsl_vector) *)
|
700
|
+
v = (GSL_TYPE(gsl_vector) *)FUNCTION(tensor,2vector)(t->tensor);
|
701
701
|
return Data_Wrap_Struct(QUALIFIED_VIEW(cgsl_vector,view), 0, FUNCTION(gsl_vector,free), v);
|
702
702
|
}
|
703
703
|
|
@@ -718,8 +718,8 @@ static VALUE FUNCTION(rb_tensor,to_v)(VALUE obj)
|
|
718
718
|
rank: rank of the tensor created
|
719
719
|
*/
|
720
720
|
GSL_TYPE(tensor) FUNCTION(tensor,subtensor)(const GSL_TYPE(tensor) *t,
|
721
|
-
|
722
|
-
|
721
|
+
const unsigned int rank,
|
722
|
+
size_t *indices)
|
723
723
|
{
|
724
724
|
GSL_TYPE(tensor) tnew;
|
725
725
|
size_t position;
|
@@ -740,16 +740,16 @@ static VALUE FUNCTION(rb_tensor,subtensor)(int argc, VALUE *argv, VALUE obj)
|
|
740
740
|
size_t n;
|
741
741
|
Data_Get_Struct(obj, GSL_TYPE(rbgsl_tensor), t);
|
742
742
|
/* n: number of indices given */
|
743
|
-
rbgsl_tensor_get_indices(argc, argv, t->indices, &n);
|
744
|
-
rank = t->tensor->rank - n;
|
743
|
+
rbgsl_tensor_get_indices(argc, argv, t->indices, &n);
|
744
|
+
rank = t->tensor->rank - n;
|
745
745
|
tnew = ALLOC(GSL_TYPE(rbgsl_tensor));
|
746
|
-
tnew->tensor = (GSL_TYPE(tensor)*)
|
746
|
+
tnew->tensor = (GSL_TYPE(tensor)*)malloc(sizeof(GSL_TYPE(tensor)));
|
747
747
|
*(tnew->tensor) = FUNCTION(tensor,subtensor)(t->tensor, rank, t->indices->data);
|
748
|
-
if (rank == 0)
|
748
|
+
if (rank == 0)
|
749
749
|
tnew->indices = gsl_permutation_alloc(1);
|
750
750
|
else
|
751
751
|
tnew->indices = gsl_permutation_alloc(rank);
|
752
|
-
return Data_Wrap_Struct(QUALIFIED_VIEW(cgsl_tensor,view), 0, FUNCTION(rbgsl_tensor,free2), tnew);
|
752
|
+
return Data_Wrap_Struct(QUALIFIED_VIEW(cgsl_tensor,view), 0, FUNCTION(rbgsl_tensor,free2), tnew);
|
753
753
|
}
|
754
754
|
|
755
755
|
#ifdef BASE_DOUBLE
|
@@ -782,29 +782,29 @@ static VALUE FUNCTION(rb_tensor,to_s)(VALUE obj)
|
|
782
782
|
m = &(matrix.matrix);
|
783
783
|
for (i = 0; i < m->size1; i++) {
|
784
784
|
if (i != 0) {
|
785
|
-
|
786
|
-
|
785
|
+
strcpy(buf, " ");
|
786
|
+
rb_str_cat(str, buf, strlen(buf));
|
787
787
|
}
|
788
788
|
for (j = 0; j < m->size2; j++) {
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
789
|
+
sprintf(buf, PRINTF_FORMAT, FUNCTION(gsl_matrix,get)(m, i, j));
|
790
|
+
rb_str_cat(str, buf, strlen(buf));
|
791
|
+
if (j == SHOW_ELM) {
|
792
|
+
strcpy(buf, "... ");
|
793
|
+
rb_str_cat(str, buf, strlen(buf));
|
794
|
+
break;
|
795
|
+
}
|
796
796
|
}
|
797
797
|
if (i == 6) {
|
798
|
-
|
799
|
-
|
800
|
-
|
798
|
+
strcpy(buf, "\n ... ]");
|
799
|
+
rb_str_cat(str, buf, strlen(buf));
|
800
|
+
break;
|
801
801
|
}
|
802
802
|
if (i == m->size1 - 1) {
|
803
|
-
|
804
|
-
|
803
|
+
strcpy(buf, "]");
|
804
|
+
rb_str_cat(str, buf, strlen(buf));
|
805
805
|
} else {
|
806
|
-
|
807
|
-
|
806
|
+
strcpy(buf, "\n");
|
807
|
+
rb_str_cat(str, buf, strlen(buf));
|
808
808
|
}
|
809
809
|
}
|
810
810
|
return str;
|
@@ -871,8 +871,8 @@ VALUE FUNCTION(rb_tensor,equal)(int argc, VALUE *argv, VALUE obj)
|
|
871
871
|
if (a->tensor->dimension != b->tensor->dimension) return Qfalse;
|
872
872
|
if (a->tensor->size != b->tensor->size) return Qfalse;
|
873
873
|
for (i = 0; i < a->tensor->size; i++)
|
874
|
-
if (fabs(a->tensor->data[i]-b->tensor->data[i]) > eps)
|
875
|
-
|
874
|
+
if (fabs(a->tensor->data[i]-b->tensor->data[i]) > eps)
|
875
|
+
return Qfalse;
|
876
876
|
return Qtrue;
|
877
877
|
} else if (MAT_P(other)) {
|
878
878
|
if (a->tensor->rank != 2) return Qfalse;
|
@@ -880,19 +880,19 @@ VALUE FUNCTION(rb_tensor,equal)(int argc, VALUE *argv, VALUE obj)
|
|
880
880
|
if (a->tensor->dimension != m->size1 || a->tensor->dimension != m->size2)
|
881
881
|
return Qfalse;
|
882
882
|
for (i = 0; i < a->tensor->size; i++)
|
883
|
-
if (fabs(a->tensor->data[i]-m->data[i]) > eps)
|
884
|
-
|
883
|
+
if (fabs(a->tensor->data[i]-m->data[i]) > eps)
|
884
|
+
return Qfalse;
|
885
885
|
return Qtrue;
|
886
886
|
} else if (VEC_P(other)) {
|
887
887
|
Data_Get_Struct(other, GSL_TYPE(gsl_vector), v);
|
888
888
|
if (a->tensor->size != v->size) return Qfalse;
|
889
889
|
for (i = 0; i < a->tensor->size; i++)
|
890
|
-
if (fabs(a->tensor->data[i]-v->data[i]) > eps)
|
891
|
-
|
890
|
+
if (fabs(a->tensor->data[i]-v->data[i]) > eps)
|
891
|
+
return Qfalse;
|
892
892
|
return Qtrue;
|
893
893
|
} else {
|
894
|
-
rb_raise(rb_eTypeError, "wrong argument type %s (Tensor, Matrix or Vector expected)",
|
895
|
-
|
894
|
+
rb_raise(rb_eTypeError, "wrong argument type %s (Tensor, Matrix or Vector expected)",
|
895
|
+
rb_class2name(CLASS_OF(other)));
|
896
896
|
}
|
897
897
|
}
|
898
898
|
|
@@ -927,8 +927,8 @@ static VALUE FUNCTION(rb_tensor,coerce)(VALUE obj, VALUE other)
|
|
927
927
|
return rb_ary_new3(2, tt, obj);
|
928
928
|
break;
|
929
929
|
default:
|
930
|
-
rb_raise(rb_eRuntimeError, "undefined operation with %s",
|
931
|
-
|
930
|
+
rb_raise(rb_eRuntimeError, "undefined operation with %s",
|
931
|
+
rb_class2name(CLASS_OF(other)));
|
932
932
|
break;
|
933
933
|
}
|
934
934
|
}
|
@@ -953,99 +953,99 @@ void FUNCTION(Init_tensor,init)(VALUE module)
|
|
953
953
|
cgsl_tensor_int = rb_define_class_under(cgsl_tensor, "Int", cGSL_Object);
|
954
954
|
cgsl_tensor_view = rb_define_class_under(cgsl_tensor, "View", cgsl_tensor);
|
955
955
|
cgsl_tensor_int_view = rb_define_class_under(cgsl_tensor_int, "View",
|
956
|
-
|
956
|
+
cgsl_tensor_int);
|
957
957
|
/*
|
958
|
-
cgsl_index = rb_define_class_under(cgsl_tensor, "Index",
|
958
|
+
cgsl_index = rb_define_class_under(cgsl_tensor, "Index",
|
959
959
|
cgsl_permutation);*/
|
960
960
|
#endif
|
961
961
|
|
962
962
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "new",
|
963
|
-
|
963
|
+
FUNCTION(rb_tensor,new), -1);
|
964
964
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "[]",
|
965
|
-
|
965
|
+
FUNCTION(rb_tensor,new), -1);
|
966
966
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "alloc",
|
967
|
-
|
967
|
+
FUNCTION(rb_tensor,new), -1);
|
968
968
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "calloc",
|
969
|
-
|
969
|
+
FUNCTION(rb_tensor,calloc), 2);
|
970
970
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "copy",
|
971
|
-
|
971
|
+
FUNCTION(rb_tensor,copy_singleton), 1);
|
972
972
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "memcpy",
|
973
|
-
|
973
|
+
FUNCTION(rb_tensor,memcpy_singleton), 2);
|
974
974
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "swap",
|
975
|
-
|
975
|
+
FUNCTION(rb_tensor,swap_singleton), 2);
|
976
976
|
|
977
977
|
/*****/
|
978
978
|
|
979
979
|
rb_define_method(GSL_TYPE(cgsl_tensor), "copy",
|
980
|
-
|
980
|
+
FUNCTION(rb_tensor,copy), 0);
|
981
981
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "clone", "copy");
|
982
982
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "duplicate", "copy");
|
983
983
|
rb_define_method(GSL_TYPE(cgsl_tensor), "set_zero",
|
984
|
-
|
984
|
+
FUNCTION(rb_tensor,set_zero), 0);
|
985
985
|
rb_define_method(GSL_TYPE(cgsl_tensor), "set_all",
|
986
|
-
|
986
|
+
FUNCTION(rb_tensor,set_all), 1);
|
987
987
|
|
988
988
|
rb_define_method(GSL_TYPE(cgsl_tensor), "position",
|
989
|
-
|
989
|
+
FUNCTION(rb_tensor,position), -1);
|
990
990
|
rb_define_method(GSL_TYPE(cgsl_tensor), "get",
|
991
|
-
|
991
|
+
FUNCTION(rb_tensor,get), -1);
|
992
992
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "[]", "get");
|
993
993
|
rb_define_method(GSL_TYPE(cgsl_tensor), "set",
|
994
|
-
|
994
|
+
FUNCTION(rb_tensor,set), -1);
|
995
995
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "[]=", "set");
|
996
996
|
|
997
997
|
rb_define_method(GSL_TYPE(cgsl_tensor), "fread",
|
998
|
-
|
998
|
+
FUNCTION(rb_tensor,fread), 1);
|
999
999
|
rb_define_method(GSL_TYPE(cgsl_tensor), "fwrite",
|
1000
|
-
|
1000
|
+
FUNCTION(rb_tensor,fwrite), 1);
|
1001
1001
|
rb_define_method(GSL_TYPE(cgsl_tensor), "fprintf",
|
1002
|
-
|
1002
|
+
FUNCTION(rb_tensor,fprintf), -1);
|
1003
1003
|
rb_define_method(GSL_TYPE(cgsl_tensor), "printf",
|
1004
|
-
|
1004
|
+
FUNCTION(rb_tensor,printf), -1);
|
1005
1005
|
rb_define_method(GSL_TYPE(cgsl_tensor), "fscanf",
|
1006
|
-
|
1006
|
+
FUNCTION(rb_tensor,fscanf), 1);
|
1007
1007
|
|
1008
1008
|
rb_define_method(GSL_TYPE(cgsl_tensor), "swap_indices",
|
1009
|
-
|
1009
|
+
FUNCTION(rb_tensor,swap_indices), 2);
|
1010
1010
|
|
1011
1011
|
rb_define_method(GSL_TYPE(cgsl_tensor), "max",
|
1012
|
-
|
1012
|
+
FUNCTION(rb_tensor,max), 0);
|
1013
1013
|
rb_define_method(GSL_TYPE(cgsl_tensor), "min",
|
1014
|
-
|
1014
|
+
FUNCTION(rb_tensor,min), 0);
|
1015
1015
|
rb_define_method(GSL_TYPE(cgsl_tensor), "minmax",
|
1016
|
-
|
1016
|
+
FUNCTION(rb_tensor,minmax), 0);
|
1017
1017
|
rb_define_method(GSL_TYPE(cgsl_tensor), "max_index",
|
1018
|
-
|
1018
|
+
FUNCTION(rb_tensor,max_index), 0);
|
1019
1019
|
rb_define_method(GSL_TYPE(cgsl_tensor), "min_index",
|
1020
|
-
|
1020
|
+
FUNCTION(rb_tensor,min_index), 0);
|
1021
1021
|
rb_define_method(GSL_TYPE(cgsl_tensor), "minmax_index",
|
1022
|
-
|
1022
|
+
FUNCTION(rb_tensor,minmax_index), 0);
|
1023
1023
|
|
1024
1024
|
rb_define_method(GSL_TYPE(cgsl_tensor), "isnull",
|
1025
|
-
|
1025
|
+
FUNCTION(rb_tensor,isnull), 0);
|
1026
1026
|
rb_define_method(GSL_TYPE(cgsl_tensor), "isnull?",
|
1027
|
-
|
1027
|
+
FUNCTION(rb_tensor,isnull2), 0);
|
1028
1028
|
|
1029
1029
|
rb_define_method(GSL_TYPE(cgsl_tensor), "add",
|
1030
|
-
|
1030
|
+
FUNCTION(rb_tensor,add), 1);
|
1031
1031
|
rb_define_method(GSL_TYPE(cgsl_tensor), "sub",
|
1032
|
-
|
1032
|
+
FUNCTION(rb_tensor,sub), 1);
|
1033
1033
|
rb_define_method(GSL_TYPE(cgsl_tensor), "mul_elements",
|
1034
|
-
|
1034
|
+
FUNCTION(rb_tensor,mul_elements), 1);
|
1035
1035
|
rb_define_method(GSL_TYPE(cgsl_tensor), "div_elements",
|
1036
|
-
|
1036
|
+
FUNCTION(rb_tensor,div_elements), 1);
|
1037
1037
|
rb_define_method(GSL_TYPE(cgsl_tensor), "add_constant",
|
1038
|
-
|
1038
|
+
FUNCTION(rb_tensor,add_constant), 1);
|
1039
1039
|
rb_define_method(GSL_TYPE(cgsl_tensor), "add_diagonal",
|
1040
|
-
|
1040
|
+
FUNCTION(rb_tensor,add_diagonal), 1);
|
1041
1041
|
rb_define_method(GSL_TYPE(cgsl_tensor), "scale",
|
1042
|
-
|
1042
|
+
FUNCTION(rb_tensor,scale), 1);
|
1043
1043
|
rb_define_singleton_method(GSL_TYPE(cgsl_tensor), "product",
|
1044
|
-
|
1044
|
+
FUNCTION(rb_tensor,product_singleton), 2);
|
1045
1045
|
rb_define_method(GSL_TYPE(cgsl_tensor), "product",
|
1046
|
-
|
1046
|
+
FUNCTION(rb_tensor,product), 1);
|
1047
1047
|
rb_define_method(GSL_TYPE(cgsl_tensor), "contract",
|
1048
|
-
|
1048
|
+
FUNCTION(rb_tensor,contract), 2);
|
1049
1049
|
|
1050
1050
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "+", "add");
|
1051
1051
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "-", "sub");
|
@@ -1054,62 +1054,62 @@ void FUNCTION(Init_tensor,init)(VALUE module)
|
|
1054
1054
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "*", "product");
|
1055
1055
|
|
1056
1056
|
rb_define_method(GSL_TYPE(cgsl_tensor), "add!",
|
1057
|
-
|
1057
|
+
FUNCTION(rb_tensor,add_bang), 1);
|
1058
1058
|
rb_define_method(GSL_TYPE(cgsl_tensor), "sub!",
|
1059
|
-
|
1059
|
+
FUNCTION(rb_tensor,sub_bang), 1);
|
1060
1060
|
rb_define_method(GSL_TYPE(cgsl_tensor), "mul_elements!",
|
1061
|
-
|
1061
|
+
FUNCTION(rb_tensor,mul_elements_bang), 1);
|
1062
1062
|
rb_define_method(GSL_TYPE(cgsl_tensor), "div_elements!",
|
1063
|
-
|
1063
|
+
FUNCTION(rb_tensor,div_elements_bang), 1);
|
1064
1064
|
rb_define_method(GSL_TYPE(cgsl_tensor), "add_constant!",
|
1065
|
-
|
1065
|
+
FUNCTION(rb_tensor,add_constant_bang), 1);
|
1066
1066
|
rb_define_method(GSL_TYPE(cgsl_tensor), "add_diagonal!",
|
1067
|
-
|
1067
|
+
FUNCTION(rb_tensor,add_diagonal_bang), 1);
|
1068
1068
|
rb_define_method(GSL_TYPE(cgsl_tensor), "scale!",
|
1069
|
-
|
1069
|
+
FUNCTION(rb_tensor,scale_bang), 1);
|
1070
1070
|
|
1071
1071
|
rb_define_method(GSL_TYPE(cgsl_tensor), "+@",
|
1072
|
-
|
1072
|
+
FUNCTION(rb_tensor,uplus), 0);
|
1073
1073
|
rb_define_method(GSL_TYPE(cgsl_tensor), "-@",
|
1074
|
-
|
1074
|
+
FUNCTION(rb_tensor,uminus), 0);
|
1075
1075
|
|
1076
1076
|
rb_define_method(GSL_TYPE(cgsl_tensor), "size",
|
1077
|
-
|
1077
|
+
FUNCTION(rb_tensor,size), 0);
|
1078
1078
|
rb_define_method(GSL_TYPE(cgsl_tensor), "rank",
|
1079
|
-
|
1079
|
+
FUNCTION(rb_tensor,rank), 0);
|
1080
1080
|
rb_define_method(GSL_TYPE(cgsl_tensor), "dimension",
|
1081
|
-
|
1081
|
+
FUNCTION(rb_tensor,dimension), 0);
|
1082
1082
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "dim", "dimension");
|
1083
1083
|
rb_define_method(GSL_TYPE(cgsl_tensor), "data",
|
1084
|
-
|
1084
|
+
FUNCTION(rb_tensor,data), 0);
|
1085
1085
|
|
1086
1086
|
rb_define_method(GSL_TYPE(cgsl_tensor), "to_v",
|
1087
|
-
|
1087
|
+
FUNCTION(rb_tensor,to_v), 0);
|
1088
1088
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "to_gv", "to_v");
|
1089
1089
|
|
1090
1090
|
rb_define_method(GSL_TYPE(cgsl_tensor), "to_vector",
|
1091
|
-
|
1091
|
+
FUNCTION(rb_tensor,2vector), 0);
|
1092
1092
|
rb_define_method(GSL_TYPE(cgsl_tensor), "to_matrix",
|
1093
|
-
|
1093
|
+
FUNCTION(rb_tensor,2matrix), 0);
|
1094
1094
|
|
1095
1095
|
rb_define_method(GSL_TYPE(cgsl_tensor), "subtensor",
|
1096
|
-
|
1096
|
+
FUNCTION(rb_tensor,subtensor), -1);
|
1097
1097
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "view", "subtensor");
|
1098
1098
|
|
1099
1099
|
rb_define_method(GSL_TYPE(cgsl_tensor), "to_s",
|
1100
|
-
|
1100
|
+
FUNCTION(rb_tensor,to_s), 0);
|
1101
1101
|
rb_define_method(GSL_TYPE(cgsl_tensor), "inspect",
|
1102
|
-
|
1102
|
+
FUNCTION(rb_tensor,inspect), 0);
|
1103
1103
|
|
1104
1104
|
rb_define_method(GSL_TYPE(cgsl_tensor), "equal?",
|
1105
|
-
|
1105
|
+
FUNCTION(rb_tensor,equal), -1);
|
1106
1106
|
rb_define_alias(GSL_TYPE(cgsl_tensor), "==", "equal?");
|
1107
1107
|
|
1108
1108
|
rb_define_method(GSL_TYPE(cgsl_tensor), "coerce",
|
1109
|
-
|
1109
|
+
FUNCTION(rb_tensor,coerce), 1);
|
1110
1110
|
|
1111
|
-
rb_define_method(GSL_TYPE(cgsl_tensor), "info",
|
1112
|
-
|
1111
|
+
rb_define_method(GSL_TYPE(cgsl_tensor), "info",
|
1112
|
+
FUNCTION(rb_tensor,info), 0);
|
1113
1113
|
}
|
1114
1114
|
|
1115
1115
|
#undef NUMCONV
|