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
@@ -38,7 +38,40 @@ enum {
|
|
38
38
|
|
39
39
|
#ifdef HAVE_NARRAY_H
|
40
40
|
static VALUE rb_gsl_linalg_LU_decomp_narray(int argc, VALUE *argv, VALUE obj,
|
41
|
-
|
41
|
+
int flag)
|
42
|
+
{
|
43
|
+
struct NARRAY *na, *na2;
|
44
|
+
VALUE m;
|
45
|
+
gsl_matrix_view mv;
|
46
|
+
gsl_permutation *p;
|
47
|
+
int signum;
|
48
|
+
|
49
|
+
if (argc != 1)
|
50
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
|
51
|
+
GetNArray(argv[0], na);
|
52
|
+
if (na->rank < 2) rb_raise(rb_eRuntimeError, "rank >= 2 required");
|
53
|
+
if (na->shape[0] != na->shape[1])
|
54
|
+
rb_raise(rb_eRuntimeError, "square matrix required");
|
55
|
+
if (flag == LINALG_DECOMP) {
|
56
|
+
m = na_make_object(NA_DFLOAT, 2, na->shape, CLASS_OF(argv[0]));
|
57
|
+
GetNArray(m, na2);
|
58
|
+
memcpy((double*)na2->ptr, (double*)na->ptr, sizeof(double)*na2->total);
|
59
|
+
mv = gsl_matrix_view_array((double*)na2->ptr, na->shape[1], na->shape[0]);
|
60
|
+
} else {
|
61
|
+
mv = gsl_matrix_view_array((double*)na->ptr, na->shape[1], na->shape[0]);
|
62
|
+
}
|
63
|
+
p = gsl_permutation_alloc(mv.matrix.size1);
|
64
|
+
gsl_linalg_LU_decomp(&mv.matrix, p, &signum);
|
65
|
+
if (flag == LINALG_DECOMP) {
|
66
|
+
return rb_ary_new3(3, m,
|
67
|
+
Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p),
|
68
|
+
INT2FIX(signum));
|
69
|
+
} else {
|
70
|
+
return rb_ary_new3(3, argv[0],
|
71
|
+
Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p),
|
72
|
+
INT2FIX(signum));
|
73
|
+
}
|
74
|
+
}
|
42
75
|
#endif
|
43
76
|
|
44
77
|
static VALUE rb_gsl_linalg_LU_decomposition(int argc, VALUE *argv, VALUE obj, int flag)
|
@@ -51,7 +84,7 @@ static VALUE rb_gsl_linalg_LU_decomposition(int argc, VALUE *argv, VALUE obj, in
|
|
51
84
|
switch (TYPE(obj)) {
|
52
85
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
53
86
|
#ifdef HAVE_NARRAY_H
|
54
|
-
if (NA_IsNArray(argv[0]))
|
87
|
+
if (NA_IsNArray(argv[0]))
|
55
88
|
return rb_gsl_linalg_LU_decomp_narray(argc, argv, obj, flag);
|
56
89
|
#endif
|
57
90
|
if (MATRIX_COMPLEX_P(argv[0]))
|
@@ -109,45 +142,6 @@ static VALUE rb_gsl_linalg_LU_decomp_bang(int argc, VALUE *argv, VALUE obj)
|
|
109
142
|
return rb_gsl_linalg_LU_decomposition(argc, argv, obj, LINALG_DECOMP_BANG);
|
110
143
|
}
|
111
144
|
|
112
|
-
#ifdef HAVE_NARRAY_H
|
113
|
-
static VALUE rb_gsl_linalg_LU_decomp_narray(int argc, VALUE *argv, VALUE obj,
|
114
|
-
int flag)
|
115
|
-
{
|
116
|
-
struct NARRAY *na, *na2;
|
117
|
-
VALUE m;
|
118
|
-
gsl_matrix_view mv;
|
119
|
-
gsl_permutation *p;
|
120
|
-
int signum;
|
121
|
-
|
122
|
-
if (argc != 1)
|
123
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
|
124
|
-
GetNArray(argv[0], na);
|
125
|
-
if (na->rank < 2) rb_raise(rb_eRuntimeError, "rank >= 2 required");
|
126
|
-
if (na->shape[0] != na->shape[1])
|
127
|
-
rb_raise(rb_eRuntimeError, "square matrix required");
|
128
|
-
if (flag == LINALG_DECOMP) {
|
129
|
-
m = na_make_object(NA_DFLOAT, 2, na->shape, CLASS_OF(argv[0]));
|
130
|
-
GetNArray(m, na2);
|
131
|
-
memcpy((double*)na2->ptr, (double*)na->ptr, sizeof(double)*na2->total);
|
132
|
-
mv = gsl_matrix_view_array((double*)na2->ptr, na->shape[1], na->shape[0]);
|
133
|
-
} else {
|
134
|
-
mv = gsl_matrix_view_array((double*)na->ptr, na->shape[1], na->shape[0]);
|
135
|
-
}
|
136
|
-
p = gsl_permutation_alloc(mv.matrix.size1);
|
137
|
-
gsl_linalg_LU_decomp(&mv.matrix, p, &signum);
|
138
|
-
if (flag == LINALG_DECOMP) {
|
139
|
-
return rb_ary_new3(3, m,
|
140
|
-
Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p),
|
141
|
-
INT2FIX(signum));
|
142
|
-
} else {
|
143
|
-
return rb_ary_new3(3, argv[0],
|
144
|
-
Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p),
|
145
|
-
INT2FIX(signum));
|
146
|
-
}
|
147
|
-
|
148
|
-
}
|
149
|
-
#endif
|
150
|
-
|
151
145
|
static gsl_matrix* get_matrix(VALUE obj, VALUE klass,int *flagm);
|
152
146
|
static gsl_permutation* get_permutation(VALUE obj, size_t size, int *flagp);
|
153
147
|
static gsl_vector* get_vector2(VALUE obj, int *flagv);
|
@@ -155,15 +149,13 @@ static gsl_vector* get_vector2(VALUE obj, int *flagv);
|
|
155
149
|
static gsl_matrix* get_matrix(VALUE obj, VALUE klass, int *flagm)
|
156
150
|
{
|
157
151
|
gsl_matrix *mtmp = NULL, *m = NULL;
|
158
|
-
#ifdef HAVE_NARRAY_H
|
159
|
-
gsl_matrix_view mv;
|
160
|
-
struct NARRAY *na;
|
161
|
-
#endif
|
162
152
|
if (CLASS_OF(obj) == klass) {
|
163
153
|
Data_Get_Struct(obj, gsl_matrix, m);
|
164
154
|
*flagm = 0;
|
165
155
|
#ifdef HAVE_NARRAY_H
|
166
156
|
} else if (NA_IsNArray(obj)) {
|
157
|
+
gsl_matrix_view mv;
|
158
|
+
struct NARRAY *na;
|
167
159
|
GetNArray(obj, na);
|
168
160
|
mv = gsl_matrix_view_array((double*)na->ptr, na->shape[1], na->shape[0]);
|
169
161
|
m = &mv.matrix;
|
@@ -194,15 +186,13 @@ static gsl_permutation* get_permutation(VALUE obj, size_t size, int *flagp)
|
|
194
186
|
static gsl_vector* get_vector2(VALUE obj, int *flagv)
|
195
187
|
{
|
196
188
|
gsl_vector *v = NULL;
|
197
|
-
#ifdef HAVE_NARRAY_H
|
198
|
-
gsl_vector_view vv;
|
199
|
-
struct NARRAY *na;
|
200
|
-
#endif
|
201
189
|
if (TYPE(obj) == T_ARRAY) {
|
202
190
|
v = make_cvector_from_rarray(obj);
|
203
191
|
*flagv = 1;
|
204
192
|
#ifdef HAVE_NARRAY_H
|
205
193
|
} else if (NA_IsNArray(obj)) {
|
194
|
+
gsl_vector_view vv;
|
195
|
+
struct NARRAY *na;
|
206
196
|
GetNArray(obj, na);
|
207
197
|
vv = gsl_vector_view_array((double*) na->ptr, na->total);
|
208
198
|
v = &vv.vector;
|
@@ -217,7 +207,36 @@ static gsl_vector* get_vector2(VALUE obj, int *flagv)
|
|
217
207
|
}
|
218
208
|
|
219
209
|
#ifdef HAVE_NARRAY_H
|
220
|
-
static VALUE rb_gsl_linalg_LU_solve_narray(int argc, VALUE *argv, VALUE obj)
|
210
|
+
static VALUE rb_gsl_linalg_LU_solve_narray(int argc, VALUE *argv, VALUE obj)
|
211
|
+
{
|
212
|
+
struct NARRAY *na, *b;
|
213
|
+
VALUE ret;
|
214
|
+
gsl_permutation *p;
|
215
|
+
gsl_matrix_view mv;
|
216
|
+
gsl_vector_view bv, xv;
|
217
|
+
double *x;
|
218
|
+
int shape[1];
|
219
|
+
if (argc < 3)
|
220
|
+
rb_raise(rb_eArgError,
|
221
|
+
"wrong number of arguments %d(NArray, GSL::Permutation and NArray expected",
|
222
|
+
argc);
|
223
|
+
GetNArray(argv[0], na);
|
224
|
+
mv = gsl_matrix_view_array((double*) na->ptr, na->shape[1], na->shape[0]);
|
225
|
+
CHECK_PERMUTATION(argv[1]);
|
226
|
+
Data_Get_Struct(argv[1], gsl_permutation, p);
|
227
|
+
GetNArray(argv[2], b);
|
228
|
+
bv = gsl_vector_view_array((double*) b->ptr, b->total);
|
229
|
+
if (argc == 3) {
|
230
|
+
shape[0] = b->total;
|
231
|
+
ret = na_make_object(NA_DFLOAT, 1, shape, CLASS_OF(argv[0]));
|
232
|
+
} else {
|
233
|
+
ret = argv[3];
|
234
|
+
}
|
235
|
+
x = NA_PTR_TYPE(ret,double*);
|
236
|
+
xv = gsl_vector_view_array(x, b->total);
|
237
|
+
gsl_linalg_LU_solve(&mv.matrix, p, &bv.vector, &xv.vector);
|
238
|
+
return ret;
|
239
|
+
}
|
221
240
|
#endif
|
222
241
|
|
223
242
|
VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
|
@@ -230,19 +249,18 @@ VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
|
|
230
249
|
VALUE bb;
|
231
250
|
switch (TYPE(obj)) {
|
232
251
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
233
|
-
if (argc < 2 || argc > 4)
|
252
|
+
if (argc < 2 || argc > 4)
|
234
253
|
rb_raise(rb_eArgError, "Usage: solve(m, b), solve(m, b, x), solve(lu, p, b), solve(lu, p, b, x)");
|
235
254
|
#ifdef HAVE_NARRAY_H
|
236
|
-
if (NA_IsNArray(argv[0]))
|
255
|
+
if (NA_IsNArray(argv[0]))
|
237
256
|
return rb_gsl_linalg_LU_solve_narray(argc, argv, obj);
|
238
257
|
#endif
|
239
258
|
m = get_matrix(argv[0], cgsl_matrix_LU, &flagm);
|
240
259
|
itmp = 1;
|
241
260
|
break;
|
242
261
|
default:
|
243
|
-
if (argc < 1 || argc > 3)
|
262
|
+
if (argc < 1 || argc > 3)
|
244
263
|
rb_raise(rb_eArgError, "Usage: LU_solve(b), LU_solve(p, b), LU_solve(b, x), solve(p, b, x)");
|
245
|
-
|
246
264
|
m = get_matrix(obj, cgsl_matrix_LU, &flagm);
|
247
265
|
itmp = 0;
|
248
266
|
break;
|
@@ -252,7 +270,6 @@ VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
|
|
252
270
|
p = get_permutation(argv[itmp], size, &flagp);
|
253
271
|
if (flagp == 1 && flagm == 0) rb_raise(rb_eArgError, "permutation must be given");
|
254
272
|
if (flagp == 0) itmp++;
|
255
|
-
|
256
273
|
bb = argv[itmp];
|
257
274
|
b = get_vector2(argv[itmp], &flagb);
|
258
275
|
itmp++;
|
@@ -274,42 +291,27 @@ VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
|
|
274
291
|
}
|
275
292
|
|
276
293
|
#ifdef HAVE_NARRAY_H
|
277
|
-
static VALUE
|
294
|
+
static VALUE rb_gsl_linalg_LU_svx_narray(int argc, VALUE *argv, VALUE obj)
|
278
295
|
{
|
279
296
|
struct NARRAY *na, *b;
|
280
|
-
VALUE ret;
|
281
297
|
gsl_permutation *p;
|
282
298
|
gsl_matrix_view mv;
|
283
|
-
gsl_vector_view bv
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
"wrong number of arguments %d(NArray, GSL::Permutation and NArray expected",
|
289
|
-
argc);
|
299
|
+
gsl_vector_view bv;
|
300
|
+
if (argc != 3)
|
301
|
+
rb_raise(rb_eArgError,
|
302
|
+
"wrong number of arguments %d(NArray, GSL::Permutation and NArray expected",
|
303
|
+
argc);
|
290
304
|
GetNArray(argv[0], na);
|
291
305
|
mv = gsl_matrix_view_array((double*) na->ptr, na->shape[1], na->shape[0]);
|
292
306
|
CHECK_PERMUTATION(argv[1]);
|
293
307
|
Data_Get_Struct(argv[1], gsl_permutation, p);
|
294
308
|
GetNArray(argv[2], b);
|
295
309
|
bv = gsl_vector_view_array((double*) b->ptr, b->total);
|
296
|
-
|
297
|
-
|
298
|
-
ret = na_make_object(NA_DFLOAT, 1, shape, CLASS_OF(argv[0]));
|
299
|
-
} else {
|
300
|
-
ret = argv[3];
|
301
|
-
}
|
302
|
-
x = NA_PTR_TYPE(ret,double*);
|
303
|
-
xv = gsl_vector_view_array(x, b->total);
|
304
|
-
gsl_linalg_LU_solve(&mv.matrix, p, &bv.vector, &xv.vector);
|
305
|
-
return ret;
|
310
|
+
gsl_linalg_LU_svx(&mv.matrix, p, &bv.vector);
|
311
|
+
return argv[2];
|
306
312
|
}
|
307
313
|
#endif
|
308
314
|
|
309
|
-
#ifdef HAVE_NARRAY_H
|
310
|
-
static VALUE rb_gsl_linalg_LU_svx_narray(int argc, VALUE *argv, VALUE obj);
|
311
|
-
#endif
|
312
|
-
|
313
315
|
/* bb must be Vector, it is replaced by the root of the system */
|
314
316
|
static VALUE rb_gsl_linalg_LU_svx(int argc, VALUE *argv, VALUE obj)
|
315
317
|
{
|
@@ -321,18 +323,18 @@ static VALUE rb_gsl_linalg_LU_svx(int argc, VALUE *argv, VALUE obj)
|
|
321
323
|
|
322
324
|
switch (TYPE(obj)) {
|
323
325
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
324
|
-
if (argc < 2 || argc > 3)
|
326
|
+
if (argc < 2 || argc > 3)
|
325
327
|
rb_raise(rb_eArgError, "Usage: svx(m, b), svx(lu, p, b)");
|
326
328
|
#ifdef HAVE_NARRAY_H
|
327
|
-
|
328
|
-
|
329
|
+
if (NA_IsNArray(argv[0]))
|
330
|
+
return rb_gsl_linalg_LU_svx_narray(argc, argv, obj);
|
329
331
|
#endif
|
330
332
|
m = get_matrix(argv[0], cgsl_matrix_LU, &flagm);
|
331
333
|
itmp = 1;
|
332
334
|
break;
|
333
335
|
default:
|
334
|
-
|
335
|
-
|
336
|
+
if (argc < 1 || argc > 2)
|
337
|
+
rb_raise(rb_eArgError, "Usage: LU_svx(b), LU_svx(p, b)");
|
336
338
|
m = get_matrix(obj, cgsl_matrix_LU, &flagm);
|
337
339
|
itmp = 0;
|
338
340
|
break;
|
@@ -350,32 +352,10 @@ static VALUE rb_gsl_linalg_LU_svx(int argc, VALUE *argv, VALUE obj)
|
|
350
352
|
return argv[itmp];
|
351
353
|
}
|
352
354
|
|
353
|
-
#ifdef HAVE_NARRAY_H
|
354
|
-
static VALUE rb_gsl_linalg_LU_svx_narray(int argc, VALUE *argv, VALUE obj)
|
355
|
-
{
|
356
|
-
struct NARRAY *na, *b;
|
357
|
-
gsl_permutation *p;
|
358
|
-
gsl_matrix_view mv;
|
359
|
-
gsl_vector_view bv;
|
360
|
-
if (argc != 3)
|
361
|
-
rb_raise(rb_eArgError,
|
362
|
-
"wrong number of arguments %d(NArray, GSL::Permutation and NArray expected",
|
363
|
-
argc);
|
364
|
-
GetNArray(argv[0], na);
|
365
|
-
mv = gsl_matrix_view_array((double*) na->ptr, na->shape[1], na->shape[0]);
|
366
|
-
CHECK_PERMUTATION(argv[1]);
|
367
|
-
Data_Get_Struct(argv[1], gsl_permutation, p);
|
368
|
-
GetNArray(argv[2], b);
|
369
|
-
bv = gsl_vector_view_array((double*) b->ptr, b->total);
|
370
|
-
gsl_linalg_LU_svx(&mv.matrix, p, &bv.vector);
|
371
|
-
return argv[2];
|
372
|
-
}
|
373
|
-
#endif
|
374
|
-
|
375
355
|
/* singleton */
|
376
356
|
static VALUE rb_gsl_linalg_LU_refine(VALUE obj, VALUE vm,
|
377
|
-
|
378
|
-
|
357
|
+
VALUE lu, VALUE pp, VALUE bb,
|
358
|
+
VALUE xx)
|
379
359
|
{
|
380
360
|
gsl_matrix *m = NULL, *mlu = NULL;
|
381
361
|
gsl_permutation *p = NULL;
|
@@ -402,59 +382,6 @@ static VALUE rb_gsl_linalg_LU_refine(VALUE obj, VALUE vm,
|
|
402
382
|
return rb_ary_new3(2, xx, vr);
|
403
383
|
}
|
404
384
|
|
405
|
-
#ifdef HAVE_NARRAY_H
|
406
|
-
static VALUE rb_gsl_linalg_LU_invert_narray(int argc, VALUE *argv, VALUE obj);
|
407
|
-
#endif
|
408
|
-
|
409
|
-
static VALUE rb_gsl_linalg_LU_invert(int argc, VALUE *argv, VALUE obj)
|
410
|
-
{
|
411
|
-
gsl_matrix *m = NULL, *inverse = NULL;
|
412
|
-
gsl_permutation *p = NULL;
|
413
|
-
int signum, flagm = 0, flagp = 0, itmp;
|
414
|
-
size_t size;
|
415
|
-
switch (TYPE(obj)) {
|
416
|
-
case T_MODULE: case T_CLASS: case T_OBJECT:
|
417
|
-
#ifdef HAVE_NARRAY_H
|
418
|
-
if (NA_IsNArray(argv[0]))
|
419
|
-
return rb_gsl_linalg_LU_invert_narray(argc, argv, obj);
|
420
|
-
#endif
|
421
|
-
m = get_matrix(argv[0], cgsl_matrix_LU, &flagm);
|
422
|
-
itmp = 1;
|
423
|
-
break;
|
424
|
-
default:
|
425
|
-
m = get_matrix(obj, cgsl_matrix_LU, &flagm);
|
426
|
-
itmp = 0;
|
427
|
-
}
|
428
|
-
size = m->size1;
|
429
|
-
|
430
|
-
if (argc == itmp) {
|
431
|
-
p = gsl_permutation_alloc(size);
|
432
|
-
flagp = 1;
|
433
|
-
} else {
|
434
|
-
CHECK_PERMUTATION(argv[itmp]);
|
435
|
-
p = get_permutation(argv[itmp], size, &flagp);
|
436
|
-
}
|
437
|
-
if (flagp == 1 && flagm == 0) rb_raise(rb_eArgError, "permutation must be given");
|
438
|
-
if (flagp == 0) itmp++;
|
439
|
-
|
440
|
-
if (flagm == 1 || flagp == 1) {
|
441
|
-
gsl_linalg_LU_decomp(m, p, &signum);
|
442
|
-
}
|
443
|
-
|
444
|
-
if (argc-1 == itmp) {
|
445
|
-
CHECK_MATRIX(argv[itmp]);
|
446
|
-
Data_Get_Struct(argv[itmp], gsl_matrix, inverse);
|
447
|
-
} else {
|
448
|
-
inverse = gsl_matrix_alloc(size, size);
|
449
|
-
}
|
450
|
-
gsl_linalg_LU_invert(m, p, inverse);
|
451
|
-
if (flagm == 1) gsl_matrix_free(m);
|
452
|
-
if (flagp == 1) gsl_permutation_free(p);
|
453
|
-
if (argc-1 == itmp) return argv[itmp];
|
454
|
-
else return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, inverse);
|
455
|
-
|
456
|
-
}
|
457
|
-
|
458
385
|
#ifdef HAVE_NARRAY_H
|
459
386
|
static VALUE rb_gsl_linalg_LU_invert_narray(int argc, VALUE *argv, VALUE obj)
|
460
387
|
{
|
@@ -483,7 +410,7 @@ static VALUE rb_gsl_linalg_LU_det_narray(int argc, VALUE *argv, VALUE obj)
|
|
483
410
|
switch (argc) {
|
484
411
|
case 2:
|
485
412
|
signum = FIX2INT(argv[1]);
|
486
|
-
|
413
|
+
/* no break */
|
487
414
|
case 1:
|
488
415
|
GetNArray(argv[0], na);
|
489
416
|
mv = gsl_matrix_view_array((double*)na->ptr, na->shape[1], na->shape[0]);
|
@@ -512,6 +439,51 @@ static VALUE rb_gsl_linalg_LU_lndet_narray(int argc, VALUE *argv, VALUE obj)
|
|
512
439
|
|
513
440
|
#endif
|
514
441
|
|
442
|
+
static VALUE rb_gsl_linalg_LU_invert(int argc, VALUE *argv, VALUE obj)
|
443
|
+
{
|
444
|
+
gsl_matrix *m = NULL, *inverse = NULL;
|
445
|
+
gsl_permutation *p = NULL;
|
446
|
+
int signum, flagm = 0, flagp = 0, itmp;
|
447
|
+
size_t size;
|
448
|
+
switch (TYPE(obj)) {
|
449
|
+
case T_MODULE: case T_CLASS: case T_OBJECT:
|
450
|
+
#ifdef HAVE_NARRAY_H
|
451
|
+
if (NA_IsNArray(argv[0]))
|
452
|
+
return rb_gsl_linalg_LU_invert_narray(argc, argv, obj);
|
453
|
+
#endif
|
454
|
+
m = get_matrix(argv[0], cgsl_matrix_LU, &flagm);
|
455
|
+
itmp = 1;
|
456
|
+
break;
|
457
|
+
default:
|
458
|
+
m = get_matrix(obj, cgsl_matrix_LU, &flagm);
|
459
|
+
itmp = 0;
|
460
|
+
}
|
461
|
+
size = m->size1;
|
462
|
+
|
463
|
+
if (argc == itmp) {
|
464
|
+
p = gsl_permutation_alloc(size);
|
465
|
+
flagp = 1;
|
466
|
+
} else {
|
467
|
+
CHECK_PERMUTATION(argv[itmp]);
|
468
|
+
p = get_permutation(argv[itmp], size, &flagp);
|
469
|
+
}
|
470
|
+
if (flagp == 1 && flagm == 0) rb_raise(rb_eArgError, "permutation must be given");
|
471
|
+
if (flagp == 0) itmp++;
|
472
|
+
if (flagm == 1 || flagp == 1) {
|
473
|
+
gsl_linalg_LU_decomp(m, p, &signum);
|
474
|
+
}
|
475
|
+
if (argc-1 == itmp) {
|
476
|
+
CHECK_MATRIX(argv[itmp]);
|
477
|
+
Data_Get_Struct(argv[itmp], gsl_matrix, inverse);
|
478
|
+
} else {
|
479
|
+
inverse = gsl_matrix_alloc(size, size);
|
480
|
+
}
|
481
|
+
gsl_linalg_LU_invert(m, p, inverse);
|
482
|
+
if (flagm == 1) gsl_matrix_free(m);
|
483
|
+
if (flagp == 1) gsl_permutation_free(p);
|
484
|
+
if (argc-1 == itmp) return argv[itmp];
|
485
|
+
else return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, inverse);
|
486
|
+
}
|
515
487
|
static VALUE rb_gsl_linalg_LU_det(int argc, VALUE *argv, VALUE obj)
|
516
488
|
{
|
517
489
|
gsl_matrix *m = NULL;
|
@@ -522,7 +494,7 @@ static VALUE rb_gsl_linalg_LU_det(int argc, VALUE *argv, VALUE obj)
|
|
522
494
|
switch (TYPE(obj)) {
|
523
495
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
524
496
|
if (argc < 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
525
|
-
|
497
|
+
argc);
|
526
498
|
#ifdef HAVE_NARRAY_H
|
527
499
|
if (NA_IsNArray(argv[0]))
|
528
500
|
return rb_gsl_linalg_LU_det_narray(argc, argv, obj);
|
@@ -547,8 +519,8 @@ static VALUE rb_gsl_linalg_LU_det(int argc, VALUE *argv, VALUE obj)
|
|
547
519
|
p = gsl_permutation_alloc(size);
|
548
520
|
flagp = 1;
|
549
521
|
}
|
550
|
-
}
|
551
|
-
if (flagm == 1) gsl_linalg_LU_decomp(m, p, &sign);
|
522
|
+
}
|
523
|
+
if (flagm == 1) gsl_linalg_LU_decomp(m, p, &sign);
|
552
524
|
det = gsl_linalg_LU_det(m, sign);
|
553
525
|
if (flagm == 1) gsl_matrix_free(m);
|
554
526
|
if (flagp == 1) gsl_permutation_free(p);
|
@@ -565,7 +537,7 @@ static VALUE rb_gsl_linalg_LU_lndet(int argc, VALUE *argv, VALUE obj)
|
|
565
537
|
switch (TYPE(obj)) {
|
566
538
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
567
539
|
if (argc < 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
568
|
-
|
540
|
+
argc);
|
569
541
|
#ifdef HAVE_NARRAY_H
|
570
542
|
if (NA_IsNArray(argv[0]))
|
571
543
|
return rb_gsl_linalg_LU_lndet_narray(argc, argv, obj);
|
@@ -579,7 +551,7 @@ static VALUE rb_gsl_linalg_LU_lndet(int argc, VALUE *argv, VALUE obj)
|
|
579
551
|
}
|
580
552
|
if (flagm == 1) {
|
581
553
|
p = gsl_permutation_alloc(m->size1);
|
582
|
-
gsl_linalg_LU_decomp(m, p, &sign);
|
554
|
+
gsl_linalg_LU_decomp(m, p, &sign);
|
583
555
|
}
|
584
556
|
lndet = gsl_linalg_LU_lndet(m);
|
585
557
|
if (flagm == 1) {
|
@@ -606,7 +578,7 @@ static VALUE rb_gsl_linalg_LU_sgndet(int argc, VALUE *argv, VALUE obj)
|
|
606
578
|
}
|
607
579
|
if (flagm == 1) {
|
608
580
|
p = gsl_permutation_alloc(m->size1);
|
609
|
-
gsl_linalg_LU_decomp(m, p, &sign);
|
581
|
+
gsl_linalg_LU_decomp(m, p, &sign);
|
610
582
|
} else {
|
611
583
|
if (argc-itmp != 1) rb_raise(rb_eArgError, "sign must be given");
|
612
584
|
sign = FIX2INT(argv[itmp]);
|
@@ -619,12 +591,11 @@ static VALUE rb_gsl_linalg_LU_sgndet(int argc, VALUE *argv, VALUE obj)
|
|
619
591
|
return INT2FIX(signdet);
|
620
592
|
}
|
621
593
|
|
622
|
-
#ifdef GSL_1_6_LATER
|
623
594
|
int gsl_linalg_LQ_solve_T(const gsl_matrix*, const gsl_vector*, const gsl_vector*, gsl_vector*);
|
624
595
|
int gsl_linalg_LQ_svx_T (const gsl_matrix*, const gsl_vector*, gsl_vector*);
|
625
|
-
int gsl_linalg_LQ_lssolve_T(const gsl_matrix * LQ, const gsl_vector * tau,
|
626
|
-
|
627
|
-
|
596
|
+
int gsl_linalg_LQ_lssolve_T(const gsl_matrix * LQ, const gsl_vector * tau,
|
597
|
+
const gsl_vector * b, gsl_vector * x,
|
598
|
+
gsl_vector * residual);
|
628
599
|
int
|
629
600
|
gsl_linalg_LQ_Lsolve_T (const gsl_matrix * LQ, const gsl_vector * b, gsl_vector* x);
|
630
601
|
int
|
@@ -632,9 +603,6 @@ gsl_linalg_LQ_Lsvx_T (const gsl_matrix * LQ, gsl_vector * x);
|
|
632
603
|
int
|
633
604
|
gsl_linalg_L_solve_T (const gsl_matrix * L, const gsl_vector * b, gsl_vector * x);
|
634
605
|
|
635
|
-
|
636
|
-
#endif
|
637
|
-
|
638
606
|
enum {
|
639
607
|
LINALG_QR_DECOMP,
|
640
608
|
LINALG_QR_DECOMP_BANG,
|
@@ -659,7 +627,7 @@ enum {
|
|
659
627
|
};
|
660
628
|
|
661
629
|
static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
|
662
|
-
|
630
|
+
int flag)
|
663
631
|
{
|
664
632
|
gsl_matrix *m = NULL, *mtmp = NULL;
|
665
633
|
gsl_vector *tau = NULL;
|
@@ -679,7 +647,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
|
|
679
647
|
break;
|
680
648
|
}
|
681
649
|
CHECK_MATRIX(omatrix);
|
682
|
-
Data_Get_Struct(omatrix, gsl_matrix, mtmp);
|
650
|
+
Data_Get_Struct(omatrix, gsl_matrix, mtmp);
|
683
651
|
|
684
652
|
switch (flag) {
|
685
653
|
case LINALG_QR_DECOMP:
|
@@ -693,7 +661,6 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
|
|
693
661
|
mdecomp = omatrix;
|
694
662
|
RBGSL_SET_CLASS(mdecomp, cgsl_matrix_QR);
|
695
663
|
break;
|
696
|
-
#ifdef GSL_1_6_LATER
|
697
664
|
case LINALG_LQ_DECOMP:
|
698
665
|
fdecomp = &gsl_linalg_LQ_decomp;
|
699
666
|
m = make_matrix_clone(mtmp);
|
@@ -705,7 +672,6 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
|
|
705
672
|
mdecomp = omatrix;
|
706
673
|
RBGSL_SET_CLASS(mdecomp, cgsl_matrix_LQ);
|
707
674
|
break;
|
708
|
-
#endif
|
709
675
|
default:
|
710
676
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
711
677
|
break;
|
@@ -736,7 +702,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
|
|
736
702
|
break;
|
737
703
|
case LINALG_QR_DECOMP_BANG:
|
738
704
|
case LINALG_LQ_DECOMP_BANG:
|
739
|
-
|
705
|
+
if (argc == itmp) {
|
740
706
|
return Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
|
741
707
|
} else {
|
742
708
|
RBGSL_SET_CLASS(argv[itmp], cgsl_vector_tau);
|
@@ -751,7 +717,88 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
|
|
751
717
|
}
|
752
718
|
|
753
719
|
#ifdef HAVE_NARRAY_H
|
754
|
-
static VALUE rb_gsl_linalg_QR_decomp_narray(int argc, VALUE *argv, VALUE obj)
|
720
|
+
static VALUE rb_gsl_linalg_QR_decomp_narray(int argc, VALUE *argv, VALUE obj)
|
721
|
+
{
|
722
|
+
struct NARRAY *na;
|
723
|
+
gsl_matrix_view mv;
|
724
|
+
gsl_vector_view vv;
|
725
|
+
int shapem[2], shapev[1];
|
726
|
+
VALUE qr, tau;
|
727
|
+
if (argc < 1) rb_raise(rb_eArgError, "too few arguments.");
|
728
|
+
GetNArray(argv[0], na);
|
729
|
+
shapem[0] = na->shape[1];
|
730
|
+
shapem[1] = na->shape[1];
|
731
|
+
shapev[0] = shapem[0];
|
732
|
+
qr = na_make_object(NA_DFLOAT, 2, shapem, CLASS_OF(argv[0]));
|
733
|
+
tau = na_make_object(NA_DFLOAT, 1, shapev, cNVector);
|
734
|
+
memcpy(NA_PTR_TYPE(qr,double*),na->ptr,sizeof(double)*shapem[0]*shapem[1]);
|
735
|
+
mv = gsl_matrix_view_array(NA_PTR_TYPE(qr,double*), shapem[0], shapem[1]);
|
736
|
+
vv = gsl_vector_view_array(NA_PTR_TYPE(tau,double*), shapev[0]);
|
737
|
+
gsl_linalg_QR_decomp(&mv.matrix, &vv.vector);
|
738
|
+
return rb_ary_new3(2, qr, tau);
|
739
|
+
}
|
740
|
+
|
741
|
+
static VALUE rb_gsl_linalg_QR_unpack_narray(int argc, VALUE *argv, VALUE obj)
|
742
|
+
{
|
743
|
+
struct NARRAY *m, *tau;
|
744
|
+
gsl_matrix_view mv, mq, mr;
|
745
|
+
gsl_vector_view vv;
|
746
|
+
int shape[2];
|
747
|
+
VALUE q, r;
|
748
|
+
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
|
749
|
+
argc);
|
750
|
+
GetNArray(argv[0], m);
|
751
|
+
GetNArray(argv[1], tau);
|
752
|
+
mv = gsl_matrix_view_array((double*)m->ptr, m->shape[1], m->shape[0]);
|
753
|
+
vv = gsl_vector_view_array((double*)tau->ptr, tau->shape[0]);
|
754
|
+
shape[0] = m->shape[1];
|
755
|
+
shape[1] = m->shape[1];
|
756
|
+
q = na_make_object(NA_DFLOAT, 2, shape, CLASS_OF(argv[0]));
|
757
|
+
shape[0] = m->shape[1];
|
758
|
+
shape[1] = m->shape[0];
|
759
|
+
r = na_make_object(NA_DFLOAT, 2, shape, CLASS_OF(argv[0]));
|
760
|
+
mq = gsl_matrix_view_array(NA_PTR_TYPE(q,double*), m->shape[1], m->shape[1]);
|
761
|
+
mr = gsl_matrix_view_array(NA_PTR_TYPE(r,double*), m->shape[1], m->shape[0]);
|
762
|
+
// printf("OK 4 %d %d\n", mq.matrix.size1, mr.matrix.size2);
|
763
|
+
gsl_linalg_QR_unpack(&mv.matrix, &vv.vector, &mq.matrix, &mr.matrix);
|
764
|
+
// printf("OK 5\n");
|
765
|
+
return rb_ary_new3(2, q, r);
|
766
|
+
}
|
767
|
+
|
768
|
+
static VALUE rb_gsl_linalg_QR_solve_narray(int argc, VALUE *argv, VALUE obj)
|
769
|
+
{
|
770
|
+
struct NARRAY *qr, *tau, *b;
|
771
|
+
VALUE x;
|
772
|
+
gsl_matrix_view mv;
|
773
|
+
gsl_vector_view tv, bv, xv;
|
774
|
+
if (argc != 3) rb_raise(rb_eArgError, "Usage: QR.solve(qr, tau, b)");
|
775
|
+
GetNArray(argv[0], qr);
|
776
|
+
GetNArray(argv[1], tau);
|
777
|
+
GetNArray(argv[2], b);
|
778
|
+
x = na_make_object(NA_DFLOAT, 1, b->shape, CLASS_OF(argv[2]));
|
779
|
+
mv = gsl_matrix_view_array((double*)qr->ptr, qr->shape[1], qr->shape[0]);
|
780
|
+
tv = gsl_vector_view_array((double*)tau->ptr, tau->shape[0]);
|
781
|
+
bv = gsl_vector_view_array((double*)b->ptr, b->shape[0]);
|
782
|
+
xv = gsl_vector_view_array(NA_PTR_TYPE(x,double*), b->shape[0]);
|
783
|
+
gsl_linalg_QR_solve(&mv.matrix, &tv.vector, &bv.vector, &xv.vector);
|
784
|
+
return x;
|
785
|
+
}
|
786
|
+
static VALUE rb_gsl_linalg_QR_svx_narray(int argc, VALUE *argv, VALUE obj)
|
787
|
+
{
|
788
|
+
struct NARRAY *qr, *tau, *b;
|
789
|
+
gsl_matrix_view mv;
|
790
|
+
gsl_vector_view tv, bv;
|
791
|
+
if (argc != 3) rb_raise(rb_eArgError, "Usage: QR.solve(qr, tau, b)");
|
792
|
+
GetNArray(argv[0], qr);
|
793
|
+
GetNArray(argv[1], tau);
|
794
|
+
GetNArray(argv[2], b);
|
795
|
+
mv = gsl_matrix_view_array((double*)qr->ptr, qr->shape[1], qr->shape[0]);
|
796
|
+
tv = gsl_vector_view_array((double*)tau->ptr, tau->shape[0]);
|
797
|
+
bv = gsl_vector_view_array((double*)b->ptr, b->shape[0]);
|
798
|
+
gsl_linalg_QR_svx(&mv.matrix, &tv.vector, &bv.vector);
|
799
|
+
return argv[2];
|
800
|
+
}
|
801
|
+
|
755
802
|
#endif
|
756
803
|
|
757
804
|
static VALUE rb_gsl_linalg_QR_decomp(int argc, VALUE *argv, VALUE obj)
|
@@ -768,7 +815,6 @@ static VALUE rb_gsl_linalg_QR_decomp_bang(int argc, VALUE *argv, VALUE obj)
|
|
768
815
|
return rb_gsl_linalg_QR_LQ_decomposition(argc, argv, obj, LINALG_QR_DECOMP_BANG);
|
769
816
|
}
|
770
817
|
|
771
|
-
#ifdef GSL_1_6_LATER
|
772
818
|
static VALUE rb_gsl_linalg_LQ_decomp(int argc, VALUE *argv, VALUE obj)
|
773
819
|
{
|
774
820
|
return rb_gsl_linalg_QR_LQ_decomposition(argc, argv, obj, LINALG_LQ_DECOMP);
|
@@ -778,7 +824,6 @@ static VALUE rb_gsl_linalg_LQ_decomp_bang(int argc, VALUE *argv, VALUE obj)
|
|
778
824
|
{
|
779
825
|
return rb_gsl_linalg_QR_LQ_decomposition(argc, argv, obj, LINALG_LQ_DECOMP_BANG);
|
780
826
|
}
|
781
|
-
#endif
|
782
827
|
|
783
828
|
static VALUE rb_gsl_linalg_QR_LQ_solve(int argc, VALUE *argv, VALUE obj, int flag)
|
784
829
|
{
|
@@ -810,13 +855,11 @@ static VALUE rb_gsl_linalg_QR_LQ_solve(int argc, VALUE *argv, VALUE obj, int fla
|
|
810
855
|
fdecomp = &gsl_linalg_QR_decomp;
|
811
856
|
fsolve = &gsl_linalg_QR_solve;
|
812
857
|
break;
|
813
|
-
#ifdef GSL_1_6_LATER
|
814
858
|
case LINALG_LQ_SOLVE:
|
815
859
|
m = get_matrix(omatrix, cgsl_matrix_LQ, &flagm);
|
816
860
|
fdecomp = &gsl_linalg_LQ_decomp;
|
817
861
|
fsolve = &gsl_linalg_LQ_solve_T;
|
818
862
|
break;
|
819
|
-
#endif
|
820
863
|
default:
|
821
864
|
rb_raise(rb_eRuntimeError, "unknown operatioin");
|
822
865
|
break;
|
@@ -878,7 +921,7 @@ static VALUE rb_gsl_linalg_QR_LQ_svx(int argc, VALUE *argv, VALUE obj, int flag)
|
|
878
921
|
itmp = 0;
|
879
922
|
break;
|
880
923
|
}
|
881
|
-
if (argc-itmp < 1 || argc-itmp > 2)
|
924
|
+
if (argc-itmp < 1 || argc-itmp > 2)
|
882
925
|
rb_raise(rb_eArgError, "wrong number of arguments");
|
883
926
|
CHECK_MATRIX(omatrix);
|
884
927
|
switch (flag) {
|
@@ -887,13 +930,11 @@ static VALUE rb_gsl_linalg_QR_LQ_svx(int argc, VALUE *argv, VALUE obj, int flag)
|
|
887
930
|
fdecomp = &gsl_linalg_QR_decomp;
|
888
931
|
fsvx = &gsl_linalg_QR_svx;
|
889
932
|
break;
|
890
|
-
#ifdef GSL_1_6_LATER
|
891
933
|
case LINALG_LQ_SOLVE:
|
892
934
|
m = get_matrix(omatrix, cgsl_matrix_LQ, &flagm);
|
893
935
|
fdecomp = &gsl_linalg_LQ_decomp;
|
894
936
|
fsvx = &gsl_linalg_LQ_svx_T;
|
895
937
|
break;
|
896
|
-
#endif
|
897
938
|
default:
|
898
939
|
rb_raise(rb_eRuntimeError, "unknown operatioin");
|
899
940
|
break;
|
@@ -932,7 +973,7 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
|
|
932
973
|
size_t size;
|
933
974
|
int (*fdecomp)(gsl_matrix*, gsl_vector*);
|
934
975
|
int (*flssolve)(const gsl_matrix*, const gsl_vector*, const gsl_vector*, gsl_vector*,
|
935
|
-
|
976
|
+
gsl_vector*);
|
936
977
|
|
937
978
|
switch (TYPE(obj)) {
|
938
979
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
@@ -954,13 +995,11 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
|
|
954
995
|
fdecomp = &gsl_linalg_QR_decomp;
|
955
996
|
flssolve = &gsl_linalg_QR_lssolve;
|
956
997
|
break;
|
957
|
-
#ifdef GSL_1_6_LATER
|
958
998
|
case LINALG_LQ_SOLVE:
|
959
999
|
m = get_matrix(omatrix, cgsl_matrix_LQ, &flagm);
|
960
1000
|
fdecomp = &gsl_linalg_LQ_decomp;
|
961
1001
|
flssolve = &gsl_linalg_LQ_lssolve_T;
|
962
1002
|
break;
|
963
|
-
#endif
|
964
1003
|
default:
|
965
1004
|
rb_raise(rb_eRuntimeError, "unknown operatioin");
|
966
1005
|
break;
|
@@ -1009,7 +1048,6 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
|
|
1009
1048
|
if (flagm == 1) gsl_matrix_free(m);
|
1010
1049
|
if (flagt == 1) gsl_vector_free(tau);
|
1011
1050
|
if (flagb == 1) gsl_vector_free(b);
|
1012
|
-
|
1013
1051
|
switch (argc - itmp) {
|
1014
1052
|
case 2:
|
1015
1053
|
return INT2FIX(status);
|
@@ -1019,16 +1057,11 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
|
|
1019
1057
|
break;
|
1020
1058
|
default:
|
1021
1059
|
return rb_ary_new3(2, Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, x),
|
1022
|
-
|
1060
|
+
Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, r));
|
1023
1061
|
}
|
1024
1062
|
return Qnil;
|
1025
1063
|
}
|
1026
1064
|
|
1027
|
-
#ifdef HAVE_NARRAY_H
|
1028
|
-
static VALUE rb_gsl_linalg_QR_solve_narray(int argc, VALUE *argv, VALUE obj);
|
1029
|
-
static VALUE rb_gsl_linalg_QR_svx_narray(int argc, VALUE *argv, VALUE obj);
|
1030
|
-
#endif
|
1031
|
-
|
1032
1065
|
static VALUE rb_gsl_linalg_QR_solve(int argc, VALUE *argv, VALUE obj)
|
1033
1066
|
{
|
1034
1067
|
#ifdef HAVE_NARRAY_H
|
@@ -1052,7 +1085,6 @@ static VALUE rb_gsl_linalg_QR_lssolve(int argc, VALUE *argv, VALUE obj)
|
|
1052
1085
|
return rb_gsl_linalg_QR_LQ_lssolve(argc, argv, obj, LINALG_QR_SOLVE);
|
1053
1086
|
}
|
1054
1087
|
|
1055
|
-
#ifdef GSL_1_6_LATER
|
1056
1088
|
static VALUE rb_gsl_linalg_LQ_solve(int argc, VALUE *argv, VALUE obj)
|
1057
1089
|
{
|
1058
1090
|
return rb_gsl_linalg_QR_LQ_solve(argc, argv, obj, LINALG_LQ_SOLVE);
|
@@ -1067,18 +1099,17 @@ static VALUE rb_gsl_linalg_LQ_lssolve(int argc, VALUE *argv, VALUE obj)
|
|
1067
1099
|
{
|
1068
1100
|
return rb_gsl_linalg_QR_LQ_lssolve(argc, argv, obj, LINALG_LQ_SOLVE);
|
1069
1101
|
}
|
1070
|
-
#endif
|
1071
1102
|
|
1072
1103
|
static VALUE rb_gsl_linalg_QRLQ_QTvec(int argc, VALUE *argv, VALUE obj,
|
1073
|
-
|
1104
|
+
int flag)
|
1074
1105
|
{
|
1075
1106
|
gsl_matrix *QR = NULL;
|
1076
1107
|
gsl_vector *tau = NULL, *v = NULL;
|
1077
1108
|
VALUE ret;
|
1078
1109
|
switch (TYPE(obj)) {
|
1079
1110
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
1080
|
-
if (argc != 3) rb_raise(rb_eArgError,
|
1081
|
-
|
1111
|
+
if (argc != 3) rb_raise(rb_eArgError,
|
1112
|
+
"wrong number of arguments (%d for 3)", argc);
|
1082
1113
|
CHECK_MATRIX(argv[0]); CHECK_VECTOR(argv[1]); CHECK_VECTOR(argv[2]);
|
1083
1114
|
Data_Get_Struct(argv[0], gsl_matrix, QR);
|
1084
1115
|
Data_Get_Struct(argv[1], gsl_vector, tau);
|
@@ -1086,8 +1117,8 @@ static VALUE rb_gsl_linalg_QRLQ_QTvec(int argc, VALUE *argv, VALUE obj,
|
|
1086
1117
|
ret = argv[2];
|
1087
1118
|
break;
|
1088
1119
|
default:
|
1089
|
-
if (argc != 2) rb_raise(rb_eArgError,
|
1090
|
-
|
1120
|
+
if (argc != 2) rb_raise(rb_eArgError,
|
1121
|
+
"wrong number of arguments (%d for 2)", argc);
|
1091
1122
|
CHECK_VECTOR(argv[2]); CHECK_VECTOR(argv[1]);
|
1092
1123
|
Data_Get_Struct(obj, gsl_matrix, QR);
|
1093
1124
|
Data_Get_Struct(argv[0], gsl_vector, tau);
|
@@ -1102,14 +1133,12 @@ static VALUE rb_gsl_linalg_QRLQ_QTvec(int argc, VALUE *argv, VALUE obj,
|
|
1102
1133
|
case LINALG_QR_Qvec:
|
1103
1134
|
gsl_linalg_QR_Qvec(QR, tau, v);
|
1104
1135
|
break;
|
1105
|
-
#ifdef GSL_1_6_LATER
|
1106
1136
|
case LINALG_LQ_vecQ:
|
1107
1137
|
gsl_linalg_LQ_vecQ(QR, tau, v);
|
1108
1138
|
break;
|
1109
1139
|
case LINALG_LQ_vecQT:
|
1110
1140
|
gsl_linalg_LQ_vecQT(QR, tau, v);
|
1111
1141
|
break;
|
1112
|
-
#endif
|
1113
1142
|
default:
|
1114
1143
|
break;
|
1115
1144
|
}
|
@@ -1126,7 +1155,6 @@ static VALUE rb_gsl_linalg_QR_Qvec(int argc, VALUE *argv, VALUE obj)
|
|
1126
1155
|
return rb_gsl_linalg_QRLQ_QTvec(argc, argv, obj, LINALG_QR_Qvec);
|
1127
1156
|
}
|
1128
1157
|
|
1129
|
-
#ifdef GSL_1_6_LATER
|
1130
1158
|
static VALUE rb_gsl_linalg_LQ_vecQT(int argc, VALUE *argv, VALUE obj)
|
1131
1159
|
{
|
1132
1160
|
return rb_gsl_linalg_QRLQ_QTvec(argc, argv, obj, LINALG_LQ_vecQT);
|
@@ -1136,10 +1164,9 @@ static VALUE rb_gsl_linalg_LQ_vecQ(int argc, VALUE *argv, VALUE obj)
|
|
1136
1164
|
{
|
1137
1165
|
return rb_gsl_linalg_QRLQ_QTvec(argc, argv, obj, LINALG_LQ_vecQ);
|
1138
1166
|
}
|
1139
|
-
#endif
|
1140
1167
|
|
1141
1168
|
static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
|
1142
|
-
|
1169
|
+
int flag)
|
1143
1170
|
{
|
1144
1171
|
gsl_matrix *QR = NULL, *Q = NULL, *R = NULL;
|
1145
1172
|
gsl_vector *tau = NULL;
|
@@ -1158,14 +1185,14 @@ static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
|
|
1158
1185
|
}
|
1159
1186
|
switch (TYPE(obj)) {
|
1160
1187
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
1161
|
-
if (argc != 2) rb_raise(rb_eArgError,
|
1162
|
-
|
1188
|
+
if (argc != 2) rb_raise(rb_eArgError,
|
1189
|
+
"wrong number of arguments (%d for 2)", argc);
|
1163
1190
|
vtmp = argv[0];
|
1164
1191
|
itmp = 1;
|
1165
1192
|
break;
|
1166
1193
|
default:
|
1167
|
-
if (argc != 1) rb_raise(rb_eArgError,
|
1168
|
-
|
1194
|
+
if (argc != 1) rb_raise(rb_eArgError,
|
1195
|
+
"wrong number of arguments (%d for 1)", argc);
|
1169
1196
|
vtmp = obj;
|
1170
1197
|
itmp = 0;
|
1171
1198
|
break;
|
@@ -1186,13 +1213,11 @@ static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
|
|
1186
1213
|
vQ = Data_Wrap_Struct(cgsl_matrix_Q, 0, gsl_matrix_free, Q);
|
1187
1214
|
vR = Data_Wrap_Struct(cgsl_matrix_R, 0, gsl_matrix_free, R);
|
1188
1215
|
break;
|
1189
|
-
#ifdef GSL_1_6_LATER
|
1190
1216
|
case LINALG_LQ_UNPACK:
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1217
|
+
gsl_linalg_LQ_unpack(QR, tau, Q, R);
|
1218
|
+
vQ = Data_Wrap_Struct(cgsl_matrix_L, 0, gsl_matrix_free, Q);
|
1219
|
+
vR = Data_Wrap_Struct(cgsl_matrix_Q, 0, gsl_matrix_free, R);
|
1194
1220
|
break;
|
1195
|
-
#endif
|
1196
1221
|
default:
|
1197
1222
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1198
1223
|
break;
|
@@ -1200,10 +1225,6 @@ static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
|
|
1200
1225
|
return rb_ary_new3(2, vQ, vR);
|
1201
1226
|
}
|
1202
1227
|
|
1203
|
-
#ifdef HAVE_NARRAY_H
|
1204
|
-
static VALUE rb_gsl_linalg_QR_unpack_narray(int argc, VALUE *argv, VALUE obj);
|
1205
|
-
#endif
|
1206
|
-
|
1207
1228
|
static VALUE rb_gsl_linalg_QR_unpack(int argc, VALUE *argv, VALUE obj)
|
1208
1229
|
{
|
1209
1230
|
#ifdef HAVE_NARRAY_H
|
@@ -1213,16 +1234,14 @@ static VALUE rb_gsl_linalg_QR_unpack(int argc, VALUE *argv, VALUE obj)
|
|
1213
1234
|
return rb_gsl_linalg_QRLQ_unpack(argc, argv, obj, LINALG_QR_UNPACK);
|
1214
1235
|
}
|
1215
1236
|
|
1216
|
-
#ifdef GSL_1_6_LATER
|
1217
1237
|
static VALUE rb_gsl_linalg_LQ_unpack(int argc, VALUE *argv, VALUE obj)
|
1218
1238
|
{
|
1219
1239
|
return rb_gsl_linalg_QRLQ_unpack(argc, argv, obj, LINALG_LQ_UNPACK);
|
1220
1240
|
}
|
1221
|
-
#endif
|
1222
1241
|
|
1223
1242
|
/* singleton */
|
1224
1243
|
static VALUE rb_gsl_linalg_QRLQ_QRLQsolve(int argc, VALUE *argv, VALUE obj,
|
1225
|
-
|
1244
|
+
int flag)
|
1226
1245
|
{
|
1227
1246
|
gsl_matrix *Q = NULL, *R = NULL;
|
1228
1247
|
gsl_vector *b = NULL, *x = NULL;
|
@@ -1251,21 +1270,19 @@ static VALUE rb_gsl_linalg_QRLQ_QRLQsolve(int argc, VALUE *argv, VALUE obj,
|
|
1251
1270
|
}
|
1252
1271
|
switch (flag) {
|
1253
1272
|
case LINALG_QR_DECOMP:
|
1254
|
-
if (CLASS_OF(argv[0]) != cgsl_matrix_Q)
|
1273
|
+
if (CLASS_OF(argv[0]) != cgsl_matrix_Q)
|
1255
1274
|
rb_raise(rb_eTypeError, "not a Q matrix");
|
1256
|
-
if (CLASS_OF(argv[1]) != cgsl_matrix_R)
|
1275
|
+
if (CLASS_OF(argv[1]) != cgsl_matrix_R)
|
1257
1276
|
rb_raise(rb_eTypeError, "not a R matrix");
|
1258
1277
|
fsolve = &gsl_linalg_QR_QRsolve;
|
1259
1278
|
break;
|
1260
|
-
#ifdef GSL_1_6_LATER
|
1261
1279
|
case LINALG_LQ_DECOMP:
|
1262
|
-
/* if (CLASS_OF(argv[0]) != cgsl_matrix_L)
|
1280
|
+
/* if (CLASS_OF(argv[0]) != cgsl_matrix_L)
|
1263
1281
|
rb_raise(rb_eTypeError, "not a L matrix");
|
1264
|
-
if (CLASS_OF(argv[1]) != cgsl_matrix_Q)
|
1282
|
+
if (CLASS_OF(argv[1]) != cgsl_matrix_Q)
|
1265
1283
|
rb_raise(rb_eTypeError, "not a Q matrix");*/
|
1266
1284
|
fsolve = &gsl_linalg_LQ_LQsolve;
|
1267
1285
|
break;
|
1268
|
-
#endif
|
1269
1286
|
default:
|
1270
1287
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1271
1288
|
break;
|
@@ -1284,7 +1301,7 @@ static VALUE rb_gsl_linalg_QRLQ_QRLQsolve(int argc, VALUE *argv, VALUE obj,
|
|
1284
1301
|
|
1285
1302
|
/*****/
|
1286
1303
|
static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
|
1287
|
-
|
1304
|
+
int flag)
|
1288
1305
|
{
|
1289
1306
|
gsl_matrix *QR = NULL, *mtmp;
|
1290
1307
|
gsl_vector *b = NULL, *x = NULL, *tau = NULL;
|
@@ -1338,7 +1355,6 @@ static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
|
|
1338
1355
|
}
|
1339
1356
|
fsolve = &gsl_linalg_R_solve;
|
1340
1357
|
break;
|
1341
|
-
#ifdef GSL_1_6_LATER
|
1342
1358
|
case LINALG_LQ_LSOLVE:
|
1343
1359
|
if (CLASS_OF(omatrix) != cgsl_matrix_LQ) {
|
1344
1360
|
QR = make_matrix_clone(mtmp);
|
@@ -1357,7 +1373,6 @@ static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
|
|
1357
1373
|
}
|
1358
1374
|
fsolve = &gsl_linalg_L_solve_T;
|
1359
1375
|
break;
|
1360
|
-
#endif
|
1361
1376
|
default:
|
1362
1377
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1363
1378
|
break;
|
@@ -1379,7 +1394,7 @@ static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
|
|
1379
1394
|
}
|
1380
1395
|
|
1381
1396
|
static VALUE rb_gsl_linalg_QRLQ_RLsvx(int argc, VALUE *argv, VALUE obj,
|
1382
|
-
|
1397
|
+
int flag)
|
1383
1398
|
{
|
1384
1399
|
gsl_matrix *QR = NULL, *mtmp;
|
1385
1400
|
gsl_vector *x = NULL, *tau = NULL;
|
@@ -1424,18 +1439,17 @@ static VALUE rb_gsl_linalg_QRLQ_RLsvx(int argc, VALUE *argv, VALUE obj,
|
|
1424
1439
|
}
|
1425
1440
|
fsolve = &gsl_linalg_QR_Rsvx;
|
1426
1441
|
break;
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
#ifdef GSL_1_6_LATER
|
1442
|
+
/*
|
1443
|
+
case LINALG_R_SVX:
|
1444
|
+
if (CLASS_OF(omatrix) != cgsl_matrix_QR) {
|
1445
|
+
QR = make_matrix_clone(mtmp);
|
1446
|
+
tau = gsl_vector_alloc(QR->size1);
|
1447
|
+
gsl_linalg_QR_decomp(QR, tau);
|
1448
|
+
flagq = 1;
|
1449
|
+
}
|
1450
|
+
fsolve = &gsl_linalg_R_svx;
|
1451
|
+
break;
|
1452
|
+
*/
|
1439
1453
|
case LINALG_LQ_LSVX:
|
1440
1454
|
if (CLASS_OF(omatrix) != cgsl_matrix_LQ) {
|
1441
1455
|
QR = make_matrix_clone(mtmp);
|
@@ -1445,7 +1459,6 @@ static VALUE rb_gsl_linalg_QRLQ_RLsvx(int argc, VALUE *argv, VALUE obj,
|
|
1445
1459
|
}
|
1446
1460
|
fsolve = &gsl_linalg_LQ_Lsvx_T;
|
1447
1461
|
break;
|
1448
|
-
#endif
|
1449
1462
|
default:
|
1450
1463
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1451
1464
|
break;
|
@@ -1475,12 +1488,11 @@ static VALUE rb_gsl_linalg_R_solve(int argc, VALUE *argv, VALUE obj)
|
|
1475
1488
|
|
1476
1489
|
/* singleton */
|
1477
1490
|
static VALUE rb_gsl_linalg_QR_QRsolve(int argc, VALUE *argv, VALUE obj,
|
1478
|
-
|
1491
|
+
int flag)
|
1479
1492
|
{
|
1480
1493
|
return rb_gsl_linalg_QRLQ_QRLQsolve(argc, argv, obj, LINALG_QR_DECOMP);
|
1481
1494
|
}
|
1482
1495
|
|
1483
|
-
#ifdef GSL_1_6_LATER
|
1484
1496
|
static VALUE rb_gsl_linalg_LQ_Lsolve(int argc, VALUE *argv, VALUE obj)
|
1485
1497
|
{
|
1486
1498
|
return rb_gsl_linalg_QRLQ_RLsolve(argc, argv, obj, LINALG_LQ_LSOLVE);
|
@@ -1498,14 +1510,13 @@ static VALUE rb_gsl_linalg_L_solve(int argc, VALUE *argv, VALUE obj)
|
|
1498
1510
|
|
1499
1511
|
/* singleton */
|
1500
1512
|
static VALUE rb_gsl_linalg_LQ_LQsolve(int argc, VALUE *argv, VALUE obj,
|
1501
|
-
|
1513
|
+
int flag)
|
1502
1514
|
{
|
1503
1515
|
return rb_gsl_linalg_QRLQ_QRLQsolve(argc, argv, obj, LINALG_LQ_DECOMP);
|
1504
1516
|
}
|
1505
|
-
#endif
|
1506
1517
|
|
1507
1518
|
static VALUE rb_gsl_linalg_QRLQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
|
1508
|
-
|
1519
|
+
VALUE vv, int flag)
|
1509
1520
|
{
|
1510
1521
|
gsl_matrix *Q = NULL, *R = NULL;
|
1511
1522
|
gsl_vector *w = NULL, *v = NULL;
|
@@ -1520,11 +1531,9 @@ static VALUE rb_gsl_linalg_QRLQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
|
|
1520
1531
|
case LINALG_QR_DECOMP:
|
1521
1532
|
status = gsl_linalg_QR_update(Q, R, w, v);
|
1522
1533
|
break;
|
1523
|
-
#ifdef GSL_1_6_LATER
|
1524
1534
|
case LINALG_LQ_DECOMP:
|
1525
1535
|
status = gsl_linalg_LQ_update(Q, R, w, v);
|
1526
1536
|
break;
|
1527
|
-
#endif
|
1528
1537
|
default:
|
1529
1538
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1530
1539
|
break;
|
@@ -1534,18 +1543,16 @@ static VALUE rb_gsl_linalg_QRLQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
|
|
1534
1543
|
|
1535
1544
|
/* singleton */
|
1536
1545
|
static VALUE rb_gsl_linalg_QR_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
|
1537
|
-
|
1546
|
+
VALUE vv)
|
1538
1547
|
{
|
1539
1548
|
return rb_gsl_linalg_QRLQ_update(obj, qq, rr, ww, vv, LINALG_QR_DECOMP);
|
1540
1549
|
}
|
1541
1550
|
|
1542
|
-
#ifdef GSL_1_6_LATER
|
1543
1551
|
static VALUE rb_gsl_linalg_LQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
|
1544
|
-
|
1552
|
+
VALUE vv)
|
1545
1553
|
{
|
1546
1554
|
return rb_gsl_linalg_QRLQ_update(obj, qq, rr, ww, vv, LINALG_LQ_DECOMP);
|
1547
1555
|
}
|
1548
|
-
#endif
|
1549
1556
|
|
1550
1557
|
/******/
|
1551
1558
|
enum {
|
@@ -1564,7 +1571,7 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp(int argc, VALUE *argv, VALUE obj, int f
|
|
1564
1571
|
switch (TYPE(obj)) {
|
1565
1572
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
1566
1573
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
1567
|
-
|
1574
|
+
argc);
|
1568
1575
|
vA = argv[0];
|
1569
1576
|
break;
|
1570
1577
|
default:
|
@@ -1585,14 +1592,12 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp(int argc, VALUE *argv, VALUE obj, int f
|
|
1585
1592
|
vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
|
1586
1593
|
gsl_linalg_QRPT_decomp(QR, tau, p, &signum, norm);
|
1587
1594
|
break;
|
1588
|
-
#ifdef GSL_1_6_LATER
|
1589
1595
|
case LINALG_PTLQ:
|
1590
1596
|
vQR = Data_Wrap_Struct(cgsl_matrix_PTLQ, 0, gsl_matrix_free, QR);
|
1591
1597
|
vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
|
1592
1598
|
vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
|
1593
1599
|
gsl_linalg_PTLQ_decomp(QR, tau, p, &signum, norm);
|
1594
1600
|
break;
|
1595
|
-
#endif
|
1596
1601
|
default:
|
1597
1602
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1598
1603
|
break;
|
@@ -1612,7 +1617,7 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp_bang(int argc, VALUE *argv, VALUE obj,
|
|
1612
1617
|
switch (TYPE(obj)) {
|
1613
1618
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
1614
1619
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
1615
|
-
|
1620
|
+
argc);
|
1616
1621
|
vA = argv[0];
|
1617
1622
|
break;
|
1618
1623
|
default:
|
@@ -1632,14 +1637,12 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp_bang(int argc, VALUE *argv, VALUE obj,
|
|
1632
1637
|
vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
|
1633
1638
|
gsl_linalg_QRPT_decomp(A, tau, p, &signum, norm);
|
1634
1639
|
break;
|
1635
|
-
#ifdef GSL_1_6_LATER
|
1636
1640
|
case LINALG_PTLQ:
|
1637
1641
|
RBGSL_SET_CLASS(vA, cgsl_matrix_PTLQ);
|
1638
1642
|
vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
|
1639
1643
|
vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
|
1640
1644
|
gsl_linalg_PTLQ_decomp(A, tau, p, &signum, norm);
|
1641
1645
|
break;
|
1642
|
-
#endif
|
1643
1646
|
default:
|
1644
1647
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1645
1648
|
break;
|
@@ -1658,7 +1661,6 @@ static VALUE rb_gsl_linalg_QRPT_decomp_bang(int argc, VALUE *argv, VALUE obj)
|
|
1658
1661
|
return rb_gsl_linalg_QRLQPT_decomp_bang(argc, argv, obj, LINALG_QRPT);
|
1659
1662
|
}
|
1660
1663
|
|
1661
|
-
#ifdef GSL_1_6_LATER
|
1662
1664
|
static VALUE rb_gsl_linalg_PTLQ_decomp(int argc, VALUE *argv, VALUE obj)
|
1663
1665
|
{
|
1664
1666
|
return rb_gsl_linalg_QRLQPT_decomp(argc, argv, obj, LINALG_PTLQ);
|
@@ -1668,7 +1670,6 @@ static VALUE rb_gsl_linalg_PTLQ_decomp_bang(int argc, VALUE *argv, VALUE obj)
|
|
1668
1670
|
{
|
1669
1671
|
return rb_gsl_linalg_QRLQPT_decomp_bang(argc, argv, obj, LINALG_PTLQ);
|
1670
1672
|
}
|
1671
|
-
#endif
|
1672
1673
|
|
1673
1674
|
static VALUE rb_gsl_linalg_QRLQPT_decomp2(int argc, VALUE *argv, VALUE obj,int flag)
|
1674
1675
|
{
|
@@ -1706,13 +1707,11 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp2(int argc, VALUE *argv, VALUE obj,int f
|
|
1706
1707
|
vR = Data_Wrap_Struct(cgsl_matrix_R, 0, gsl_matrix_free, R);
|
1707
1708
|
gsl_linalg_QRPT_decomp2(A, Q, R, tau, p, &signum, norm);
|
1708
1709
|
break;
|
1709
|
-
#ifdef GSL_1_6_LATER
|
1710
1710
|
case LINALG_PTLQ:
|
1711
1711
|
vR = Data_Wrap_Struct(cgsl_matrix_L, 0, gsl_matrix_free, R);
|
1712
1712
|
vQ = Data_Wrap_Struct(cgsl_matrix_Q, 0, gsl_matrix_free, Q);
|
1713
1713
|
gsl_linalg_PTLQ_decomp2(A, Q, R, tau, p, &signum, norm);
|
1714
1714
|
break;
|
1715
|
-
#endif
|
1716
1715
|
default:
|
1717
1716
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1718
1717
|
}
|
@@ -1725,33 +1724,29 @@ static VALUE rb_gsl_linalg_QRPT_decomp2(int argc, VALUE *argv, VALUE obj)
|
|
1725
1724
|
return rb_gsl_linalg_QRLQPT_decomp2(argc, argv, obj, LINALG_QRPT);
|
1726
1725
|
}
|
1727
1726
|
|
1728
|
-
#ifdef GSL_1_6_LATER
|
1729
1727
|
static VALUE rb_gsl_linalg_PTLQ_decomp2(int argc, VALUE *argv, VALUE obj)
|
1730
1728
|
{
|
1731
1729
|
return rb_gsl_linalg_QRLQPT_decomp2(argc, argv, obj, LINALG_PTLQ);
|
1732
1730
|
}
|
1733
|
-
#endif
|
1734
1731
|
|
1735
|
-
#ifdef GSL_1_6_LATER
|
1736
1732
|
int gsl_linalg_PTLQ_solve_T(const gsl_matrix * QR, const gsl_vector * tau,
|
1737
|
-
|
1738
|
-
|
1733
|
+
const gsl_permutation * p, const gsl_vector * b,
|
1734
|
+
gsl_vector * x);
|
1739
1735
|
int gsl_linalg_PTLQ_svx_T(const gsl_matrix * LQ,
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1736
|
+
const gsl_vector * tau,
|
1737
|
+
const gsl_permutation * p,
|
1738
|
+
gsl_vector * x);
|
1743
1739
|
int gsl_linalg_PTLQ_LQsolve_T (const gsl_matrix * Q, const gsl_matrix * L,
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1740
|
+
const gsl_permutation * p,
|
1741
|
+
const gsl_vector * b,
|
1742
|
+
gsl_vector * x);
|
1747
1743
|
int gsl_linalg_PTLQ_Lsolve_T (const gsl_matrix * LQ,
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1744
|
+
const gsl_permutation * p,
|
1745
|
+
const gsl_vector * b,
|
1746
|
+
gsl_vector * x);
|
1751
1747
|
int gsl_linalg_PTLQ_Lsvx_T (const gsl_matrix * LQ,
|
1752
|
-
|
1753
|
-
|
1754
|
-
#endif
|
1748
|
+
const gsl_permutation * p,
|
1749
|
+
gsl_vector * x);
|
1755
1750
|
|
1756
1751
|
static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int flag)
|
1757
1752
|
{
|
@@ -1762,21 +1757,19 @@ static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int fl
|
|
1762
1757
|
VALUE vtmp, klass;
|
1763
1758
|
size_t size0;
|
1764
1759
|
int (*fdecomp)(gsl_matrix*, gsl_vector*, gsl_permutation*, int *, gsl_vector*);
|
1765
|
-
int (*fsolve)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
|
1766
|
-
|
1760
|
+
int (*fsolve)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
|
1761
|
+
const gsl_vector*, gsl_vector *);
|
1767
1762
|
switch (flag) {
|
1768
1763
|
case LINALG_QRPT:
|
1769
1764
|
klass = cgsl_matrix_QRPT;
|
1770
1765
|
fdecomp = &gsl_linalg_QRPT_decomp;
|
1771
1766
|
fsolve = &gsl_linalg_QRPT_solve;
|
1772
1767
|
break;
|
1773
|
-
#ifdef GSL_1_6_LATER
|
1774
1768
|
case LINALG_PTLQ:
|
1775
1769
|
klass = cgsl_matrix_PTLQ;
|
1776
1770
|
fdecomp = &gsl_linalg_PTLQ_decomp;
|
1777
1771
|
fsolve = &gsl_linalg_PTLQ_solve_T;
|
1778
1772
|
break;
|
1779
|
-
#endif
|
1780
1773
|
default:
|
1781
1774
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1782
1775
|
break;
|
@@ -1794,11 +1787,11 @@ static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int fl
|
|
1794
1787
|
}
|
1795
1788
|
CHECK_MATRIX(vtmp);
|
1796
1789
|
if (CLASS_OF(vtmp) == klass) {
|
1797
|
-
if (argc-itmp != 3) rb_raise(rb_eArgError,
|
1798
|
-
|
1799
|
-
|
1790
|
+
if (argc-itmp != 3) rb_raise(rb_eArgError,
|
1791
|
+
"wrong number of arguments (%d for %d)",
|
1792
|
+
argc, 4-itmp);
|
1800
1793
|
CHECK_VECTOR(argv[itmp]);
|
1801
|
-
if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
|
1794
|
+
if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
|
1802
1795
|
rb_raise(rb_eTypeError, "not a tau vector");
|
1803
1796
|
CHECK_PERMUTATION(argv[itmp+1]);
|
1804
1797
|
Data_Get_Struct(argv[itmp], gsl_vector, tau);
|
@@ -1807,8 +1800,8 @@ static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int fl
|
|
1807
1800
|
size0 = GSL_MIN(QR->size1, QR->size2);
|
1808
1801
|
itmp += 2;
|
1809
1802
|
} else {
|
1810
|
-
if (argc-itmp != 1) rb_raise(rb_eArgError,
|
1811
|
-
|
1803
|
+
if (argc-itmp != 1) rb_raise(rb_eArgError,
|
1804
|
+
"wrong number of arguments (%d for %d)", argc, 2-itmp);
|
1812
1805
|
Data_Get_Struct(vtmp, gsl_matrix, A);
|
1813
1806
|
QR = make_matrix_clone(A);
|
1814
1807
|
size0 = GSL_MIN(QR->size1, QR->size2);
|
@@ -1842,12 +1835,10 @@ static VALUE rb_gsl_linalg_QRPT_solve(int argc, VALUE *argv, VALUE obj)
|
|
1842
1835
|
return rb_gsl_linalg_QRLQPT_solve(argc, argv, obj, LINALG_QRPT);
|
1843
1836
|
}
|
1844
1837
|
|
1845
|
-
#ifdef GSL_1_6_LATER
|
1846
1838
|
static VALUE rb_gsl_linalg_PTLQ_solve(int argc, VALUE *argv, VALUE obj)
|
1847
1839
|
{
|
1848
1840
|
return rb_gsl_linalg_QRLQPT_solve(argc, argv, obj, LINALG_PTLQ);
|
1849
1841
|
}
|
1850
|
-
#endif
|
1851
1842
|
|
1852
1843
|
static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag)
|
1853
1844
|
{
|
@@ -1858,21 +1849,19 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
|
|
1858
1849
|
VALUE vtmp, klass;
|
1859
1850
|
size_t size0;
|
1860
1851
|
int (*fdecomp)(gsl_matrix*, gsl_vector*, gsl_permutation*, int *, gsl_vector*);
|
1861
|
-
int (*fsvx)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
|
1862
|
-
|
1852
|
+
int (*fsvx)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
|
1853
|
+
gsl_vector *);
|
1863
1854
|
switch (flag) {
|
1864
1855
|
case LINALG_QRPT:
|
1865
1856
|
klass = cgsl_matrix_QRPT;
|
1866
1857
|
fdecomp = &gsl_linalg_QRPT_decomp;
|
1867
1858
|
fsvx = &gsl_linalg_QRPT_svx;
|
1868
1859
|
break;
|
1869
|
-
#ifdef GSL_1_6_LATER
|
1870
1860
|
case LINALG_PTLQ:
|
1871
1861
|
klass = cgsl_matrix_PTLQ;
|
1872
1862
|
fdecomp = &gsl_linalg_PTLQ_decomp;
|
1873
1863
|
fsvx = &gsl_linalg_PTLQ_svx_T;
|
1874
1864
|
break;
|
1875
|
-
#endif
|
1876
1865
|
default:
|
1877
1866
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1878
1867
|
break;
|
@@ -1881,7 +1870,7 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
|
|
1881
1870
|
switch (TYPE(obj)) {
|
1882
1871
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
1883
1872
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
1884
|
-
|
1873
|
+
argc);
|
1885
1874
|
vtmp = argv[0];
|
1886
1875
|
itmp = 1;
|
1887
1876
|
break;
|
@@ -1892,11 +1881,11 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
|
|
1892
1881
|
}
|
1893
1882
|
CHECK_MATRIX(vtmp);
|
1894
1883
|
if (CLASS_OF(vtmp) == klass) {
|
1895
|
-
if (argc-itmp != 3) rb_raise(rb_eArgError,
|
1896
|
-
|
1897
|
-
|
1884
|
+
if (argc-itmp != 3) rb_raise(rb_eArgError,
|
1885
|
+
"wrong number of arguments (%d for %d)",
|
1886
|
+
argc, 3+itmp);
|
1898
1887
|
CHECK_VECTOR(argv[itmp]);
|
1899
|
-
if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
|
1888
|
+
if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
|
1900
1889
|
rb_raise(rb_eTypeError, "not a tau vector");
|
1901
1890
|
CHECK_PERMUTATION(argv[itmp+1]);
|
1902
1891
|
Data_Get_Struct(argv[itmp], gsl_vector, tau);
|
@@ -1905,8 +1894,8 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
|
|
1905
1894
|
size0 = GSL_MIN(QR->size1, QR->size2);
|
1906
1895
|
itmp += 2;
|
1907
1896
|
} else {
|
1908
|
-
if (argc-itmp != 1) rb_raise(rb_eArgError,
|
1909
|
-
|
1897
|
+
if (argc-itmp != 1) rb_raise(rb_eArgError,
|
1898
|
+
"wrong number of arguments (%d for %d)", argc, 2+itmp);
|
1910
1899
|
Data_Get_Struct(vtmp, gsl_matrix, A);
|
1911
1900
|
QR = make_matrix_clone(A);
|
1912
1901
|
size0 = GSL_MIN(QR->size1, QR->size2);
|
@@ -1933,36 +1922,32 @@ static VALUE rb_gsl_linalg_QRPT_svx(int argc, VALUE *argv, VALUE obj)
|
|
1933
1922
|
return rb_gsl_linalg_QRLQPT_svx(argc, argv, obj, LINALG_QRPT);
|
1934
1923
|
}
|
1935
1924
|
|
1936
|
-
#ifdef GSL_1_6_LATER
|
1937
1925
|
static VALUE rb_gsl_linalg_PTLQ_svx(int argc, VALUE *argv, VALUE obj)
|
1938
1926
|
{
|
1939
1927
|
return rb_gsl_linalg_QRLQPT_svx(argc, argv, obj, LINALG_PTLQ);
|
1940
1928
|
}
|
1941
|
-
#endif
|
1942
1929
|
|
1943
1930
|
/* singleton */
|
1944
|
-
static VALUE rb_gsl_linalg_QRLQPT_QRLQsolve(VALUE obj, VALUE qq, VALUE rr,
|
1945
|
-
|
1931
|
+
static VALUE rb_gsl_linalg_QRLQPT_QRLQsolve(VALUE obj, VALUE qq, VALUE rr,
|
1932
|
+
VALUE pp, VALUE bb, int flag)
|
1946
1933
|
{
|
1947
1934
|
gsl_matrix *Q = NULL, *R = NULL;
|
1948
1935
|
gsl_vector *b = NULL, *x = NULL;
|
1949
1936
|
gsl_permutation *p = NULL;
|
1950
1937
|
int flagb = 0;
|
1951
|
-
int (*fsolve)(const gsl_matrix*, const gsl_matrix*, const gsl_permutation*,
|
1952
|
-
|
1938
|
+
int (*fsolve)(const gsl_matrix*, const gsl_matrix*, const gsl_permutation*,
|
1939
|
+
const gsl_vector*, gsl_vector*);
|
1953
1940
|
switch (flag) {
|
1954
1941
|
case LINALG_QRPT:
|
1955
1942
|
if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
|
1956
1943
|
if (CLASS_OF(rr) != cgsl_matrix_R) rb_raise(rb_eTypeError, "not a R matrix");
|
1957
1944
|
fsolve = &gsl_linalg_QRPT_QRsolve;
|
1958
1945
|
break;
|
1959
|
-
#ifdef GSL_1_6_LATER
|
1960
1946
|
case LINALG_PTLQ:
|
1961
1947
|
if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
|
1962
1948
|
if (CLASS_OF(rr) != cgsl_matrix_L) rb_raise(rb_eTypeError, "not a L matrix");
|
1963
1949
|
fsolve = &gsl_linalg_PTLQ_LQsolve_T;
|
1964
1950
|
break;
|
1965
|
-
#endif
|
1966
1951
|
default:
|
1967
1952
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
1968
1953
|
break;
|
@@ -1984,23 +1969,21 @@ static VALUE rb_gsl_linalg_QRLQPT_QRLQsolve(VALUE obj, VALUE qq, VALUE rr,
|
|
1984
1969
|
return Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, x);
|
1985
1970
|
}
|
1986
1971
|
|
1987
|
-
static VALUE rb_gsl_linalg_QRPT_QRsolve(VALUE obj, VALUE qq, VALUE rr,
|
1988
|
-
|
1972
|
+
static VALUE rb_gsl_linalg_QRPT_QRsolve(VALUE obj, VALUE qq, VALUE rr,
|
1973
|
+
VALUE pp, VALUE bb)
|
1989
1974
|
{
|
1990
1975
|
return rb_gsl_linalg_QRLQPT_QRLQsolve(obj, qq, rr, pp, bb, LINALG_QRPT);
|
1991
1976
|
}
|
1992
1977
|
|
1993
|
-
|
1994
|
-
|
1995
|
-
VALUE pp, VALUE bb)
|
1978
|
+
static VALUE rb_gsl_linalg_PTLQ_LQsolve(VALUE obj, VALUE qq, VALUE rr,
|
1979
|
+
VALUE pp, VALUE bb)
|
1996
1980
|
{
|
1997
1981
|
return rb_gsl_linalg_QRLQPT_QRLQsolve(obj, qq, rr, pp, bb, LINALG_PTLQ);
|
1998
1982
|
}
|
1999
|
-
#endif
|
2000
1983
|
|
2001
1984
|
/* singleton */
|
2002
|
-
static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
|
2003
|
-
|
1985
|
+
static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
|
1986
|
+
VALUE pp, VALUE ww, VALUE vv, int flag)
|
2004
1987
|
{
|
2005
1988
|
gsl_matrix *Q = NULL, *R = NULL;
|
2006
1989
|
gsl_vector *w = NULL, *v = NULL;
|
@@ -2010,12 +1993,10 @@ static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
|
|
2010
1993
|
if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
|
2011
1994
|
if (CLASS_OF(rr) != cgsl_matrix_R) rb_raise(rb_eTypeError, "not a R matrix");
|
2012
1995
|
break;
|
2013
|
-
#ifdef GSL_1_6_LATER
|
2014
1996
|
case LINALG_PTLQ:
|
2015
1997
|
if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
|
2016
1998
|
if (CLASS_OF(rr) != cgsl_matrix_L) rb_raise(rb_eTypeError, "not a L matrix");
|
2017
1999
|
break;
|
2018
|
-
#endif
|
2019
2000
|
}
|
2020
2001
|
CHECK_PERMUTATION(pp);
|
2021
2002
|
Data_Get_Struct(qq, gsl_matrix, Q);
|
@@ -2027,28 +2008,24 @@ static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
|
|
2027
2008
|
case LINALG_QRPT:
|
2028
2009
|
gsl_linalg_QRPT_update(Q, R, p, w, v);
|
2029
2010
|
break;
|
2030
|
-
#ifdef GSL_1_6_LATER
|
2031
2011
|
case LINALG_PTLQ:
|
2032
2012
|
gsl_linalg_PTLQ_update(Q, R, p, w, v);
|
2033
2013
|
break;
|
2034
|
-
#endif
|
2035
2014
|
}
|
2036
2015
|
return obj;
|
2037
2016
|
}
|
2038
2017
|
|
2039
|
-
static VALUE rb_gsl_linalg_QRPT_update(VALUE obj, VALUE qq, VALUE rr,
|
2040
|
-
|
2018
|
+
static VALUE rb_gsl_linalg_QRPT_update(VALUE obj, VALUE qq, VALUE rr,
|
2019
|
+
VALUE pp, VALUE ww, VALUE vv)
|
2041
2020
|
{
|
2042
2021
|
return rb_gsl_linalg_QRLQPT_update(obj, qq, rr, pp, ww, vv, LINALG_QRPT);
|
2043
2022
|
}
|
2044
2023
|
|
2045
|
-
|
2046
|
-
|
2047
|
-
VALUE pp, VALUE ww, VALUE vv)
|
2024
|
+
static VALUE rb_gsl_linalg_PTLQ_update(VALUE obj, VALUE qq, VALUE rr,
|
2025
|
+
VALUE pp, VALUE ww, VALUE vv)
|
2048
2026
|
{
|
2049
2027
|
return rb_gsl_linalg_QRLQPT_update(obj, qq, rr, pp, ww, vv, LINALG_PTLQ);
|
2050
2028
|
}
|
2051
|
-
#endif
|
2052
2029
|
|
2053
2030
|
static VALUE rb_gsl_linalg_QRLQPT_RLsolve(int argc, VALUE *argv, VALUE obj, int flag)
|
2054
2031
|
{
|
@@ -2057,19 +2034,17 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsolve(int argc, VALUE *argv, VALUE obj, int
|
|
2057
2034
|
gsl_permutation *p = NULL;
|
2058
2035
|
int itmp, flagb = 0;
|
2059
2036
|
VALUE vtmp, klass;
|
2060
|
-
int (*fsolve)(const gsl_matrix*, const gsl_permutation*, const gsl_vector*,
|
2061
|
-
|
2037
|
+
int (*fsolve)(const gsl_matrix*, const gsl_permutation*, const gsl_vector*,
|
2038
|
+
gsl_vector*);
|
2062
2039
|
switch (flag) {
|
2063
2040
|
case LINALG_QRPT:
|
2064
2041
|
klass = cgsl_matrix_QRPT;
|
2065
2042
|
fsolve = &gsl_linalg_QRPT_Rsolve;
|
2066
2043
|
break;
|
2067
|
-
#ifdef GSL_1_6_LATER
|
2068
2044
|
case LINALG_PTLQ:
|
2069
2045
|
klass = cgsl_matrix_PTLQ;
|
2070
2046
|
fsolve = &gsl_linalg_PTLQ_Lsolve_T;
|
2071
2047
|
break;
|
2072
|
-
#endif
|
2073
2048
|
default:
|
2074
2049
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
2075
2050
|
break;
|
@@ -2077,7 +2052,7 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsolve(int argc, VALUE *argv, VALUE obj, int
|
|
2077
2052
|
switch (TYPE(obj)) {
|
2078
2053
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2079
2054
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
2080
|
-
|
2055
|
+
argc);
|
2081
2056
|
vtmp = argv[0];
|
2082
2057
|
itmp = 1;
|
2083
2058
|
break;
|
@@ -2113,12 +2088,11 @@ static VALUE rb_gsl_linalg_QRPT_Rsolve(int argc, VALUE *argv, VALUE obj)
|
|
2113
2088
|
{
|
2114
2089
|
return rb_gsl_linalg_QRLQPT_RLsolve(argc, argv, obj, LINALG_QRPT);
|
2115
2090
|
}
|
2116
|
-
|
2091
|
+
|
2117
2092
|
static VALUE rb_gsl_linalg_PTLQ_Lsolve(int argc, VALUE *argv, VALUE obj)
|
2118
2093
|
{
|
2119
2094
|
return rb_gsl_linalg_QRLQPT_RLsolve(argc, argv, obj, LINALG_PTLQ);
|
2120
2095
|
}
|
2121
|
-
#endif
|
2122
2096
|
|
2123
2097
|
static VALUE rb_gsl_linalg_QRLQPT_RLsvx(int argc, VALUE *argv, VALUE obj, int flag)
|
2124
2098
|
{
|
@@ -2133,11 +2107,9 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsvx(int argc, VALUE *argv, VALUE obj, int fl
|
|
2133
2107
|
klass = cgsl_matrix_QRPT;
|
2134
2108
|
fsvx = &gsl_linalg_QRPT_Rsvx;
|
2135
2109
|
break;
|
2136
|
-
#ifdef GSL_1_6_LATER
|
2137
2110
|
case LINALG_PTLQ:
|
2138
2111
|
klass = cgsl_matrix_PTLQ;
|
2139
2112
|
fsvx = &gsl_linalg_PTLQ_Lsvx_T;
|
2140
|
-
#endif
|
2141
2113
|
default:
|
2142
2114
|
rb_raise(rb_eRuntimeError, "unknown operation");
|
2143
2115
|
break;
|
@@ -2145,7 +2117,7 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsvx(int argc, VALUE *argv, VALUE obj, int fl
|
|
2145
2117
|
switch (TYPE(obj)) {
|
2146
2118
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2147
2119
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
2148
|
-
|
2120
|
+
argc);
|
2149
2121
|
vtmp = argv[0];
|
2150
2122
|
itmp = 1;
|
2151
2123
|
break;
|
@@ -2178,12 +2150,11 @@ static VALUE rb_gsl_linalg_QRPT_Rsvx(int argc, VALUE *argv, VALUE obj)
|
|
2178
2150
|
{
|
2179
2151
|
return rb_gsl_linalg_QRLQPT_RLsvx(argc, argv, obj, LINALG_QRPT);
|
2180
2152
|
}
|
2181
|
-
|
2153
|
+
|
2182
2154
|
static VALUE rb_gsl_linalg_PTLQ_Lsvx(int argc, VALUE *argv, VALUE obj)
|
2183
2155
|
{
|
2184
2156
|
return rb_gsl_linalg_QRLQPT_RLsvx(argc, argv, obj, LINALG_PTLQ);
|
2185
2157
|
}
|
2186
|
-
#endif
|
2187
2158
|
|
2188
2159
|
/*******/
|
2189
2160
|
#ifdef HAVE_NARRAY_H
|
@@ -2266,11 +2237,11 @@ static VALUE rb_gsl_linalg_SV_decomp(int argc, VALUE *argv, VALUE obj)
|
|
2266
2237
|
CHECK_VECTOR(argv[1]);
|
2267
2238
|
Data_Get_Struct(argv[1], gsl_vector, w);
|
2268
2239
|
flag = 0;
|
2269
|
-
|
2240
|
+
/* no break, do next */
|
2270
2241
|
case 1:
|
2271
2242
|
#ifdef HAVE_NARRAY_H
|
2272
2243
|
if (NA_IsNArray(argv[0]))
|
2273
|
-
|
2244
|
+
return rb_gsl_linalg_SV_decomp_narray(argc, argv, obj);
|
2274
2245
|
#endif
|
2275
2246
|
CHECK_MATRIX(argv[0]);
|
2276
2247
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
@@ -2317,7 +2288,7 @@ static VALUE rb_gsl_linalg_SV_decomp_mod(int argc, VALUE *argv, VALUE obj)
|
|
2317
2288
|
switch (TYPE(obj)) {
|
2318
2289
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2319
2290
|
if (argc != 1) rb_raise(rb_eArgError,
|
2320
|
-
|
2291
|
+
"wrong number of argument (%d for 1)", argc);
|
2321
2292
|
CHECK_MATRIX(argv[0]);
|
2322
2293
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
2323
2294
|
break;
|
@@ -2347,10 +2318,10 @@ static VALUE rb_gsl_linalg_SV_decomp_jacobi(int argc, VALUE *argv, VALUE obj)
|
|
2347
2318
|
switch (TYPE(obj)) {
|
2348
2319
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2349
2320
|
if (argc != 1) rb_raise(rb_eArgError,
|
2350
|
-
|
2321
|
+
"wrong number of argument (%d for 1)", argc);
|
2351
2322
|
#ifdef HAVE_NARRAY_H
|
2352
|
-
|
2353
|
-
|
2323
|
+
if (NA_IsNArray(argv[0]))
|
2324
|
+
return rb_gsl_linalg_SV_decomp_jacobi_narray(argc, argv, obj);
|
2354
2325
|
#endif
|
2355
2326
|
CHECK_MATRIX(argv[0]);
|
2356
2327
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
@@ -2374,7 +2345,7 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
|
|
2374
2345
|
gsl_matrix *A = NULL, *U = NULL, *V = NULL;
|
2375
2346
|
gsl_vector *S = NULL, *b = NULL, *x = NULL;
|
2376
2347
|
int flagb = 0, flagv = 0;
|
2377
|
-
|
2348
|
+
|
2378
2349
|
switch (TYPE(obj)) {
|
2379
2350
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2380
2351
|
if (argc < 1) rb_raise(rb_eArgError, "too few arguments.");
|
@@ -2385,35 +2356,35 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
|
|
2385
2356
|
|
2386
2357
|
CHECK_MATRIX(argv[0]);
|
2387
2358
|
if (CLASS_OF(argv[0]) == cgsl_matrix_U) {
|
2388
|
-
if (argc != 4) rb_raise(rb_eArgError,
|
2389
|
-
|
2359
|
+
if (argc != 4) rb_raise(rb_eArgError,
|
2360
|
+
"wrong number of arguments (%d for 4)", argc);
|
2390
2361
|
Data_Get_Struct(argv[0], gsl_matrix, U);
|
2391
2362
|
CHECK_MATRIX(argv[1]);
|
2392
|
-
if (CLASS_OF(argv[1]) != cgsl_matrix_V)
|
2393
|
-
|
2363
|
+
if (CLASS_OF(argv[1]) != cgsl_matrix_V)
|
2364
|
+
rb_raise(rb_eTypeError, "not a V matrix");
|
2394
2365
|
Data_Get_Struct(argv[1], gsl_matrix, V);
|
2395
2366
|
CHECK_VECTOR(argv[2]);
|
2396
|
-
if (CLASS_OF(argv[2]) != cgsl_vector_S)
|
2397
|
-
|
2367
|
+
if (CLASS_OF(argv[2]) != cgsl_vector_S)
|
2368
|
+
rb_raise(rb_eTypeError, "not a S vector");
|
2398
2369
|
Data_Get_Struct(argv[2], gsl_vector, S);
|
2399
2370
|
if (TYPE(argv[3]) == T_ARRAY) {
|
2400
|
-
|
2401
|
-
|
2371
|
+
b = make_cvector_from_rarray(argv[3]);
|
2372
|
+
flagb = 1;
|
2402
2373
|
} else {
|
2403
|
-
|
2404
|
-
|
2374
|
+
CHECK_VECTOR(argv[3]);
|
2375
|
+
Data_Get_Struct(argv[3], gsl_vector, b);
|
2405
2376
|
}
|
2406
2377
|
} else {
|
2407
|
-
if (argc != 2) rb_raise(rb_eArgError,
|
2408
|
-
|
2378
|
+
if (argc != 2) rb_raise(rb_eArgError,
|
2379
|
+
"wrong number of arguments (%d for 2)", argc);
|
2409
2380
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
2410
2381
|
U = make_matrix_clone(A);
|
2411
2382
|
if (TYPE(argv[1]) == T_ARRAY) {
|
2412
|
-
|
2413
|
-
|
2383
|
+
b = make_cvector_from_rarray(argv[1]);
|
2384
|
+
flagb = 1;
|
2414
2385
|
} else {
|
2415
|
-
|
2416
|
-
|
2386
|
+
CHECK_VECTOR(argv[1]);
|
2387
|
+
Data_Get_Struct(argv[1], gsl_vector, b);
|
2417
2388
|
}
|
2418
2389
|
S = gsl_vector_alloc(A->size2); /* see manual p 123 */
|
2419
2390
|
V = gsl_matrix_alloc(A->size2, A->size2);
|
@@ -2422,8 +2393,8 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
|
|
2422
2393
|
}
|
2423
2394
|
break;
|
2424
2395
|
default:
|
2425
|
-
if (argc != 1) rb_raise(rb_eArgError,
|
2426
|
-
|
2396
|
+
if (argc != 1) rb_raise(rb_eArgError,
|
2397
|
+
"wrong number of arguments (%d for 1)", argc);
|
2427
2398
|
Data_Get_Struct(obj, gsl_matrix, A);
|
2428
2399
|
U = make_matrix_clone(A);
|
2429
2400
|
if (TYPE(argv[0]) == T_ARRAY) {
|
@@ -2439,7 +2410,7 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
|
|
2439
2410
|
flagv = 1;
|
2440
2411
|
break;
|
2441
2412
|
}
|
2442
|
-
// x = gsl_vector_alloc(b->size);
|
2413
|
+
// x = gsl_vector_alloc(b->size);
|
2443
2414
|
// Bug report #25842
|
2444
2415
|
x = gsl_vector_alloc(S->size);
|
2445
2416
|
gsl_linalg_SV_solve(U, V, S, b, x);
|
@@ -2486,8 +2457,8 @@ static VALUE rb_gsl_linalg_cholesky_solve_narray(int argc, VALUE *argv, VALUE ob
|
|
2486
2457
|
x = argv[2];
|
2487
2458
|
break;
|
2488
2459
|
default:
|
2489
|
-
rb_raise(rb_eArgError,
|
2490
|
-
|
2460
|
+
rb_raise(rb_eArgError,
|
2461
|
+
"Usage: Cholesky.solve(chol, b) or Cholesky.solve(chol, b, x)");
|
2491
2462
|
break;
|
2492
2463
|
}
|
2493
2464
|
mv = gsl_matrix_view_array((double*)nm->ptr, nm->shape[1], nm->shape[0]);
|
@@ -2517,7 +2488,7 @@ static VALUE rb_gsl_linalg_cholesky_decomp(int argc, VALUE *argv, VALUE obj)
|
|
2517
2488
|
switch(TYPE(obj)) {
|
2518
2489
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2519
2490
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2520
|
-
|
2491
|
+
argc);
|
2521
2492
|
#ifdef HAVE_NARRAY_H
|
2522
2493
|
if (NA_IsNArray(argv[0]))
|
2523
2494
|
return rb_gsl_linalg_cholesky_decomp_narray(argc, argv, obj);
|
@@ -2544,7 +2515,7 @@ static VALUE rb_gsl_linalg_cholesky_solve(int argc, VALUE *argv, VALUE obj)
|
|
2544
2515
|
switch(TYPE(obj)) {
|
2545
2516
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2546
2517
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
2547
|
-
|
2518
|
+
argc);
|
2548
2519
|
#ifdef HAVE_NARRAY_H
|
2549
2520
|
if (NA_IsNArray(argv[0]))
|
2550
2521
|
return rb_gsl_linalg_cholesky_solve_narray(argc, argv, obj);
|
@@ -2554,7 +2525,7 @@ static VALUE rb_gsl_linalg_cholesky_solve(int argc, VALUE *argv, VALUE obj)
|
|
2554
2525
|
break;
|
2555
2526
|
default:
|
2556
2527
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2557
|
-
|
2528
|
+
argc);
|
2558
2529
|
vA = obj;
|
2559
2530
|
vb = argv[0];
|
2560
2531
|
break;
|
@@ -2592,7 +2563,7 @@ static VALUE rb_gsl_linalg_cholesky_svx(int argc, VALUE *argv, VALUE obj)
|
|
2592
2563
|
switch(TYPE(obj)) {
|
2593
2564
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2594
2565
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
2595
|
-
|
2566
|
+
argc);
|
2596
2567
|
#ifdef HAVE_NARRAY_H
|
2597
2568
|
if (NA_IsNArray(argv[0]))
|
2598
2569
|
return rb_gsl_linalg_cholesky_svx_narray(argc, argv, obj);
|
@@ -2602,7 +2573,7 @@ static VALUE rb_gsl_linalg_cholesky_svx(int argc, VALUE *argv, VALUE obj)
|
|
2602
2573
|
break;
|
2603
2574
|
default:
|
2604
2575
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2605
|
-
|
2576
|
+
argc);
|
2606
2577
|
vA = obj;
|
2607
2578
|
vb = argv[0];
|
2608
2579
|
break;
|
@@ -2631,7 +2602,7 @@ static VALUE rb_gsl_linalg_symmtd_decomp(int argc, VALUE *argv, VALUE obj)
|
|
2631
2602
|
switch (TYPE(obj)) {
|
2632
2603
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2633
2604
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2634
|
-
|
2605
|
+
argc);
|
2635
2606
|
CHECK_MATRIX(argv[0]);
|
2636
2607
|
Data_Get_Struct(argv[0], gsl_matrix, Atmp);
|
2637
2608
|
break;
|
@@ -2656,7 +2627,7 @@ static VALUE rb_gsl_linalg_symmtd_decomp2(int argc, VALUE *argv, VALUE obj)
|
|
2656
2627
|
switch (TYPE(obj)) {
|
2657
2628
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2658
2629
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2659
|
-
|
2630
|
+
argc);
|
2660
2631
|
CHECK_MATRIX(argv[0]);
|
2661
2632
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
2662
2633
|
break;
|
@@ -2678,14 +2649,14 @@ static VALUE rb_gsl_linalg_symmtd_unpack(int argc, VALUE *argv, VALUE obj)
|
|
2678
2649
|
switch (TYPE(obj)) {
|
2679
2650
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2680
2651
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
2681
|
-
|
2652
|
+
argc);
|
2682
2653
|
CHECK_MATRIX(argv[0]);
|
2683
2654
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
2684
2655
|
Data_Get_Struct(argv[1], gsl_vector, tau);
|
2685
2656
|
break;
|
2686
2657
|
default:
|
2687
2658
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2688
|
-
|
2659
|
+
argc);
|
2689
2660
|
CHECK_MATRIX(obj);
|
2690
2661
|
Data_Get_Struct(obj, gsl_matrix, A);
|
2691
2662
|
Data_Get_Struct(argv[0], gsl_vector, tau);
|
@@ -2711,7 +2682,7 @@ static VALUE rb_gsl_linalg_symmtd_unpack_T(int argc, VALUE *argv, VALUE obj)
|
|
2711
2682
|
switch (TYPE(obj)) {
|
2712
2683
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2713
2684
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
2714
|
-
|
2685
|
+
argc);
|
2715
2686
|
CHECK_MATRIX(argv[0]);
|
2716
2687
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
2717
2688
|
break;
|
@@ -2739,7 +2710,7 @@ static VALUE rb_gsl_linalg_hermtd_decomp(int argc, VALUE *argv, VALUE obj)
|
|
2739
2710
|
switch (TYPE(obj)) {
|
2740
2711
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2741
2712
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2742
|
-
|
2713
|
+
argc);
|
2743
2714
|
CHECK_MATRIX_COMPLEX(argv[0]);
|
2744
2715
|
Data_Get_Struct(argv[0], gsl_matrix_complex, Atmp);
|
2745
2716
|
break;
|
@@ -2763,7 +2734,7 @@ static VALUE rb_gsl_linalg_hermtd_decomp2(int argc, VALUE *argv, VALUE obj)
|
|
2763
2734
|
switch (TYPE(obj)) {
|
2764
2735
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2765
2736
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2766
|
-
|
2737
|
+
argc);
|
2767
2738
|
CHECK_MATRIX_COMPLEX(argv[0]);
|
2768
2739
|
Data_Get_Struct(argv[0], gsl_matrix_complex, A);
|
2769
2740
|
break;
|
@@ -2786,14 +2757,14 @@ static VALUE rb_gsl_linalg_hermtd_unpack(int argc, VALUE *argv, VALUE obj)
|
|
2786
2757
|
switch (TYPE(obj)) {
|
2787
2758
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2788
2759
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2789
|
-
|
2760
|
+
argc);
|
2790
2761
|
CHECK_MATRIX_COMPLEX(argv[0]);
|
2791
2762
|
Data_Get_Struct(argv[0], gsl_matrix_complex, A);
|
2792
2763
|
Data_Get_Struct(argv[1], gsl_vector_complex, tau);
|
2793
2764
|
break;
|
2794
2765
|
default:
|
2795
2766
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2796
|
-
|
2767
|
+
argc);
|
2797
2768
|
CHECK_MATRIX_COMPLEX(obj);
|
2798
2769
|
Data_Get_Struct(obj, gsl_matrix_complex, A);
|
2799
2770
|
Data_Get_Struct(argv[0], gsl_vector_complex, tau);
|
@@ -2819,7 +2790,7 @@ static VALUE rb_gsl_linalg_hermtd_unpack_T(int argc, VALUE *argv, VALUE obj)
|
|
2819
2790
|
switch (TYPE(obj)) {
|
2820
2791
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2821
2792
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
2822
|
-
|
2793
|
+
argc);
|
2823
2794
|
CHECK_MATRIX_COMPLEX(argv[0]);
|
2824
2795
|
Data_Get_Struct(argv[0], gsl_matrix_complex, A);
|
2825
2796
|
break;
|
@@ -2851,7 +2822,7 @@ static VALUE rb_gsl_linalg_bidiag_decomp(int argc, VALUE *argv, VALUE obj)
|
|
2851
2822
|
switch (TYPE(obj)) {
|
2852
2823
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2853
2824
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
2854
|
-
|
2825
|
+
argc);
|
2855
2826
|
Data_Get_Struct(argv[0], gsl_matrix, Atmp);
|
2856
2827
|
break;
|
2857
2828
|
default:
|
@@ -2879,7 +2850,7 @@ static VALUE rb_gsl_linalg_bidiag_decomp2(int argc, VALUE *argv, VALUE obj)
|
|
2879
2850
|
switch (TYPE(obj)) {
|
2880
2851
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2881
2852
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
2882
|
-
|
2853
|
+
argc);
|
2883
2854
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
2884
2855
|
break;
|
2885
2856
|
default:
|
@@ -2905,7 +2876,7 @@ static VALUE rb_gsl_linalg_bidiag_unpack(int argc, VALUE *argv, VALUE obj)
|
|
2905
2876
|
switch (TYPE(obj)) {
|
2906
2877
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2907
2878
|
if (argc != 3) rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)",
|
2908
|
-
|
2879
|
+
argc);
|
2909
2880
|
CHECK_MATRIX(argv[0]);
|
2910
2881
|
CHECK_VECTOR(argv[1]);
|
2911
2882
|
CHECK_VECTOR(argv[2]);
|
@@ -2915,7 +2886,7 @@ static VALUE rb_gsl_linalg_bidiag_unpack(int argc, VALUE *argv, VALUE obj)
|
|
2915
2886
|
break;
|
2916
2887
|
default:
|
2917
2888
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
|
2918
|
-
|
2889
|
+
argc);
|
2919
2890
|
CHECK_MATRIX(obj);
|
2920
2891
|
CHECK_VECTOR(argv[0]);
|
2921
2892
|
CHECK_VECTOR(argv[1]);
|
@@ -2946,8 +2917,8 @@ static VALUE rb_gsl_linalg_bidiag_unpack2(int argc, VALUE *argv, VALUE obj)
|
|
2946
2917
|
|
2947
2918
|
switch (TYPE(obj)) {
|
2948
2919
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2949
|
-
|
2950
|
-
|
2920
|
+
if (argc != 3) rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)",
|
2921
|
+
argc);
|
2951
2922
|
CHECK_MATRIX(argv[0]);
|
2952
2923
|
CHECK_VECTOR(argv[1]);
|
2953
2924
|
CHECK_VECTOR(argv[2]);
|
@@ -2957,7 +2928,7 @@ static VALUE rb_gsl_linalg_bidiag_unpack2(int argc, VALUE *argv, VALUE obj)
|
|
2957
2928
|
break;
|
2958
2929
|
default:
|
2959
2930
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
|
2960
|
-
|
2931
|
+
argc);
|
2961
2932
|
CHECK_MATRIX(obj);
|
2962
2933
|
CHECK_VECTOR(argv[0]);
|
2963
2934
|
CHECK_VECTOR(argv[1]);
|
@@ -2965,7 +2936,7 @@ static VALUE rb_gsl_linalg_bidiag_unpack2(int argc, VALUE *argv, VALUE obj)
|
|
2965
2936
|
Data_Get_Struct(argv[0], gsl_vector, tau_U);
|
2966
2937
|
Data_Get_Struct(argv[1], gsl_vector, tau_V);
|
2967
2938
|
break;
|
2968
|
-
}
|
2939
|
+
}
|
2969
2940
|
V = gsl_matrix_alloc(A->size2, A->size2);
|
2970
2941
|
gsl_linalg_bidiag_unpack2(A, tau_U, tau_V, V);
|
2971
2942
|
vv = Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, V);
|
@@ -2982,7 +2953,7 @@ static VALUE rb_gsl_linalg_bidiag_unpack_B(int argc, VALUE *argv, VALUE obj)
|
|
2982
2953
|
switch (TYPE(obj)) {
|
2983
2954
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
2984
2955
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)",
|
2985
|
-
|
2956
|
+
argc);
|
2986
2957
|
CHECK_MATRIX(argv[0]);
|
2987
2958
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
2988
2959
|
break;
|
@@ -2990,7 +2961,7 @@ static VALUE rb_gsl_linalg_bidiag_unpack_B(int argc, VALUE *argv, VALUE obj)
|
|
2990
2961
|
CHECK_MATRIX(obj);
|
2991
2962
|
Data_Get_Struct(obj, gsl_matrix, A);
|
2992
2963
|
break;
|
2993
|
-
}
|
2964
|
+
}
|
2994
2965
|
size0 = GSL_MIN(A->size1, A->size2);
|
2995
2966
|
d = gsl_vector_alloc(size0);
|
2996
2967
|
s = gsl_vector_alloc(size0);
|
@@ -3101,7 +3072,7 @@ static VALUE rb_gsl_linalg_HH_solve(int argc, VALUE *argv, VALUE obj)
|
|
3101
3072
|
switch (TYPE(obj)) {
|
3102
3073
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
3103
3074
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
3104
|
-
|
3075
|
+
argc);
|
3105
3076
|
#ifdef HAVE_NARRAY_H
|
3106
3077
|
if (NA_IsNArray(argv[0]))
|
3107
3078
|
return rb_gsl_linalg_HH_solve_narray(argc, argv, obj);
|
@@ -3111,7 +3082,7 @@ static VALUE rb_gsl_linalg_HH_solve(int argc, VALUE *argv, VALUE obj)
|
|
3111
3082
|
break;
|
3112
3083
|
default:
|
3113
3084
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
3114
|
-
|
3085
|
+
argc);
|
3115
3086
|
vA = obj;
|
3116
3087
|
vb = argv[0];
|
3117
3088
|
break;
|
@@ -3142,13 +3113,13 @@ static VALUE rb_gsl_linalg_HH_solve_bang(int argc, VALUE *argv, VALUE obj)
|
|
3142
3113
|
switch (TYPE(obj)) {
|
3143
3114
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
3144
3115
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
3145
|
-
|
3116
|
+
argc);
|
3146
3117
|
vA = argv[0];
|
3147
3118
|
vb = argv[1];
|
3148
3119
|
break;
|
3149
3120
|
default:
|
3150
3121
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
3151
|
-
|
3122
|
+
argc);
|
3152
3123
|
vA = obj;
|
3153
3124
|
vb = argv[0];
|
3154
3125
|
break;
|
@@ -3176,7 +3147,7 @@ static VALUE rb_gsl_linalg_HH_svx(int argc, VALUE *argv, VALUE obj)
|
|
3176
3147
|
switch (TYPE(obj)) {
|
3177
3148
|
case T_MODULE: case T_CLASS: case T_OBJECT:
|
3178
3149
|
if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
|
3179
|
-
|
3150
|
+
argc);
|
3180
3151
|
#ifdef HAVE_NARRAY_H
|
3181
3152
|
if (NA_IsNArray(argv[0]))
|
3182
3153
|
return rb_gsl_linalg_HH_svx_narray(argc, argv, obj);
|
@@ -3186,7 +3157,7 @@ static VALUE rb_gsl_linalg_HH_svx(int argc, VALUE *argv, VALUE obj)
|
|
3186
3157
|
break;
|
3187
3158
|
default:
|
3188
3159
|
if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
|
3189
|
-
|
3160
|
+
argc);
|
3190
3161
|
vA = obj;
|
3191
3162
|
vb = argv[0];
|
3192
3163
|
break;
|
@@ -3214,9 +3185,8 @@ static VALUE rb_gsl_linalg_solve_symm_tridiag(VALUE obj, VALUE dd, VALUE ee, VAL
|
|
3214
3185
|
return Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, x);
|
3215
3186
|
}
|
3216
3187
|
|
3217
|
-
#ifdef GSL_1_2_LATER
|
3218
3188
|
static VALUE rb_gsl_linalg_solve_tridiag(VALUE obj, VALUE dd, VALUE ee, VALUE ff,
|
3219
|
-
|
3189
|
+
VALUE bb)
|
3220
3190
|
{
|
3221
3191
|
gsl_vector *b = NULL, *x = NULL, *d = NULL, *e = NULL, *f = NULL;
|
3222
3192
|
|
@@ -3243,8 +3213,8 @@ static VALUE rb_gsl_linalg_solve_symm_cyc_tridiag(VALUE obj, VALUE dd, VALUE ee,
|
|
3243
3213
|
return Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, x);
|
3244
3214
|
}
|
3245
3215
|
|
3246
|
-
static VALUE rb_gsl_linalg_solve_cyc_tridiag(VALUE obj, VALUE dd, VALUE ee,
|
3247
|
-
|
3216
|
+
static VALUE rb_gsl_linalg_solve_cyc_tridiag(VALUE obj, VALUE dd, VALUE ee,
|
3217
|
+
VALUE ff, VALUE bb)
|
3248
3218
|
{
|
3249
3219
|
gsl_vector *b = NULL, *x = NULL, *d = NULL, *e = NULL, *f = NULL;
|
3250
3220
|
Data_Get_Struct(dd, gsl_vector, d);
|
@@ -3255,11 +3225,10 @@ static VALUE rb_gsl_linalg_solve_cyc_tridiag(VALUE obj, VALUE dd, VALUE ee,
|
|
3255
3225
|
gsl_linalg_solve_cyc_tridiag(d, e, f, b, x);
|
3256
3226
|
return Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, x);
|
3257
3227
|
}
|
3258
|
-
#endif
|
3259
3228
|
|
3260
3229
|
static void rb_gsl_linalg_balance_columns_init(int argc, VALUE *argv, VALUE obj,
|
3261
|
-
|
3262
|
-
|
3230
|
+
VALUE *mat, VALUE *vec,
|
3231
|
+
gsl_matrix **M, gsl_vector **V)
|
3263
3232
|
{
|
3264
3233
|
gsl_matrix *A = NULL;
|
3265
3234
|
gsl_vector *D = NULL;
|
@@ -3333,92 +3302,6 @@ static VALUE rb_gsl_linalg_balance_columns(int argc, VALUE *argv, VALUE obj)
|
|
3333
3302
|
return rb_ary_new3(2, mat, vec);
|
3334
3303
|
}
|
3335
3304
|
|
3336
|
-
#ifdef HAVE_NARRAY_H
|
3337
|
-
static VALUE rb_gsl_linalg_QR_decomp_narray(int argc, VALUE *argv, VALUE obj)
|
3338
|
-
{
|
3339
|
-
struct NARRAY *na;
|
3340
|
-
gsl_matrix_view mv;
|
3341
|
-
gsl_vector_view vv;
|
3342
|
-
int shapem[2], shapev[1];
|
3343
|
-
VALUE qr, tau;
|
3344
|
-
if (argc < 1) rb_raise(rb_eArgError, "too few arguments.");
|
3345
|
-
GetNArray(argv[0], na);
|
3346
|
-
shapem[0] = na->shape[1];
|
3347
|
-
shapem[1] = na->shape[1];
|
3348
|
-
shapev[0] = shapem[0];
|
3349
|
-
qr = na_make_object(NA_DFLOAT, 2, shapem, CLASS_OF(argv[0]));
|
3350
|
-
tau = na_make_object(NA_DFLOAT, 1, shapev, cNVector);
|
3351
|
-
memcpy(NA_PTR_TYPE(qr,double*),na->ptr,sizeof(double)*shapem[0]*shapem[1]);
|
3352
|
-
mv = gsl_matrix_view_array(NA_PTR_TYPE(qr,double*), shapem[0], shapem[1]);
|
3353
|
-
vv = gsl_vector_view_array(NA_PTR_TYPE(tau,double*), shapev[0]);
|
3354
|
-
gsl_linalg_QR_decomp(&mv.matrix, &vv.vector);
|
3355
|
-
return rb_ary_new3(2, qr, tau);
|
3356
|
-
}
|
3357
|
-
|
3358
|
-
static VALUE rb_gsl_linalg_QR_unpack_narray(int argc, VALUE *argv, VALUE obj)
|
3359
|
-
{
|
3360
|
-
struct NARRAY *m, *tau;
|
3361
|
-
gsl_matrix_view mv, mq, mr;
|
3362
|
-
gsl_vector_view vv;
|
3363
|
-
int shape[2];
|
3364
|
-
VALUE q, r;
|
3365
|
-
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
|
3366
|
-
argc);
|
3367
|
-
GetNArray(argv[0], m);
|
3368
|
-
GetNArray(argv[1], tau);
|
3369
|
-
mv = gsl_matrix_view_array((double*)m->ptr, m->shape[1], m->shape[0]);
|
3370
|
-
vv = gsl_vector_view_array((double*)tau->ptr, tau->shape[0]);
|
3371
|
-
shape[0] = m->shape[1];
|
3372
|
-
shape[1] = m->shape[1];
|
3373
|
-
q = na_make_object(NA_DFLOAT, 2, shape, CLASS_OF(argv[0]));
|
3374
|
-
shape[0] = m->shape[1];
|
3375
|
-
shape[1] = m->shape[0];
|
3376
|
-
r = na_make_object(NA_DFLOAT, 2, shape, CLASS_OF(argv[0]));
|
3377
|
-
mq = gsl_matrix_view_array(NA_PTR_TYPE(q,double*), m->shape[1], m->shape[1]);
|
3378
|
-
mr = gsl_matrix_view_array(NA_PTR_TYPE(r,double*), m->shape[1], m->shape[0]);
|
3379
|
-
// printf("OK 4 %d %d\n", mq.matrix.size1, mr.matrix.size2);
|
3380
|
-
gsl_linalg_QR_unpack(&mv.matrix, &vv.vector, &mq.matrix, &mr.matrix);
|
3381
|
-
// printf("OK 5\n");
|
3382
|
-
return rb_ary_new3(2, q, r);
|
3383
|
-
}
|
3384
|
-
|
3385
|
-
static VALUE rb_gsl_linalg_QR_solve_narray(int argc, VALUE *argv, VALUE obj)
|
3386
|
-
{
|
3387
|
-
struct NARRAY *qr, *tau, *b;
|
3388
|
-
VALUE x;
|
3389
|
-
gsl_matrix_view mv;
|
3390
|
-
gsl_vector_view tv, bv, xv;
|
3391
|
-
if (argc != 3) rb_raise(rb_eArgError, "Usage: QR.solve(qr, tau, b)");
|
3392
|
-
GetNArray(argv[0], qr);
|
3393
|
-
GetNArray(argv[1], tau);
|
3394
|
-
GetNArray(argv[2], b);
|
3395
|
-
x = na_make_object(NA_DFLOAT, 1, b->shape, CLASS_OF(argv[2]));
|
3396
|
-
mv = gsl_matrix_view_array((double*)qr->ptr, qr->shape[1], qr->shape[0]);
|
3397
|
-
tv = gsl_vector_view_array((double*)tau->ptr, tau->shape[0]);
|
3398
|
-
bv = gsl_vector_view_array((double*)b->ptr, b->shape[0]);
|
3399
|
-
xv = gsl_vector_view_array(NA_PTR_TYPE(x,double*), b->shape[0]);
|
3400
|
-
gsl_linalg_QR_solve(&mv.matrix, &tv.vector, &bv.vector, &xv.vector);
|
3401
|
-
return x;
|
3402
|
-
}
|
3403
|
-
static VALUE rb_gsl_linalg_QR_svx_narray(int argc, VALUE *argv, VALUE obj)
|
3404
|
-
{
|
3405
|
-
struct NARRAY *qr, *tau, *b;
|
3406
|
-
gsl_matrix_view mv;
|
3407
|
-
gsl_vector_view tv, bv;
|
3408
|
-
if (argc != 3) rb_raise(rb_eArgError, "Usage: QR.solve(qr, tau, b)");
|
3409
|
-
GetNArray(argv[0], qr);
|
3410
|
-
GetNArray(argv[1], tau);
|
3411
|
-
GetNArray(argv[2], b);
|
3412
|
-
mv = gsl_matrix_view_array((double*)qr->ptr, qr->shape[1], qr->shape[0]);
|
3413
|
-
tv = gsl_vector_view_array((double*)tau->ptr, tau->shape[0]);
|
3414
|
-
bv = gsl_vector_view_array((double*)b->ptr, b->shape[0]);
|
3415
|
-
gsl_linalg_QR_svx(&mv.matrix, &tv.vector, &bv.vector);
|
3416
|
-
return argv[2];
|
3417
|
-
}
|
3418
|
-
|
3419
|
-
#endif
|
3420
|
-
|
3421
|
-
#ifdef GSL_1_9_LATER
|
3422
3305
|
static VALUE rb_gsl_linalg_hessenberg_decomp(VALUE module, VALUE AA)
|
3423
3306
|
{
|
3424
3307
|
gsl_matrix *A = NULL, *Atmp = NULL;
|
@@ -3500,7 +3383,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp(int argc, VALUE *argv, VALUE module)
|
|
3500
3383
|
break;
|
3501
3384
|
case 3:
|
3502
3385
|
CHECK_VECTOR(argv[2]);
|
3503
|
-
Data_Get_Struct(argv[2], gsl_vector, work);
|
3386
|
+
Data_Get_Struct(argv[2], gsl_vector, work);
|
3504
3387
|
break;
|
3505
3388
|
case 4:
|
3506
3389
|
CHECK_MATRIX(argv[2]);
|
@@ -3508,7 +3391,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp(int argc, VALUE *argv, VALUE module)
|
|
3508
3391
|
Data_Get_Struct(argv[2], gsl_matrix, U);
|
3509
3392
|
Data_Get_Struct(argv[3], gsl_matrix, V);
|
3510
3393
|
flag = 1;
|
3511
|
-
break;
|
3394
|
+
break;
|
3512
3395
|
case 5:
|
3513
3396
|
CHECK_MATRIX(argv[2]);
|
3514
3397
|
CHECK_MATRIX(argv[3]);
|
@@ -3523,17 +3406,17 @@ static VALUE rb_gsl_linalg_hesstri_decomp(int argc, VALUE *argv, VALUE module)
|
|
3523
3406
|
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 2-55)", argc);
|
3524
3407
|
}
|
3525
3408
|
CHECK_MATRIX(argv[0]);
|
3526
|
-
CHECK_MATRIX(argv[1]);
|
3409
|
+
CHECK_MATRIX(argv[1]);
|
3527
3410
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
3528
3411
|
Data_Get_Struct(argv[1], gsl_matrix, B);
|
3529
3412
|
Anew = make_matrix_clone(A);
|
3530
|
-
Bnew = make_matrix_clone(B);
|
3413
|
+
Bnew = make_matrix_clone(B);
|
3531
3414
|
if (flag == 1) work = gsl_vector_alloc(A->size1);
|
3532
3415
|
gsl_linalg_hesstri_decomp(Anew, Bnew, U, V, work);
|
3533
3416
|
if (flag == 1) gsl_vector_free(work);
|
3534
3417
|
vH = Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, Anew);
|
3535
|
-
vR = Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, Bnew);
|
3536
|
-
if (argc == 2 || argc == 3) {
|
3418
|
+
vR = Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, Bnew);
|
3419
|
+
if (argc == 2 || argc == 3) {
|
3537
3420
|
ary = rb_ary_new3(2, vH, vR);
|
3538
3421
|
} else {
|
3539
3422
|
ary = rb_ary_new3(4, vH, vR, vU, vV);
|
@@ -3553,7 +3436,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp_bang(int argc, VALUE *argv, VALUE modu
|
|
3553
3436
|
break;
|
3554
3437
|
case 3:
|
3555
3438
|
CHECK_VECTOR(argv[2]);
|
3556
|
-
Data_Get_Struct(argv[2], gsl_vector, work);
|
3439
|
+
Data_Get_Struct(argv[2], gsl_vector, work);
|
3557
3440
|
break;
|
3558
3441
|
case 4:
|
3559
3442
|
CHECK_MATRIX(argv[2]);
|
@@ -3561,7 +3444,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp_bang(int argc, VALUE *argv, VALUE modu
|
|
3561
3444
|
Data_Get_Struct(argv[2], gsl_matrix, U);
|
3562
3445
|
Data_Get_Struct(argv[3], gsl_matrix, V);
|
3563
3446
|
flag = 1;
|
3564
|
-
break;
|
3447
|
+
break;
|
3565
3448
|
case 5:
|
3566
3449
|
CHECK_MATRIX(argv[2]);
|
3567
3450
|
CHECK_MATRIX(argv[3]);
|
@@ -3576,7 +3459,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp_bang(int argc, VALUE *argv, VALUE modu
|
|
3576
3459
|
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 2-55)", argc);
|
3577
3460
|
}
|
3578
3461
|
CHECK_MATRIX(argv[0]);
|
3579
|
-
CHECK_MATRIX(argv[1]);
|
3462
|
+
CHECK_MATRIX(argv[1]);
|
3580
3463
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
3581
3464
|
Data_Get_Struct(argv[1], gsl_matrix, B);
|
3582
3465
|
if (flag == 1) work = gsl_vector_alloc(A->size1);
|
@@ -3584,7 +3467,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp_bang(int argc, VALUE *argv, VALUE modu
|
|
3584
3467
|
if (flag == 1) gsl_vector_free(work);
|
3585
3468
|
vH = argv[0];
|
3586
3469
|
vR = argv[1];
|
3587
|
-
if (argc == 2 || argc == 3) {
|
3470
|
+
if (argc == 2 || argc == 3) {
|
3588
3471
|
ary = rb_ary_new3(2, vH, vR);
|
3589
3472
|
} else {
|
3590
3473
|
ary = rb_ary_new3(4, vH, vR, vU, vV);
|
@@ -3610,7 +3493,7 @@ static VALUE rb_gsl_linalg_balance_matrix(int argc, VALUE *argv, VALUE module)
|
|
3610
3493
|
CHECK_VECTOR(argv[1]);
|
3611
3494
|
Data_Get_Struct(argv[0], gsl_matrix, A);
|
3612
3495
|
Data_Get_Struct(argv[1], gsl_vector, D);
|
3613
|
-
Anew = make_matrix_clone(A);
|
3496
|
+
Anew = make_matrix_clone(A);
|
3614
3497
|
vD = argv[1];
|
3615
3498
|
break;
|
3616
3499
|
default:
|
@@ -3645,7 +3528,6 @@ static VALUE rb_gsl_linalg_balance_matrix2(int argc, VALUE *argv, VALUE module)
|
|
3645
3528
|
}
|
3646
3529
|
return Qtrue;
|
3647
3530
|
}
|
3648
|
-
#endif
|
3649
3531
|
|
3650
3532
|
void Init_gsl_linalg_complex(VALUE module);
|
3651
3533
|
void Init_gsl_linalg(VALUE module)
|
@@ -3664,9 +3546,7 @@ void Init_gsl_linalg(VALUE module)
|
|
3664
3546
|
VALUE mgsl_linalg_tridiag;
|
3665
3547
|
VALUE mgsl_linalg_HH;
|
3666
3548
|
VALUE mgsl_linalg_Householder;
|
3667
|
-
#ifdef GSL_1_9_LATER
|
3668
3549
|
VALUE mhessen;
|
3669
|
-
#endif
|
3670
3550
|
|
3671
3551
|
mgsl_linalg = rb_define_module_under(module, "Linalg");
|
3672
3552
|
mgsl_linalg_LU = rb_define_module_under(mgsl_linalg, "LU");
|
@@ -3769,7 +3649,7 @@ void Init_gsl_linalg(VALUE module)
|
|
3769
3649
|
|
3770
3650
|
rb_define_module_function(mgsl_linalg_QR, "QTvec", rb_gsl_linalg_QR_QTvec, -1);
|
3771
3651
|
rb_define_method(cgsl_matrix_QR, "QTvec", rb_gsl_linalg_QR_QTvec, -1);
|
3772
|
-
|
3652
|
+
rb_define_module_function(mgsl_linalg_QR, "Qvec", rb_gsl_linalg_QR_Qvec, -1);
|
3773
3653
|
rb_define_method(cgsl_matrix_QR, "Qvec", rb_gsl_linalg_QR_Qvec, -1);
|
3774
3654
|
|
3775
3655
|
rb_define_module_function(mgsl_linalg_QR, "Rsolve", rb_gsl_linalg_QR_Rsolve, -1);
|
@@ -3795,7 +3675,7 @@ void Init_gsl_linalg(VALUE module)
|
|
3795
3675
|
rb_define_module_function(mgsl_linalg_QRPT, "decomp!", rb_gsl_linalg_QRPT_decomp_bang, -1);
|
3796
3676
|
rb_define_method(cgsl_matrix, "QRPT_decomp!", rb_gsl_linalg_QRPT_decomp_bang, -1);
|
3797
3677
|
|
3798
|
-
|
3678
|
+
rb_define_module_function(mgsl_linalg_QRPT, "decomp2", rb_gsl_linalg_QRPT_decomp2, -1);
|
3799
3679
|
rb_define_method(cgsl_matrix, "QRPT_decomp2", rb_gsl_linalg_QRPT_decomp2, -1);
|
3800
3680
|
|
3801
3681
|
rb_define_module_function(mgsl_linalg_QRPT, "solve", rb_gsl_linalg_QRPT_solve, -1);
|
@@ -3854,9 +3734,9 @@ void Init_gsl_linalg(VALUE module)
|
|
3854
3734
|
/*****/
|
3855
3735
|
rb_define_module_function(mgsl_linalg_hermtd, "decomp", rb_gsl_linalg_hermtd_decomp, -1);
|
3856
3736
|
rb_define_method(cgsl_matrix, "hermtd_decomp", rb_gsl_linalg_hermtd_decomp, -1);
|
3857
|
-
|
3737
|
+
rb_define_module_function(mgsl_linalg_hermtd, "decomp!", rb_gsl_linalg_hermtd_decomp2, -1);
|
3858
3738
|
rb_define_method(cgsl_matrix, "hermtd_decomp!", rb_gsl_linalg_hermtd_decomp2, -1);
|
3859
|
-
|
3739
|
+
|
3860
3740
|
rb_define_method(cgsl_matrix_complex, "hermtd_unpack", rb_gsl_linalg_hermtd_unpack, -1);
|
3861
3741
|
rb_define_module_function(mgsl_linalg_hermtd, "unpack", rb_gsl_linalg_hermtd_unpack, -1);
|
3862
3742
|
rb_define_method(cgsl_matrix_complex, "hermtd_unpack_T", rb_gsl_linalg_hermtd_unpack_T, -1);
|
@@ -3882,35 +3762,35 @@ void Init_gsl_linalg(VALUE module)
|
|
3882
3762
|
rb_define_module_function(mgsl_linalg, "bidiag_unpack_B", rb_gsl_linalg_bidiag_unpack_B, -1);
|
3883
3763
|
rb_define_module_function(mgsl_linalg_bidiag, "unpack_B", rb_gsl_linalg_bidiag_unpack_B, -1);
|
3884
3764
|
/*****/
|
3885
|
-
rb_define_module_function(mgsl_linalg, "householder_transform",
|
3886
|
-
|
3887
|
-
rb_define_module_function(mgsl_linalg_Householder, "transform",
|
3888
|
-
|
3889
|
-
rb_define_module_function(mgsl_linalg_HH, "transform",
|
3890
|
-
|
3891
|
-
rb_define_method(cgsl_vector, "householder_transform",
|
3892
|
-
|
3893
|
-
|
3894
|
-
rb_define_module_function(mgsl_linalg, "householder_hm",
|
3895
|
-
|
3896
|
-
rb_define_module_function(mgsl_linalg_Householder, "hm",
|
3897
|
-
|
3898
|
-
rb_define_module_function(mgsl_linalg_HH, "hm",
|
3899
|
-
|
3900
|
-
|
3901
|
-
rb_define_module_function(mgsl_linalg, "householder_mh",
|
3902
|
-
|
3903
|
-
rb_define_module_function(mgsl_linalg_Householder, "mh",
|
3904
|
-
|
3905
|
-
rb_define_module_function(mgsl_linalg_HH, "mh",
|
3906
|
-
|
3907
|
-
|
3908
|
-
rb_define_module_function(mgsl_linalg, "householder_hv",
|
3909
|
-
|
3910
|
-
rb_define_module_function(mgsl_linalg_Householder, "hv",
|
3911
|
-
|
3912
|
-
rb_define_module_function(mgsl_linalg_HH, "hv",
|
3913
|
-
|
3765
|
+
rb_define_module_function(mgsl_linalg, "householder_transform",
|
3766
|
+
rb_gsl_linalg_householder_transform, -1);
|
3767
|
+
rb_define_module_function(mgsl_linalg_Householder, "transform",
|
3768
|
+
rb_gsl_linalg_householder_transform, -1);
|
3769
|
+
rb_define_module_function(mgsl_linalg_HH, "transform",
|
3770
|
+
rb_gsl_linalg_householder_transform, -1);
|
3771
|
+
rb_define_method(cgsl_vector, "householder_transform",
|
3772
|
+
rb_gsl_linalg_householder_transform, -1);
|
3773
|
+
|
3774
|
+
rb_define_module_function(mgsl_linalg, "householder_hm",
|
3775
|
+
rb_gsl_linalg_householder_hm, 3);
|
3776
|
+
rb_define_module_function(mgsl_linalg_Householder, "hm",
|
3777
|
+
rb_gsl_linalg_householder_hm, 3);
|
3778
|
+
rb_define_module_function(mgsl_linalg_HH, "hm",
|
3779
|
+
rb_gsl_linalg_householder_hm, 3);
|
3780
|
+
|
3781
|
+
rb_define_module_function(mgsl_linalg, "householder_mh",
|
3782
|
+
rb_gsl_linalg_householder_mh, 3);
|
3783
|
+
rb_define_module_function(mgsl_linalg_Householder, "mh",
|
3784
|
+
rb_gsl_linalg_householder_mh, 3);
|
3785
|
+
rb_define_module_function(mgsl_linalg_HH, "mh",
|
3786
|
+
rb_gsl_linalg_householder_mh, 3);
|
3787
|
+
|
3788
|
+
rb_define_module_function(mgsl_linalg, "householder_hv",
|
3789
|
+
rb_gsl_linalg_householder_hv, 3);
|
3790
|
+
rb_define_module_function(mgsl_linalg_Householder, "hv",
|
3791
|
+
rb_gsl_linalg_householder_hv, 3);
|
3792
|
+
rb_define_module_function(mgsl_linalg_HH, "hv",
|
3793
|
+
rb_gsl_linalg_householder_hv, 3);
|
3914
3794
|
|
3915
3795
|
rb_define_module_function(mgsl_linalg_HH, "solve", rb_gsl_linalg_HH_solve, -1);
|
3916
3796
|
rb_define_module_function(mgsl_linalg_HH, "solve!", rb_gsl_linalg_HH_solve_bang, -1);
|
@@ -3925,32 +3805,29 @@ void Init_gsl_linalg(VALUE module)
|
|
3925
3805
|
|
3926
3806
|
rb_define_module_function(mgsl_linalg_tridiag, "solve_symm", rb_gsl_linalg_solve_symm_tridiag, 3);
|
3927
3807
|
|
3928
|
-
#ifdef GSL_1_2_LATER
|
3929
3808
|
rb_define_module_function(mgsl_linalg, "solve_tridiag", rb_gsl_linalg_solve_tridiag, 4);
|
3930
3809
|
rb_define_module_function(mgsl_linalg_tridiag, "solve", rb_gsl_linalg_solve_tridiag, 4);
|
3931
3810
|
rb_define_module_function(mgsl_linalg, "solve_symm_cyc_tridiag", rb_gsl_linalg_solve_symm_cyc_tridiag, 3);
|
3932
3811
|
rb_define_module_function(mgsl_linalg, "solve_cyc_tridiag", rb_gsl_linalg_solve_cyc_tridiag, 4);
|
3933
3812
|
rb_define_module_function(mgsl_linalg_tridiag, "solve_symm_cyc", rb_gsl_linalg_solve_symm_cyc_tridiag, 3);
|
3934
3813
|
rb_define_module_function(mgsl_linalg_tridiag, "solve_cyc", rb_gsl_linalg_solve_cyc_tridiag, 4);
|
3935
|
-
#endif
|
3936
3814
|
|
3937
3815
|
/*****/
|
3938
|
-
rb_define_module_function(mgsl_linalg, "balance_columns!",
|
3939
|
-
|
3940
|
-
rb_define_method(cgsl_matrix, "balance_columns!",
|
3941
|
-
|
3942
|
-
rb_define_module_function(mgsl_linalg, "balance_columns",
|
3943
|
-
|
3944
|
-
rb_define_method(cgsl_matrix, "balance_columns",
|
3945
|
-
|
3816
|
+
rb_define_module_function(mgsl_linalg, "balance_columns!",
|
3817
|
+
rb_gsl_linalg_balance_columns_bang, -1);
|
3818
|
+
rb_define_method(cgsl_matrix, "balance_columns!",
|
3819
|
+
rb_gsl_linalg_balance_columns_bang, -1);
|
3820
|
+
rb_define_module_function(mgsl_linalg, "balance_columns",
|
3821
|
+
rb_gsl_linalg_balance_columns, -1);
|
3822
|
+
rb_define_method(cgsl_matrix, "balance_columns",
|
3823
|
+
rb_gsl_linalg_balance_columns, -1);
|
3946
3824
|
rb_define_alias(cgsl_matrix, "balance", "balance_columns");
|
3947
3825
|
rb_define_alias(cgsl_matrix, "balanc", "balance_columns");
|
3948
3826
|
/*****/
|
3949
3827
|
|
3950
|
-
Init_gsl_linalg_complex(mgsl_linalg);
|
3828
|
+
Init_gsl_linalg_complex(mgsl_linalg);
|
3951
3829
|
|
3952
3830
|
/** GSL-1.6 **/
|
3953
|
-
#ifdef GSL_1_6_LATER
|
3954
3831
|
rb_define_module_function(mgsl_linalg, "LQ_decomp", rb_gsl_linalg_LQ_decomp, -1);
|
3955
3832
|
rb_define_module_function(mgsl_linalg_LQ, "decomp", rb_gsl_linalg_LQ_decomp, -1);
|
3956
3833
|
rb_define_method(cgsl_matrix, "LQ_decomp", rb_gsl_linalg_LQ_decomp, -1);
|
@@ -3999,7 +3876,7 @@ void Init_gsl_linalg(VALUE module)
|
|
3999
3876
|
rb_define_module_function(mgsl_linalg_PTLQ, "decomp!", rb_gsl_linalg_PTLQ_decomp_bang, -1);
|
4000
3877
|
rb_define_method(cgsl_matrix, "PTLQ_decomp!", rb_gsl_linalg_PTLQ_decomp_bang, -1);
|
4001
3878
|
|
4002
|
-
|
3879
|
+
rb_define_module_function(mgsl_linalg_PTLQ, "decomp2", rb_gsl_linalg_PTLQ_decomp2, -1);
|
4003
3880
|
rb_define_method(cgsl_matrix, "PTLQ_decomp2", rb_gsl_linalg_PTLQ_decomp2, -1);
|
4004
3881
|
|
4005
3882
|
rb_define_module_function(mgsl_linalg_PTLQ, "solve_T", rb_gsl_linalg_PTLQ_solve, -1);
|
@@ -4018,26 +3895,21 @@ void Init_gsl_linalg(VALUE module)
|
|
4018
3895
|
rb_define_module_function(mgsl_linalg_PTLQ, "Lsvx_T", rb_gsl_linalg_PTLQ_Lsvx, -1);
|
4019
3896
|
rb_define_method(cgsl_matrix_PTLQ, "Lsvx_T", rb_gsl_linalg_PTLQ_Lsvx, -1);
|
4020
3897
|
|
4021
|
-
#endif
|
4022
|
-
|
4023
|
-
#ifdef GSL_1_9_LATER
|
4024
3898
|
mhessen = rb_define_module_under(mgsl_linalg, "Hessenberg");
|
4025
3899
|
rb_define_module_function(mhessen, "decomp", rb_gsl_linalg_hessenberg_decomp, 1);
|
4026
|
-
rb_define_module_function(mgsl_linalg, "heesenberg_decomp", rb_gsl_linalg_hessenberg_decomp, 1);
|
4027
|
-
rb_define_module_function(mhessen, "unpack", rb_gsl_linalg_hessenberg_unpack, 2);
|
4028
|
-
rb_define_module_function(mgsl_linalg, "hessenberg_unpack", rb_gsl_linalg_hessenberg_unpack, 2);
|
4029
|
-
rb_define_module_function(mhessen, "unpack_accum", rb_gsl_linalg_hessenberg_unpack_accum, -1);
|
4030
|
-
rb_define_module_function(mgsl_linalg, "hessenberg_unpack_accum", rb_gsl_linalg_hessenberg_unpack_accum, -1);
|
4031
|
-
rb_define_module_function(mhessen, "set_zero", rb_gsl_linalg_hessenberg_set_zero, 1);
|
4032
|
-
rb_define_module_function(mgsl_linalg, "hessenberg_set_zero", rb_gsl_linalg_hessenberg_set_zero, 1);
|
4033
|
-
|
3900
|
+
rb_define_module_function(mgsl_linalg, "heesenberg_decomp", rb_gsl_linalg_hessenberg_decomp, 1);
|
3901
|
+
rb_define_module_function(mhessen, "unpack", rb_gsl_linalg_hessenberg_unpack, 2);
|
3902
|
+
rb_define_module_function(mgsl_linalg, "hessenberg_unpack", rb_gsl_linalg_hessenberg_unpack, 2);
|
3903
|
+
rb_define_module_function(mhessen, "unpack_accum", rb_gsl_linalg_hessenberg_unpack_accum, -1);
|
3904
|
+
rb_define_module_function(mgsl_linalg, "hessenberg_unpack_accum", rb_gsl_linalg_hessenberg_unpack_accum, -1);
|
3905
|
+
rb_define_module_function(mhessen, "set_zero", rb_gsl_linalg_hessenberg_set_zero, 1);
|
3906
|
+
rb_define_module_function(mgsl_linalg, "hessenberg_set_zero", rb_gsl_linalg_hessenberg_set_zero, 1);
|
3907
|
+
|
4034
3908
|
rb_define_module_function(mgsl_linalg, "hesstri_decomp", rb_gsl_linalg_hesstri_decomp, -1);
|
4035
3909
|
rb_define_module_function(mgsl_linalg, "hesstri_decomp!", rb_gsl_linalg_hesstri_decomp_bang, -1);
|
4036
|
-
|
4037
|
-
rb_define_module_function(mgsl_linalg, "balance_matrix", rb_gsl_linalg_balance_matrix, -1);
|
4038
|
-
rb_define_module_function(mgsl_linalg, "balance_matrix!", rb_gsl_linalg_balance_matrix2, -1);
|
4039
|
-
rb_define_module_function(mgsl_linalg, "balance", rb_gsl_linalg_balance_matrix, -1);
|
4040
|
-
rb_define_module_function(mgsl_linalg, "balance!", rb_gsl_linalg_balance_matrix2, -1);
|
4041
|
-
#endif
|
4042
3910
|
|
3911
|
+
rb_define_module_function(mgsl_linalg, "balance_matrix", rb_gsl_linalg_balance_matrix, -1);
|
3912
|
+
rb_define_module_function(mgsl_linalg, "balance_matrix!", rb_gsl_linalg_balance_matrix2, -1);
|
3913
|
+
rb_define_module_function(mgsl_linalg, "balance", rb_gsl_linalg_balance_matrix, -1);
|
3914
|
+
rb_define_module_function(mgsl_linalg, "balance!", rb_gsl_linalg_balance_matrix2, -1);
|
4043
3915
|
}
|