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,19 +18,17 @@
|
|
18
18
|
#include "include/rb_gsl_histogram.h"
|
19
19
|
#include "include/rb_gsl_complex.h"
|
20
20
|
#include "include/rb_gsl_poly.h"
|
21
|
-
#ifdef HAVE_NARRAY_H
|
22
21
|
#include "include/rb_gsl_with_narray.h"
|
23
|
-
#endif
|
24
22
|
|
25
23
|
#define BASE_DOUBLE
|
26
24
|
#include "include/templates_on.h"
|
27
|
-
#include "vector_source.
|
25
|
+
#include "vector_source.h"
|
28
26
|
#include "include/templates_off.h"
|
29
27
|
#undef BASE_DOUBLE
|
30
28
|
|
31
29
|
#define BASE_INT
|
32
30
|
#include "include/templates_on.h"
|
33
|
-
#include "vector_source.
|
31
|
+
#include "vector_source.h"
|
34
32
|
#include "include/templates_off.h"
|
35
33
|
#undef BASE_INT
|
36
34
|
|
@@ -21,7 +21,7 @@ void get_range_beg_en_n(VALUE range, double *beg, double *en, size_t *n, int *st
|
|
21
21
|
//
|
22
22
|
// From vector_source.c
|
23
23
|
void parse_subvector_args(int argc, VALUE *argv, size_t size,
|
24
|
-
|
24
|
+
size_t *offset, size_t *stride, size_t *n);
|
25
25
|
|
26
26
|
// From complex.c
|
27
27
|
gsl_complex rb_gsl_obj_to_gsl_complex(VALUE obj, gsl_complex *z);
|
@@ -41,30 +41,30 @@ static VALUE rb_gsl_vector_complex_new(int argc, VALUE *argv, VALUE klass)
|
|
41
41
|
v = gsl_vector_complex_calloc(n);
|
42
42
|
if (v == NULL) rb_raise(rb_eNoMemError, "gsl_vector_complex_alloc failed");
|
43
43
|
break;
|
44
|
-
case T_ARRAY:
|
44
|
+
case T_ARRAY:
|
45
45
|
n = RARRAY_LEN(argv[0]);
|
46
46
|
v = gsl_vector_complex_alloc(n);
|
47
47
|
if (v == NULL) rb_raise(rb_eNoMemError, "gsl_vector_complex_alloc failed");
|
48
48
|
for (i = 0; i < n; i++) {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
49
|
+
z2 = &z;
|
50
|
+
tmp = rb_ary_entry(argv[0], i);
|
51
|
+
if (TYPE(tmp) == T_ARRAY) {
|
52
|
+
GSL_SET_REAL(z2, NUM2DBL(rb_ary_entry(tmp, 0)));
|
53
|
+
GSL_SET_IMAG(z2, NUM2DBL(rb_ary_entry(tmp, 1)));
|
54
|
+
} else if (COMPLEX_P(tmp)) {
|
55
|
+
Data_Get_Struct(tmp, gsl_complex, z2);
|
56
|
+
} else {
|
57
|
+
rb_raise(rb_eTypeError,
|
58
|
+
"wrong argument type %s (Array or Complex expected)",
|
59
|
+
rb_class2name(CLASS_OF(tmp)));
|
60
|
+
|
61
|
+
}
|
62
|
+
gsl_vector_complex_set(v, i, *z2);
|
63
63
|
}
|
64
64
|
break;
|
65
65
|
default:
|
66
|
-
rb_raise(rb_eTypeError,
|
67
|
-
|
66
|
+
rb_raise(rb_eTypeError,
|
67
|
+
"wrong argument type %s", rb_class2name(CLASS_OF(argv[0])));
|
68
68
|
break;
|
69
69
|
}
|
70
70
|
break;
|
@@ -75,9 +75,9 @@ static VALUE rb_gsl_vector_complex_new(int argc, VALUE *argv, VALUE klass)
|
|
75
75
|
n = GSL_MIN_INT(x->size, y->size);
|
76
76
|
v = gsl_vector_complex_alloc(n);
|
77
77
|
for (i = 0; i < n; i++) {
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
z.dat[0] = gsl_vector_get(x, i);
|
79
|
+
z.dat[1] = gsl_vector_get(y, i);
|
80
|
+
gsl_vector_complex_set(v, i, z);
|
81
81
|
}
|
82
82
|
break;
|
83
83
|
}
|
@@ -86,15 +86,15 @@ static VALUE rb_gsl_vector_complex_new(int argc, VALUE *argv, VALUE klass)
|
|
86
86
|
if (v == NULL) rb_raise(rb_eNoMemError, "gsl_vector_complex_alloc failed");
|
87
87
|
for (i = 0; i < n; i++) {
|
88
88
|
if (TYPE(argv[i]) == T_ARRAY) {
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
GSL_SET_REAL(&z, NUM2DBL(rb_ary_entry(argv[i], 0)));
|
90
|
+
GSL_SET_IMAG(&z, NUM2DBL(rb_ary_entry(argv[i], 1)));
|
91
|
+
z2 = &z;
|
92
92
|
} else if (COMPLEX_P(argv[i])) {
|
93
|
-
|
93
|
+
Data_Get_Struct(argv[i], gsl_complex, z2);
|
94
94
|
} else {
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
rb_raise(rb_eTypeError,
|
96
|
+
"wrong argument type %s (Array or Complex expected)",
|
97
|
+
rb_class2name(CLASS_OF(argv[i])));
|
98
98
|
}
|
99
99
|
gsl_vector_complex_set(v, i, *z2);
|
100
100
|
}
|
@@ -175,9 +175,9 @@ static VALUE rb_gsl_vector_complex_get(int argc, VALUE *argv, VALUE obj)
|
|
175
175
|
case T_ARRAY:
|
176
176
|
vnew = gsl_vector_complex_alloc(RARRAY_LEN(argv[0]));
|
177
177
|
for (j = 0; j < vnew->size; j++) {
|
178
|
-
|
179
|
-
|
180
|
-
|
178
|
+
i = FIX2INT(rb_ary_entry(argv[0], j));
|
179
|
+
if (i < 0) i = v->size + i;
|
180
|
+
gsl_vector_complex_set(vnew, j, gsl_vector_complex_get(v, i));
|
181
181
|
}
|
182
182
|
retval = Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, vnew);
|
183
183
|
break;
|
@@ -207,7 +207,6 @@ static VALUE rb_gsl_vector_complex_set_all(int argc, VALUE *argv, VALUE obj)
|
|
207
207
|
gsl_complex tmp;
|
208
208
|
|
209
209
|
if (argc < 1) rb_raise(rb_eArgError, "wrong number of arguments");
|
210
|
-
|
211
210
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
212
211
|
|
213
212
|
switch (argc) {
|
@@ -284,7 +283,6 @@ static VALUE rb_gsl_vector_complex_set(int argc, VALUE *argv, VALUE obj)
|
|
284
283
|
if(argc < 1 || argc > 4) {
|
285
284
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1-4)", argc);
|
286
285
|
}
|
287
|
-
|
288
286
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
289
287
|
other = argv[argc-1];
|
290
288
|
|
@@ -309,7 +307,6 @@ static VALUE rb_gsl_vector_complex_set(int argc, VALUE *argv, VALUE obj)
|
|
309
307
|
// assignment to v.subvector(...)
|
310
308
|
rb_gsl_vector_complex_set_subvector(argc-1, argv, v, other);
|
311
309
|
}
|
312
|
-
|
313
310
|
return obj;
|
314
311
|
}
|
315
312
|
|
@@ -428,15 +425,15 @@ static VALUE rb_gsl_vector_complex_to_s(VALUE obj)
|
|
428
425
|
if (VECTOR_COMPLEX_COL_P(obj)) {
|
429
426
|
for (i = 0; i < v->size; i++) {
|
430
427
|
if (i != 0) {
|
431
|
-
|
428
|
+
rb_str_cat(str, " ", 2);
|
432
429
|
}
|
433
430
|
z = GSL_COMPLEX_AT(v, i);
|
434
431
|
sprintf(buf, "[%4.3e %4.3e]", GSL_REAL(*z), GSL_IMAG(*z));
|
435
432
|
if (i != v->size-1) strcat(buf, "\n");
|
436
433
|
rb_str_cat(str, buf, strlen(buf));
|
437
434
|
if (i >= 10 && i != v->size-1) {
|
438
|
-
|
439
|
-
|
435
|
+
rb_str_cat(str, " ...", 5);
|
436
|
+
break;
|
440
437
|
}
|
441
438
|
}
|
442
439
|
} else {
|
@@ -448,8 +445,8 @@ static VALUE rb_gsl_vector_complex_to_s(VALUE obj)
|
|
448
445
|
sprintf(buf, " [%4.3e %4.3e]", GSL_REAL(*z), GSL_IMAG(*z));
|
449
446
|
rb_str_cat(str, buf, strlen(buf));
|
450
447
|
if (i >= 10 && i != v->size-1) {
|
451
|
-
|
452
|
-
|
448
|
+
rb_str_cat(str, " ...", 4);
|
449
|
+
break;
|
453
450
|
}
|
454
451
|
}
|
455
452
|
}
|
@@ -629,10 +626,10 @@ static VALUE rb_gsl_vector_complex_conj(VALUE obj)
|
|
629
626
|
gsl_vector_complex *vout = NULL;
|
630
627
|
Data_Get_Struct(obj, gsl_vector_complex, vin);
|
631
628
|
vout = gsl_vector_complex_alloc(vin->size);
|
632
|
-
for(i=0; i<vin->size; i++) {
|
629
|
+
for(i = 0; i<vin->size; i++) {
|
633
630
|
gsl_vector_complex_set(vout, i,
|
634
|
-
|
635
|
-
|
631
|
+
gsl_complex_conjugate(
|
632
|
+
gsl_vector_complex_get(vin, i)));
|
636
633
|
}
|
637
634
|
return Data_Wrap_Struct(VECTOR_COMPLEX_ROW_COL(obj), 0, gsl_vector_complex_free, vout);
|
638
635
|
}
|
@@ -642,10 +639,10 @@ static VALUE rb_gsl_vector_complex_conj_bang(VALUE obj)
|
|
642
639
|
size_t i;
|
643
640
|
gsl_vector_complex *v = NULL;
|
644
641
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
645
|
-
for(i=0; i<v->size; i++) {
|
642
|
+
for(i = 0; i<v->size; i++) {
|
646
643
|
gsl_vector_complex_set(v, i,
|
647
|
-
|
648
|
-
|
644
|
+
gsl_complex_conjugate(
|
645
|
+
gsl_vector_complex_get(v, i)));
|
649
646
|
}
|
650
647
|
return obj;
|
651
648
|
}
|
@@ -658,7 +655,7 @@ static VALUE rb_gsl_vector_complex_to_a(VALUE obj)
|
|
658
655
|
VALUE ary;
|
659
656
|
Data_Get_Struct(obj, gsl_vector_complex, c);
|
660
657
|
ary = rb_ary_new2(c->size*2);
|
661
|
-
for (i = 0, j = 0; i < c->size; i++, j+=2) {
|
658
|
+
for (i = 0, j = 0; i < c->size; i++, j += 2) {
|
662
659
|
z = GSL_COMPLEX_AT(c, i);
|
663
660
|
rb_ary_store(ary, j, rb_float_new(GSL_REAL(*z)));
|
664
661
|
rb_ary_store(ary, j+1, rb_float_new(GSL_IMAG(*z)));
|
@@ -770,7 +767,7 @@ static VALUE rb_gsl_vector_complex_reverse2(VALUE obj)
|
|
770
767
|
vnew = gsl_vector_complex_alloc(v->size);
|
771
768
|
gsl_vector_complex_memcpy(vnew, v);
|
772
769
|
gsl_vector_complex_reverse(vnew);
|
773
|
-
if (VECTOR_COMPLEX_ROW_P(obj))
|
770
|
+
if (VECTOR_COMPLEX_ROW_P(obj))
|
774
771
|
return Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, vnew);
|
775
772
|
else
|
776
773
|
return Data_Wrap_Struct(cgsl_vector_complex_col, 0, gsl_vector_complex_free, vnew);
|
@@ -807,7 +804,6 @@ static VALUE rb_gsl_vector_complex_fftshift_bang(VALUE obj)
|
|
807
804
|
gsl_vector_complex_swap_elements(v, i, i+n/2);
|
808
805
|
}
|
809
806
|
}
|
810
|
-
|
811
807
|
return obj;
|
812
808
|
}
|
813
809
|
|
@@ -829,7 +825,7 @@ static VALUE rb_gsl_vector_complex_fftshift(VALUE obj)
|
|
829
825
|
vvnew = gsl_vector_complex_subvector(vnew, 0, n/2);
|
830
826
|
gsl_vector_complex_memcpy(&vvnew.vector, &vv.vector);
|
831
827
|
|
832
|
-
return Data_Wrap_Struct(VECTOR_COMPLEX_ROW_COL(obj), 0, gsl_vector_complex_free, vnew);
|
828
|
+
return Data_Wrap_Struct(VECTOR_COMPLEX_ROW_COL(obj), 0, gsl_vector_complex_free, vnew);
|
833
829
|
}
|
834
830
|
|
835
831
|
static VALUE rb_gsl_vector_complex_ifftshift_bang(VALUE obj)
|
@@ -854,7 +850,6 @@ static VALUE rb_gsl_vector_complex_ifftshift_bang(VALUE obj)
|
|
854
850
|
gsl_vector_complex_swap_elements(v, i, i+n/2);
|
855
851
|
}
|
856
852
|
}
|
857
|
-
|
858
853
|
return obj;
|
859
854
|
}
|
860
855
|
|
@@ -900,8 +895,8 @@ static VALUE rb_gsl_vector_complex_matrix_view(int argc, VALUE *argv, VALUE obj)
|
|
900
895
|
break;
|
901
896
|
case 3:
|
902
897
|
mv = gsl_matrix_complex_view_alloc();
|
903
|
-
*mv = gsl_matrix_complex_view_vector_with_tda(v, FIX2INT(argv[0]), FIX2INT(argv[1]),
|
904
|
-
|
898
|
+
*mv = gsl_matrix_complex_view_vector_with_tda(v, FIX2INT(argv[0]), FIX2INT(argv[1]),
|
899
|
+
FIX2INT(argv[2]));
|
905
900
|
break;
|
906
901
|
default:
|
907
902
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
|
@@ -911,7 +906,7 @@ static VALUE rb_gsl_vector_complex_matrix_view(int argc, VALUE *argv, VALUE obj)
|
|
911
906
|
}
|
912
907
|
|
913
908
|
static VALUE rb_gsl_vector_complex_matrix_view_with_tda(VALUE obj, VALUE nn1, VALUE nn2,
|
914
|
-
|
909
|
+
VALUE tda)
|
915
910
|
{
|
916
911
|
gsl_vector_complex *v = NULL;
|
917
912
|
gsl_matrix_complex_view *mv = NULL;
|
@@ -928,9 +923,9 @@ static VALUE rb_gsl_vector_complex_trans(VALUE obj)
|
|
928
923
|
gsl_vector_complex *v = NULL, *vnew = NULL;
|
929
924
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
930
925
|
vnew = make_vector_complex_clone(v);
|
931
|
-
if (VECTOR_COMPLEX_ROW_P(obj))
|
926
|
+
if (VECTOR_COMPLEX_ROW_P(obj))
|
932
927
|
return Data_Wrap_Struct(cgsl_vector_complex_col, 0, gsl_vector_complex_free, vnew);
|
933
|
-
else if (VECTOR_COMPLEX_COL_P(obj))
|
928
|
+
else if (VECTOR_COMPLEX_COL_P(obj))
|
934
929
|
return Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, vnew);
|
935
930
|
else {
|
936
931
|
rb_raise(rb_eTypeError, "wrong type");
|
@@ -939,13 +934,13 @@ static VALUE rb_gsl_vector_complex_trans(VALUE obj)
|
|
939
934
|
|
940
935
|
static VALUE rb_gsl_vector_complex_trans2(VALUE obj)
|
941
936
|
{
|
942
|
-
if (CLASS_OF(obj) == cgsl_vector_complex)
|
937
|
+
if (CLASS_OF(obj) == cgsl_vector_complex)
|
943
938
|
RBGSL_SET_CLASS(obj, cgsl_vector_complex_col);
|
944
|
-
else if (CLASS_OF(obj) == cgsl_vector_complex_col)
|
939
|
+
else if (CLASS_OF(obj) == cgsl_vector_complex_col)
|
945
940
|
RBGSL_SET_CLASS(obj, cgsl_vector_complex);
|
946
941
|
else {
|
947
942
|
rb_raise(rb_eRuntimeError, "method trans! for %s is forbidden",
|
948
|
-
|
943
|
+
rb_class2name(CLASS_OF(obj)));
|
949
944
|
}
|
950
945
|
return obj;
|
951
946
|
}
|
@@ -982,7 +977,7 @@ enum {
|
|
982
977
|
|
983
978
|
static VALUE rb_gsl_vector_complex_arithmetics(int flag, VALUE obj, VALUE bb);
|
984
979
|
|
985
|
-
static VALUE rb_gsl_vector_complex_arithmetics(int flag, VALUE obj, VALUE bb)
|
980
|
+
static VALUE rb_gsl_vector_complex_arithmetics(int flag, VALUE obj, VALUE bb)
|
986
981
|
{
|
987
982
|
gsl_vector *b = NULL;
|
988
983
|
gsl_vector_complex *cv = NULL, *cvnew = NULL, *cb = NULL;
|
@@ -1037,20 +1032,20 @@ static VALUE rb_gsl_vector_complex_arithmetics(int flag, VALUE obj, VALUE bb)
|
|
1037
1032
|
switch (flag) {
|
1038
1033
|
case GSL_VECTOR_COMPLEX_ADD:
|
1039
1034
|
case GSL_VECTOR_COMPLEX_ADD_BANG:
|
1040
|
-
|
1041
|
-
|
1035
|
+
gsl_vector_complex_add(cvnew, cb);
|
1036
|
+
break;
|
1042
1037
|
case GSL_VECTOR_COMPLEX_SUB:
|
1043
1038
|
case GSL_VECTOR_COMPLEX_SUB_BANG:
|
1044
|
-
|
1045
|
-
|
1039
|
+
gsl_vector_complex_sub(cvnew, cb);
|
1040
|
+
break;
|
1046
1041
|
case GSL_VECTOR_COMPLEX_MUL:
|
1047
1042
|
case GSL_VECTOR_COMPLEX_MUL_BANG:
|
1048
|
-
|
1049
|
-
|
1043
|
+
gsl_vector_complex_mul(cvnew, cb);
|
1044
|
+
break;
|
1050
1045
|
case GSL_VECTOR_COMPLEX_DIV:
|
1051
1046
|
case GSL_VECTOR_COMPLEX_DIV_BANG:
|
1052
|
-
|
1053
|
-
|
1047
|
+
gsl_vector_complex_div(cvnew, cb);
|
1048
|
+
break;
|
1054
1049
|
}
|
1055
1050
|
gsl_vector_complex_free(cb);
|
1056
1051
|
} else if (VECTOR_COMPLEX_P(bb)) {
|
@@ -1058,40 +1053,40 @@ static VALUE rb_gsl_vector_complex_arithmetics(int flag, VALUE obj, VALUE bb)
|
|
1058
1053
|
switch (flag) {
|
1059
1054
|
case GSL_VECTOR_COMPLEX_ADD:
|
1060
1055
|
case GSL_VECTOR_COMPLEX_ADD_BANG:
|
1061
|
-
|
1062
|
-
|
1056
|
+
gsl_vector_complex_add(cvnew, cb);
|
1057
|
+
break;
|
1063
1058
|
case GSL_VECTOR_COMPLEX_SUB:
|
1064
1059
|
case GSL_VECTOR_COMPLEX_SUB_BANG:
|
1065
|
-
|
1066
|
-
|
1060
|
+
gsl_vector_complex_sub(cvnew, cb);
|
1061
|
+
break;
|
1067
1062
|
case GSL_VECTOR_COMPLEX_MUL:
|
1068
1063
|
case GSL_VECTOR_COMPLEX_MUL_BANG:
|
1069
|
-
|
1070
|
-
|
1064
|
+
gsl_vector_complex_mul(cvnew, cb);
|
1065
|
+
break;
|
1071
1066
|
case GSL_VECTOR_COMPLEX_DIV:
|
1072
1067
|
case GSL_VECTOR_COMPLEX_DIV_BANG:
|
1073
|
-
|
1074
|
-
|
1068
|
+
gsl_vector_complex_div(cvnew, cb);
|
1069
|
+
break;
|
1075
1070
|
}
|
1076
1071
|
} else if (COMPLEX_P(bb)) {
|
1077
1072
|
Data_Get_Struct(bb, gsl_complex, c);
|
1078
1073
|
switch (flag) {
|
1079
1074
|
case GSL_VECTOR_COMPLEX_ADD:
|
1080
1075
|
case GSL_VECTOR_COMPLEX_ADD_BANG:
|
1081
|
-
|
1082
|
-
|
1076
|
+
gsl_vector_complex_add_constant(cvnew, *c);
|
1077
|
+
break;
|
1083
1078
|
case GSL_VECTOR_COMPLEX_SUB:
|
1084
1079
|
case GSL_VECTOR_COMPLEX_SUB_BANG:
|
1085
|
-
|
1086
|
-
|
1080
|
+
gsl_vector_complex_add_constant(cvnew, gsl_complex_negative(*c));
|
1081
|
+
break;
|
1087
1082
|
case GSL_VECTOR_COMPLEX_MUL:
|
1088
1083
|
case GSL_VECTOR_COMPLEX_MUL_BANG:
|
1089
|
-
|
1090
|
-
|
1084
|
+
gsl_vector_complex_scale(cvnew, *c);
|
1085
|
+
break;
|
1091
1086
|
case GSL_VECTOR_COMPLEX_DIV:
|
1092
1087
|
case GSL_VECTOR_COMPLEX_DIV_BANG:
|
1093
|
-
|
1094
|
-
|
1088
|
+
gsl_vector_complex_scale(cvnew, gsl_complex_inverse(*c));
|
1089
|
+
break;
|
1095
1090
|
}
|
1096
1091
|
} else {
|
1097
1092
|
rb_raise(rb_eTypeError, "wrong type argument %s", rb_class2name(CLASS_OF(bb)));
|
@@ -1186,22 +1181,22 @@ static VALUE rb_gsl_vector_complex_inner_product(int argc, VALUE *argv, VALUE ob
|
|
1186
1181
|
case T_CLASS:
|
1187
1182
|
case T_OBJECT:
|
1188
1183
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
|
1189
|
-
|
1184
|
+
argc);
|
1190
1185
|
if (!VECTOR_COMPLEX_ROW_P(argv[0]))
|
1191
1186
|
rb_raise(rb_eTypeError, "wrong argument type %s (GSL::Vector::Complex expected)",
|
1192
|
-
|
1187
|
+
rb_class2name(CLASS_OF(argv[0])));
|
1193
1188
|
if (!VECTOR_COMPLEX_COL_P(argv[1]))
|
1194
1189
|
rb_raise(rb_eTypeError, "wrong argument type %s (GSL::Vector::Complex::Col expected)",
|
1195
|
-
|
1190
|
+
rb_class2name(CLASS_OF(argv[1])));
|
1196
1191
|
Data_Get_Struct(argv[0], gsl_vector_complex, v);
|
1197
1192
|
Data_Get_Struct(argv[1], gsl_vector_complex, v2);
|
1198
1193
|
break;
|
1199
1194
|
default:
|
1200
1195
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
1201
|
-
|
1196
|
+
argc);
|
1202
1197
|
if (!VECTOR_COMPLEX_COL_P(argv[0]))
|
1203
1198
|
rb_raise(rb_eTypeError, "wrong argument type %s (GSL::Vector::Complex::Col expected)",
|
1204
|
-
|
1199
|
+
rb_class2name(CLASS_OF(argv[0])));
|
1205
1200
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
1206
1201
|
Data_Get_Struct(argv[0], gsl_vector_complex, v2);
|
1207
1202
|
break;
|
@@ -1229,25 +1224,25 @@ static VALUE rb_gsl_vector_complex_product_to_m(int argc, VALUE *argv, VALUE obj
|
|
1229
1224
|
case T_CLASS:
|
1230
1225
|
case T_OBJECT:
|
1231
1226
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
|
1232
|
-
|
1227
|
+
argc);
|
1233
1228
|
if (!VECTOR_COMPLEX_COL_P(argv[0]))
|
1234
|
-
rb_raise(rb_eTypeError,
|
1235
|
-
|
1236
|
-
|
1229
|
+
rb_raise(rb_eTypeError,
|
1230
|
+
"wrong argument type %s (GSL::Vector::Complex::Col expected)",
|
1231
|
+
rb_class2name(CLASS_OF(argv[0])));
|
1237
1232
|
if (!VECTOR_COMPLEX_ROW_P(argv[1]))
|
1238
|
-
rb_raise(rb_eTypeError,
|
1239
|
-
|
1240
|
-
|
1233
|
+
rb_raise(rb_eTypeError,
|
1234
|
+
"wrong argument type %s (GSL::Vector::Complex expected)",
|
1235
|
+
rb_class2name(CLASS_OF(argv[1])));
|
1241
1236
|
Data_Get_Struct(argv[0], gsl_vector_complex, v);
|
1242
1237
|
Data_Get_Struct(argv[1], gsl_vector_complex, v2);
|
1243
1238
|
break;
|
1244
1239
|
default:
|
1245
1240
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
1246
|
-
|
1241
|
+
argc);
|
1247
1242
|
if (!VECTOR_COMPLEX_ROW_P(argv[0]))
|
1248
|
-
rb_raise(rb_eTypeError,
|
1249
|
-
|
1250
|
-
|
1243
|
+
rb_raise(rb_eTypeError,
|
1244
|
+
"wrong argument type %s (GSL::Vector::Complex expected)",
|
1245
|
+
rb_class2name(CLASS_OF(argv[0])));
|
1251
1246
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
1252
1247
|
Data_Get_Struct(argv[0], gsl_vector_complex, v2);
|
1253
1248
|
break;
|
@@ -1324,8 +1319,8 @@ static VALUE rb_gsl_vector_complex_XXXz_bang(VALUE obj, gsl_complex (*f)(gsl_com
|
|
1324
1319
|
return obj;
|
1325
1320
|
}
|
1326
1321
|
|
1327
|
-
static VALUE rb_gsl_vector_complex_XXXz2(VALUE obj, VALUE a,
|
1328
|
-
|
1322
|
+
static VALUE rb_gsl_vector_complex_XXXz2(VALUE obj, VALUE a,
|
1323
|
+
gsl_complex (*f)(gsl_complex, gsl_complex))
|
1329
1324
|
{
|
1330
1325
|
gsl_vector_complex *m, *v;
|
1331
1326
|
gsl_complex c, *z;
|
@@ -1341,8 +1336,8 @@ static VALUE rb_gsl_vector_complex_XXXz2(VALUE obj, VALUE a,
|
|
1341
1336
|
return Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, v);
|
1342
1337
|
}
|
1343
1338
|
|
1344
|
-
static VALUE rb_gsl_vector_complex_XXXz2_bang(VALUE obj, VALUE a,
|
1345
|
-
|
1339
|
+
static VALUE rb_gsl_vector_complex_XXXz2_bang(VALUE obj, VALUE a,
|
1340
|
+
gsl_complex (*f)(gsl_complex, gsl_complex))
|
1346
1341
|
{
|
1347
1342
|
gsl_vector_complex *v;
|
1348
1343
|
gsl_complex c, *z;
|
@@ -1443,7 +1438,7 @@ static gsl_complex rb_gsl_vector_complex_sum_gsl(gsl_vector_complex * v)
|
|
1443
1438
|
size_t i;
|
1444
1439
|
gsl_complex z = gsl_complex_rect(0.0,0.0);
|
1445
1440
|
|
1446
|
-
for(i=0; i<v->size; i++) {
|
1441
|
+
for(i = 0; i<v->size; i++) {
|
1447
1442
|
z = gsl_complex_add(z, gsl_vector_complex_get(v,i));
|
1448
1443
|
}
|
1449
1444
|
return z;
|
@@ -1462,7 +1457,7 @@ static double rb_gsl_vector_complex_tss_m_gsl(gsl_vector_complex * v, gsl_comple
|
|
1462
1457
|
size_t i;
|
1463
1458
|
double tss = 0.0;
|
1464
1459
|
|
1465
|
-
for(i=0; i<v->size; i++) {
|
1460
|
+
for(i = 0; i<v->size; i++) {
|
1466
1461
|
tss += gsl_complex_abs2(gsl_complex_sub(gsl_vector_complex_get(v,i), mean));
|
1467
1462
|
}
|
1468
1463
|
return tss;
|
@@ -1522,7 +1517,7 @@ static double rb_gsl_vector_complex_sd_gsl(gsl_vector_complex * v)
|
|
1522
1517
|
* (e.g. sum and mean)
|
1523
1518
|
*/
|
1524
1519
|
static VALUE rb_gsl_vector_complex_z_stats_v(VALUE obj,
|
1525
|
-
|
1520
|
+
gsl_complex (*func)(gsl_vector_complex*))
|
1526
1521
|
{
|
1527
1522
|
gsl_vector_complex * v;
|
1528
1523
|
gsl_complex * zp;
|
@@ -1531,7 +1526,7 @@ static VALUE rb_gsl_vector_complex_z_stats_v(VALUE obj,
|
|
1531
1526
|
CHECK_VECTOR_COMPLEX(obj);
|
1532
1527
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
1533
1528
|
|
1534
|
-
zv = Data_Make_Struct(cgsl_complex, gsl_complex, 0, free, zp);
|
1529
|
+
zv = Data_Make_Struct(cgsl_complex, gsl_complex, 0, free, zp);
|
1535
1530
|
*zp = func(v);
|
1536
1531
|
|
1537
1532
|
return zv;
|
@@ -1542,7 +1537,7 @@ static VALUE rb_gsl_vector_complex_z_stats_v(VALUE obj,
|
|
1542
1537
|
* (e.g. tss, variance, sd)
|
1543
1538
|
*/
|
1544
1539
|
static VALUE rb_gsl_vector_complex_d_stats_v(VALUE obj,
|
1545
|
-
|
1540
|
+
double (*func)(gsl_vector_complex*))
|
1546
1541
|
{
|
1547
1542
|
gsl_vector_complex * v;
|
1548
1543
|
double d;
|
@@ -1560,7 +1555,7 @@ static VALUE rb_gsl_vector_complex_d_stats_v(VALUE obj,
|
|
1560
1555
|
* (e.g. tss_m, variance_m, sd_m, variance_fm, sd_fm)
|
1561
1556
|
*/
|
1562
1557
|
static VALUE rb_gsl_vector_complex_d_stats_v_z(VALUE obj, VALUE arg,
|
1563
|
-
|
1558
|
+
double (*func)(gsl_vector_complex*, gsl_complex))
|
1564
1559
|
{
|
1565
1560
|
gsl_vector_complex * v;
|
1566
1561
|
gsl_complex z;
|
@@ -1773,58 +1768,58 @@ static VALUE rb_gsl_vector_complex_concat(VALUE obj, VALUE other)
|
|
1773
1768
|
Data_Get_Struct(obj, gsl_vector_complex, v);
|
1774
1769
|
|
1775
1770
|
switch(TYPE(other)) {
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1771
|
+
case T_FIXNUM:
|
1772
|
+
case T_BIGNUM:
|
1773
|
+
case T_FLOAT:
|
1774
|
+
vnew = gsl_vector_complex_alloc(v->size + 1);
|
1775
|
+
vv = gsl_vector_complex_subvector(vnew, 0, v->size);
|
1776
|
+
gsl_vector_complex_memcpy(&vv.vector, v);
|
1777
|
+
gsl_vector_complex_set(vnew, v->size, rb_gsl_obj_to_gsl_complex(other, NULL));
|
1778
|
+
break;
|
1779
|
+
|
1780
|
+
case T_ARRAY:
|
1781
|
+
size2 = RARRAY_LEN(other);
|
1782
|
+
vnew = gsl_vector_complex_alloc(v->size + size2);
|
1783
|
+
vv = gsl_vector_complex_subvector(vnew, 0, v->size);
|
1784
|
+
gsl_vector_complex_memcpy(&vv.vector, v);
|
1785
|
+
for (i = 0; i < size2; i++) {
|
1786
|
+
x = rb_ary_entry(other, i);
|
1787
|
+
gsl_vector_complex_set(vnew, v->size + i, rb_gsl_obj_to_gsl_complex(x, NULL));
|
1788
|
+
}
|
1789
|
+
break;
|
1790
|
+
|
1791
|
+
default:
|
1792
|
+
if(rb_obj_is_kind_of(other, cgsl_complex)) {
|
1779
1793
|
vnew = gsl_vector_complex_alloc(v->size + 1);
|
1780
1794
|
vv = gsl_vector_complex_subvector(vnew, 0, v->size);
|
1781
1795
|
gsl_vector_complex_memcpy(&vv.vector, v);
|
1782
1796
|
gsl_vector_complex_set(vnew, v->size, rb_gsl_obj_to_gsl_complex(other, NULL));
|
1783
|
-
|
1784
|
-
|
1785
|
-
case T_ARRAY:
|
1786
|
-
size2 = RARRAY_LEN(other);
|
1797
|
+
} else if(rb_obj_is_kind_of(other, rb_cRange)) {
|
1798
|
+
get_range_beg_en_n(other, &beg, &end, &size2, &step);
|
1787
1799
|
vnew = gsl_vector_complex_alloc(v->size + size2);
|
1788
1800
|
vv = gsl_vector_complex_subvector(vnew, 0, v->size);
|
1789
1801
|
gsl_vector_complex_memcpy(&vv.vector, v);
|
1802
|
+
GSL_SET_COMPLEX(&tmp, beg, 0.0);
|
1790
1803
|
for (i = 0; i < size2; i++) {
|
1791
|
-
|
1792
|
-
|
1804
|
+
gsl_vector_complex_set(vnew, v->size + i, tmp);
|
1805
|
+
GSL_SET_REAL(&tmp, GSL_REAL(tmp) + step);
|
1793
1806
|
}
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
GSL_SET_COMPLEX(&tmp, beg, 0.0);
|
1808
|
-
for (i = 0; i < size2; i++) {
|
1809
|
-
gsl_vector_complex_set(vnew, v->size + i, tmp);
|
1810
|
-
GSL_SET_REAL(&tmp, GSL_REAL(tmp) + step);
|
1811
|
-
}
|
1812
|
-
} else if (rb_obj_is_kind_of(other, cgsl_vector_complex)) {
|
1813
|
-
Data_Get_Struct(other, gsl_vector_complex, v2);
|
1814
|
-
size2 = v2->size;
|
1815
|
-
vnew = gsl_vector_complex_alloc(v->size + size2);
|
1816
|
-
vv = gsl_vector_complex_subvector(vnew, 0, v->size);
|
1817
|
-
gsl_vector_complex_memcpy(&vv.vector, v);
|
1818
|
-
vv = gsl_vector_complex_subvector(vnew, v->size, size2);
|
1819
|
-
gsl_vector_complex_memcpy(&vv.vector, v2);
|
1820
|
-
} else {
|
1821
|
-
rb_raise(rb_eTypeError, "wrong argument type %s (Array, Numeric, Range, GSL::Complex, or %s expected)",
|
1822
|
-
rb_class2name(CLASS_OF(other)), rb_class2name(cgsl_vector_complex));
|
1823
|
-
}
|
1824
|
-
break;
|
1807
|
+
} else if (rb_obj_is_kind_of(other, cgsl_vector_complex)) {
|
1808
|
+
Data_Get_Struct(other, gsl_vector_complex, v2);
|
1809
|
+
size2 = v2->size;
|
1810
|
+
vnew = gsl_vector_complex_alloc(v->size + size2);
|
1811
|
+
vv = gsl_vector_complex_subvector(vnew, 0, v->size);
|
1812
|
+
gsl_vector_complex_memcpy(&vv.vector, v);
|
1813
|
+
vv = gsl_vector_complex_subvector(vnew, v->size, size2);
|
1814
|
+
gsl_vector_complex_memcpy(&vv.vector, v2);
|
1815
|
+
} else {
|
1816
|
+
rb_raise(rb_eTypeError, "wrong argument type %s (Array, Numeric, Range, GSL::Complex, or %s expected)",
|
1817
|
+
rb_class2name(CLASS_OF(other)), rb_class2name(cgsl_vector_complex));
|
1818
|
+
}
|
1819
|
+
break;
|
1825
1820
|
}
|
1826
1821
|
|
1827
|
-
return Data_Wrap_Struct(VECTOR_COMPLEX_ROW_COL(obj), 0, gsl_vector_complex_free, vnew);
|
1822
|
+
return Data_Wrap_Struct(VECTOR_COMPLEX_ROW_COL(obj), 0, gsl_vector_complex_free, vnew);
|
1828
1823
|
}
|
1829
1824
|
|
1830
1825
|
static VALUE rb_gsl_vector_complex_block(VALUE obj)
|
@@ -1958,7 +1953,7 @@ static VALUE rb_gsl_vector_complex_zip(int argc, VALUE *argv, VALUE obj)
|
|
1958
1953
|
argv2 = argv;
|
1959
1954
|
} else {
|
1960
1955
|
if (argc < 1) rb_raise(rb_eArgError, "Too few arguments.");
|
1961
|
-
Data_Get_Struct(argv[0], gsl_vector_complex, v0);
|
1956
|
+
Data_Get_Struct(argv[0], gsl_vector_complex, v0);
|
1962
1957
|
argc2 = argc - 1;
|
1963
1958
|
argv2 = argv + 1;
|
1964
1959
|
}
|
@@ -1975,14 +1970,13 @@ static VALUE rb_gsl_vector_complex_zip(int argc, VALUE *argv, VALUE obj)
|
|
1975
1970
|
gsl_vector_complex_set(vnew, 0, gsl_vector_complex_get(v0, i));
|
1976
1971
|
for (j = 0; (int) j < argc2; j++) {
|
1977
1972
|
if (i < vp[j]->size) {
|
1978
|
-
|
1973
|
+
gsl_vector_complex_set(vnew, j+1, gsl_vector_complex_get(vp[j], i));
|
1979
1974
|
} else {
|
1980
|
-
|
1975
|
+
gsl_vector_complex_set(vnew, j+1, zzero);
|
1981
1976
|
}
|
1982
1977
|
}
|
1983
1978
|
rb_ary_store(ary, i, Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, vnew));
|
1984
1979
|
}
|
1985
|
-
|
1986
1980
|
free((gsl_vector_complex**) vp);
|
1987
1981
|
return ary;
|
1988
1982
|
}
|
@@ -1991,7 +1985,7 @@ static VALUE rb_gsl_vector_complex_zip(int argc, VALUE *argv, VALUE obj)
|
|
1991
1985
|
// function, but it only determines absolute equality (i.e. is has no epsilon
|
1992
1986
|
// argument).
|
1993
1987
|
static int gsl_vector_complex_equal_eps(const gsl_vector_complex *v1,
|
1994
|
-
|
1988
|
+
const gsl_vector_complex *v2, double eps)
|
1995
1989
|
{
|
1996
1990
|
gsl_complex z1, z2;
|
1997
1991
|
size_t i;
|
@@ -2002,7 +1996,7 @@ static int gsl_vector_complex_equal_eps(const gsl_vector_complex *v1,
|
|
2002
1996
|
if (!rbgsl_complex_equal(&z1, &z2, eps)) return 0;
|
2003
1997
|
}
|
2004
1998
|
return 1;
|
2005
|
-
|
1999
|
+
|
2006
2000
|
}
|
2007
2001
|
|
2008
2002
|
static VALUE rb_gsl_vector_complex_equal(int argc, VALUE *argv, VALUE obj)
|
@@ -2043,8 +2037,8 @@ void Init_gsl_vector_complex(VALUE module)
|
|
2043
2037
|
rb_define_singleton_method(cgsl_vector_complex, "alloc", rb_gsl_vector_complex_new, -1);
|
2044
2038
|
rb_define_singleton_method(cgsl_vector_complex, "calloc", rb_gsl_vector_complex_calloc, 1);
|
2045
2039
|
|
2046
|
-
rb_define_singleton_method(cgsl_vector_complex_col, "new",
|
2047
|
-
|
2040
|
+
rb_define_singleton_method(cgsl_vector_complex_col, "new",
|
2041
|
+
rb_gsl_vector_complex_row_new, -1);
|
2048
2042
|
|
2049
2043
|
rb_define_method(cgsl_vector_complex, "size", rb_gsl_vector_complex_size, 0);
|
2050
2044
|
rb_define_alias(cgsl_vector_complex, "len", "size");
|
@@ -2103,7 +2097,7 @@ void Init_gsl_vector_complex(VALUE module)
|
|
2103
2097
|
rb_define_method(cgsl_vector_complex, "subvector", rb_gsl_vector_complex_subvector, -1);
|
2104
2098
|
rb_define_alias(cgsl_vector_complex, "view", "subvector");
|
2105
2099
|
rb_define_method(cgsl_vector_complex, "subvector_with_stride", rb_gsl_vector_complex_subvector_with_stride, 3);
|
2106
|
-
|
2100
|
+
|
2107
2101
|
rb_define_singleton_method(cgsl_vector_complex, "memcpy", rb_gsl_vector_complex_memcpy, 2);
|
2108
2102
|
rb_define_method(cgsl_vector_complex, "clone", rb_gsl_vector_complex_clone, 0);
|
2109
2103
|
rb_define_alias(cgsl_vector_complex, "duplicate", "clone");
|
@@ -2132,17 +2126,17 @@ void Init_gsl_vector_complex(VALUE module)
|
|
2132
2126
|
rb_define_alias(cgsl_vector_complex_col, "row", "trans");
|
2133
2127
|
rb_define_alias(cgsl_vector_complex_col, "row!", "trans!");
|
2134
2128
|
|
2135
|
-
|
2129
|
+
/*****/
|
2136
2130
|
rb_define_method(cgsl_vector_complex, "to_real", rb_gsl_vector_complex_to_real, 0);
|
2137
2131
|
|
2138
|
-
rb_define_method(cgsl_vector_complex, "add", rb_gsl_vector_complex_add, 1);
|
2139
|
-
rb_define_method(cgsl_vector_complex, "sub", rb_gsl_vector_complex_sub, 1);
|
2140
|
-
rb_define_method(cgsl_vector_complex, "mul", rb_gsl_vector_complex_mul, 1);
|
2141
|
-
rb_define_method(cgsl_vector_complex, "div", rb_gsl_vector_complex_div, 1);
|
2142
|
-
rb_define_method(cgsl_vector_complex, "add!", rb_gsl_vector_complex_add_bang, 1);
|
2143
|
-
rb_define_method(cgsl_vector_complex, "sub!", rb_gsl_vector_complex_sub_bang, 1);
|
2144
|
-
rb_define_method(cgsl_vector_complex, "mul!", rb_gsl_vector_complex_mul_bang, 1);
|
2145
|
-
rb_define_method(cgsl_vector_complex, "div!", rb_gsl_vector_complex_div_bang, 1);
|
2132
|
+
rb_define_method(cgsl_vector_complex, "add", rb_gsl_vector_complex_add, 1);
|
2133
|
+
rb_define_method(cgsl_vector_complex, "sub", rb_gsl_vector_complex_sub, 1);
|
2134
|
+
rb_define_method(cgsl_vector_complex, "mul", rb_gsl_vector_complex_mul, 1);
|
2135
|
+
rb_define_method(cgsl_vector_complex, "div", rb_gsl_vector_complex_div, 1);
|
2136
|
+
rb_define_method(cgsl_vector_complex, "add!", rb_gsl_vector_complex_add_bang, 1);
|
2137
|
+
rb_define_method(cgsl_vector_complex, "sub!", rb_gsl_vector_complex_sub_bang, 1);
|
2138
|
+
rb_define_method(cgsl_vector_complex, "mul!", rb_gsl_vector_complex_mul_bang, 1);
|
2139
|
+
rb_define_method(cgsl_vector_complex, "div!", rb_gsl_vector_complex_div_bang, 1);
|
2146
2140
|
|
2147
2141
|
rb_define_alias(cgsl_vector_complex, "+", "add");
|
2148
2142
|
rb_define_alias(cgsl_vector_complex, "add_constant", "add");
|
@@ -2153,7 +2147,7 @@ void Init_gsl_vector_complex(VALUE module)
|
|
2153
2147
|
rb_define_alias(cgsl_vector_complex, "scale!", "mul!");
|
2154
2148
|
rb_define_alias(cgsl_vector_complex, "/", "div");
|
2155
2149
|
|
2156
|
-
rb_define_method(cgsl_vector_complex, "coerce", rb_gsl_vector_complex_coerce, 1);
|
2150
|
+
rb_define_method(cgsl_vector_complex, "coerce", rb_gsl_vector_complex_coerce, 1);
|
2157
2151
|
|
2158
2152
|
/* 2.Aug.2004 */
|
2159
2153
|
rb_define_singleton_method(cgsl_vector_complex, "inner_product", rb_gsl_vector_complex_inner_product, -1);
|
@@ -2238,10 +2232,10 @@ void Init_gsl_vector_complex(VALUE module)
|
|
2238
2232
|
|
2239
2233
|
rb_define_method(cgsl_vector_complex, "zip", rb_gsl_vector_complex_zip, -1);
|
2240
2234
|
rb_define_singleton_method(cgsl_vector_complex, "zip", rb_gsl_vector_complex_zip, -1);
|
2241
|
-
|
2235
|
+
|
2242
2236
|
rb_define_method(cgsl_vector_complex, "equal?", rb_gsl_vector_complex_equal, -1);
|
2243
2237
|
rb_define_alias(cgsl_vector_complex, "==", "equal?");
|
2244
2238
|
rb_define_method(cgsl_vector_complex, "not_equal?", rb_gsl_vector_complex_not_equal, -1);
|
2245
|
-
rb_define_alias(cgsl_vector_complex, "!=", "not_equal?");
|
2239
|
+
rb_define_alias(cgsl_vector_complex, "!=", "not_equal?");
|
2246
2240
|
}
|
2247
2241
|
|