rb-gsl 1.15.3.1 → 1.15.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHORS +2 -2
  3. data/ChangeLog +8 -0
  4. data/Rakefile +39 -96
  5. data/VERSION +1 -1
  6. data/ext/array.c +2 -2
  7. data/ext/block_source.c +1 -1
  8. data/ext/dirac.c +1 -1
  9. data/ext/eigen.c +13 -13
  10. data/ext/extconf.rb +17 -11
  11. data/ext/function.c +5 -5
  12. data/ext/gsl_narray.c +6 -6
  13. data/ext/histogram.c +7 -6
  14. data/ext/histogram2d.c +4 -4
  15. data/ext/interp.c +1 -1
  16. data/ext/linalg.c +13 -11
  17. data/ext/linalg_complex.c +8 -6
  18. data/ext/math.c +1 -1
  19. data/ext/matrix_complex.c +6 -6
  20. data/ext/matrix_source.c +10 -10
  21. data/ext/monte.c +2 -2
  22. data/ext/multimin.c +4 -4
  23. data/ext/multiroots.c +8 -8
  24. data/ext/nmf.c +6 -6
  25. data/ext/ntuple.c +4 -4
  26. data/ext/odeiv.c +2 -2
  27. data/ext/permutation.c +1 -1
  28. data/ext/poly2.c +6 -6
  29. data/ext/poly_source.c +9 -6
  30. data/ext/sf.c +31 -45
  31. data/ext/signal.c +2 -2
  32. data/ext/vector_complex.c +11 -10
  33. data/ext/vector_double.c +7 -4
  34. data/ext/vector_source.c +29 -26
  35. data/ext/wavelet.c +1 -1
  36. data/include/rb_gsl_common.h +12 -0
  37. data/include/rb_gsl_config.h +10 -1
  38. data/rdoc/blas.rdoc +4 -4
  39. data/rdoc/bspline.rdoc +8 -8
  40. data/rdoc/cheb.rdoc +9 -9
  41. data/rdoc/cholesky_complex.rdoc +1 -1
  42. data/rdoc/combi.rdoc +10 -10
  43. data/rdoc/complex.rdoc +12 -12
  44. data/rdoc/const.rdoc +21 -21
  45. data/rdoc/dht.rdoc +7 -7
  46. data/rdoc/diff.rdoc +7 -7
  47. data/rdoc/ehandling.rdoc +4 -4
  48. data/rdoc/eigen.rdoc +12 -12
  49. data/rdoc/fft.rdoc +27 -27
  50. data/rdoc/fit.rdoc +19 -19
  51. data/rdoc/function.rdoc +1 -1
  52. data/rdoc/graph.rdoc +3 -3
  53. data/rdoc/hist.rdoc +17 -17
  54. data/rdoc/hist2d.rdoc +5 -5
  55. data/rdoc/hist3d.rdoc +4 -4
  56. data/rdoc/index.rdoc +4 -4
  57. data/rdoc/integration.rdoc +17 -17
  58. data/rdoc/interp.rdoc +12 -12
  59. data/rdoc/intro.rdoc +4 -4
  60. data/rdoc/linalg.rdoc +21 -21
  61. data/rdoc/linalg_complex.rdoc +1 -1
  62. data/rdoc/math.rdoc +14 -14
  63. data/rdoc/matrix.rdoc +21 -21
  64. data/rdoc/min.rdoc +10 -10
  65. data/rdoc/monte.rdoc +4 -4
  66. data/rdoc/multimin.rdoc +13 -13
  67. data/rdoc/multiroot.rdoc +13 -13
  68. data/rdoc/narray.rdoc +10 -10
  69. data/rdoc/ndlinear.rdoc +5 -5
  70. data/rdoc/nonlinearfit.rdoc +18 -18
  71. data/rdoc/ntuple.rdoc +6 -6
  72. data/rdoc/odeiv.rdoc +13 -13
  73. data/rdoc/perm.rdoc +12 -12
  74. data/rdoc/poly.rdoc +18 -18
  75. data/rdoc/qrng.rdoc +10 -10
  76. data/rdoc/randist.rdoc +11 -11
  77. data/rdoc/ref.rdoc +50 -50
  78. data/rdoc/rng.rdoc +10 -10
  79. data/rdoc/rngextra.rdoc +5 -5
  80. data/rdoc/roots.rdoc +13 -13
  81. data/rdoc/sf.rdoc +36 -36
  82. data/rdoc/siman.rdoc +4 -4
  83. data/rdoc/sort.rdoc +7 -7
  84. data/rdoc/start.rdoc +1 -1
  85. data/rdoc/stats.rdoc +14 -14
  86. data/rdoc/sum.rdoc +5 -5
  87. data/rdoc/tensor.rdoc +4 -4
  88. data/rdoc/tut.rdoc +1 -1
  89. data/rdoc/use.rdoc +5 -5
  90. data/rdoc/vector.rdoc +29 -29
  91. data/rdoc/vector_complex.rdoc +6 -6
  92. data/rdoc/wavelet.rdoc +9 -9
  93. data/test/gsl/blas_test.rb +79 -0
  94. data/test/gsl/bspline_test.rb +63 -0
  95. data/test/gsl/cdf_test.rb +1512 -0
  96. data/test/gsl/cheb_test.rb +80 -0
  97. data/test/gsl/combination_test.rb +100 -0
  98. data/test/gsl/complex_test.rb +20 -0
  99. data/test/gsl/const_test.rb +29 -0
  100. data/test/gsl/deriv_test.rb +62 -0
  101. data/test/gsl/dht_test.rb +79 -0
  102. data/test/gsl/diff_test.rb +53 -0
  103. data/test/gsl/eigen_test.rb +563 -0
  104. data/test/gsl/err_test.rb +23 -0
  105. data/test/gsl/fit_test.rb +101 -0
  106. data/test/gsl/histo_test.rb +14 -0
  107. data/test/gsl/integration_test.rb +274 -0
  108. data/test/gsl/interp_test.rb +27 -0
  109. data/test/gsl/linalg_test.rb +463 -0
  110. data/test/gsl/matrix_nmf_test.rb +37 -0
  111. data/test/gsl/matrix_test.rb +77 -0
  112. data/test/gsl/min_test.rb +89 -0
  113. data/test/gsl/monte_test.rb +77 -0
  114. data/test/gsl/multifit_test.rb +753 -0
  115. data/test/gsl/multimin_test.rb +157 -0
  116. data/test/gsl/multiroot_test.rb +135 -0
  117. data/test/gsl/multiset_test.rb +52 -0
  118. data/test/gsl/odeiv_test.rb +275 -0
  119. data/test/gsl/poly_test.rb +338 -0
  120. data/test/gsl/qrng_test.rb +94 -0
  121. data/test/gsl/quartic_test.rb +28 -0
  122. data/test/gsl/randist_test.rb +122 -0
  123. data/test/gsl/rng_test.rb +303 -0
  124. data/test/gsl/roots_test.rb +78 -0
  125. data/test/gsl/sf_test.rb +2079 -0
  126. data/test/gsl/stats_test.rb +122 -0
  127. data/test/gsl/sum_test.rb +69 -0
  128. data/test/gsl/tensor_test.rb +396 -0
  129. data/test/gsl/vector_test.rb +223 -0
  130. data/test/gsl/wavelet_test.rb +130 -0
  131. data/test/gsl_test.rb +321 -0
  132. data/test/test_helper.rb +42 -0
  133. metadata +107 -150
  134. data/setup.rb +0 -1585
  135. data/tests/blas/amax.rb +0 -14
  136. data/tests/blas/asum.rb +0 -16
  137. data/tests/blas/axpy.rb +0 -25
  138. data/tests/blas/copy.rb +0 -23
  139. data/tests/blas/dot.rb +0 -23
  140. data/tests/bspline.rb +0 -53
  141. data/tests/cdf.rb +0 -1388
  142. data/tests/cheb.rb +0 -112
  143. data/tests/combination.rb +0 -123
  144. data/tests/complex.rb +0 -17
  145. data/tests/const.rb +0 -24
  146. data/tests/deriv.rb +0 -85
  147. data/tests/dht/dht1.rb +0 -17
  148. data/tests/dht/dht2.rb +0 -23
  149. data/tests/dht/dht3.rb +0 -23
  150. data/tests/dht/dht4.rb +0 -23
  151. data/tests/diff.rb +0 -78
  152. data/tests/eigen/eigen.rb +0 -220
  153. data/tests/eigen/gen.rb +0 -105
  154. data/tests/eigen/genherm.rb +0 -66
  155. data/tests/eigen/gensymm.rb +0 -68
  156. data/tests/eigen/nonsymm.rb +0 -53
  157. data/tests/eigen/nonsymmv.rb +0 -53
  158. data/tests/eigen/symm-herm.rb +0 -74
  159. data/tests/err.rb +0 -58
  160. data/tests/fit.rb +0 -124
  161. data/tests/gsl_test.rb +0 -118
  162. data/tests/gsl_test2.rb +0 -110
  163. data/tests/histo.rb +0 -12
  164. data/tests/integration/integration1.rb +0 -72
  165. data/tests/integration/integration2.rb +0 -71
  166. data/tests/integration/integration3.rb +0 -71
  167. data/tests/integration/integration4.rb +0 -71
  168. data/tests/interp.rb +0 -45
  169. data/tests/linalg/HH.rb +0 -64
  170. data/tests/linalg/LU.rb +0 -47
  171. data/tests/linalg/QR.rb +0 -77
  172. data/tests/linalg/SV.rb +0 -24
  173. data/tests/linalg/TDN.rb +0 -116
  174. data/tests/linalg/TDS.rb +0 -122
  175. data/tests/linalg/bidiag.rb +0 -73
  176. data/tests/linalg/cholesky.rb +0 -20
  177. data/tests/linalg/linalg.rb +0 -158
  178. data/tests/matrix/matrix_complex_test.rb +0 -36
  179. data/tests/matrix/matrix_nmf_test.rb +0 -39
  180. data/tests/matrix/matrix_test.rb +0 -48
  181. data/tests/min.rb +0 -99
  182. data/tests/monte/miser.rb +0 -31
  183. data/tests/monte/vegas.rb +0 -45
  184. data/tests/multifit/test_2dgauss.rb +0 -112
  185. data/tests/multifit/test_brown.rb +0 -90
  186. data/tests/multifit/test_enso.rb +0 -246
  187. data/tests/multifit/test_filip.rb +0 -155
  188. data/tests/multifit/test_gauss.rb +0 -97
  189. data/tests/multifit/test_longley.rb +0 -110
  190. data/tests/multifit/test_multifit.rb +0 -52
  191. data/tests/multimin.rb +0 -139
  192. data/tests/multiroot.rb +0 -131
  193. data/tests/multiset.rb +0 -52
  194. data/tests/narray/blas_dnrm2.rb +0 -20
  195. data/tests/odeiv.rb +0 -353
  196. data/tests/poly/poly.rb +0 -290
  197. data/tests/poly/special.rb +0 -65
  198. data/tests/qrng.rb +0 -131
  199. data/tests/quartic.rb +0 -29
  200. data/tests/randist.rb +0 -134
  201. data/tests/rng.rb +0 -305
  202. data/tests/roots.rb +0 -76
  203. data/tests/run-test.sh +0 -17
  204. data/tests/sf/gsl_test_sf.rb +0 -249
  205. data/tests/sf/test_airy.rb +0 -83
  206. data/tests/sf/test_bessel.rb +0 -306
  207. data/tests/sf/test_coulomb.rb +0 -17
  208. data/tests/sf/test_dilog.rb +0 -25
  209. data/tests/sf/test_gamma.rb +0 -209
  210. data/tests/sf/test_hyperg.rb +0 -356
  211. data/tests/sf/test_legendre.rb +0 -227
  212. data/tests/sf/test_mathieu.rb +0 -59
  213. data/tests/sf/test_mode.rb +0 -19
  214. data/tests/sf/test_sf.rb +0 -839
  215. data/tests/stats.rb +0 -174
  216. data/tests/stats_mt.rb +0 -16
  217. data/tests/sum.rb +0 -98
  218. data/tests/sys.rb +0 -323
  219. data/tests/tensor.rb +0 -419
  220. data/tests/vector/vector_complex_test.rb +0 -101
  221. data/tests/vector/vector_test.rb +0 -141
  222. data/tests/wavelet.rb +0 -142
