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
@@ -31,11 +31,9 @@ gsl_complex rb_gsl_obj_to_gsl_complex(VALUE obj, gsl_complex *z)
|
|
31
31
|
z = &tmp;
|
32
32
|
GSL_SET_COMPLEX(z, 0.0, 0.0);
|
33
33
|
}
|
34
|
-
|
35
34
|
if(obj == Qnil) {
|
36
35
|
return *z;
|
37
36
|
}
|
38
|
-
|
39
37
|
switch(TYPE(obj)) {
|
40
38
|
case T_ARRAY:
|
41
39
|
vre = rb_ary_entry(obj,0);
|
@@ -54,8 +52,8 @@ gsl_complex rb_gsl_obj_to_gsl_complex(VALUE obj, gsl_complex *z)
|
|
54
52
|
*z = *zz;
|
55
53
|
} else {
|
56
54
|
rb_raise(rb_eTypeError,
|
57
|
-
|
58
|
-
|
55
|
+
"wrong type %s, (nil, Array, Float, Integer, or GSL::Complex expected)",
|
56
|
+
rb_class2name(CLASS_OF(obj)));
|
59
57
|
}
|
60
58
|
break;
|
61
59
|
}
|
@@ -66,7 +64,7 @@ static VALUE rb_gsl_complex_new(int argc, VALUE *argv, VALUE klass)
|
|
66
64
|
{
|
67
65
|
gsl_complex *c = NULL;
|
68
66
|
VALUE obj;
|
69
|
-
obj = Data_Make_Struct(klass, gsl_complex, 0, free, c);
|
67
|
+
obj = Data_Make_Struct(klass, gsl_complex, 0, free, c);
|
70
68
|
switch (argc) {
|
71
69
|
case 1:
|
72
70
|
switch (TYPE(argv[0])) {
|
@@ -80,8 +78,8 @@ static VALUE rb_gsl_complex_new(int argc, VALUE *argv, VALUE klass)
|
|
80
78
|
*c = gsl_complex_rect(NUM2DBL(argv[0]), 0.0);
|
81
79
|
break;
|
82
80
|
default:
|
83
|
-
rb_raise(rb_eTypeError, "wrong argument type %s",
|
84
|
-
|
81
|
+
rb_raise(rb_eTypeError, "wrong argument type %s",
|
82
|
+
rb_class2name(CLASS_OF(argv[0])));
|
85
83
|
}
|
86
84
|
break;
|
87
85
|
case 2:
|
@@ -107,7 +105,7 @@ static VALUE rb_gsl_complex_polar(VALUE klass, VALUE r, VALUE theta)
|
|
107
105
|
VALUE obj;
|
108
106
|
gsl_complex *c = NULL;
|
109
107
|
Need_Float(r); Need_Float(theta);
|
110
|
-
obj = Data_Make_Struct(klass, gsl_complex, 0, free, c);
|
108
|
+
obj = Data_Make_Struct(klass, gsl_complex, 0, free, c);
|
111
109
|
*c = gsl_complex_polar(NUM2DBL(r), NUM2DBL(theta));
|
112
110
|
return obj;
|
113
111
|
}
|
@@ -121,10 +119,10 @@ static VALUE rb_gsl_complex_get(VALUE obj, VALUE ii)
|
|
121
119
|
i = FIX2INT(ii);
|
122
120
|
switch (i) {
|
123
121
|
case 0:
|
124
|
-
return
|
122
|
+
return rb_float_new(GSL_REAL(*c));
|
125
123
|
break;
|
126
124
|
case 1:
|
127
|
-
return
|
125
|
+
return rb_float_new(GSL_IMAG(*c));
|
128
126
|
break;
|
129
127
|
default:
|
130
128
|
rb_raise(rb_eArgError, "wrong argument (%d for 0 or 1)", i);
|
@@ -137,14 +135,14 @@ static VALUE rb_gsl_complex_real(VALUE obj)
|
|
137
135
|
{
|
138
136
|
gsl_complex *c = NULL;
|
139
137
|
Data_Get_Struct(obj, gsl_complex, c);
|
140
|
-
return
|
138
|
+
return rb_float_new(GSL_REAL(*c));
|
141
139
|
}
|
142
140
|
|
143
141
|
static VALUE rb_gsl_complex_imag(VALUE obj)
|
144
142
|
{
|
145
143
|
gsl_complex *c = NULL;
|
146
144
|
Data_Get_Struct(obj, gsl_complex, c);
|
147
|
-
return
|
145
|
+
return rb_float_new(GSL_IMAG(*c));
|
148
146
|
}
|
149
147
|
|
150
148
|
static VALUE rb_gsl_complex_print(VALUE obj)
|
@@ -172,7 +170,7 @@ static VALUE rb_gsl_complex_return_double(double (*func)(gsl_complex), VALUE obj
|
|
172
170
|
{
|
173
171
|
gsl_complex *c = NULL;
|
174
172
|
Data_Get_Struct(obj, gsl_complex, c);
|
175
|
-
return
|
173
|
+
return rb_float_new((*func)(*c));
|
176
174
|
}
|
177
175
|
|
178
176
|
static VALUE rb_gsl_complex_arg(VALUE obj)
|
@@ -196,10 +194,10 @@ static VALUE rb_gsl_complex_logabs(VALUE obj)
|
|
196
194
|
}
|
197
195
|
|
198
196
|
static VALUE rb_gsl_complex_arithmetics2(gsl_complex (*func)(gsl_complex, double),
|
199
|
-
|
197
|
+
VALUE obj, VALUE xx);
|
200
198
|
|
201
199
|
static VALUE rb_gsl_complex_arithmetics2(gsl_complex (*func)(gsl_complex, double),
|
202
|
-
|
200
|
+
VALUE obj, VALUE xx)
|
203
201
|
{
|
204
202
|
gsl_complex *a = NULL, *c = NULL, tmp;
|
205
203
|
VALUE obj2;
|
@@ -208,7 +206,7 @@ static VALUE rb_gsl_complex_arithmetics2(gsl_complex (*func)(gsl_complex, double
|
|
208
206
|
Data_Get_Struct(obj, gsl_complex, a);
|
209
207
|
x = NUM2DBL(xx);
|
210
208
|
tmp = (*func)(*a, x);
|
211
|
-
obj2 = Data_Make_Struct(cgsl_complex, gsl_complex, 0, free, c);
|
209
|
+
obj2 = Data_Make_Struct(cgsl_complex, gsl_complex, 0, free, c);
|
212
210
|
*c = tmp;
|
213
211
|
return obj2;
|
214
212
|
}
|
@@ -262,7 +260,7 @@ static VALUE rb_gsl_complex_operate(gsl_complex (*func)(gsl_complex), VALUE obj)
|
|
262
260
|
Data_Get_Struct(obj, gsl_complex, c);
|
263
261
|
cnew = ALLOC(gsl_complex);
|
264
262
|
*cnew = (*func)(*c);
|
265
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
263
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
266
264
|
}
|
267
265
|
|
268
266
|
static VALUE rb_gsl_complex_operate2(gsl_complex (*func)(gsl_complex), int argc, VALUE *argv, VALUE obj)
|
@@ -279,33 +277,33 @@ static VALUE rb_gsl_complex_operate2(gsl_complex (*func)(gsl_complex), int argc,
|
|
279
277
|
case 1:
|
280
278
|
switch (TYPE(argv[0])) {
|
281
279
|
case T_ARRAY:
|
282
|
-
|
283
|
-
|
284
|
-
|
280
|
+
tmp = ary2complex(argv[0]);
|
281
|
+
c = &tmp;
|
282
|
+
break;
|
285
283
|
default:
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
284
|
+
if (VECTOR_COMPLEX_P(argv[0])) {
|
285
|
+
Data_Get_Struct(argv[0], gsl_vector_complex, v);
|
286
|
+
vnew = gsl_vector_complex_alloc(v->size);
|
287
|
+
for (i = 0; i < v->size; i++) {
|
288
|
+
c = GSL_COMPLEX_AT(v, i);
|
289
|
+
gsl_vector_complex_set(vnew, i, (*func)(*c));
|
290
|
+
}
|
291
|
+
return Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_free, vnew);
|
292
|
+
} else if (MATRIX_COMPLEX_P(obj)) {
|
293
|
+
Data_Get_Struct(obj, gsl_matrix_complex, m);
|
294
|
+
mnew = gsl_matrix_complex_alloc(m->size1, m->size2);
|
295
|
+
for (i = 0; i < m->size1; i++) {
|
296
|
+
for (j = 0; j < m->size2; j++) {
|
297
|
+
gsl_matrix_complex_set(mnew, i, j,
|
298
|
+
(*func)(gsl_matrix_complex_get(m, i, j)));
|
299
|
+
}
|
300
|
+
}
|
301
|
+
return Data_Wrap_Struct(cgsl_matrix_complex, 0, gsl_matrix_complex_free, mnew);
|
302
|
+
} else {
|
303
|
+
CHECK_COMPLEX(argv[0]);
|
304
|
+
Data_Get_Struct(argv[0], gsl_complex, c);
|
305
|
+
}
|
306
|
+
break;
|
309
307
|
}
|
310
308
|
break;
|
311
309
|
case 2:
|
@@ -324,7 +322,7 @@ static VALUE rb_gsl_complex_operate2(gsl_complex (*func)(gsl_complex), int argc,
|
|
324
322
|
}
|
325
323
|
cnew = ALLOC(gsl_complex);
|
326
324
|
*cnew = (*func)(*c);
|
327
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
325
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
328
326
|
}
|
329
327
|
|
330
328
|
static VALUE rb_gsl_complex_conjugate(VALUE obj)
|
@@ -350,7 +348,7 @@ static VALUE rb_gsl_complex_sqrt_real(VALUE obj, VALUE x)
|
|
350
348
|
tmp = gsl_complex_sqrt_real(NUM2DBL(x));
|
351
349
|
cnew = ALLOC(gsl_complex);
|
352
350
|
*cnew = tmp;
|
353
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
351
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
354
352
|
}
|
355
353
|
|
356
354
|
static VALUE rb_gsl_complex_sqrt(int argc, VALUE *argv, VALUE obj)
|
@@ -362,22 +360,22 @@ static VALUE rb_gsl_complex_sqrt(int argc, VALUE *argv, VALUE obj)
|
|
362
360
|
case 1:
|
363
361
|
switch (TYPE(argv[0])) {
|
364
362
|
case T_FIXNUM: case T_FLOAT:
|
365
|
-
|
366
|
-
|
363
|
+
return rb_gsl_complex_sqrt_real(obj, argv[0]);
|
364
|
+
break;
|
367
365
|
case T_ARRAY:
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
366
|
+
tmp = ary2complex(argv[0]);
|
367
|
+
z = ALLOC(gsl_complex);
|
368
|
+
*z = gsl_complex_sqrt(tmp);
|
369
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, z);
|
370
|
+
break;
|
373
371
|
default:
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
372
|
+
CHECK_COMPLEX(argv[0]);
|
373
|
+
Data_Get_Struct(argv[0], gsl_complex, z);
|
374
|
+
tmp = *z;
|
375
|
+
z = ALLOC(gsl_complex);
|
376
|
+
*z = gsl_complex_sqrt(tmp);
|
377
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, z);
|
378
|
+
break;
|
381
379
|
}
|
382
380
|
break;
|
383
381
|
case 2:
|
@@ -385,7 +383,7 @@ static VALUE rb_gsl_complex_sqrt(int argc, VALUE *argv, VALUE obj)
|
|
385
383
|
GSL_SET_REAL(&tmp, NUM2DBL(argv[0]));
|
386
384
|
GSL_SET_IMAG(&tmp, NUM2DBL(argv[1]));
|
387
385
|
*z = gsl_complex_sqrt(tmp);
|
388
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, z);
|
386
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, z);
|
389
387
|
break;
|
390
388
|
default:
|
391
389
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
|
@@ -408,14 +406,14 @@ VALUE rb_gsl_complex_pow(int argc, VALUE *argv, VALUE obj)
|
|
408
406
|
case T_MODULE:
|
409
407
|
case T_CLASS:
|
410
408
|
case T_OBJECT:
|
411
|
-
if (argc != 2)
|
409
|
+
if (argc != 2)
|
412
410
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
|
413
411
|
switch (TYPE(argv[1])) {
|
414
412
|
case T_ARRAY:
|
415
413
|
tmpa = ary2complex(argv[1]);
|
416
414
|
a = &tmpa;
|
417
415
|
break;
|
418
|
-
case T_FLOAT: case T_FIXNUM:
|
416
|
+
case T_FLOAT: case T_FIXNUM:
|
419
417
|
return rb_gsl_complex_pow_real(argc, argv, obj);
|
420
418
|
break;
|
421
419
|
default:
|
@@ -431,24 +429,24 @@ VALUE rb_gsl_complex_pow(int argc, VALUE *argv, VALUE obj)
|
|
431
429
|
break;
|
432
430
|
default:
|
433
431
|
if (VECTOR_COMPLEX_P(argv[0])) {
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
432
|
+
Data_Get_Struct(argv[0], gsl_vector_complex, v);
|
433
|
+
vnew = gsl_vector_complex_alloc(v->size);
|
434
|
+
for (i = 0; i < v->size; i++) {
|
435
|
+
c = GSL_COMPLEX_AT(v, i);
|
436
|
+
gsl_vector_complex_set(vnew, i, gsl_complex_pow(*c, *a));
|
437
|
+
}
|
438
|
+
return Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, vnew);
|
441
439
|
}
|
442
440
|
if (MATRIX_COMPLEX_P(argv[0])) {
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
441
|
+
Data_Get_Struct(argv[0], gsl_matrix_complex, m);
|
442
|
+
mnew = gsl_matrix_complex_alloc(m->size1, m->size2);
|
443
|
+
for (i = 0; i < m->size1; i++) {
|
444
|
+
for (j = 0; j < m->size2; j++) {
|
445
|
+
c = gsl_matrix_complex_ptr(m, i, j);
|
446
|
+
gsl_matrix_complex_set(mnew, i, j, gsl_complex_pow(*c, *a));
|
447
|
+
}
|
448
|
+
}
|
449
|
+
return Data_Wrap_Struct(cgsl_matrix_complex, 0, gsl_matrix_complex_free, mnew);
|
452
450
|
}
|
453
451
|
CHECK_COMPLEX(argv[0]);
|
454
452
|
Data_Get_Struct(argv[0], gsl_complex, c);
|
@@ -457,7 +455,7 @@ VALUE rb_gsl_complex_pow(int argc, VALUE *argv, VALUE obj)
|
|
457
455
|
|
458
456
|
break;
|
459
457
|
default:
|
460
|
-
if (argc != 1)
|
458
|
+
if (argc != 1)
|
461
459
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
|
462
460
|
CHECK_COMPLEX(obj);
|
463
461
|
Data_Get_Struct(obj, gsl_complex, c);
|
@@ -466,7 +464,7 @@ VALUE rb_gsl_complex_pow(int argc, VALUE *argv, VALUE obj)
|
|
466
464
|
tmpa = ary2complex(argv[0]);
|
467
465
|
a = &tmpa;
|
468
466
|
break;
|
469
|
-
case T_FLOAT: case T_FIXNUM:
|
467
|
+
case T_FLOAT: case T_FIXNUM:
|
470
468
|
return rb_gsl_complex_pow_real(argc, argv, obj);
|
471
469
|
break;
|
472
470
|
default:
|
@@ -478,7 +476,7 @@ VALUE rb_gsl_complex_pow(int argc, VALUE *argv, VALUE obj)
|
|
478
476
|
}
|
479
477
|
cnew = ALLOC(gsl_complex);
|
480
478
|
*cnew = gsl_complex_pow(*c, *a);
|
481
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
479
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
482
480
|
}
|
483
481
|
|
484
482
|
VALUE rb_gsl_complex_pow_real(int argc, VALUE *argv, VALUE obj)
|
@@ -492,7 +490,7 @@ VALUE rb_gsl_complex_pow_real(int argc, VALUE *argv, VALUE obj)
|
|
492
490
|
case T_MODULE:
|
493
491
|
case T_CLASS:
|
494
492
|
case T_OBJECT:
|
495
|
-
if (argc != 2)
|
493
|
+
if (argc != 2)
|
496
494
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
|
497
495
|
switch (TYPE(argv[0])) {
|
498
496
|
case T_ARRAY:
|
@@ -502,26 +500,26 @@ VALUE rb_gsl_complex_pow_real(int argc, VALUE *argv, VALUE obj)
|
|
502
500
|
break;
|
503
501
|
default:
|
504
502
|
if (VECTOR_COMPLEX_P(argv[0])) {
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
503
|
+
Data_Get_Struct(argv[0], gsl_vector_complex, v);
|
504
|
+
vnew = gsl_vector_complex_alloc(v->size);
|
505
|
+
a = NUM2DBL(argv[1]);
|
506
|
+
for (i = 0; i < v->size; i++) {
|
507
|
+
c = GSL_COMPLEX_AT(v, i);
|
508
|
+
tmpc = gsl_complex_pow_real(*c, a);
|
509
|
+
gsl_vector_complex_set(vnew, i, tmpc);
|
510
|
+
}
|
511
|
+
return Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_free, vnew);
|
514
512
|
}
|
515
513
|
if (MATRIX_COMPLEX_P(argv[0])) {
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
514
|
+
Data_Get_Struct(argv[0], gsl_matrix_complex, m);
|
515
|
+
mnew = gsl_matrix_complex_alloc(m->size1, m->size2);
|
516
|
+
for (i = 0; i < m->size1; i++) {
|
517
|
+
for (j = 0; j < m->size2; j++) {
|
518
|
+
tmpc = gsl_complex_pow_real(gsl_matrix_complex_get(m, i, j), a);
|
519
|
+
gsl_matrix_complex_set(mnew, i, j, tmpc);
|
520
|
+
}
|
521
|
+
}
|
522
|
+
return Data_Wrap_Struct(cgsl_matrix_complex, 0, gsl_matrix_complex_free, mnew);
|
525
523
|
}
|
526
524
|
CHECK_COMPLEX(argv[0]);
|
527
525
|
Data_Get_Struct(argv[0], gsl_complex, c);
|
@@ -531,7 +529,7 @@ VALUE rb_gsl_complex_pow_real(int argc, VALUE *argv, VALUE obj)
|
|
531
529
|
a = NUM2DBL(argv[1]);
|
532
530
|
break;
|
533
531
|
default:
|
534
|
-
if (argc != 1)
|
532
|
+
if (argc != 1)
|
535
533
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
|
536
534
|
CHECK_COMPLEX(obj);
|
537
535
|
Need_Float(argv[0]);
|
@@ -541,7 +539,7 @@ VALUE rb_gsl_complex_pow_real(int argc, VALUE *argv, VALUE obj)
|
|
541
539
|
}
|
542
540
|
cnew = ALLOC(gsl_complex);
|
543
541
|
*cnew = gsl_complex_pow_real(*c, a);
|
544
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
542
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
545
543
|
}
|
546
544
|
|
547
545
|
static VALUE rb_gsl_complex_exp(int argc, VALUE *argv, VALUE obj)
|
@@ -566,7 +564,7 @@ static VALUE rb_gsl_complex_log_b(int argc, VALUE *argv, VALUE obj)
|
|
566
564
|
case T_MODULE:
|
567
565
|
case T_CLASS:
|
568
566
|
case T_OBJECT:
|
569
|
-
if (argc != 2)
|
567
|
+
if (argc != 2)
|
570
568
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
|
571
569
|
switch (TYPE(argv[1])) {
|
572
570
|
case T_ARRAY:
|
@@ -592,7 +590,7 @@ static VALUE rb_gsl_complex_log_b(int argc, VALUE *argv, VALUE obj)
|
|
592
590
|
|
593
591
|
break;
|
594
592
|
default:
|
595
|
-
if (argc != 1)
|
593
|
+
if (argc != 1)
|
596
594
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
|
597
595
|
CHECK_COMPLEX(obj);
|
598
596
|
Data_Get_Struct(obj, gsl_complex, c);
|
@@ -610,7 +608,7 @@ static VALUE rb_gsl_complex_log_b(int argc, VALUE *argv, VALUE obj)
|
|
610
608
|
}
|
611
609
|
cnew = ALLOC(gsl_complex);
|
612
610
|
*cnew = gsl_complex_log_b(*c, *a);
|
613
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
611
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
614
612
|
}
|
615
613
|
|
616
614
|
static VALUE rb_gsl_complex_sin(int argc, VALUE *argv, VALUE obj)
|
@@ -658,7 +656,7 @@ static VALUE rb_gsl_complex_arcsin_real(VALUE obj, VALUE xx)
|
|
658
656
|
tmp = gsl_complex_arcsin_real(x);
|
659
657
|
cnew = ALLOC(gsl_complex);
|
660
658
|
*cnew = tmp;
|
661
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
659
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
662
660
|
}
|
663
661
|
|
664
662
|
static VALUE rb_gsl_complex_arccos(int argc, VALUE *argv, VALUE obj)
|
@@ -675,7 +673,7 @@ static VALUE rb_gsl_complex_arccos_real(VALUE obj, VALUE xx)
|
|
675
673
|
tmp = gsl_complex_arccos_real(x);
|
676
674
|
cnew = ALLOC(gsl_complex);
|
677
675
|
*cnew = tmp;
|
678
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
676
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
679
677
|
}
|
680
678
|
|
681
679
|
static VALUE rb_gsl_complex_arctan(int argc, VALUE *argv, VALUE obj)
|
@@ -697,7 +695,7 @@ static VALUE rb_gsl_complex_arcsec_real(VALUE obj, VALUE xx)
|
|
697
695
|
tmp = gsl_complex_arcsec_real(x);
|
698
696
|
cnew = ALLOC(gsl_complex);
|
699
697
|
*cnew = tmp;
|
700
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
698
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
701
699
|
}
|
702
700
|
|
703
701
|
static VALUE rb_gsl_complex_arccsc(int argc, VALUE *argv, VALUE obj)
|
@@ -714,7 +712,7 @@ static VALUE rb_gsl_complex_arccsc_real(VALUE obj, VALUE xx)
|
|
714
712
|
tmp = gsl_complex_arccsc_real(x);
|
715
713
|
cnew = ALLOC(gsl_complex);
|
716
714
|
*cnew = tmp;
|
717
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
715
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
718
716
|
}
|
719
717
|
|
720
718
|
static VALUE rb_gsl_complex_arccot(int argc, VALUE *argv, VALUE obj)
|
@@ -766,7 +764,7 @@ static VALUE rb_gsl_complex_arccosh_real(VALUE obj, VALUE xx)
|
|
766
764
|
tmp = gsl_complex_arccosh_real(x);
|
767
765
|
cnew = ALLOC(gsl_complex);
|
768
766
|
*cnew = tmp;
|
769
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
767
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
770
768
|
}
|
771
769
|
|
772
770
|
static VALUE rb_gsl_complex_arccosh(int argc, VALUE *argv, VALUE obj)
|
@@ -788,7 +786,7 @@ static VALUE rb_gsl_complex_arctanh_real(VALUE obj, VALUE xx)
|
|
788
786
|
tmp = gsl_complex_arctanh_real(x);
|
789
787
|
cnew = ALLOC(gsl_complex);
|
790
788
|
*cnew = tmp;
|
791
|
-
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
789
|
+
return Data_Wrap_Struct(cgsl_complex, 0, free, cnew);
|
792
790
|
}
|
793
791
|
|
794
792
|
static VALUE rb_gsl_complex_arcsech(int argc, VALUE *argv, VALUE obj)
|
@@ -807,10 +805,10 @@ static VALUE rb_gsl_complex_arccoth(int argc, VALUE *argv, VALUE obj)
|
|
807
805
|
}
|
808
806
|
|
809
807
|
int rbgsl_complex_equal(const gsl_complex *z1, const gsl_complex *z2,
|
810
|
-
|
808
|
+
double eps)
|
811
809
|
{
|
812
810
|
if (gsl_fcmp(z1->dat[0], z2->dat[0], eps) != 0) return 0;
|
813
|
-
if (gsl_fcmp(z1->dat[1], z2->dat[1], eps) != 0) return 0;
|
811
|
+
if (gsl_fcmp(z1->dat[1], z2->dat[1], eps) != 0) return 0;
|
814
812
|
return 1;
|
815
813
|
}
|
816
814
|
|
@@ -825,11 +823,11 @@ static VALUE rb_gsl_complex_equal(int argc, VALUE *argv, VALUE obj)
|
|
825
823
|
{
|
826
824
|
gsl_complex *z1 = NULL, *z2 = NULL;
|
827
825
|
double eps = 1e-8;
|
828
|
-
|
826
|
+
|
829
827
|
switch (argc) {
|
830
828
|
case 1:
|
831
829
|
CHECK_COMPLEX(argv[0]);
|
832
|
-
Data_Get_Struct(argv[0], gsl_complex, z2);
|
830
|
+
Data_Get_Struct(argv[0], gsl_complex, z2);
|
833
831
|
break;
|
834
832
|
case 2:
|
835
833
|
CHECK_COMPLEX(argv[0]);
|