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
data/examples/vector/decimate.rb
CHANGED
data/examples/vector/gnuplot.rb
CHANGED
@@ -9,28 +9,28 @@ require 'gsl/gnuplot';
|
|
9
9
|
# Plot using gnuplot
|
10
10
|
Gnuplot.open do |gp|
|
11
11
|
Gnuplot::Plot.new( gp ) do |plot|
|
12
|
-
|
12
|
+
|
13
13
|
plot.xrange "[0:10]"
|
14
14
|
plot.yrange "[-1.5:1.5]"
|
15
15
|
plot.title "Sin Wave Example"
|
16
16
|
plot.xlabel "x"
|
17
17
|
plot.ylabel "sin(x)"
|
18
18
|
plot.pointsize 3
|
19
|
-
plot.grid
|
19
|
+
plot.grid
|
20
20
|
|
21
21
|
x = GSL::Vector[0..10]
|
22
22
|
y = GSL::Sf::sin(x)
|
23
23
|
|
24
24
|
plot.data = [
|
25
25
|
Gnuplot::DataSet.new( "sin(x)" ) { |ds|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
ds.with = "lines"
|
27
|
+
ds.title = "String function"
|
28
|
+
ds.linewidth = 4
|
29
29
|
},
|
30
|
-
|
30
|
+
|
31
31
|
Gnuplot::DataSet.new( [x, y] ) { |ds|
|
32
|
-
|
33
|
-
|
32
|
+
ds.with = "linespoints"
|
33
|
+
ds.title = "Array data"
|
34
34
|
}
|
35
35
|
]
|
36
36
|
|
data/examples/vector/vector.rb
CHANGED
@@ -19,7 +19,7 @@ static VALUE rb_alf_params(VALUE obj, VALUE csphase, VALUE cnorm, VALUE norm)
|
|
19
19
|
int ret;
|
20
20
|
Data_Get_Struct(obj, alf_workspace, w);
|
21
21
|
ret = alf_params(FIX2INT(csphase), FIX2INT(cnorm), (alf_norm_t) FIX2INT(norm), w);
|
22
|
-
return INT2FIX(ret);
|
22
|
+
return INT2FIX(ret);
|
23
23
|
}
|
24
24
|
|
25
25
|
static void define_constants(VALUE klass)
|
@@ -60,11 +60,11 @@ static VALUE rb_alf_Plm_array(int argc, VALUE *argv, VALUE obj)
|
|
60
60
|
Data_Get_Struct(argv[1], gsl_vector, res);
|
61
61
|
lmax = w->lmax;
|
62
62
|
if (res->size < alf_array_size(lmax)) {
|
63
|
-
|
64
|
-
|
63
|
+
rb_raise(rb_eRuntimeError, "Vector length is too small. (%d for >= %d\n", (int) res->size,
|
64
|
+
(int) alf_array_size(lmax));
|
65
65
|
}
|
66
|
-
ret = argv[1];
|
67
|
-
} else {
|
66
|
+
ret = argv[1];
|
67
|
+
} else {
|
68
68
|
lmax = FIX2INT(argv[0]);
|
69
69
|
x = NUM2DBL(argv[1]);
|
70
70
|
res = gsl_vector_alloc(alf_array_size(lmax));
|
@@ -85,8 +85,8 @@ static VALUE rb_alf_Plm_array(int argc, VALUE *argv, VALUE obj)
|
|
85
85
|
CHECK_VECTOR(argv[2]);
|
86
86
|
Data_Get_Struct(argv[2], gsl_vector, res);
|
87
87
|
if (res->size < alf_array_size(lmax)) {
|
88
|
-
|
89
|
-
|
88
|
+
rb_raise(rb_eRuntimeError, "Vector length is too small. (%d for >= %d\n", (int) res->size,
|
89
|
+
(int) alf_array_size(lmax));
|
90
90
|
}
|
91
91
|
ret = argv[2];
|
92
92
|
}
|
@@ -155,11 +155,11 @@ static VALUE rb_alf_Plm_deriv_array(int argc, VALUE *argv, VALUE obj)
|
|
155
155
|
Data_Get_Struct(argv[3], gsl_vector, deriv);
|
156
156
|
if (res->size < alf_array_size(lmax)) {
|
157
157
|
rb_raise(rb_eRuntimeError, "Vector length is too small. (%d for >= %d\n", (int) res->size,
|
158
|
-
|
158
|
+
(int) alf_array_size(lmax));
|
159
159
|
}
|
160
160
|
if (deriv->size < alf_array_size(lmax)) {
|
161
161
|
rb_raise(rb_eRuntimeError, "Vector length is too small. (%d for >= %d\n", (int) res->size,
|
162
|
-
|
162
|
+
(int) alf_array_size(lmax));
|
163
163
|
}
|
164
164
|
ret1 = argv[2];
|
165
165
|
ret2 = argv[3];
|
@@ -12,9 +12,7 @@
|
|
12
12
|
#include "include/rb_gsl_common.h"
|
13
13
|
#include "include/rb_gsl_array.h"
|
14
14
|
#include "include/rb_gsl_complex.h"
|
15
|
-
#ifdef HAVE_NARRAY_H
|
16
15
|
#include "include/rb_gsl_with_narray.h"
|
17
|
-
#endif
|
18
16
|
|
19
17
|
/* global variables */
|
20
18
|
VALUE cgsl_block, cgsl_block_int;
|
@@ -47,9 +45,6 @@ double* get_vector_ptr(VALUE ary, size_t *stride, size_t *n)
|
|
47
45
|
gsl_vector *v = NULL;
|
48
46
|
gsl_vector_complex *vc = NULL;
|
49
47
|
gsl_matrix *m;
|
50
|
-
#ifdef HAVE_NARRAY_H
|
51
|
-
VALUE ary2;
|
52
|
-
#endif
|
53
48
|
if (VECTOR_P(ary)) {
|
54
49
|
Data_Get_Struct(ary, gsl_vector, v);
|
55
50
|
*stride = v->stride;
|
@@ -67,6 +62,7 @@ double* get_vector_ptr(VALUE ary, size_t *stride, size_t *n)
|
|
67
62
|
return m->data;
|
68
63
|
#ifdef HAVE_NARRAY_H
|
69
64
|
} else if (NA_IsNArray(ary)) {
|
65
|
+
VALUE ary2;
|
70
66
|
*n = NA_TOTAL(ary);
|
71
67
|
*stride = 1;
|
72
68
|
ary2 = na_change_type(ary, NA_DFLOAT);
|
@@ -74,7 +70,7 @@ double* get_vector_ptr(VALUE ary, size_t *stride, size_t *n)
|
|
74
70
|
#endif
|
75
71
|
} else {
|
76
72
|
rb_raise(rb_eTypeError,
|
77
|
-
|
73
|
+
"wrong argument type %s", rb_class2name(CLASS_OF(ary)));
|
78
74
|
}
|
79
75
|
}
|
80
76
|
|
@@ -91,7 +87,7 @@ gsl_vector* get_cvector(VALUE obj)
|
|
91
87
|
rb_raise(rb_eTypeError,
|
92
88
|
"wrong argument type %s", rb_class2name(CLASS_OF(obj)));
|
93
89
|
}
|
94
|
-
return v;
|
90
|
+
return v;
|
95
91
|
}
|
96
92
|
|
97
93
|
VALUE make_rarray_from_cvector(const gsl_vector *v)
|
@@ -142,7 +138,7 @@ gsl_vector* get_vector(VALUE ary)
|
|
142
138
|
return v;
|
143
139
|
} else {
|
144
140
|
rb_raise(rb_eTypeError,
|
145
|
-
|
141
|
+
"wrong argument type %s", rb_class2name(CLASS_OF(ary)));
|
146
142
|
}
|
147
143
|
}
|
148
144
|
|
@@ -157,7 +153,7 @@ gsl_vector* make_cvector_from_rarrays(VALUE ary)
|
|
157
153
|
#endif
|
158
154
|
} else {
|
159
155
|
rb_raise(rb_eTypeError,
|
160
|
-
|
156
|
+
"wrong argument type %s", rb_class2name(CLASS_OF(ary)));
|
161
157
|
}
|
162
158
|
}
|
163
159
|
|
@@ -184,7 +180,7 @@ void carray_set_from_rarrays(double *a, VALUE ary)
|
|
184
180
|
#endif
|
185
181
|
} else {
|
186
182
|
rb_raise(rb_eTypeError,
|
187
|
-
|
183
|
+
"wrong argument type %s", rb_class2name(CLASS_OF(ary)));
|
188
184
|
}
|
189
185
|
}
|
190
186
|
|
@@ -274,7 +270,7 @@ VALUE make_matrix_clone2(VALUE vm)
|
|
274
270
|
mnew = gsl_matrix_alloc(m->size1, m->size2);
|
275
271
|
if (mnew == NULL) rb_raise(rb_eNoMemError, "gsl_matrix_alloc failed");
|
276
272
|
gsl_matrix_memcpy(mnew, m);
|
277
|
-
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew)
|
273
|
+
return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, mnew);
|
278
274
|
}
|
279
275
|
|
280
276
|
gsl_matrix_complex* make_matrix_complex_clone(const gsl_matrix_complex *m)
|
@@ -316,8 +312,8 @@ gsl_matrix_complex* matrix_to_complex(const gsl_matrix *m)
|
|
316
312
|
return cm;
|
317
313
|
}
|
318
314
|
|
319
|
-
void gsl_matrix_complex_mul(gsl_matrix_complex *mnew, const gsl_matrix_complex *m,
|
320
|
-
|
315
|
+
void gsl_matrix_complex_mul(gsl_matrix_complex *mnew, const gsl_matrix_complex *m,
|
316
|
+
const gsl_matrix_complex *mb)
|
321
317
|
{
|
322
318
|
gsl_complex a, b, c, sum;
|
323
319
|
size_t i, j, k;
|
@@ -325,45 +321,45 @@ void gsl_matrix_complex_mul(gsl_matrix_complex *mnew, const gsl_matrix_complex *
|
|
325
321
|
for (j = 0; j < m->size2; j++) {
|
326
322
|
sum = gsl_complex_rect(0.0, 0.0);
|
327
323
|
for (k = 0; k < m->size2; k++) {
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
324
|
+
a = gsl_matrix_complex_get(m, j, k);
|
325
|
+
b = gsl_matrix_complex_get(mb, k, i);
|
326
|
+
c = gsl_complex_mul(a, b);
|
327
|
+
sum = gsl_complex_add(sum, c);
|
332
328
|
}
|
333
329
|
gsl_matrix_complex_set(mnew, j, i, sum);
|
334
330
|
}
|
335
331
|
}
|
336
332
|
}
|
337
333
|
|
338
|
-
void gsl_matrix_mul_vector(gsl_vector *vnew,
|
339
|
-
|
334
|
+
void gsl_matrix_mul_vector(gsl_vector *vnew,
|
335
|
+
const gsl_matrix *m, const gsl_vector *v)
|
340
336
|
{
|
341
337
|
size_t i, j;
|
342
338
|
double val;
|
343
339
|
for (i = 0; i < m->size1; i++) {
|
344
340
|
val = 0;
|
345
|
-
for (j = 0; j < m->size2; j++)
|
341
|
+
for (j = 0; j < m->size2; j++)
|
346
342
|
val += gsl_matrix_get(m, i, j)*gsl_vector_get(v, j);
|
347
343
|
gsl_vector_set(vnew, i, val);
|
348
344
|
}
|
349
345
|
}
|
350
346
|
|
351
|
-
void gsl_matrix_int_mul_vector(gsl_vector_int *vnew,
|
352
|
-
|
347
|
+
void gsl_matrix_int_mul_vector(gsl_vector_int *vnew,
|
348
|
+
const gsl_matrix_int *m, const gsl_vector_int *v)
|
353
349
|
{
|
354
350
|
size_t i, j;
|
355
351
|
int val;
|
356
352
|
for (i = 0; i < m->size1; i++) {
|
357
353
|
val = 0;
|
358
|
-
for (j = 0; j < m->size2; j++)
|
354
|
+
for (j = 0; j < m->size2; j++)
|
359
355
|
val += gsl_matrix_int_get(m, i, j)*gsl_vector_int_get(v, j);
|
360
356
|
gsl_vector_int_set(vnew, i, val);
|
361
357
|
}
|
362
358
|
}
|
363
359
|
|
364
|
-
void gsl_matrix_complex_mul_vector(gsl_vector_complex *vnew,
|
365
|
-
|
366
|
-
|
360
|
+
void gsl_matrix_complex_mul_vector(gsl_vector_complex *vnew,
|
361
|
+
const gsl_matrix_complex *m,
|
362
|
+
const gsl_vector_complex *v)
|
367
363
|
{
|
368
364
|
gsl_complex a, b, c, sum;
|
369
365
|
size_t i, j;
|
@@ -377,98 +373,17 @@ void gsl_matrix_complex_mul_vector(gsl_vector_complex *vnew,
|
|
377
373
|
}
|
378
374
|
gsl_vector_complex_set(vnew, i, sum);
|
379
375
|
}
|
380
|
-
|
381
|
-
}
|
382
|
-
|
383
|
-
/*****/
|
384
|
-
#ifndef GSL_1_12_LATER
|
385
|
-
int gsl_vector_complex_add(gsl_vector_complex *cv, const gsl_vector_complex *cv2)
|
386
|
-
{
|
387
|
-
size_t i;
|
388
|
-
gsl_complex a, b, c;
|
389
|
-
for (i = 0; i < cv->size; i++) {
|
390
|
-
a = gsl_vector_complex_get(cv, i);
|
391
|
-
b = gsl_vector_complex_get(cv2, i);
|
392
|
-
c = gsl_complex_add(a, b);
|
393
|
-
gsl_vector_complex_set(cv, i, c);
|
394
|
-
}
|
395
|
-
return 0;
|
396
376
|
}
|
397
377
|
|
398
|
-
int gsl_vector_complex_add_constant(gsl_vector_complex *cv, gsl_complex b)
|
399
|
-
{
|
400
|
-
size_t i;
|
401
|
-
gsl_complex a, c;
|
402
|
-
for (i = 0; i < cv->size; i++) {
|
403
|
-
a = gsl_vector_complex_get(cv, i);
|
404
|
-
c = gsl_complex_add(a, b);
|
405
|
-
gsl_vector_complex_set(cv, i, c);
|
406
|
-
}
|
407
|
-
return 0;
|
408
|
-
}
|
409
|
-
|
410
|
-
int gsl_vector_complex_scale(gsl_vector_complex *cv, gsl_complex b)
|
411
|
-
{
|
412
|
-
size_t i;
|
413
|
-
gsl_complex a, c;
|
414
|
-
for (i = 0; i < cv->size; i++) {
|
415
|
-
a = gsl_vector_complex_get(cv, i);
|
416
|
-
c = gsl_complex_mul(a, b);
|
417
|
-
gsl_vector_complex_set(cv, i, c);
|
418
|
-
}
|
419
|
-
return 0;
|
420
|
-
}
|
421
|
-
|
422
|
-
|
423
|
-
int gsl_vector_complex_sub(gsl_vector_complex *cv, const gsl_vector_complex *cv2)
|
424
|
-
{
|
425
|
-
size_t i;
|
426
|
-
gsl_complex a, b, c;
|
427
|
-
for (i = 0; i < cv->size; i++) {
|
428
|
-
a = gsl_vector_complex_get(cv, i);
|
429
|
-
b = gsl_vector_complex_get(cv2, i);
|
430
|
-
c = gsl_complex_sub(a, b);
|
431
|
-
gsl_vector_complex_set(cv, i, c);
|
432
|
-
}
|
433
|
-
return 0;
|
434
|
-
}
|
435
|
-
|
436
|
-
int gsl_vector_complex_mul(gsl_vector_complex *cv, const gsl_vector_complex *cv2)
|
437
|
-
{
|
438
|
-
size_t i;
|
439
|
-
gsl_complex a, b, c;
|
440
|
-
for (i = 0; i < cv->size; i++) {
|
441
|
-
a = gsl_vector_complex_get(cv, i);
|
442
|
-
b = gsl_vector_complex_get(cv2, i);
|
443
|
-
c = gsl_complex_mul(a, b);
|
444
|
-
gsl_vector_complex_set(cv, i, c);
|
445
|
-
}
|
446
|
-
return 0;
|
447
|
-
}
|
448
|
-
|
449
|
-
int gsl_vector_complex_div(gsl_vector_complex *cv, const gsl_vector_complex *cv2)
|
450
|
-
{
|
451
|
-
size_t i;
|
452
|
-
gsl_complex a, b, c;
|
453
|
-
for (i = 0; i < cv->size; i++) {
|
454
|
-
a = gsl_vector_complex_get(cv, i);
|
455
|
-
b = gsl_vector_complex_get(cv2, i);
|
456
|
-
c = gsl_complex_div(a, b);
|
457
|
-
gsl_vector_complex_set(cv, i, c);
|
458
|
-
}
|
459
|
-
return 0;
|
460
|
-
}
|
461
|
-
#endif
|
462
|
-
|
463
378
|
VALUE rb_gsl_range2ary(VALUE obj)
|
464
379
|
{
|
465
380
|
// double beg, en;
|
466
381
|
// size_t n;
|
467
382
|
// int step;
|
468
383
|
VALUE ary;
|
469
|
-
if (CLASS_OF(obj) != rb_cRange)
|
384
|
+
if (CLASS_OF(obj) != rb_cRange)
|
470
385
|
rb_raise(rb_eTypeError, "wrong argument type %s (Range expected)",
|
471
|
-
|
386
|
+
rb_class2name(CLASS_OF(obj)));
|
472
387
|
ary = rb_funcall(obj, rb_gsl_id_to_a, 0);
|
473
388
|
return ary;
|
474
389
|
}
|
@@ -480,9 +395,9 @@ VALUE rb_gsl_range2vector(VALUE obj)
|
|
480
395
|
size_t n;
|
481
396
|
int i, step;
|
482
397
|
gsl_vector *v;
|
483
|
-
if (CLASS_OF(obj) != rb_cRange)
|
398
|
+
if (CLASS_OF(obj) != rb_cRange)
|
484
399
|
rb_raise(rb_eTypeError, "wrong argument type %s (Range expected)",
|
485
|
-
|
400
|
+
rb_class2name(CLASS_OF(obj)));
|
486
401
|
get_range_beg_en_n(obj, &beg, &en, &n, &step);
|
487
402
|
v = gsl_vector_alloc(n);
|
488
403
|
for (i = 0; i < (int) n; i++) gsl_vector_set(v, i, (double) (beg+i));
|
@@ -495,9 +410,9 @@ VALUE rb_gsl_range2vector_int(VALUE obj)
|
|
495
410
|
int beg, en, i, step;
|
496
411
|
size_t n;
|
497
412
|
gsl_vector_int *v;
|
498
|
-
if (CLASS_OF(obj) != rb_cRange)
|
413
|
+
if (CLASS_OF(obj) != rb_cRange)
|
499
414
|
rb_raise(rb_eTypeError, "wrong argument type %s (Range expected)",
|
500
|
-
|
415
|
+
rb_class2name(CLASS_OF(obj)));
|
501
416
|
get_range_int_beg_en_n(obj, &beg, &en, &n, &step);
|
502
417
|
v = gsl_vector_int_alloc(n);
|
503
418
|
for (i = 0; i < (int) n; i++) gsl_vector_int_set(v, i, beg+i);
|
@@ -547,71 +462,71 @@ void rb_gsl_matrix_int_view_free(gsl_matrix_int_view * mv)
|
|
547
462
|
|
548
463
|
void Init_gsl_array(VALUE module)
|
549
464
|
{
|
550
|
-
cgsl_block = rb_define_class_under(module, "Block",
|
551
|
-
|
552
|
-
cgsl_block_int = rb_define_class_under(cgsl_block, "Int",
|
553
|
-
|
554
|
-
cgsl_block_uchar = rb_define_class_under(cgsl_block, "Byte",
|
555
|
-
|
465
|
+
cgsl_block = rb_define_class_under(module, "Block",
|
466
|
+
cGSL_Object);
|
467
|
+
cgsl_block_int = rb_define_class_under(cgsl_block, "Int",
|
468
|
+
cGSL_Object);
|
469
|
+
cgsl_block_uchar = rb_define_class_under(cgsl_block, "Byte",
|
470
|
+
cGSL_Object);
|
556
471
|
|
557
472
|
cgsl_block_complex = rb_define_class_under(cgsl_block, "Complex", cgsl_block);
|
558
|
-
cgsl_vector = rb_define_class_under(module, "Vector",
|
559
|
-
|
560
|
-
cgsl_vector_col = rb_define_class_under(cgsl_vector, "Col",
|
561
|
-
|
562
|
-
cgsl_vector_complex = rb_define_class_under(cgsl_vector, "Complex",
|
563
|
-
|
473
|
+
cgsl_vector = rb_define_class_under(module, "Vector",
|
474
|
+
cGSL_Object);
|
475
|
+
cgsl_vector_col = rb_define_class_under(cgsl_vector, "Col",
|
476
|
+
cgsl_vector);
|
477
|
+
cgsl_vector_complex = rb_define_class_under(cgsl_vector, "Complex",
|
478
|
+
cGSL_Object);
|
564
479
|
cgsl_vector_complex_col = rb_define_class_under(cgsl_vector_complex, "Col",
|
565
|
-
|
480
|
+
cgsl_vector_complex);
|
566
481
|
cgsl_matrix = rb_define_class_under(module, "Matrix", cGSL_Object);
|
567
482
|
cgsl_matrix_complex = rb_define_class_under(cgsl_matrix, "Complex", cGSL_Object);
|
568
483
|
|
569
484
|
cgsl_vector_view = rb_define_class_under(cgsl_vector, "View", cgsl_vector);
|
570
485
|
cgsl_vector_col_view = rb_define_class_under(cgsl_vector_col, "View", cgsl_vector_col);
|
571
486
|
|
572
|
-
cgsl_vector_complex_view = rb_define_class_under(cgsl_vector_complex, "View",
|
573
|
-
|
574
|
-
cgsl_vector_complex_col_view = rb_define_class_under(cgsl_vector_complex_col, "View",
|
575
|
-
|
487
|
+
cgsl_vector_complex_view = rb_define_class_under(cgsl_vector_complex, "View",
|
488
|
+
cgsl_vector_complex);
|
489
|
+
cgsl_vector_complex_col_view = rb_define_class_under(cgsl_vector_complex_col, "View",
|
490
|
+
cgsl_vector_complex_col);
|
576
491
|
|
577
492
|
cgsl_vector_int = rb_define_class_under(cgsl_vector, "Int", cGSL_Object);
|
578
|
-
cgsl_vector_int_col = rb_define_class_under(cgsl_vector_int, "Col", cgsl_vector_int);
|
493
|
+
cgsl_vector_int_col = rb_define_class_under(cgsl_vector_int, "Col", cgsl_vector_int);
|
579
494
|
cgsl_vector_int_view = rb_define_class_under(cgsl_vector_int, "View", cgsl_vector_int);
|
580
495
|
cgsl_vector_int_col_view = rb_define_class_under(cgsl_vector_int_col, "View", cgsl_vector_int_col);
|
581
496
|
|
582
497
|
|
583
498
|
/*****/
|
584
499
|
|
585
|
-
cgsl_matrix_view = rb_define_class_under(cgsl_matrix, "View",
|
586
|
-
|
587
|
-
cgsl_matrix_complex_view = rb_define_class_under(cgsl_matrix_complex, "View",
|
588
|
-
|
589
|
-
cgsl_permutation = rb_define_class_under(module, "Permutation", cGSL_Object);
|
500
|
+
cgsl_matrix_view = rb_define_class_under(cgsl_matrix, "View",
|
501
|
+
cgsl_matrix);
|
502
|
+
cgsl_matrix_complex_view = rb_define_class_under(cgsl_matrix_complex, "View",
|
503
|
+
cgsl_matrix_complex);
|
504
|
+
cgsl_permutation = rb_define_class_under(module, "Permutation", cGSL_Object);
|
590
505
|
cgsl_index = rb_define_class_under(module, "Index", cgsl_permutation);
|
591
506
|
|
592
507
|
cgsl_vector_view_ro = rb_define_class_under(cgsl_vector_view, "ReadOnly",
|
593
|
-
|
508
|
+
cgsl_vector_view);
|
594
509
|
cgsl_vector_col_view_ro = rb_define_class_under(cgsl_vector_col_view, "ReadOnly",
|
595
|
-
|
510
|
+
cgsl_vector_col_view);
|
596
511
|
cgsl_vector_int_view_ro = rb_define_class_under(cgsl_vector_int_view, "ReadOnly",
|
597
|
-
|
512
|
+
cgsl_vector_int_view);
|
598
513
|
cgsl_vector_int_col_view_ro = rb_define_class_under(cgsl_vector_int_col_view, "ReadOnly",
|
599
|
-
|
514
|
+
cgsl_vector_int_col_view);
|
600
515
|
cgsl_matrix_view_ro = rb_define_class_under(cgsl_matrix_view, "ReadOnly",
|
601
|
-
|
516
|
+
cgsl_matrix_view);
|
602
517
|
|
603
|
-
cgsl_vector_complex_view_ro = rb_define_class_under(cgsl_vector_complex_view,
|
604
|
-
|
605
|
-
|
606
|
-
cgsl_matrix_complex_view_ro = rb_define_class_under(cgsl_matrix_complex_view,
|
607
|
-
|
608
|
-
|
518
|
+
cgsl_vector_complex_view_ro = rb_define_class_under(cgsl_vector_complex_view,
|
519
|
+
"ReadOnly",
|
520
|
+
cgsl_vector_complex_view);
|
521
|
+
cgsl_matrix_complex_view_ro = rb_define_class_under(cgsl_matrix_complex_view,
|
522
|
+
"ReadOnly",
|
523
|
+
cgsl_matrix_complex_view);
|
609
524
|
|
610
525
|
/*****/
|
611
526
|
cgsl_matrix_int = rb_define_class_under(cgsl_matrix, "Int", cGSL_Object);
|
612
527
|
cgsl_matrix_int_view = rb_define_class_under(cgsl_matrix_int, "View", cgsl_matrix_int);
|
613
528
|
cgsl_matrix_int_view_ro = rb_define_class_under(cgsl_matrix_int_view, "ReadOnly",
|
614
|
-
|
529
|
+
cgsl_matrix_int_view);
|
615
530
|
/*****/
|
616
531
|
Init_gsl_block_init(module);
|
617
532
|
Init_gsl_block_int_init(module);
|
@@ -624,16 +539,14 @@ void Init_gsl_array(VALUE module)
|
|
624
539
|
Init_gsl_matrix_int(module);
|
625
540
|
Init_gsl_matrix_complex(module);
|
626
541
|
Init_gsl_permutation(module);
|
627
|
-
#ifdef GSL_1_1_LATER
|
628
542
|
Init_gsl_combination(module);
|
629
|
-
#endif
|
630
543
|
Init_gsl_array_complex(module);
|
631
544
|
Init_gsl_matrix_nmf();
|
632
545
|
|
633
546
|
rb_define_method(cgsl_vector_view_ro, "set", rb_gsl_obj_read_only, -1);
|
634
547
|
rb_define_method(cgsl_matrix_view_ro, "set", rb_gsl_obj_read_only, -1);
|
635
548
|
rb_define_method(cgsl_vector_int_view_ro, "set", rb_gsl_obj_read_only, -1);
|
636
|
-
rb_define_method(cgsl_matrix_int_view_ro, "set", rb_gsl_obj_read_only, -1);
|
549
|
+
rb_define_method(cgsl_matrix_int_view_ro, "set", rb_gsl_obj_read_only, -1);
|
637
550
|
rb_define_method(cgsl_vector_complex_view_ro, "set", rb_gsl_obj_read_only, -1);
|
638
551
|
rb_define_method(cgsl_matrix_complex_view_ro, "set", rb_gsl_obj_read_only, -1);
|
639
552
|
|