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
@@ -18,9 +18,7 @@ EXTERN VALUE mgsl_linalg;
|
|
18
18
|
EXTERN VALUE cgsl_complex;
|
19
19
|
|
20
20
|
static VALUE cgsl_matrix_complex_LU;
|
21
|
-
#ifdef GSL_1_10_LATER
|
22
21
|
static VALUE cgsl_matrix_complex_C;
|
23
|
-
#endif
|
24
22
|
|
25
23
|
VALUE rb_gsl_linalg_complex_LU_decomp(int argc, VALUE *argv, VALUE obj)
|
26
24
|
{
|
@@ -35,7 +33,7 @@ VALUE rb_gsl_linalg_complex_LU_decomp(int argc, VALUE *argv, VALUE obj)
|
|
35
33
|
case T_CLASS:
|
36
34
|
case T_OBJECT:
|
37
35
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
38
|
-
|
36
|
+
argc);
|
39
37
|
CHECK_MATRIX_COMPLEX(argv[0]);
|
40
38
|
Data_Get_Struct(argv[0], gsl_matrix_complex, m);
|
41
39
|
itmp = 1;
|
@@ -81,7 +79,7 @@ VALUE rb_gsl_linalg_complex_LU_decomp2(int argc, VALUE *argv, VALUE obj)
|
|
81
79
|
case T_CLASS:
|
82
80
|
case T_OBJECT:
|
83
81
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
84
|
-
|
82
|
+
argc);
|
85
83
|
CHECK_MATRIX_COMPLEX(argv[0]);
|
86
84
|
Data_Get_Struct(argv[0], gsl_matrix_complex, m);
|
87
85
|
itmp = 1;
|
@@ -100,13 +98,13 @@ VALUE rb_gsl_linalg_complex_LU_decomp2(int argc, VALUE *argv, VALUE obj)
|
|
100
98
|
p = gsl_permutation_alloc(size);
|
101
99
|
gsl_linalg_complex_LU_decomp(mnew, p, &signum);
|
102
100
|
obj2 = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
|
103
|
-
return rb_ary_new3(3, objm
|
101
|
+
return rb_ary_new3(3, objm,obj2, INT2FIX(signum));
|
104
102
|
break;
|
105
103
|
case 1: /* when a permutation object is given */
|
106
104
|
CHECK_PERMUTATION(argv[itmp]);
|
107
105
|
Data_Get_Struct(argv[itmp], gsl_permutation, p);
|
108
106
|
gsl_linalg_complex_LU_decomp(m, p, &signum);
|
109
|
-
return rb_ary_new3(3, objm
|
107
|
+
return rb_ary_new3(3, objm, argv[itmp], INT2FIX(signum));
|
110
108
|
break;
|
111
109
|
default:
|
112
110
|
rb_raise(rb_eArgError, "Usage: LU_decomp!() or LU_decomp!(permutation)");
|
@@ -119,14 +117,13 @@ static VALUE rb_gsl_linalg_complex_LU_solve(int argc, VALUE *argv, VALUE obj)
|
|
119
117
|
gsl_permutation *p = NULL;
|
120
118
|
gsl_vector_complex *b = NULL, *x = NULL;
|
121
119
|
int flagm = 0, flagx = 0, itmp, signum;
|
122
|
-
|
120
|
+
|
123
121
|
switch (TYPE(obj)) {
|
124
122
|
case T_MODULE:
|
125
123
|
case T_CLASS:
|
126
124
|
case T_OBJECT:
|
127
|
-
if (argc < 2 || argc > 4)
|
125
|
+
if (argc < 2 || argc > 4)
|
128
126
|
rb_raise(rb_eArgError, "Usage: solve(m, b), solve(m, b, x), solve(lu, p, b), solve(lu, p, b, x)");
|
129
|
-
|
130
127
|
CHECK_MATRIX(argv[0]);
|
131
128
|
Data_Get_Struct(argv[0], gsl_matrix_complex, m);
|
132
129
|
if (CLASS_OF(argv[0]) != cgsl_matrix_complex_LU) {
|
@@ -139,7 +136,7 @@ static VALUE rb_gsl_linalg_complex_LU_solve(int argc, VALUE *argv, VALUE obj)
|
|
139
136
|
itmp = 1;
|
140
137
|
break;
|
141
138
|
default:
|
142
|
-
if (argc < 1 || argc > 3)
|
139
|
+
if (argc < 1 || argc > 3)
|
143
140
|
rb_raise(rb_eArgError, "Usage: LU_solve(b), LU_solve(p, b), LU_solve(b, x), solve(p, b, x)");
|
144
141
|
Data_Get_Struct(obj, gsl_matrix_complex, m);
|
145
142
|
if (CLASS_OF(obj) != cgsl_matrix_complex_LU) {
|
@@ -185,7 +182,7 @@ static VALUE rb_gsl_linalg_complex_LU_svx(int argc, VALUE *argv, VALUE obj)
|
|
185
182
|
gsl_permutation *p = NULL;
|
186
183
|
gsl_vector_complex *x = NULL;
|
187
184
|
int flagm = 0, itmp, signum;
|
188
|
-
|
185
|
+
|
189
186
|
switch (TYPE(obj)) {
|
190
187
|
case T_MODULE:
|
191
188
|
case T_CLASS:
|
@@ -232,8 +229,8 @@ static VALUE rb_gsl_linalg_complex_LU_svx(int argc, VALUE *argv, VALUE obj)
|
|
232
229
|
}
|
233
230
|
|
234
231
|
static VALUE rb_gsl_linalg_complex_LU_refine(VALUE obj, VALUE vm,
|
235
|
-
|
236
|
-
|
232
|
+
VALUE lu, VALUE pp, VALUE bb,
|
233
|
+
VALUE xx)
|
237
234
|
{
|
238
235
|
gsl_matrix_complex *m = NULL, *mlu = NULL;
|
239
236
|
gsl_permutation *p = NULL;
|
@@ -306,7 +303,6 @@ static VALUE rb_gsl_linalg_complex_LU_invert(int argc, VALUE *argv, VALUE obj)
|
|
306
303
|
}
|
307
304
|
return Data_Wrap_Struct(cgsl_matrix_complex, 0, gsl_matrix_complex_free, inverse);
|
308
305
|
}
|
309
|
-
#ifdef GSL_1_1_1_LATER
|
310
306
|
static VALUE rb_gsl_linalg_complex_LU_det(int argc, VALUE *argv, VALUE obj)
|
311
307
|
{
|
312
308
|
gsl_matrix_complex *m = NULL, *mtmp = NULL;
|
@@ -389,7 +385,7 @@ static VALUE rb_gsl_linalg_complex_LU_lndet(int argc, VALUE *argv, VALUE obj)
|
|
389
385
|
if (flagm == 1) {
|
390
386
|
p = gsl_permutation_alloc(m->size1);
|
391
387
|
gsl_linalg_complex_LU_decomp(mtmp, p, &signum);
|
392
|
-
}
|
388
|
+
}
|
393
389
|
lndet = gsl_linalg_complex_LU_lndet(mtmp);
|
394
390
|
if (flagm == 1) {
|
395
391
|
gsl_matrix_complex_free(mtmp);
|
@@ -446,9 +442,6 @@ static VALUE rb_gsl_linalg_complex_LU_sgndet(int argc, VALUE *argv, VALUE obj)
|
|
446
442
|
}
|
447
443
|
return vz;
|
448
444
|
}
|
449
|
-
#endif
|
450
|
-
|
451
|
-
#ifdef GSL_1_10_LATER
|
452
445
|
|
453
446
|
static VALUE rb_gsl_linalg_cholesky_decomp(int argc, VALUE *argv, VALUE obj)
|
454
447
|
{
|
@@ -456,7 +449,7 @@ static VALUE rb_gsl_linalg_cholesky_decomp(int argc, VALUE *argv, VALUE obj)
|
|
456
449
|
switch(TYPE(obj)) {
|
457
450
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
458
451
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
459
|
-
|
452
|
+
argc);
|
460
453
|
CHECK_MATRIX_COMPLEX(argv[0]);
|
461
454
|
Data_Get_Struct(argv[0], gsl_matrix_complex, Atmp);
|
462
455
|
break;
|
@@ -479,13 +472,13 @@ static VALUE rb_gsl_linalg_cholesky_solve(int argc, VALUE *argv, VALUE obj)
|
|
479
472
|
switch(TYPE(obj)) {
|
480
473
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
481
474
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
482
|
-
|
475
|
+
argc);
|
483
476
|
vA = argv[0];
|
484
477
|
vb = argv[1];
|
485
478
|
break;
|
486
479
|
default:
|
487
480
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
488
|
-
|
481
|
+
argc);
|
489
482
|
vA = obj;
|
490
483
|
vb = argv[0];
|
491
484
|
break;
|
@@ -519,13 +512,13 @@ static VALUE rb_gsl_linalg_cholesky_svx(int argc, VALUE *argv, VALUE obj)
|
|
519
512
|
switch(TYPE(obj)) {
|
520
513
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
521
514
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
522
|
-
|
515
|
+
argc);
|
523
516
|
vA = argv[0];
|
524
517
|
vb = argv[1];
|
525
518
|
break;
|
526
519
|
default:
|
527
520
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
528
|
-
|
521
|
+
argc);
|
529
522
|
vA = obj;
|
530
523
|
vb = argv[0];
|
531
524
|
break;
|
@@ -572,7 +565,7 @@ static VALUE rb_gsl_linalg_complex_householder_hm(VALUE obj, VALUE t, VALUE vv,
|
|
572
565
|
gsl_vector_complex *v = NULL;
|
573
566
|
gsl_complex *tau;
|
574
567
|
gsl_matrix_complex *A = NULL;
|
575
|
-
CHECK_COMPLEX(t);
|
568
|
+
CHECK_COMPLEX(t);
|
576
569
|
CHECK_VECTOR_COMPLEX(vv);
|
577
570
|
CHECK_MATRIX_COMPLEX(aa);
|
578
571
|
Data_Get_Struct(t, gsl_complex, tau);
|
@@ -587,7 +580,7 @@ static VALUE rb_gsl_linalg_complex_householder_mh(VALUE obj, VALUE t, VALUE vv,
|
|
587
580
|
gsl_vector_complex *v = NULL;
|
588
581
|
gsl_complex *tau;
|
589
582
|
gsl_matrix_complex *A = NULL;
|
590
|
-
CHECK_COMPLEX(t);
|
583
|
+
CHECK_COMPLEX(t);
|
591
584
|
CHECK_VECTOR_COMPLEX(vv);
|
592
585
|
CHECK_MATRIX_COMPLEX(aa);
|
593
586
|
Data_Get_Struct(t, gsl_complex, tau);
|
@@ -601,7 +594,7 @@ static VALUE rb_gsl_linalg_complex_householder_hv(VALUE obj, VALUE t, VALUE vv,
|
|
601
594
|
{
|
602
595
|
gsl_vector_complex *v = NULL, *w = NULL;
|
603
596
|
gsl_complex *tau;
|
604
|
-
CHECK_COMPLEX(t);
|
597
|
+
CHECK_COMPLEX(t);
|
605
598
|
CHECK_VECTOR_COMPLEX(vv);
|
606
599
|
CHECK_VECTOR_COMPLEX(ww);
|
607
600
|
Data_Get_Struct(t, gsl_complex, tau);
|
@@ -610,103 +603,97 @@ static VALUE rb_gsl_linalg_complex_householder_hv(VALUE obj, VALUE t, VALUE vv,
|
|
610
603
|
gsl_linalg_complex_householder_hv(*tau, v, w);
|
611
604
|
return ww;
|
612
605
|
}
|
613
|
-
#endif
|
614
606
|
|
615
607
|
void Init_gsl_linalg_complex(VALUE module)
|
616
608
|
{
|
617
609
|
VALUE mgsl_linalg_complex;
|
618
610
|
VALUE mgsl_linalg_complex_LU;
|
619
|
-
#ifdef GSL_1_10_LATER
|
620
611
|
VALUE mgsl_linalg_complex_chol, mgsl_linalg_complex_Householder;
|
621
|
-
#endif
|
622
612
|
|
623
613
|
mgsl_linalg_complex = rb_define_module_under(module, "Complex");
|
624
614
|
mgsl_linalg_complex_LU = rb_define_module_under(mgsl_linalg_complex, "LU");
|
625
615
|
|
626
616
|
cgsl_matrix_complex_LU = rb_define_class_under(mgsl_linalg_complex_LU,
|
627
|
-
|
617
|
+
"LUMatrix", cgsl_matrix_complex);
|
628
618
|
|
629
619
|
rb_define_singleton_method(mgsl_linalg_complex, "LU_decomp!",
|
630
|
-
|
620
|
+
rb_gsl_linalg_complex_LU_decomp, -1);
|
631
621
|
rb_define_singleton_method(mgsl_linalg_complex_LU, "decomp!",
|
632
|
-
|
633
|
-
rb_define_method(cgsl_matrix_complex, "LU_decomp!",
|
634
|
-
|
622
|
+
rb_gsl_linalg_complex_LU_decomp, -1);
|
623
|
+
rb_define_method(cgsl_matrix_complex, "LU_decomp!",
|
624
|
+
rb_gsl_linalg_complex_LU_decomp, -1);
|
635
625
|
rb_define_alias(cgsl_matrix_complex, "decomp!", "LU_decomp!");
|
636
626
|
|
637
627
|
rb_define_singleton_method(mgsl_linalg_complex, "LU_decomp",
|
638
|
-
|
628
|
+
rb_gsl_linalg_complex_LU_decomp2, -1);
|
639
629
|
rb_define_singleton_method(mgsl_linalg_complex_LU, "decomp",
|
640
|
-
|
641
|
-
rb_define_method(cgsl_matrix_complex, "LU_decomp",
|
642
|
-
|
630
|
+
rb_gsl_linalg_complex_LU_decomp2, -1);
|
631
|
+
rb_define_method(cgsl_matrix_complex, "LU_decomp",
|
632
|
+
rb_gsl_linalg_complex_LU_decomp2, -1);
|
643
633
|
rb_define_alias(cgsl_matrix_complex, "decomp", "LU_decomp");
|
644
634
|
|
645
635
|
rb_define_singleton_method(mgsl_linalg_complex, "LU_solve",
|
646
|
-
|
636
|
+
rb_gsl_linalg_complex_LU_solve, -1);
|
647
637
|
rb_define_singleton_method(mgsl_linalg_complex_LU, "solve",
|
648
|
-
|
649
|
-
rb_define_method(cgsl_matrix_complex, "LU_solve",
|
650
|
-
|
651
|
-
rb_define_method(cgsl_matrix_complex_LU, "solve",
|
652
|
-
|
638
|
+
rb_gsl_linalg_complex_LU_solve, -1);
|
639
|
+
rb_define_method(cgsl_matrix_complex, "LU_solve",
|
640
|
+
rb_gsl_linalg_complex_LU_solve, -1);
|
641
|
+
rb_define_method(cgsl_matrix_complex_LU, "solve",
|
642
|
+
rb_gsl_linalg_complex_LU_solve, -1);
|
653
643
|
|
654
644
|
rb_define_singleton_method(mgsl_linalg_complex, "LU_svx",
|
655
|
-
|
645
|
+
rb_gsl_linalg_complex_LU_svx, -1);
|
656
646
|
rb_define_singleton_method(mgsl_linalg_complex_LU, "svx",
|
657
|
-
|
658
|
-
rb_define_method(cgsl_matrix_complex, "LU_svx",
|
659
|
-
|
660
|
-
rb_define_method(cgsl_matrix_complex_LU, "svx",
|
661
|
-
|
647
|
+
rb_gsl_linalg_complex_LU_svx, -1);
|
648
|
+
rb_define_method(cgsl_matrix_complex, "LU_svx",
|
649
|
+
rb_gsl_linalg_complex_LU_svx, -1);
|
650
|
+
rb_define_method(cgsl_matrix_complex_LU, "svx",
|
651
|
+
rb_gsl_linalg_complex_LU_svx, -1);
|
662
652
|
|
663
653
|
rb_define_singleton_method(mgsl_linalg_complex, "LU_refine",
|
664
|
-
|
654
|
+
rb_gsl_linalg_complex_LU_refine, 5);
|
665
655
|
rb_define_singleton_method(mgsl_linalg_complex_LU, "refine",
|
666
|
-
|
656
|
+
rb_gsl_linalg_complex_LU_refine, 5);
|
667
657
|
|
668
658
|
rb_define_singleton_method(mgsl_linalg_complex, "LU_invert",
|
669
|
-
|
659
|
+
rb_gsl_linalg_complex_LU_invert, -1);
|
670
660
|
rb_define_singleton_method(mgsl_linalg_complex_LU, "invert",
|
671
|
-
|
672
|
-
rb_define_method(cgsl_matrix_complex, "LU_invert",
|
673
|
-
|
661
|
+
rb_gsl_linalg_complex_LU_invert, -1);
|
662
|
+
rb_define_method(cgsl_matrix_complex, "LU_invert",
|
663
|
+
rb_gsl_linalg_complex_LU_invert, -1);
|
674
664
|
rb_define_alias(cgsl_matrix_complex, "invert", "LU_invert");
|
675
665
|
rb_define_alias(cgsl_matrix_complex, "inv", "LU_invert");
|
676
|
-
rb_define_method(cgsl_matrix_complex_LU, "invert",
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
rb_gsl_linalg_complex_LU_det, -1);
|
666
|
+
rb_define_method(cgsl_matrix_complex_LU, "invert",
|
667
|
+
rb_gsl_linalg_complex_LU_invert, -1);
|
668
|
+
|
669
|
+
rb_define_singleton_method(mgsl_linalg_complex, "LU_det",
|
670
|
+
rb_gsl_linalg_complex_LU_det, -1);
|
671
|
+
rb_define_singleton_method(mgsl_linalg_complex_LU, "det",
|
672
|
+
rb_gsl_linalg_complex_LU_det, -1);
|
684
673
|
rb_define_method(cgsl_matrix_complex, "LU_det", rb_gsl_linalg_complex_LU_det, -1);
|
685
674
|
rb_define_alias(cgsl_matrix_complex, "det", "LU_det");
|
686
675
|
rb_define_method(cgsl_matrix_complex_LU, "det", rb_gsl_linalg_complex_LU_det, -1);
|
687
676
|
|
688
|
-
rb_define_singleton_method(mgsl_linalg_complex, "LU_lndet",
|
689
|
-
|
690
|
-
rb_define_singleton_method(mgsl_linalg_complex_LU, "lndet",
|
691
|
-
|
677
|
+
rb_define_singleton_method(mgsl_linalg_complex, "LU_lndet",
|
678
|
+
rb_gsl_linalg_complex_LU_lndet, -1);
|
679
|
+
rb_define_singleton_method(mgsl_linalg_complex_LU, "lndet",
|
680
|
+
rb_gsl_linalg_complex_LU_lndet, -1);
|
692
681
|
rb_define_method(cgsl_matrix_complex, "LU_lndet", rb_gsl_linalg_complex_LU_lndet, -1);
|
693
682
|
rb_define_alias(cgsl_matrix_complex, "lndet", "LU_lndet");
|
694
683
|
rb_define_method(cgsl_matrix_complex_LU, "LU_lndet", rb_gsl_linalg_complex_LU_lndet, -1);
|
695
684
|
|
696
|
-
rb_define_singleton_method(mgsl_linalg_complex, "LU_sgndet",
|
697
|
-
|
698
|
-
rb_define_singleton_method(mgsl_linalg_complex_LU, "sgndet",
|
699
|
-
|
685
|
+
rb_define_singleton_method(mgsl_linalg_complex, "LU_sgndet",
|
686
|
+
rb_gsl_linalg_complex_LU_sgndet, -1);
|
687
|
+
rb_define_singleton_method(mgsl_linalg_complex_LU, "sgndet",
|
688
|
+
rb_gsl_linalg_complex_LU_sgndet, -1);
|
700
689
|
rb_define_method(cgsl_matrix_complex, "LU_sgndet", rb_gsl_linalg_complex_LU_sgndet, -1);
|
701
690
|
rb_define_alias(cgsl_matrix_complex, "sgndet", "LU_sgndet");
|
702
691
|
rb_define_method(cgsl_matrix_complex_LU, "LU_sgndet", rb_gsl_linalg_complex_LU_sgndet, -1);
|
703
|
-
#endif
|
704
692
|
|
705
|
-
#ifdef GSL_1_10_LATER
|
706
693
|
mgsl_linalg_complex_chol = rb_define_module_under(mgsl_linalg_complex, "Cholesky");
|
707
|
-
cgsl_matrix_complex_C = rb_define_class_under(mgsl_linalg_complex_chol, "CholeskyMatrix", cgsl_matrix_complex);
|
694
|
+
cgsl_matrix_complex_C = rb_define_class_under(mgsl_linalg_complex_chol, "CholeskyMatrix", cgsl_matrix_complex);
|
708
695
|
rb_define_singleton_method(mgsl_linalg_complex_chol, "decomp", rb_gsl_linalg_cholesky_decomp, -1);
|
709
|
-
rb_define_method(cgsl_matrix_complex, "cholesky_decomp", rb_gsl_linalg_cholesky_decomp, -1);
|
696
|
+
rb_define_method(cgsl_matrix_complex, "cholesky_decomp", rb_gsl_linalg_cholesky_decomp, -1);
|
710
697
|
rb_define_singleton_method(mgsl_linalg_complex_chol, "solve", rb_gsl_linalg_cholesky_solve, -1);
|
711
698
|
rb_define_method(cgsl_matrix_complex, "cholesky_solve", rb_gsl_linalg_cholesky_solve, -1);
|
712
699
|
rb_define_method(cgsl_matrix_complex_C, "solve", rb_gsl_linalg_cholesky_solve, -1);
|
@@ -715,26 +702,25 @@ void Init_gsl_linalg_complex(VALUE module)
|
|
715
702
|
rb_define_method(cgsl_matrix_complex_C, "svx", rb_gsl_linalg_cholesky_svx, -1);
|
716
703
|
|
717
704
|
mgsl_linalg_complex_Householder = rb_define_module_under(mgsl_linalg_complex, "Householder");
|
718
|
-
|
719
|
-
|
720
|
-
rb_define_singleton_method(mgsl_linalg_complex_Householder, "transform",
|
721
|
-
|
722
|
-
rb_define_method(cgsl_vector_complex, "householder_transform",
|
723
|
-
|
724
|
-
|
725
|
-
rb_define_singleton_method(mgsl_linalg_complex, "householder_hm",
|
726
|
-
|
727
|
-
rb_define_singleton_method(mgsl_linalg_complex_Householder, "hm",
|
728
|
-
|
729
|
-
|
730
|
-
rb_define_singleton_method(mgsl_linalg_complex, "householder_mh",
|
731
|
-
|
732
|
-
rb_define_singleton_method(mgsl_linalg_complex_Householder, "mh",
|
733
|
-
|
734
|
-
|
735
|
-
rb_define_singleton_method(mgsl_linalg_complex, "householder_hv",
|
736
|
-
|
737
|
-
rb_define_singleton_method(mgsl_linalg_complex_Householder, "hv",
|
738
|
-
|
739
|
-
#endif
|
705
|
+
rb_define_singleton_method(mgsl_linalg_complex, "householder_transform",
|
706
|
+
rb_gsl_linalg_complex_householder_transform, -1);
|
707
|
+
rb_define_singleton_method(mgsl_linalg_complex_Householder, "transform",
|
708
|
+
rb_gsl_linalg_complex_householder_transform, -1);
|
709
|
+
rb_define_method(cgsl_vector_complex, "householder_transform",
|
710
|
+
rb_gsl_linalg_complex_householder_transform, -1);
|
711
|
+
|
712
|
+
rb_define_singleton_method(mgsl_linalg_complex, "householder_hm",
|
713
|
+
rb_gsl_linalg_complex_householder_hm, 3);
|
714
|
+
rb_define_singleton_method(mgsl_linalg_complex_Householder, "hm",
|
715
|
+
rb_gsl_linalg_complex_householder_hm, 3);
|
716
|
+
|
717
|
+
rb_define_singleton_method(mgsl_linalg_complex, "householder_mh",
|
718
|
+
rb_gsl_linalg_complex_householder_mh, 3);
|
719
|
+
rb_define_singleton_method(mgsl_linalg_complex_Householder, "mh",
|
720
|
+
rb_gsl_linalg_complex_householder_mh, 3);
|
721
|
+
|
722
|
+
rb_define_singleton_method(mgsl_linalg_complex, "householder_hv",
|
723
|
+
rb_gsl_linalg_complex_householder_hv, 3);
|
724
|
+
rb_define_singleton_method(mgsl_linalg_complex_Householder, "hv",
|
725
|
+
rb_gsl_linalg_complex_householder_hv, 3);
|
740
726
|
}
|
@@ -12,9 +12,6 @@
|
|
12
12
|
|
13
13
|
#include "include/rb_gsl_math.h"
|
14
14
|
#include "include/rb_gsl_complex.h"
|
15
|
-
#ifdef HAVE_NARRAY_H
|
16
|
-
#include "narray.h"
|
17
|
-
#endif
|
18
15
|
|
19
16
|
static void rb_gsl_define_const(VALUE module);
|
20
17
|
|
@@ -124,15 +121,15 @@ VALUE rb_gsl_math_complex_eval(gsl_complex (*func)(gsl_complex), VALUE obj)
|
|
124
121
|
mnew = gsl_matrix_complex_alloc(m->size1, m->size2);
|
125
122
|
for (i = 0; i < m->size1; i++) {
|
126
123
|
for (j = 0; j < m->size2; j++) {
|
127
|
-
|
124
|
+
gsl_matrix_complex_set(mnew, i, j, (*func)(gsl_matrix_complex_get(m, i, j)));
|
128
125
|
}
|
129
126
|
}
|
130
127
|
return Data_Wrap_Struct(cgsl_matrix_complex, 0, gsl_matrix_complex_free, mnew);
|
131
128
|
} else {
|
132
|
-
rb_raise(rb_eTypeError,
|
133
|
-
|
134
|
-
|
135
|
-
|
129
|
+
rb_raise(rb_eTypeError,
|
130
|
+
"wrong argument type %s "
|
131
|
+
" (GSL::Complex or GSL::Vector::Complex expected)",
|
132
|
+
rb_class2name(CLASS_OF(obj)));
|
136
133
|
}
|
137
134
|
}
|
138
135
|
|
@@ -140,10 +137,6 @@ static VALUE rb_gsl_math_eval(double (*func)(const double), VALUE xx)
|
|
140
137
|
{
|
141
138
|
VALUE x, ary;
|
142
139
|
size_t i, size;
|
143
|
-
#ifdef HAVE_NARRAY_H
|
144
|
-
struct NARRAY *na;
|
145
|
-
double *ptr1, *ptr2;
|
146
|
-
#endif
|
147
140
|
if (CLASS_OF(xx) == rb_cRange) xx = rb_gsl_range2ary(xx);
|
148
141
|
switch (TYPE(xx)) {
|
149
142
|
case T_FIXNUM:
|
@@ -165,6 +158,8 @@ static VALUE rb_gsl_math_eval(double (*func)(const double), VALUE xx)
|
|
165
158
|
default:
|
166
159
|
#ifdef HAVE_NARRAY_H
|
167
160
|
if (NA_IsNArray(xx)) {
|
161
|
+
struct NARRAY *na;
|
162
|
+
double *ptr1, *ptr2;
|
168
163
|
GetNArray(xx, na);
|
169
164
|
ptr1 = (double*) na->ptr;
|
170
165
|
size = na->total;
|
@@ -188,18 +183,14 @@ static VALUE rb_gsl_math_eval(double (*func)(const double), VALUE xx)
|
|
188
183
|
}
|
189
184
|
|
190
185
|
static VALUE rb_gsl_math_eval2(double (*func)(const double, const double), VALUE xx,
|
191
|
-
|
186
|
+
VALUE yy);
|
192
187
|
static VALUE rb_gsl_math_eval2(double (*func)(const double, const double), VALUE xx,
|
193
|
-
|
188
|
+
VALUE yy)
|
194
189
|
{
|
195
190
|
VALUE x, y, ary;
|
196
191
|
size_t i, j, size;
|
197
192
|
gsl_vector *v = NULL, *v2 = NULL, *vnew = NULL;
|
198
193
|
gsl_matrix *m = NULL, *m2 = NULL, *mnew = NULL;
|
199
|
-
#ifdef HAVE_NARRAY_H
|
200
|
-
struct NARRAY *nax, *nay;
|
201
|
-
double *ptr1, *ptr2, *ptr3;
|
202
|
-
#endif
|
203
194
|
if (CLASS_OF(xx) == rb_cRange) xx = rb_gsl_range2ary(xx);
|
204
195
|
switch (TYPE(xx)) {
|
205
196
|
case T_FIXNUM:
|
@@ -226,6 +217,8 @@ static VALUE rb_gsl_math_eval2(double (*func)(const double, const double), VALUE
|
|
226
217
|
default:
|
227
218
|
#ifdef HAVE_NARRAY_H
|
228
219
|
if (NA_IsNArray(xx)) {
|
220
|
+
struct NARRAY *nax, *nay;
|
221
|
+
double *ptr1, *ptr2, *ptr3;
|
229
222
|
GetNArray(xx, nax);
|
230
223
|
GetNArray(yy, nay);
|
231
224
|
ptr1 = (double*) nax->ptr;
|
@@ -243,7 +236,7 @@ static VALUE rb_gsl_math_eval2(double (*func)(const double, const double), VALUE
|
|
243
236
|
Data_Get_Struct(yy, gsl_vector, v2);
|
244
237
|
vnew = gsl_vector_alloc(v->size);
|
245
238
|
for (i = 0; i < v->size; i++) {
|
246
|
-
|
239
|
+
gsl_vector_set(vnew, i, (*func)(gsl_vector_get(v, i), gsl_vector_get(v2, i)));
|
247
240
|
}
|
248
241
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
249
242
|
} else if (MATRIX_P(xx)) {
|
@@ -252,15 +245,15 @@ static VALUE rb_gsl_math_eval2(double (*func)(const double, const double), VALUE
|
|
252
245
|
Data_Get_Struct(yy, gsl_matrix, m2);
|
253
246
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
254
247
|
for (i = 0; i < m->size1; i++) {
|
255
|
-
|
256
|
-
|
257
|
-
|
248
|
+
for (j = 0; j < m->size2; j++) {
|
249
|
+
gsl_matrix_set(mnew, i, j, (*func)(gsl_matrix_get(m, i, j), gsl_matrix_get(m2, i, j)));
|
250
|
+
}
|
258
251
|
}
|
259
252
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
260
253
|
} else {
|
261
|
-
rb_raise(rb_eTypeError,
|
262
|
-
|
263
|
-
|
254
|
+
rb_raise(rb_eTypeError,
|
255
|
+
"wrong argument type %s "
|
256
|
+
"(Array or Vector or Matrix expected)", rb_class2name(CLASS_OF(xx)));
|
264
257
|
}
|
265
258
|
break;
|
266
259
|
}
|
@@ -287,32 +280,32 @@ static VALUE rb_gsl_hypot(VALUE obj, VALUE x, VALUE y)
|
|
287
280
|
{
|
288
281
|
return rb_gsl_math_eval2(gsl_hypot, x, y);
|
289
282
|
}
|
290
|
-
|
283
|
+
|
291
284
|
static VALUE rb_gsl_hypot3(VALUE obj, VALUE x, VALUE y, VALUE z)
|
292
285
|
{
|
293
286
|
Need_Float(x);
|
294
287
|
Need_Float(y);
|
295
|
-
Need_Float(z);
|
288
|
+
Need_Float(z);
|
296
289
|
return rb_float_new(gsl_hypot3(NUM2DBL(x), NUM2DBL(y), NUM2DBL(z)));
|
297
290
|
}
|
298
|
-
|
291
|
+
|
299
292
|
static VALUE rb_gsl_acosh(VALUE obj, VALUE x)
|
300
293
|
{
|
301
|
-
if (COMPLEX_P(x) || VECTOR_COMPLEX_P(x) || MATRIX_COMPLEX_P(x))
|
294
|
+
if (COMPLEX_P(x) || VECTOR_COMPLEX_P(x) || MATRIX_COMPLEX_P(x))
|
302
295
|
return rb_gsl_math_complex_eval(gsl_complex_arccosh, x);
|
303
296
|
return rb_gsl_math_eval(gsl_acosh, x);
|
304
297
|
}
|
305
298
|
|
306
299
|
static VALUE rb_gsl_asinh(VALUE obj, VALUE x)
|
307
300
|
{
|
308
|
-
if (COMPLEX_P(x) || VECTOR_COMPLEX_P(x) || MATRIX_COMPLEX_P(x))
|
301
|
+
if (COMPLEX_P(x) || VECTOR_COMPLEX_P(x) || MATRIX_COMPLEX_P(x))
|
309
302
|
return rb_gsl_math_complex_eval(gsl_complex_arcsinh, x);
|
310
303
|
return rb_gsl_math_eval(gsl_asinh, x);
|
311
304
|
}
|
312
305
|
|
313
306
|
static VALUE rb_gsl_atanh(VALUE obj, VALUE x)
|
314
307
|
{
|
315
|
-
if (COMPLEX_P(x) || VECTOR_COMPLEX_P(x) || MATRIX_COMPLEX_P(x))
|
308
|
+
if (COMPLEX_P(x) || VECTOR_COMPLEX_P(x) || MATRIX_COMPLEX_P(x))
|
316
309
|
return rb_gsl_math_complex_eval(gsl_complex_arctanh, x);
|
317
310
|
return rb_gsl_math_eval(gsl_atanh, x);
|
318
311
|
}
|
@@ -328,10 +321,6 @@ VALUE rb_gsl_pow(VALUE obj, VALUE xx, VALUE nn)
|
|
328
321
|
double n;
|
329
322
|
gsl_vector *v = NULL, *vnew = NULL;
|
330
323
|
gsl_matrix *m = NULL, *mnew = NULL;
|
331
|
-
#ifdef HAVE_NARRAY_H
|
332
|
-
struct NARRAY *na;
|
333
|
-
double *ptr1, *ptr2;
|
334
|
-
#endif
|
335
324
|
if (CLASS_OF(xx) == rb_cRange) xx = rb_gsl_range2ary(xx);
|
336
325
|
switch (TYPE(xx)) {
|
337
326
|
case T_FIXNUM:
|
@@ -353,6 +342,8 @@ VALUE rb_gsl_pow(VALUE obj, VALUE xx, VALUE nn)
|
|
353
342
|
default:
|
354
343
|
#ifdef HAVE_NARRAY_H
|
355
344
|
if (NA_IsNArray(xx)) {
|
345
|
+
struct NARRAY *na;
|
346
|
+
double *ptr1, *ptr2;
|
356
347
|
n = NUM2DBL(nn);
|
357
348
|
GetNArray(xx, na);
|
358
349
|
ptr1 = (double*) na->ptr;
|
@@ -368,21 +359,21 @@ VALUE rb_gsl_pow(VALUE obj, VALUE xx, VALUE nn)
|
|
368
359
|
Data_Get_Struct(xx, gsl_vector, v);
|
369
360
|
vnew = gsl_vector_alloc(v->size);
|
370
361
|
for (i = 0; i < v->size; i++) {
|
371
|
-
|
362
|
+
gsl_vector_set(vnew, i, pow(gsl_vector_get(v, i), n));
|
372
363
|
}
|
373
364
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
374
|
-
}
|
365
|
+
}
|
375
366
|
if (MATRIX_P(xx)) {
|
376
367
|
n = NUM2DBL(nn);
|
377
368
|
Data_Get_Struct(xx, gsl_matrix, m);
|
378
369
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
379
370
|
for (i = 0; i < m->size1; i++) {
|
380
|
-
|
381
|
-
|
382
|
-
|
371
|
+
for (j = 0; j < m->size2; j++) {
|
372
|
+
gsl_matrix_set(mnew, i, j, pow(gsl_matrix_get(m, i, j), n));
|
373
|
+
}
|
383
374
|
}
|
384
375
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
385
|
-
}
|
376
|
+
}
|
386
377
|
if (COMPLEX_P(xx) || VECTOR_COMPLEX_P(xx) || MATRIX_COMPLEX_P(xx)) {
|
387
378
|
argv[0] = xx;
|
388
379
|
argv[1] = nn;
|
@@ -402,10 +393,6 @@ static VALUE rb_gsl_pow_int(VALUE obj, VALUE xx, VALUE nn)
|
|
402
393
|
int n;
|
403
394
|
gsl_vector *v = NULL, *vnew = NULL;
|
404
395
|
gsl_matrix *m = NULL, *mnew = NULL;
|
405
|
-
#ifdef HAVE_NARRAY_H
|
406
|
-
struct NARRAY *na;
|
407
|
-
double *ptr1, *ptr2;
|
408
|
-
#endif
|
409
396
|
|
410
397
|
if (CLASS_OF(xx) == rb_cRange) xx = rb_gsl_range2ary(xx);
|
411
398
|
switch (TYPE(xx)) {
|
@@ -430,6 +417,8 @@ static VALUE rb_gsl_pow_int(VALUE obj, VALUE xx, VALUE nn)
|
|
430
417
|
default:
|
431
418
|
#ifdef HAVE_NARRAY_H
|
432
419
|
if (NA_IsNArray(xx)) {
|
420
|
+
struct NARRAY *na;
|
421
|
+
double *ptr1, *ptr2;
|
433
422
|
CHECK_FIXNUM(nn);
|
434
423
|
n = FIX2INT(nn);
|
435
424
|
GetNArray(xx, na);
|
@@ -447,7 +436,7 @@ static VALUE rb_gsl_pow_int(VALUE obj, VALUE xx, VALUE nn)
|
|
447
436
|
Data_Get_Struct(xx, gsl_vector, v);
|
448
437
|
vnew = gsl_vector_alloc(v->size);
|
449
438
|
for (i = 0; i < v->size; i++) {
|
450
|
-
|
439
|
+
gsl_vector_set(vnew, i, gsl_pow_int(gsl_vector_get(v, i), n));
|
451
440
|
}
|
452
441
|
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
|
453
442
|
} else if (MATRIX_P(xx)) {
|
@@ -456,9 +445,9 @@ static VALUE rb_gsl_pow_int(VALUE obj, VALUE xx, VALUE nn)
|
|
456
445
|
Data_Get_Struct(xx, gsl_matrix, m);
|
457
446
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
458
447
|
for (i = 0; i < m->size1; i++) {
|
459
|
-
|
460
|
-
|
461
|
-
|
448
|
+
for (j = 0; j < m->size2; j++) {
|
449
|
+
gsl_matrix_set(mnew, i, j, gsl_pow_int(gsl_matrix_get(m, i, j), n));
|
450
|
+
}
|
462
451
|
}
|
463
452
|
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
464
453
|
} else if (COMPLEX_P(xx) || VECTOR_COMPLEX_P(xx) || MATRIX_COMPLEX_P(xx)) {
|
@@ -556,7 +545,6 @@ static VALUE rb_GSL_MAX(VALUE obj, VALUE aa, VALUE bb)
|
|
556
545
|
max = GSL_MAX_DBL(a, b);
|
557
546
|
if (gsl_fcmp(max, a, 1.0e-10) == 0) return aa;
|
558
547
|
else return bb;
|
559
|
-
|
560
548
|
}
|
561
549
|
|
562
550
|
static VALUE rb_GSL_MIN(VALUE obj, VALUE aa, VALUE bb)
|
@@ -587,7 +575,7 @@ static VALUE rb_GSL_MAX_INT(VALUE obj, VALUE aa, VALUE bb)
|
|
587
575
|
{
|
588
576
|
if (TYPE(aa) != T_FIXNUM || TYPE(bb) != T_FIXNUM)
|
589
577
|
return rb_GSL_MAX(obj, aa, bb);
|
590
|
-
else
|
578
|
+
else
|
591
579
|
return INT2FIX(GSL_MAX_INT(FIX2INT(aa), FIX2INT(bb)));
|
592
580
|
}
|
593
581
|
|
@@ -595,11 +583,10 @@ static VALUE rb_GSL_MIN_INT(VALUE obj, VALUE aa, VALUE bb)
|
|
595
583
|
{
|
596
584
|
if (TYPE(aa) != T_FIXNUM || TYPE(bb) != T_FIXNUM)
|
597
585
|
return rb_GSL_MIN(obj, aa, bb);
|
598
|
-
return
|
586
|
+
return
|
599
587
|
INT2FIX(GSL_MIN_INT(FIX2INT(aa), FIX2INT(bb)));
|
600
588
|
}
|
601
589
|
|
602
|
-
#ifdef GSL_1_3_LATER
|
603
590
|
static VALUE rb_gsl_ldexp(VALUE obj, VALUE x, VALUE e)
|
604
591
|
{
|
605
592
|
return rb_float_new(gsl_ldexp(NUM2DBL(x), FIX2INT(e)));
|
@@ -613,7 +600,6 @@ static VALUE rb_gsl_frexp(VALUE obj, VALUE x)
|
|
613
600
|
val = gsl_frexp(NUM2DBL(x), &e);
|
614
601
|
return rb_ary_new3(2, rb_float_new(val), INT2FIX(e));
|
615
602
|
}
|
616
|
-
#endif
|
617
603
|
|
618
604
|
static VALUE rb_gsl_fcmp(int argc, VALUE *argv, VALUE obj)
|
619
605
|
{
|
@@ -621,7 +607,7 @@ static VALUE rb_gsl_fcmp(int argc, VALUE *argv, VALUE obj)
|
|
621
607
|
switch (argc) {
|
622
608
|
case 3:
|
623
609
|
epsilon = NUM2DBL(argv[2]);
|
624
|
-
|
610
|
+
/* no break, do next */
|
625
611
|
case 2:
|
626
612
|
a = NUM2DBL(argv[0]);
|
627
613
|
b = NUM2DBL(argv[1]);
|
@@ -641,7 +627,7 @@ static VALUE rb_gsl_equal(int argc, VALUE *argv, VALUE obj)
|
|
641
627
|
switch (argc) {
|
642
628
|
case 3:
|
643
629
|
epsilon = NUM2DBL(argv[2]);
|
644
|
-
|
630
|
+
/* no break, do next */
|
645
631
|
case 2:
|
646
632
|
a = NUM2DBL(argv[0]);
|
647
633
|
b = NUM2DBL(argv[1]);
|
@@ -668,14 +654,12 @@ void Init_gsl_math(VALUE module)
|
|
668
654
|
rb_define_module_function(module, "isinf?", rb_gsl_isinf2, 1);
|
669
655
|
rb_define_module_function(module, "finite", rb_gsl_finite, 1);
|
670
656
|
rb_define_module_function(module, "finite?", rb_gsl_finite2, 1);
|
671
|
-
|
657
|
+
|
672
658
|
rb_define_module_function(module, "sqrt", rb_gsl_sqrt, 1);
|
673
659
|
rb_define_module_function(module, "log1p", rb_gsl_log1p, 1);
|
674
660
|
rb_define_module_function(module, "expm1", rb_gsl_expm1, 1);
|
675
661
|
rb_define_module_function(module, "hypot", rb_gsl_hypot, 2);
|
676
|
-
|
677
|
-
rb_define_module_function(module, "hypot3", rb_gsl_hypot3, 3);
|
678
|
-
#endif
|
662
|
+
rb_define_module_function(module, "hypot3", rb_gsl_hypot3, 3);
|
679
663
|
rb_define_module_function(module, "acosh", rb_gsl_acosh, 1);
|
680
664
|
rb_define_module_function(module, "asinh", rb_gsl_asinh, 1);
|
681
665
|
rb_define_module_function(module, "atanh", rb_gsl_atanh, 1);
|
@@ -691,7 +675,7 @@ void Init_gsl_math(VALUE module)
|
|
691
675
|
rb_define_module_function(module, "pow_9", rb_gsl_pow_9, 1);
|
692
676
|
rb_define_module_function(module, "sign", rb_GSL_SIGN, 1);
|
693
677
|
rb_define_module_function(module, "SIGN", rb_GSL_SIGN, 1);
|
694
|
-
|
678
|
+
|
695
679
|
rb_define_module_function(module, "is_odd", rb_GSL_IS_ODD, 1);
|
696
680
|
rb_define_module_function(module, "IS_ODD", rb_GSL_IS_ODD, 1);
|
697
681
|
rb_define_module_function(module, "is_odd?", rb_GSL_IS_ODD2, 1);
|
@@ -717,8 +701,6 @@ void Init_gsl_math(VALUE module)
|
|
717
701
|
|
718
702
|
rb_define_module_function(module, "fcmp", rb_gsl_fcmp, -1);
|
719
703
|
rb_define_singleton_method(module, "equal?", rb_gsl_equal, -1);
|
720
|
-
#ifdef GSL_1_3_LATER
|
721
704
|
rb_define_module_function(module, "ldexp", rb_gsl_ldexp, 2);
|
722
705
|
rb_define_module_function(module, "frexp", rb_gsl_frexp, 1);
|
723
|
-
#endif
|
724
706
|
}
|