@@ -118,7 +118,8 @@ static VALUE rb_gsl_histogram_alloc_from_file(VALUE klass, VALUE name)
118
118
  sprintf(buf, "wc %s", filename);
119
119
  fp = popen(buf, "r");
120
120
  if (fp == NULL) rb_raise(rb_eIOError, "popen failed.");
121
- fgets(buf, 1024, fp);
121
+ if (fgets(buf, 1024, fp) == NULL)
122
+ rb_sys_fail(0);
122
123
  pclose(fp);
123
124
  sscanf(buf, "%d", &nn);
124
125
  n = (size_t) nn; /* vector length */
@@ -355,7 +356,7 @@ static VALUE rb_gsl_histogram_accumulate(int argc, VALUE *argv, VALUE obj)
355
356
  Data_Get_Struct(obj, gsl_histogram, h);
356
357
  if (TYPE(argv[0]) == T_ARRAY) {
357
358
  // for (i = 0; i < RARRAY(argv[0])->len; i++)
358
- for (i = 0; i < RARRAY_LEN(argv[0]); i++)
359
+ for (i = 0; (int) i < RARRAY_LEN(argv[0]); i++)
359
360
  gsl_histogram_accumulate(h, NUM2DBL(rb_ary_entry(argv[0], i)), weight);
360
361
  } else if (VECTOR_P(argv[0])) {
361
362
  Data_Get_Struct(argv[0], gsl_vector, v);
@@ -1556,13 +1557,13 @@ void mygsl_histogram_integrate(const gsl_histogram *h, gsl_histogram *hi,
1556
1557
  {
1557
1558
  size_t i;
1558
1559
  if (iend >= istart) {
1559
- if (istart < 0) istart = 0;
1560
+ //if (istart < 0) istart = 0;
1560
1561
  if (iend >= h->n) iend = h->n-1;
1561
1562
  hi->bin[istart] = h->bin[istart];
1562
1563
  for (i = istart+1; i <= iend; i++) hi->bin[i] = hi->bin[i-1] + h->bin[i];
1563
1564
  } else {
1564
1565
  if (istart >= h->n) istart = h->n-1;
1565
- if (iend < 0) iend = 0;
1566
+ //if (iend < 0) iend = 0;
1566
1567
  hi->bin[istart] = h->bin[istart];
1567
1568
  for (i = istart-1; i >= iend; i--) {
1568
1569
  hi->bin[i] = hi->bin[i+1] + h->bin[i];
@@ -1769,7 +1770,7 @@ static VALUE rb_gsl_histogram_reverse(VALUE obj)
1769
1770
  static double histogram_percentile(const gsl_histogram *h, double f)
1770
1771
  {
1771
1772
  double sum = gsl_histogram_sum(h), sf;
1772
- double val, s = 0, x;
1773
+ double val = 0, s = 0, x;
1773
1774
  double ri, ri1;
1774
1775
  size_t i;
1775
1776
  sf = sum * f;
@@ -1806,7 +1807,7 @@ static VALUE rb_gsl_histogram_median(VALUE obj)
1806
1807
  static double histogram_percentile_inv(const gsl_histogram *h, double x)
1807
1808
  {
1808
1809
  double sum = gsl_histogram_sum(h);
1809
- double val, s = 0;
1810
+ double val = 0, s = 0;
1810
1811
  double ri, ri1, q;
1811
1812
  size_t i;
1812
1813
 
@@ -857,17 +857,17 @@ static gsl_histogram2d* mygsl_histogram2d_calloc_integrate(const gsl_histogram2d
857
857
  if (flag == -1) {
858
858
  hi->bin[n-1] = h->bin[n-1];
859
859
  i = nx - 1;
860
- for (j = ny-2, k = 0; j >= 0; j--, k++) {
860
+ for (j = ny-2, k = 0;; j--, k++) {
861
861
  hi->bin[n-1-k] = gsl_histogram2d_get(hi, i, j+1) + gsl_histogram2d_get(h, i, j);
862
862
  if (j == 0) break;
863
863
  }
864
864
  j = ny - 1;
865
- for (i = nx-2; i >= 0; i--) {
865
+ for (i = nx-2;; i--) {
866
866
  hi->bin[i*ny + j] = gsl_histogram2d_get(hi, i+1, j) + gsl_histogram2d_get(h, i, j);
867
867
  if (i == 0) break;
868
868
  }
869
- for (i = nx-2; i >= 0; i--) {
870
- for (j = ny-2; j >= 0; j--) {
869
+ for (i = nx-2;; i--) {
870
+ for (j = ny-2;; j--) {
871
871
  hi->bin[i*ny+j] = ((gsl_histogram2d_get(hi, i+1, j)
872
872
  + gsl_histogram2d_get(hi, i, j+1))
873
873
  - gsl_histogram2d_get(hi, i+1, j+1))
@@ -220,7 +220,7 @@ static VALUE rb_gsl_interp_evaluate(VALUE obj, VALUE xxa, VALUE yya, VALUE xx,
220
220
  ptrz = (double*) na->ptr;
221
221
  ary = na_make_object(NA_DFLOAT, na->rank, na->shape, CLASS_OF(xx));
222
222
  ptr = NA_PTR_TYPE(ary, double*);
223
- for (i = 0; i < na->total; i++)
223
+ for (i = 0; (int) i < na->total; i++)
224
224
  ptr[i] = (*eval)(rgi->p, ptrx, ptry, ptrz[i], rgi->a);
225
225
  return ary;
226
226
  }
@@ -71,7 +71,7 @@ static VALUE rb_gsl_linalg_LU_decomposition(int argc, VALUE *argv, VALUE obj, in
71
71
  Data_Get_Struct(omatrix, gsl_matrix, mtmp);
72
72
  if (flag == LINALG_DECOMP_BANG) {
73
73
  m = mtmp;
74
- RBASIC(omatrix)->klass = cgsl_matrix_LU;
74
+ RBGSL_SET_CLASS(omatrix, cgsl_matrix_LU);
75
75
  objm = omatrix;
76
76
  } else {
77
77
  m = make_matrix_clone(mtmp);
@@ -692,7 +692,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
692
692
  fdecomp = &gsl_linalg_QR_decomp;
693
693
  m = mtmp;
694
694
  mdecomp = omatrix;
695
- RBASIC(mdecomp)->klass = cgsl_matrix_QR;
695
+ RBGSL_SET_CLASS(mdecomp, cgsl_matrix_QR);
696
696
  break;
697
697
  #ifdef GSL_1_6_LATER
698
698
  case LINALG_LQ_DECOMP:
@@ -704,7 +704,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
704
704
  fdecomp = &gsl_linalg_LQ_decomp;
705
705
  m = mtmp;
706
706
  mdecomp = omatrix;
707
- RBASIC(mdecomp)->klass = cgsl_matrix_LQ;
707
+ RBGSL_SET_CLASS(mdecomp, cgsl_matrix_LQ);
708
708
  break;
709
709
  #endif
710
710
  default:
@@ -731,7 +731,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
731
731
  vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
732
732
  return rb_ary_new3(2, mdecomp, vtau);
733
733
  } else {
734
- RBASIC(argv[itmp])->klass = cgsl_vector_tau;
734
+ RBGSL_SET_CLASS(argv[itmp], cgsl_vector_tau);
735
735
  return mdecomp;
736
736
  }
737
737
  break;
@@ -740,7 +740,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
740
740
  if (argc == itmp) {
741
741
  return Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
742
742
  } else {
743
- RBASIC(argv[itmp])->klass = cgsl_vector_tau;
743
+ RBGSL_SET_CLASS(argv[itmp], cgsl_vector_tau);
744
744
  return INT2FIX(status);
745
745
  }
746
746
  break;
@@ -1628,14 +1628,14 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp_bang(int argc, VALUE *argv, VALUE obj,
1628
1628
  norm = gsl_vector_alloc(size0);
1629
1629
  switch (flag) {
1630
1630
  case LINALG_QRPT:
1631
- RBASIC(vA)->klass = cgsl_matrix_QRPT;
1631
+ RBGSL_SET_CLASS(vA, cgsl_matrix_QRPT);
1632
1632
  vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
1633
1633
  vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
1634
1634
  gsl_linalg_QRPT_decomp(A, tau, p, &signum, norm);
1635
1635
  break;
1636
1636
  #ifdef GSL_1_6_LATER
1637
1637
  case LINALG_PTLQ:
1638
- RBASIC(vA)->klass = cgsl_matrix_PTLQ;
1638
+ RBGSL_SET_CLASS(vA, cgsl_matrix_PTLQ);
1639
1639
  vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
1640
1640
  vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
1641
1641
  gsl_linalg_PTLQ_decomp(A, tau, p, &signum, norm);
@@ -3454,7 +3454,7 @@ static VALUE rb_gsl_linalg_hessenberg_unpack_accum(int argc, VALUE *argv, VALUE
3454
3454
  gsl_matrix *H = NULL, *V = NULL;
3455
3455
  gsl_vector *tau = NULL;
3456
3456
  size_t i;
3457
- VALUE val;
3457
+ VALUE val = Qnil;
3458
3458
  switch (argc) {
3459
3459
  case 2:
3460
3460
  /* nothing to do */
@@ -3493,7 +3493,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp(int argc, VALUE *argv, VALUE module)
3493
3493
  gsl_matrix *A = NULL, *B = NULL, *Anew, *Bnew;
3494
3494
  gsl_matrix *U = NULL, *V = NULL;
3495
3495
  gsl_vector *work = NULL;
3496
- VALUE vH, vR, vU, vV, ary;
3496
+ VALUE vH, vR, vU = Qnil, vV = Qnil, ary;
3497
3497
  int flag = 0;
3498
3498
  switch (argc) {
3499
3499
  case 2:
@@ -3546,7 +3546,7 @@ static VALUE rb_gsl_linalg_hesstri_decomp_bang(int argc, VALUE *argv, VALUE modu
3546
3546
  gsl_matrix *A = NULL, *B = NULL;
3547
3547
  gsl_matrix *U = NULL, *V = NULL;
3548
3548
  gsl_vector *work = NULL;
3549
- VALUE vH, vR, vU, vV, ary;
3549
+ VALUE vH, vR, vU = Qnil, vV = Qnil, ary;
3550
3550
  int flag = 0;
3551
3551
  switch (argc) {
3552
3552
  case 2:
@@ -3665,6 +3665,9 @@ void Init_gsl_linalg(VALUE module)
3665
3665
  VALUE mgsl_linalg_tridiag;
3666
3666
  VALUE mgsl_linalg_HH;
3667
3667
  VALUE mgsl_linalg_Householder;
3668
+ #ifdef GSL_1_9_LATER
3669
+ VALUE mhessen;
3670
+ #endif
3668
3671
 
3669
3672
  mgsl_linalg = rb_define_module_under(module, "Linalg");
3670
3673
  mgsl_linalg_LU = rb_define_module_under(mgsl_linalg, "LU");
@@ -4019,7 +4022,6 @@ void Init_gsl_linalg(VALUE module)
4019
4022
  #endif
4020
4023
 
4021
4024
  #ifdef GSL_1_9_LATER
4022
- VALUE mhessen;
4023
4025
  mhessen = rb_define_module_under(mgsl_linalg, "Hessenberg");
4024
4026
  rb_define_module_function(mhessen, "decomp", rb_gsl_linalg_hessenberg_decomp, 1);
4025
4027
  rb_define_module_function(mgsl_linalg, "heesenberg_decomp", rb_gsl_linalg_hessenberg_decomp, 1);
@@ -51,8 +51,8 @@ VALUE rb_gsl_linalg_complex_LU_decomp(int argc, VALUE *argv, VALUE obj)
51
51
  case 0:
52
52
  p = gsl_permutation_alloc(size);
53
53
  gsl_linalg_complex_LU_decomp(m, p, &signum);
54
- if (itmp == 1) RBASIC(argv[0])->klass = cgsl_matrix_complex_LU;
55
- else RBASIC(obj)->klass = cgsl_matrix_complex_LU;
54
+ if (itmp == 1) RBGSL_SET_CLASS(argv[0], cgsl_matrix_complex_LU);
55
+ else RBGSL_SET_CLASS(obj, cgsl_matrix_complex_LU);
56
56
  obj2 = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
57
57
  return rb_ary_new3(2, obj2, INT2FIX(signum));
58
58
  break;
@@ -60,8 +60,8 @@ VALUE rb_gsl_linalg_complex_LU_decomp(int argc, VALUE *argv, VALUE obj)
60
60
  CHECK_PERMUTATION(argv[itmp]);
61
61
  Data_Get_Struct(argv[itmp], gsl_permutation, p);
62
62
  gsl_linalg_complex_LU_decomp(m, p, &signum);
63
- if (itmp == 1) RBASIC(argv[0])->klass = cgsl_matrix_complex_LU;
64
- else RBASIC(obj)->klass = cgsl_matrix_complex_LU;
63
+ if (itmp == 1) RBGSL_SET_CLASS(argv[0], cgsl_matrix_complex_LU);
64
+ else RBGSL_SET_CLASS(obj, cgsl_matrix_complex_LU);
65
65
  return INT2FIX(signum);
66
66
  break;
67
67
  default:
@@ -617,6 +617,9 @@ void Init_gsl_linalg_complex(VALUE module)
617
617
  {
618
618
  VALUE mgsl_linalg_complex;
619
619
  VALUE mgsl_linalg_complex_LU;
620
+ #ifdef GSL_1_10_LATER
621
+ VALUE mgsl_linalg_complex_chol, mgsl_linalg_complex_Householder;
622
+ #endif
620
623
 
621
624
  mgsl_linalg_complex = rb_define_module_under(module, "Complex");
622
625
  mgsl_linalg_complex_LU = rb_define_module_under(mgsl_linalg_complex, "LU");
@@ -701,7 +704,6 @@ void Init_gsl_linalg_complex(VALUE module)
701
704
  #endif
702
705
 
703
706
  #ifdef GSL_1_10_LATER
704
- VALUE mgsl_linalg_complex_chol;
705
707
  mgsl_linalg_complex_chol = rb_define_module_under(mgsl_linalg_complex, "Cholesky");
706
708
  cgsl_matrix_complex_C = rb_define_class_under(mgsl_linalg_complex_chol, "CholeskyMatrix", cgsl_matrix_complex);
707
709
  rb_define_singleton_method(mgsl_linalg_complex_chol, "decomp", rb_gsl_linalg_cholesky_decomp, -1);
@@ -713,7 +715,7 @@ void Init_gsl_linalg_complex(VALUE module)
713
715
  rb_define_method(cgsl_matrix_complex, "cholesky_svx", rb_gsl_linalg_cholesky_svx, -1);
714
716
  rb_define_method(cgsl_matrix_complex_C, "svx", rb_gsl_linalg_cholesky_svx, -1);
715
717
 
716
- VALUE mgsl_linalg_complex_Householder = rb_define_module_under(mgsl_linalg_complex, "Householder");
718
+ mgsl_linalg_complex_Householder = rb_define_module_under(mgsl_linalg_complex, "Householder");
717
719
  rb_define_singleton_method(mgsl_linalg_complex, "householder_transform",
718
720
  rb_gsl_linalg_complex_householder_transform, -1);
719
721
  rb_define_singleton_method(mgsl_linalg_complex_Householder, "transform",
data/ext/math.c CHANGED
@@ -213,7 +213,7 @@ static VALUE rb_gsl_math_eval2(double (*func)(const double, const double), VALUE
213
213
  Check_Type(yy, T_ARRAY);
214
214
  size = RARRAY_LEN(xx);
215
215
  // if (size != RARRAY(yy)->len) rb_raise(rb_eRuntimeError, "array sizes are different.");
216
- if (size != RARRAY_LEN(yy)) rb_raise(rb_eRuntimeError, "array sizes are different.");
216
+ if ((int) size != RARRAY_LEN(yy)) rb_raise(rb_eRuntimeError, "array sizes are different.");
217
217
  ary = rb_ary_new2(size);
218
218
  for (i = 0; i < size; i++) {
219
219
  x = rb_ary_entry(xx, i);
@@ -343,7 +343,7 @@ static VALUE rb_gsl_matrix_complex_set(int argc, VALUE *argv, VALUE obj)
343
343
  row_set_argv[0] = INT2FIX(0);
344
344
  row_set_argv[1] = INT2FIX(m->size2);
345
345
 
346
- for(k = 0; k < argc && k < m->size1; k++) {
346
+ for(k = 0; (int) k < argc && k < m->size1; k++) {
347
347
  vv = gsl_matrix_complex_row(m, k);
348
348
  rb_gsl_vector_complex_set_subvector(2, row_set_argv, &vv.vector, argv[k]);
349
349
  }
@@ -374,7 +374,7 @@ static VALUE rb_gsl_matrix_complex_set(int argc, VALUE *argv, VALUE obj)
374
374
  rb_gsl_vector_complex_set_subvector(2, row_set_argv, &vv.vector, other);
375
375
  } else {
376
376
  // m[...] = [[row0], [row1], ...] # multiple rows
377
- if(n1 != RARRAY_LEN(other)) {
377
+ if((int) n1 != RARRAY_LEN(other)) {
378
378
  rb_raise(rb_eRangeError, "row counts do not match (%d != %d)",
379
379
  (int) n1, (int) RARRAY_LEN(other));
380
380
  }
@@ -414,7 +414,7 @@ static VALUE rb_gsl_matrix_complex_set_row(int argc, VALUE *argv, VALUE obj)
414
414
  CHECK_FIXNUM(argv[0]);
415
415
  Data_Get_Struct(obj, gsl_matrix_complex, A);
416
416
  i = FIX2INT(argv[0]);
417
- for (k = 1; k < argc; k++) {
417
+ for (k = 1; (int) k < argc; k++) {
418
418
  if (k-1 >= A->size1) break;
419
419
  switch (TYPE(argv[k])) {
420
420
  case T_ARRAY:
@@ -442,7 +442,7 @@ static VALUE rb_gsl_matrix_complex_set_col(int argc, VALUE *argv, VALUE obj)
442
442
  Data_Get_Struct(obj, gsl_matrix_complex, A);
443
443
  j = FIX2INT(argv[0]);
444
444
  for (k = 1; k < argc; k++) {
445
- if (k-1 >= A->size2) break;
445
+ if (k-1 >= (int) A->size2) break;
446
446
  switch (TYPE(argv[k])) {
447
447
  case T_ARRAY:
448
448
  z = ary2complex(argv[k]);
@@ -632,13 +632,13 @@ static VALUE rb_gsl_matrix_complex_to_s(int argc, VALUE *argv, VALUE obj)
632
632
  "%s[ %4.3e %4.3e ]", (j==0) ? "" : " ", GSL_REAL(z), GSL_IMAG(z));
633
633
  rb_str_cat(str, buf, strlen(buf));
634
634
  // if too many cols
635
- if (j >= max_cols-1 && j != m->size2-1) {
635
+ if ((int) j >= max_cols-1 && j != m->size2-1) {
636
636
  rb_str_cat(str, " ...", 4);
637
637
  break;
638
638
  }
639
639
  }
640
640
  // if too many rows
641
- if (i >= max_rows-1 && i != m->size1-1) {
641
+ if ((int) i >= max_rows-1 && i != m->size1-1) {
642
642
  rb_str_cat(str, "\n ...", 6);
643
643
  break;
644
644
  }
@@ -349,7 +349,7 @@ static GSL_TYPE(gsl_matrix)* FUNCTION(cr_matrix,from_ranges)(int argc, VALUE *ar
349
349
  FUNCTION(get_range,beg_en_n)(argv[0], &beg, &en, &n, &step);
350
350
  m = FUNCTION(gsl_matrix,calloc)(argc, n);
351
351
  FUNCTION(set_ptr_data,by_range)(m->data, n, argv[0]);
352
- for (i = 1; i < argc; i++) {
352
+ for (i = 1; (int) i < argc; i++) {
353
353
  if (CLASS_OF(argv[i]) != rb_cRange)
354
354
  rb_raise(rb_eTypeError, "wrong argument type %s (Range expected)",
355
355
  rb_class2name(CLASS_OF(argv[i])));
@@ -392,11 +392,11 @@ GSL_TYPE(gsl_matrix)* FUNCTION(gsl_matrix,alloc_from_arrays)(int argc, VALUE *ar
392
392
  n = RARRAY_LEN(argv[0]);
393
393
  m = FUNCTION(gsl_matrix,alloc)(argc, n);
394
394
  if (m == NULL) rb_raise(rb_eNoMemError, "gsl_matrix_alloc failed");
395
- for (i = 0; i < argc; i++) {
395
+ for (i = 0; (int) i < argc; i++) {
396
396
  if (CLASS_OF(argv[i]) == rb_cRange) argv[i] = rb_gsl_range2ary(argv[i]);
397
397
  else Check_Type(argv[i], T_ARRAY);
398
398
  for (j = 0; j < n; j++) {
399
- if (j >= RARRAY_LEN(argv[i])) FUNCTION(gsl_matrix,set)(m, i, j, 0);
399
+ if ((int) j >= RARRAY_LEN(argv[i])) FUNCTION(gsl_matrix,set)(m, i, j, 0);
400
400
  else FUNCTION(gsl_matrix,set)(m, i, j, NUMCONV2(rb_ary_entry(argv[i], j)));
401
401
  }
402
402
  }
@@ -413,7 +413,7 @@ GSL_TYPE(gsl_matrix)* FUNCTION(gsl_matrix,alloc_from_vectors)(int argc, VALUE *a
413
413
  Data_Get_Struct(argv[0], GSL_TYPE(gsl_vector), v);
414
414
  m = FUNCTION(gsl_matrix,alloc)(argc, v->size);
415
415
  if (m == NULL) rb_raise(rb_eNoMemError, "gsl_matrix_alloc failed");
416
- for (i = 0; i < argc; i++) {
416
+ for (i = 0; (int) i < argc; i++) {
417
417
  CHECK_VEC(argv[i]);
418
418
  Data_Get_Struct(argv[i], GSL_TYPE(gsl_vector), v);
419
419
  FUNCTION(gsl_matrix,set_row)(m, i, v);
@@ -432,7 +432,7 @@ GSL_TYPE(gsl_matrix)* FUNCTION(gsl_matrix,alloc_from_colvectors)(int argc, VALUE
432
432
  // m = FUNCTION(gsl_matrix,alloc)(argc, v->size);
433
433
  m = FUNCTION(gsl_matrix,alloc)(v->size, argc);
434
434
  if (m == NULL) rb_raise(rb_eNoMemError, "gsl_matrix_alloc failed");
435
- for (i = 0; i < argc; i++) {
435
+ for (i = 0; (int) i < argc; i++) {
436
436
  CHECK_VEC(argv[i]);
437
437
  Data_Get_Struct(argv[i], GSL_TYPE(gsl_vector), v);
438
438
  FUNCTION(gsl_matrix,set_col)(m, i, v);
@@ -547,7 +547,7 @@ static VALUE FUNCTION(rb_gsl_matrix,diagonal_singleton)(int argc, VALUE *argv, V
547
547
  break;
548
548
  default:
549
549
  m = FUNCTION(gsl_matrix,calloc)(argc, argc);
550
- for (i = 0; i < argc; i++) {
550
+ for (i = 0; (int) i < argc; i++) {
551
551
  FUNCTION(gsl_matrix,set)(m, i, i, NUMCONV2(argv[i]));
552
552
  }
553
553
  break;
@@ -799,7 +799,7 @@ static VALUE FUNCTION(rb_gsl_matrix,set)(int argc, VALUE *argv, VALUE obj)
799
799
  FUNCTION(rb_gsl_vector,set_subvector)(2, row_set_argv, &vv.vector, other);
800
800
  } else {
801
801
  // m[...] = [[row0], [row1], ...] # multiple rows
802
- if(n1 != RARRAY_LEN(other)) {
802
+ if((int) n1 != RARRAY_LEN(other)) {
803
803
  rb_raise(rb_eRangeError, "row counts do not match (%d != %d)",
804
804
  (int) n1, (int) RARRAY_LEN(other));
805
805
  }
@@ -908,7 +908,7 @@ static VALUE FUNCTION(rb_gsl_matrix,to_s)(VALUE obj)
908
908
  else
909
909
  sprintf(buf, format2, x);
910
910
  rb_str_cat(str, buf, strlen(buf));
911
- if (j >= (55/dig)) {
911
+ if ((int) j >= (55/dig)) {
912
912
  strcpy(buf, "... ");
913
913
  rb_str_cat(str, buf, strlen(buf));
914
914
  break;
@@ -1062,7 +1062,7 @@ static VALUE FUNCTION(rb_gsl_matrix,set_row)(VALUE obj, VALUE i, VALUE vv)
1062
1062
  if (CLASS_OF(vv) == rb_cRange) vv = rb_gsl_range2ary(vv);
1063
1063
  if (TYPE(vv) == T_ARRAY) {
1064
1064
  v = FUNCTION(gsl_vector,alloc)(RARRAY_LEN(vv));
1065
- for (j = 0; j < RARRAY_LEN(vv); j++) {
1065
+ for (j = 0; (int) j < RARRAY_LEN(vv); j++) {
1066
1066
  FUNCTION(gsl_vector,set)(v, j, NUMCONV2(rb_ary_entry(vv, j)));
1067
1067
  }
1068
1068
  flag = 1;
@@ -1086,7 +1086,7 @@ static VALUE FUNCTION(rb_gsl_matrix,set_col)(VALUE obj, VALUE j, VALUE vv)
1086
1086
  if (CLASS_OF(vv) == rb_cRange) vv = rb_gsl_range2ary(vv);
1087
1087
  if (TYPE(vv) == T_ARRAY) {
1088
1088
  v = FUNCTION(gsl_vector,alloc)(RARRAY_LEN(vv));
1089
- for (i = 0; i < RARRAY_LEN(vv); i++) {
1089
+ for (i = 0; (int) i < RARRAY_LEN(vv); i++) {
1090
1090
  FUNCTION(gsl_vector,set)(v, i, NUMCONV2(rb_ary_entry(vv, i)));
1091
1091
  }
1092
1092
  flag = 1;
@@ -72,7 +72,7 @@ static VALUE rb_gsl_monte_function_set_f(int argc, VALUE *argv, VALUE obj)
72
72
  rb_ary_store(ary, 0, argv[0]);
73
73
  F->dim = FIX2INT(argv[1]);
74
74
  ary2 = rb_ary_new2(argc-2);
75
- for (i = 2; i < argc; i++) rb_ary_store(ary2, i-2, argv[i]);
75
+ for (i = 2; i < (size_t) argc; i++) rb_ary_store(ary2, i-2, argv[i]);
76
76
  rb_ary_store(ary, 1, ary2);
77
77
  break;
78
78
  }
@@ -164,7 +164,7 @@ static VALUE rb_gsl_monte_function_set_params(int argc, VALUE *argv, VALUE obj)
164
164
  rb_ary_store(ary, 1, argv[0]);
165
165
  } else {
166
166
  ary2 = rb_ary_new2(argc);
167
- for (i = 0; i < argc; i++) rb_ary_store(ary2, i, argv[i]);
167
+ for (i = 0; i < (size_t) argc; i++) rb_ary_store(ary2, i, argv[i]);
168
168
  rb_ary_store(ary, 1, ary2);
169
169
  }
170
170
  return obj;
@@ -99,7 +99,7 @@ static VALUE rb_gsl_multimin_function_new(int argc, VALUE *argv, VALUE klass)
99
99
  break;
100
100
  case 2:
101
101
  case 3:
102
- for (i = 0; i < argc; i++) set_function(i, argv, F);
102
+ for (i = 0; (int) i < argc; i++) set_function(i, argv, F);
103
103
  break;
104
104
  default:
105
105
  rb_raise(rb_eArgError, "wrong number of arguments");
@@ -172,7 +172,7 @@ static VALUE rb_gsl_multimin_function_set_f(int argc, VALUE *argv, VALUE obj)
172
172
  break;
173
173
  case 2:
174
174
  case 3:
175
- for (i = 0; i < argc; i++) set_function(i, argv, F);
175
+ for (i = 0; (int) i < argc; i++) set_function(i, argv, F);
176
176
  break;
177
177
  default:
178
178
  rb_raise(rb_eArgError, "wrong number of arguments");
@@ -197,7 +197,7 @@ static VALUE rb_gsl_multimin_function_set_params(int argc, VALUE *argv, VALUE ob
197
197
  if (argc == 1) rb_ary_store(ary, 1, argv[0]);
198
198
  else {
199
199
  ary2 = rb_ary_new2(argc);
200
- for (i = 0; i < argc; i++) rb_ary_store(ary2, i, argv[i]);
200
+ for (i = 0; (int) i < argc; i++) rb_ary_store(ary2, i, argv[i]);
201
201
  rb_ary_store(ary, 1, ary2);
202
202
  }
203
203
  return obj;
@@ -358,7 +358,7 @@ static VALUE rb_gsl_multimin_function_fdf_set_params(int argc, VALUE *argv, VALU
358
358
  rb_ary_store(ary, 3, argv[0]);
359
359
  } else {
360
360
  ary2 = rb_ary_new2(argc);
361
- for (i = 0; i < argc; i++) rb_ary_store(ary2, i, argv[i]);
361
+ for (i = 0; (int) i < argc; i++) rb_ary_store(ary2, i, argv[i]);
362
362
  rb_ary_store(ary, 3, ary2);
363
363
  }
364
364
  return obj;
@@ -80,7 +80,7 @@ static VALUE rb_gsl_multiroot_function_new(int argc, VALUE *argv, VALUE klass)
80
80
  break;
81
81
  case 2:
82
82
  case 3:
83
- for (i = 0; i < argc; i++) set_function(i, argv, F);
83
+ for (i = 0; (int) i < argc; i++) set_function(i, argv, F);
84
84
  break;
85
85
  default:
86
86
  rb_raise(rb_eArgError, "wrong number of arguments");
@@ -99,7 +99,7 @@ static void gsl_multiroot_function_mark(gsl_multiroot_function *f)
99
99
  size_t i;
100
100
  rb_gc_mark((VALUE) f->params);
101
101
  // for (i = 0; i < RARRAY(f->params)->len; i++)
102
- for (i = 0; i < RARRAY_LEN(f->params); i++)
102
+ for (i = 0; (int) i < RARRAY_LEN(f->params); i++)
103
103
  rb_gc_mark(rb_ary_entry((VALUE) f->params, i));
104
104
  }
105
105
 
@@ -161,7 +161,7 @@ static VALUE rb_gsl_multiroot_function_set_f(int argc, VALUE *argv, VALUE obj)
161
161
  break;
162
162
  case 2:
163
163
  case 3:
164
- for (i = 0; i < argc; i++) set_function(i, argv, F);
164
+ for (i = 0; (int) i < argc; i++) set_function(i, argv, F);
165
165
  break;
166
166
  default:
167
167
  rb_raise(rb_eArgError, "wrong number of arguments");
@@ -187,7 +187,7 @@ static VALUE rb_gsl_multiroot_function_set_params(int argc, VALUE *argv, VALUE o
187
187
  if (argc == 1) rb_ary_store(ary, 1, argv[0]);
188
188
  else {
189
189
  ary2 = rb_ary_new2(argc);
190
- for (i = 0; i < argc; i++) rb_ary_store(ary2, i, argv[i]);
190
+ for (i = 0; (int) i < argc; i++) rb_ary_store(ary2, i, argv[i]);
191
191
  rb_ary_store(ary, 1, ary2);
192
192
  }
193
193
  return obj;
@@ -236,7 +236,7 @@ static void gsl_multiroot_function_fdf_mark(gsl_multiroot_function_fdf *f)
236
236
  size_t i;
237
237
  rb_gc_mark((VALUE) f->params);
238
238
  // for (i = 0; i < RARRAY(f->params)->len; i++)
239
- for (i = 0; i < RARRAY_LEN(f->params); i++)
239
+ for (i = 0; (int) i < RARRAY_LEN(f->params); i++)
240
240
  rb_gc_mark(rb_ary_entry((VALUE) f->params, i));
241
241
  }
242
242
 
@@ -322,7 +322,7 @@ static VALUE rb_gsl_multiroot_function_fdf_set_params(int argc, VALUE *argv, VAL
322
322
  if (argc == 1) rb_ary_store(ary, 3, argv[0]);
323
323
  else {
324
324
  ary2 = rb_ary_new2(argc);
325
- for (i = 0; i < argc; i++) rb_ary_store(ary2, i, argv[i]);
325
+ for (i = 0; (int) i < argc; i++) rb_ary_store(ary2, i, argv[i]);
326
326
  rb_ary_store(ary, 3, ary2);
327
327
  }
328
328
  return obj;
@@ -813,7 +813,7 @@ static VALUE rb_gsl_multiroot_function_solve(int argc, VALUE *argv, VALUE obj)
813
813
  case 4:
814
814
  case 3:
815
815
  case 2:
816
- for (i = 1; i < argc; i++) {
816
+ for (i = 1; (int) i < argc; i++) {
817
817
  switch (TYPE(argv[i])) {
818
818
  case T_STRING:
819
819
  T = (gsl_multiroot_fsolver_type *) get_fsolver_type(argv[i]);
@@ -830,7 +830,7 @@ static VALUE rb_gsl_multiroot_function_solve(int argc, VALUE *argv, VALUE obj)
830
830
  case 1:
831
831
  if (TYPE(argv[0]) == T_ARRAY) {
832
832
  // if (RARRAY(argv[0])->len != F->n)
833
- if (RARRAY_LEN(argv[0]) != F->n)
833
+ if (RARRAY_LEN(argv[0]) != (int) F->n)
834
834
  rb_raise(rb_eRangeError, "array size are different.");
835
835
  x0 = gsl_vector_alloc(F->n);
836
836
  for (i = 0; i < x0->size; i++)