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
@@ -104,7 +104,7 @@ static VALUE rb_gsl_fft_conv_corr(int argc, VALUE *argv, VALUE obj,
104
104
  enum FFT_CONV_CORR flag1,
105
105
  enum FFT_CONV_CORR flag2)
106
106
  {
107
- double *data1, *data2, *data3;
107
+ double *data1, *data2, *data3 = NULL;
108
108
  size_t stride1, stride2, size1, size2;
109
109
  #ifdef HAVE_NARRAY_H
110
110
  int naflag1, naflag2, shape;
@@ -118,7 +118,7 @@ static VALUE rb_gsl_fft_conv_corr(int argc, VALUE *argv, VALUE obj,
118
118
  int flagt = 0, flagw = 0;
119
119
  // size_t i;
120
120
  gsl_vector *vtmp1 = NULL, *vtmp2 = NULL;
121
- VALUE ary;
121
+ VALUE ary = NULL;
122
122
  switch (argc) {
123
123
  case 3:
124
124
  data1 = get_ptr_double3(obj, &size1, &stride1, &naflag1);
@@ -250,7 +250,7 @@ void rb_gsl_vector_complex_set_subvector(int argc, VALUE *argv, gsl_vector_compl
250
250
  gsl_vector_complex_memcpy(&vv.vector, vother);
251
251
  } else if(rb_obj_is_kind_of(other, rb_cArray)) {
252
252
  // TODO Support other forms of Array contents as well
253
- if(n != RARRAY_LEN(other)) {
253
+ if((int) n != RARRAY_LEN(other)) {
254
254
  rb_raise(rb_eRangeError, "lengths do not match (%d != %d)", (int) n, (int) RARRAY_LEN(other));
255
255
  }
256
256
  for(i = 0; i < n; i++) {
@@ -335,10 +335,11 @@ static VALUE rb_gsl_vector_complex_reverse_each(VALUE obj)
335
335
  gsl_complex * zp;
336
336
  size_t i;
337
337
  Data_Get_Struct(obj, gsl_vector_complex, v);
338
- for (i = v->size-1; i >= 0; i--) {
338
+ for (i = v->size-1;; i--) {
339
339
  vz = Data_Make_Struct(cgsl_complex, gsl_complex, 0, free, zp);
340
340
  *zp = gsl_vector_complex_get(v, i);
341
341
  rb_yield(vz);
342
+ if (i == 0) break;
342
343
  }
343
344
  return obj;
344
345
  }
@@ -357,7 +358,7 @@ static VALUE rb_gsl_vector_complex_reverse_each_index(VALUE obj)
357
358
  gsl_vector_complex *v = NULL;
358
359
  size_t i;
359
360
  Data_Get_Struct(obj, gsl_vector_complex, v);
360
- for (i = v->size-1; i >= 0; i--) {
361
+ for (i = v->size-1;; i--) {
361
362
  rb_yield(INT2FIX(i));
362
363
  if (i == 0) break;
363
364
  }
@@ -860,7 +861,7 @@ static VALUE rb_gsl_vector_complex_ifftshift_bang(VALUE obj)
860
861
  static VALUE rb_gsl_vector_complex_ifftshift(VALUE obj)
861
862
  {
862
863
  return rb_gsl_vector_complex_ifftshift_bang(rb_gsl_vector_complex_clone(obj));
863
- gsl_vector_complex *v, *vnew;
864
+ /*gsl_vector_complex *v, *vnew;
864
865
  gsl_vector_complex_view vv, vvnew;
865
866
  size_t n;
866
867
 
@@ -876,7 +877,7 @@ static VALUE rb_gsl_vector_complex_ifftshift(VALUE obj)
876
877
  vvnew = gsl_vector_complex_subvector(v, (n+1)/2, n/2);
877
878
  gsl_vector_complex_memcpy(&vvnew.vector, &vv.vector);
878
879
 
879
- return Data_Wrap_Struct(VECTOR_COMPLEX_ROW_COL(obj), 0, gsl_vector_complex_free, vnew);
880
+ return Data_Wrap_Struct(VECTOR_COMPLEX_ROW_COL(obj), 0, gsl_vector_complex_free, vnew); */
880
881
  }
881
882
 
882
883
  static VALUE rb_gsl_vector_complex_isnull(VALUE obj)
@@ -939,9 +940,9 @@ static VALUE rb_gsl_vector_complex_trans(VALUE obj)
939
940
  static VALUE rb_gsl_vector_complex_trans2(VALUE obj)
940
941
  {
941
942
  if (CLASS_OF(obj) == cgsl_vector_complex)
942
- RBASIC(obj)->klass = cgsl_vector_complex_col;
943
+ RBGSL_SET_CLASS(obj, cgsl_vector_complex_col);
943
944
  else if (CLASS_OF(obj) == cgsl_vector_complex_col)
944
- RBASIC(obj)->klass = cgsl_vector_complex;
945
+ RBGSL_SET_CLASS(obj, cgsl_vector_complex);
945
946
  else {
946
947
  rb_raise(rb_eRuntimeError, "method trans! for %s is forbidden",
947
948
  rb_class2name(CLASS_OF(obj)));
@@ -1961,18 +1962,18 @@ static VALUE rb_gsl_vector_complex_zip(int argc, VALUE *argv, VALUE obj)
1961
1962
  argc2 = argc - 1;
1962
1963
  argv2 = argv + 1;
1963
1964
  }
1964
- for (i = 0; i < argc2; i++) {
1965
+ for (i = 0; (int) i < argc2; i++) {
1965
1966
  CHECK_VECTOR_COMPLEX(argv2[i]);
1966
1967
  }
1967
1968
  vp = (gsl_vector_complex**) malloc(sizeof(gsl_vector_complex**));
1968
- for (i = 0; i < argc2; i++) {
1969
+ for (i = 0; (int) i < argc2; i++) {
1969
1970
  Data_Get_Struct(argv2[i], gsl_vector_complex, vp[i]);
1970
1971
  }
1971
1972
  ary = rb_ary_new2(v0->size);
1972
1973
  for (i = 0; i < v0->size; i++) {
1973
1974
  vnew = gsl_vector_complex_alloc(argc2 + 1);
1974
1975
  gsl_vector_complex_set(vnew, 0, gsl_vector_complex_get(v0, i));
1975
- for (j = 0; j < argc2; j++) {
1976
+ for (j = 0; (int) j < argc2; j++) {
1976
1977
  if (i < vp[j]->size) {
1977
1978
  gsl_vector_complex_set(vnew, j+1, gsl_vector_complex_get(vp[j], i));
1978
1979
  } else {
@@ -914,13 +914,15 @@ static VALUE rb_gsl_vector_filescan_na(VALUE klass, VALUE file)
914
914
  strcpy(filename, STR2CSTR(file));
915
915
  sprintf(buf, "wc %s", filename);
916
916
  fp = popen(buf, "r");
917
- fgets(buf, 1024, fp);
917
+ if (fgets(buf, 1024, fp) == NULL)
918
+ rb_sys_fail(0);
918
919
  pclose(fp);
919
920
  sscanf(buf, "%d", &nn);
920
921
  lines = (size_t) nn; /* vector length */
921
922
  shape[0] = lines;
922
923
  fp = fopen(filename, "r");
923
- fgets(buf, 1024, fp);
924
+ if (fgets(buf, 1024, fp) == NULL)
925
+ rb_sys_fail(0);
924
926
  n = count_columns(buf); /* number of vectors created */
925
927
  ptr = (double**) xmalloc(sizeof(double**)*n);
926
928
  ary = rb_ary_new2(n);
@@ -934,7 +936,8 @@ static VALUE rb_gsl_vector_filescan_na(VALUE klass, VALUE file)
934
936
  else break;
935
937
  }
936
938
  for (i = 1; i < lines; i++) {
937
- fgets(buf, 1024, fp);
939
+ if (fgets(buf, 1024, fp) == NULL)
940
+ rb_sys_fail(0);
938
941
  p = buf;
939
942
  for (j = 0; j < n; j++) {
940
943
  p = str_scan_double(p, &val);
@@ -1252,7 +1255,7 @@ static VALUE rb_gsl_vector_clip(int argc, VALUE *argv, VALUE obj)
1252
1255
  x = gsl_vector_get(v, i);
1253
1256
  if (x > hi) x = hi;
1254
1257
  else if (x < lo) x = lo;
1255
- else;
1258
+ else {};
1256
1259
  gsl_vector_set(vnew, i, x);
1257
1260
  }
1258
1261
  return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
@@ -95,7 +95,7 @@ void parse_subvector_args(int argc, VALUE *argv, size_t size,
95
95
  } else {
96
96
  CHECK_FIXNUM(argv[0]);
97
97
  length = FIX2INT(argv[0]);
98
- if((length < 0 && -length > size) || (length > 0 && length > size)) {
98
+ if((length < 0 && -length > (int) size) || (length > 0 && length > (int) size)) {
99
99
  rb_raise(rb_eRangeError,
100
100
  "length %d is out of range for Vector of length %d",
101
101
  length, (int) size);
@@ -283,7 +283,7 @@ VALUE FUNCTION(rb_gsl_vector,new)(int argc, VALUE *argv, VALUE klass)
283
283
  default:
284
284
  v = FUNCTION(gsl_vector,alloc)(argc);
285
285
  if (v == NULL) rb_raise(rb_eNoMemError, "gsl_vector_alloc failed");
286
- for (i = 0; i < argc; i++) {
286
+ for (i = 0; (int) i < argc; i++) {
287
287
  switch(TYPE(argv[i])) {
288
288
  case T_FIXNUM: case T_BIGNUM: case T_FLOAT:
289
289
  xnative = NUMCONV2(argv[i]);
@@ -348,7 +348,7 @@ static VALUE FUNCTION(rb_gsl_vector,get)(int argc, VALUE *argv, VALUE obj)
348
348
  vnew = FUNCTION(gsl_vector,alloc)(p->size);
349
349
  for (j = 0; j < p->size; j++) {
350
350
  k = p->data[j];
351
- if (k < 0) k = p->size + j;
351
+ //if (k < 0) k = p->size + j;
352
352
  FUNCTION(gsl_vector,set)(vnew, j, FUNCTION(gsl_vector,get)(v, k));
353
353
  }
354
354
  retval = Data_Wrap_Struct(GSL_TYPE(cgsl_vector), 0, FUNCTION(gsl_vector,free), vnew);
@@ -412,7 +412,7 @@ void FUNCTION(rb_gsl_vector,set_subvector)(int argc, VALUE *argv, GSL_TYPE(gsl_v
412
412
  // Views) well.
413
413
  FUNCTION(gsl_vector,memcpy)(&vv.vector, vother);
414
414
  } else if(rb_obj_is_kind_of(other, rb_cArray)) {
415
- if(n != RARRAY_LEN(other)) {
415
+ if((int) n != RARRAY_LEN(other)) {
416
416
  rb_raise(rb_eRangeError, "lengths do not match (%d != %d)", (int) n, (int) RARRAY_LEN(other));
417
417
  }
418
418
  for(i = 0; i < n; i++) {
@@ -511,7 +511,7 @@ static VALUE FUNCTION(rb_gsl_vector,reverse_each)(VALUE obj)
511
511
  GSL_TYPE(gsl_vector) *v = NULL;
512
512
  size_t i;
513
513
  Data_Get_Struct(obj, GSL_TYPE(gsl_vector), v);
514
- for (i = v->size-1; i >= 0; i--) {
514
+ for (i = v->size-1;; i--) {
515
515
  rb_yield(C_TO_VALUE2(FUNCTION(gsl_vector,get)(v, i)));
516
516
  if (i == 0) break;
517
517
  }
@@ -532,7 +532,7 @@ static VALUE FUNCTION(rb_gsl_vector,reverse_each_index)(VALUE obj)
532
532
  GSL_TYPE(gsl_vector) *v = NULL;
533
533
  size_t i;
534
534
  Data_Get_Struct(obj, GSL_TYPE(gsl_vector), v);
535
- for (i = v->size-1; i >= 0; i--) {
535
+ for (i = v->size-1;; i--) {
536
536
  rb_yield(INT2FIX(i));
537
537
  if (i == 0) break;
538
538
  }
@@ -673,15 +673,15 @@ static VALUE FUNCTION(rb_gsl_vector,trans)(VALUE obj)
673
673
  static VALUE FUNCTION(rb_gsl_vector,trans_bang)(VALUE obj)
674
674
  {
675
675
  #ifdef BASE_DOUBLE
676
- if (CLASS_OF(obj) == cgsl_vector) RBASIC(obj)->klass = cgsl_vector_col;
677
- else if (CLASS_OF(obj) == cgsl_vector_col) RBASIC(obj)->klass = cgsl_vector;
676
+ if (CLASS_OF(obj) == cgsl_vector) RBGSL_SET_CLASS(obj, cgsl_vector_col);
677
+ else if (CLASS_OF(obj) == cgsl_vector_col) RBGSL_SET_CLASS(obj, cgsl_vector);
678
678
  else {
679
679
  rb_raise(rb_eRuntimeError, "method trans! for %s is not permitted.",
680
680
  rb_class2name(CLASS_OF(obj)));
681
681
  }
682
682
  #elif defined(BASE_INT)
683
- if (CLASS_OF(obj) == cgsl_vector_int) RBASIC(obj)->klass = cgsl_vector_int_col;
684
- else if (CLASS_OF(obj) == cgsl_vector_int_col) RBASIC(obj)->klass = cgsl_vector_int;
683
+ if (CLASS_OF(obj) == cgsl_vector_int) RBGSL_SET_CLASS(obj, cgsl_vector_int_col);
684
+ else if (CLASS_OF(obj) == cgsl_vector_int_col) RBGSL_SET_CLASS(obj, cgsl_vector_int);
685
685
  else {
686
686
  rb_raise(rb_eRuntimeError, "method trans! for %s is not permitted.",
687
687
  rb_class2name(CLASS_OF(obj)));
@@ -757,7 +757,7 @@ static VALUE FUNCTION(rb_gsl_vector,connect)(int argc, VALUE *argv, VALUE obj)
757
757
  Data_Get_Struct(obj, GSL_TYPE(gsl_vector), v);
758
758
  total += v->size;
759
759
  }
760
- for (i = 0; i < argc; i++) {
760
+ for (i = 0; (int) i < argc; i++) {
761
761
  CHECK_VEC(argv[i]);
762
762
  Data_Get_Struct(argv[i], GSL_TYPE(gsl_vector), v);
763
763
  total += v->size;
@@ -769,7 +769,7 @@ static VALUE FUNCTION(rb_gsl_vector,connect)(int argc, VALUE *argv, VALUE obj)
769
769
  memcpy(ptr, v->data, sizeof(BASE)*v->size);
770
770
  ptr += v->size;
771
771
  }
772
- for (i = 0; i < argc; i++) {
772
+ for (i = 0; (int) i < argc; i++) {
773
773
  Data_Get_Struct(argv[i], GSL_TYPE(gsl_vector), v);
774
774
  memcpy(ptr, v->data, sizeof(BASE)*v->size);
775
775
  ptr += v->size;
@@ -1345,7 +1345,7 @@ VALUE FUNCTION(rb_gsl_vector,to_s)(VALUE obj)
1345
1345
  for (i = 1; i < v->size; i++) {
1346
1346
  sprintf(buf, PRINTF_FORMAT, FUNCTION(gsl_vector,get)(v, i));
1347
1347
  rb_str_cat(str, buf, strlen(buf));
1348
- if (i >= (55/dig) && i != v->size-1) {
1348
+ if ((int) i >= (55/dig) && i != v->size-1) {
1349
1349
  strcpy(buf, "... ");
1350
1350
  rb_str_cat(str, buf, strlen(buf));
1351
1351
  break;
@@ -1409,7 +1409,7 @@ static VALUE FUNCTION(rb_gsl_vector,subvector_with_stride)(int argc, VALUE *argv
1409
1409
  if(offset < 0) {
1410
1410
  rb_raise(rb_eRangeError, "offset %d out of range", offset - (int)v->size);
1411
1411
  }
1412
- } else if(offset >= v->size) {
1412
+ } else if(offset >= (int) v->size) {
1413
1413
  rb_raise(rb_eRangeError, "offset %d out of range", offset);
1414
1414
  }
1415
1415
  if(step == 0) {
@@ -1487,7 +1487,7 @@ static VALUE FUNCTION(rb_gsl_vector,matrix_view_with_tda)(VALUE obj, VALUE nn1,
1487
1487
  void FUNCTION(mygsl_vector,shift)(GSL_TYPE(gsl_vector) *p, size_t n)
1488
1488
  {
1489
1489
  size_t i;
1490
- for (i = n; i >= 0; i--) {
1490
+ for (i = n;; i--) {
1491
1491
  FUNCTION(gsl_vector,set)(p, i+1, FUNCTION(gsl_vector,get)(p, i));
1492
1492
  if (i == 0) break;
1493
1493
  }
@@ -1497,7 +1497,7 @@ void FUNCTION(mygsl_vector,shift)(GSL_TYPE(gsl_vector) *p, size_t n)
1497
1497
  void FUNCTION(mygsl_vector,shift_scale2)(GSL_TYPE(gsl_vector) *p, size_t n)
1498
1498
  {
1499
1499
  size_t i;
1500
- for (i = n; i >= 0; i--) {
1500
+ for (i = n;; i--) {
1501
1501
  FUNCTION(gsl_vector,set)(p, i+1, 2*FUNCTION(gsl_vector,get)(p, i));
1502
1502
  if (i == 0) break;
1503
1503
  }
@@ -1617,7 +1617,7 @@ static VALUE FUNCTION(rb_gsl_vector,to_gplot)(int argc, VALUE *argv, VALUE obj)
1617
1617
  istart = 1;
1618
1618
  break;
1619
1619
  }
1620
- for (i = 0; i < argc; i++) {
1620
+ for (i = 0; (int) i < argc; i++) {
1621
1621
  if (TYPE(argv[0]) == T_ARRAY) tmp = rb_ary_entry(argv[0], i);
1622
1622
  else tmp = argv[i];
1623
1623
  CHECK_VEC(tmp);
@@ -1699,7 +1699,7 @@ GSL_TYPE(gsl_vector)* FUNCTION(mygsl_vector,mul_matrix)(GSL_TYPE(gsl_vector) *v,
1699
1699
  void FUNCTION(mygsl_vector,to_m_circulant)(GSL_TYPE(gsl_matrix) *m, GSL_TYPE(gsl_vector) *v)
1700
1700
  {
1701
1701
  size_t i, j;
1702
- for (i = v->size-1; i >= 0; i--) {
1702
+ for (i = v->size-1;; i--) {
1703
1703
  for (j = 0; j < v->size; j++) {
1704
1704
  if (j <= i) FUNCTION(gsl_matrix,set)(m, i, j, FUNCTION(gsl_vector,get)(v, v->size-1-i+j));
1705
1705
  else FUNCTION(gsl_matrix,set)(m, i, j, FUNCTION(gsl_vector,get)(v, j-i-1));
@@ -2157,7 +2157,7 @@ static VALUE FUNCTION(rb_gsl_vector,delete_at)(VALUE obj, VALUE ii)
2157
2157
  if (i2 < 0) {
2158
2158
  i2 += v->size;
2159
2159
  }
2160
- if (i2 < 0 || i2 > v->size-1) return Qnil;
2160
+ if (i2 < 0 || i2 > (int) (v->size-1)) return Qnil;
2161
2161
  i = (size_t) i2;
2162
2162
  x = FUNCTION(gsl_vector,get)(v, i);
2163
2163
  memmove(v->data+i, v->data+i+1, sizeof(BASE)*(v->size-1-i));
@@ -2209,7 +2209,7 @@ static VALUE FUNCTION(rb_gsl_vector,delete)(VALUE obj, VALUE yy)
2209
2209
  }
2210
2210
  }
2211
2211
  v->size -= count;
2212
- return count ? y : Qnil;
2212
+ return count ? (VALUE) y : Qnil;
2213
2213
  }
2214
2214
 
2215
2215
  /* singleton method */
@@ -2233,14 +2233,16 @@ static VALUE FUNCTION(rb_gsl_vector,filescan)(VALUE klass, VALUE file)
2233
2233
  sprintf(buf, "sed '/^#/d' %s | wc", filename);
2234
2234
  if ((fp = popen(buf, "r")) == NULL)
2235
2235
  rb_raise(rb_eIOError, "popen failed.");
2236
- fgets(buf, 1024, fp);
2236
+ if (fgets(buf, 1024, fp) == NULL)
2237
+ rb_sys_fail(0);
2237
2238
  pclose(fp);
2238
2239
  sscanf(buf, "%d", &nn);
2239
2240
  lines = (size_t) nn; /* vector length */
2240
2241
  if ((fp = fopen(filename, "r")) == NULL)
2241
2242
  rb_raise(rb_eIOError, "cannot open file %s.", filename);
2242
2243
  while (1) {
2243
- fgets(buf, 1024, fp); /* read the first line to count number of columns */
2244
+ if (fgets(buf, 1024, fp) == NULL) /* read the first line to count number of columns */
2245
+ rb_sys_fail(0);
2244
2246
  if (buf[0] == '#') continue;
2245
2247
  else break;
2246
2248
  }
@@ -2254,7 +2256,8 @@ static VALUE FUNCTION(rb_gsl_vector,filescan)(VALUE klass, VALUE file)
2254
2256
  rewind(fp);
2255
2257
  for (i = 0, ii = 0; ii < lines; i++) {
2256
2258
  pos = ftell(fp);
2257
- fgets(buf, 1024, fp);
2259
+ if (fgets(buf, 1024, fp) == NULL)
2260
+ rb_sys_fail(0);
2258
2261
  if (buf[0] == '#') continue;
2259
2262
  fseek(fp, pos, SEEK_SET);
2260
2263
  for (j = 0, jj = 0; jj < n; j++) {
@@ -2871,18 +2874,18 @@ static VALUE FUNCTION(rb_gsl_vector,zip)(int argc, VALUE *argv, VALUE obj)
2871
2874
  argc2 = argc - 1;
2872
2875
  argv2 = argv + 1;
2873
2876
  }
2874
- for (i = 0; i < argc2; i++) {
2877
+ for (i = 0; (int) i < argc2; i++) {
2875
2878
  CHECK_VEC(argv2[i]);
2876
2879
  }
2877
2880
  vp = (GSL_TYPE(gsl_vector)**) malloc(sizeof(GSL_TYPE(gsl_vector)**));
2878
- for (i = 0; i < argc2; i++) {
2881
+ for (i = 0; (int) i < argc2; i++) {
2879
2882
  Data_Get_Struct(argv2[i], GSL_TYPE(gsl_vector), vp[i]);
2880
2883
  }
2881
2884
  ary = rb_ary_new2(v0->size);
2882
2885
  for (i = 0; i < v0->size; i++) {
2883
2886
  vnew = FUNCTION(gsl_vector,alloc)(argc2 + 1);
2884
2887
  FUNCTION(gsl_vector,set)(vnew, 0, FUNCTION(gsl_vector,get)(v0, i));
2885
- for (j = 0; j < argc2; j++) {
2888
+ for (j = 0; (int) j < argc2; j++) {
2886
2889
  if (i < vp[j]->size) {
2887
2890
  FUNCTION(gsl_vector,set)(vnew, j+1, FUNCTION(gsl_vector,get)(vp[j], i));
2888
2891
  } else {
@@ -363,7 +363,7 @@ static VALUE rb_gsl_wavelet_trans(int argc, VALUE *argv, VALUE obj,
363
363
  //int status;
364
364
  double *ptr1 = NULL, *ptr2 = NULL;
365
365
  size_t n, stride;
366
- VALUE ary, ret;
366
+ VALUE ary = NULL, ret;
367
367
  #ifdef HAVE_NARRAY_H
368
368
  struct NARRAY *na;
369
369
  #endif
@@ -293,6 +293,18 @@ EXTERN ID rb_gsl_id_beg, rb_gsl_id_end, rb_gsl_id_excl, rb_gsl_id_to_a;
293
293
  rb_raise(rb_eTypeError, "wrong argument type (GSL::Histogram expected)");
294
294
  #endif
295
295
 
296
+ #ifndef RBGSL_SET_CLASS
297
+ #ifdef RB_OBJ_WRITE
298
+ #define RBGSL_SET_CLASS0(obj0, cls) RB_OBJ_WRITE(obj0, &(RBASIC_CLASS(obj0)), cls)
299
+ #else
300
+ #define RBGSL_SET_CLASS0(obj0, cls) RBASIC(obj0)->klass = cls
301
+ #endif
302
+ #define RBGSL_SET_CLASS(obj, cls) do { \
303
+ VALUE _obj_ = (obj); \
304
+ RBGSL_SET_CLASS0(_obj_, cls); \
305
+ } while (0)
306
+ #endif
307
+
296
308
  void rb_gsl_error_handler(const char *reason, const char *file,
297
309
  int line, int gsl_errno);
298
310
 
@@ -52,11 +52,20 @@
52
52
  #ifndef GSL_1_15_LATER
53
53
  #define GSL_1_15_LATER
54
54
  #endif
55
+ #ifndef HAVE_EIGEN_FRANCIS
56
+ #define HAVE_EIGEN_FRANCIS
57
+ #endif
55
58
  #ifndef RUBY_GSL_VERSION
56
- #define RUBY_GSL_VERSION "1.15.0"
59
+ #define RUBY_GSL_VERSION "1.15.3"
57
60
  #endif
58
61
  #ifndef RUBY_1_8_LATER
59
62
  #define RUBY_1_8_LATER
60
63
  #endif
64
+ #ifndef RUBY_1_9_LATER
65
+ #define RUBY_1_9_LATER
66
+ #endif
67
+ #ifndef RUBY_1_9_2_LATER
68
+ #define RUBY_1_9_2_LATER
69
+ #endif
61
70
 
62
71
  #endif
@@ -260,10 +260,10 @@
260
260
  # * GSL::Blas::Right
261
261
  #
262
262
  #
263
- # {prev}[link:files/rdoc/sort_rdoc.html]
264
- # {next}[link:files/rdoc/linalg_rdoc.html]
263
+ # {prev}[link:rdoc/sort_rdoc.html]
264
+ # {next}[link:rdoc/linalg_rdoc.html]
265
265
  #
266
- # {Reference index}[link:files/rdoc/ref_rdoc.html]
267
- # {top}[link:files/rdoc/index_rdoc.html]
266
+ # {Reference index}[link:rdoc/ref_rdoc.html]
267
+ # {top}[link:index.html]
268
268
  #
269
269
  #
@@ -2,10 +2,10 @@
2
2
  # = Basis Splines
3
3
  # This chapter describes functions for the computation of smoothing basis splines (B-splines). This is only for GSL-1.9 or later.
4
4
  #
5
- # 1. {Overview}[link:files/rdoc/bspline_rdoc.html#1]
6
- # 1. {Initializing the B-splines solver}[link:files/rdoc/bspline_rdoc.html#2]
7
- # 1. {Constructing the knots vector}[link:files/rdoc/bspline_rdoc.html#3]
8
- # 1. {Evaluation of B-splines}[link:files/rdoc/bspline_rdoc.html#4]
5
+ # 1. {Overview}[link:rdoc/bspline_rdoc.html#1]
6
+ # 1. {Initializing the B-splines solver}[link:rdoc/bspline_rdoc.html#2]
7
+ # 1. {Constructing the knots vector}[link:rdoc/bspline_rdoc.html#3]
8
+ # 1. {Evaluation of B-splines}[link:rdoc/bspline_rdoc.html#4]
9
9
  #
10
10
  # == {}[link:index.html"name="1] Overview
11
11
  #
@@ -34,9 +34,9 @@
34
34
  #
35
35
  # This method evaluates all B-spline basis functions at the position <tt>x</tt> and stores them in <tt>B</tt> (if given), so that the ith element of <tt>B</tt> is <tt>B_i(x)</tt>. <tt>B</tt> must be of length <tt>n = nbreak + k - 2</tt>. If <tt>B</tt> is not given, a newly created vector is returned.It is far more efficient to compute all of the basis functions at once than to compute them individually, due to the nature of the defining recurrence relation.
36
36
  #
37
- # {prev}[link:files/rdoc/nonlinearfit_rdoc.html]
38
- # {next}[link:files/rdoc/const_rdoc.html]
37
+ # {prev}[link:rdoc/nonlinearfit_rdoc.html]
38
+ # {next}[link:rdoc/const_rdoc.html]
39
39
  #
40
- # {Reference index}[link:files/rdoc/ref_rdoc.html]
41
- # {top}[link:files/rdoc/index_rdoc.html]
40
+ # {Reference index}[link:rdoc/ref_rdoc.html]
41
+ # {top}[link:index.html]
42
42
  #
@@ -10,10 +10,10 @@
10
10
  # T_0(x) = 1, T_1(x) = x, T_2(x) = 2 x^2 - 1.
11
11
  # For further information see Abramowitz & Stegun, Chapter 22.
12
12
  #
13
- # 1. {GSL::Cheb class}[link:files/rdoc/cheb_rdoc.html#1]
14
- # 1. {Chebyshev Series Evaluation}[link:files/rdoc/cheb_rdoc.html#2]
15
- # 1. {Derivatives and Integrals}[link:files/rdoc/cheb_rdoc.html#3]
16
- # 1. {Examples}[link:files/rdoc/cheb_rdoc.html#4]
13
+ # 1. {GSL::Cheb class}[link:rdoc/cheb_rdoc.html#1]
14
+ # 1. {Chebyshev Series Evaluation}[link:rdoc/cheb_rdoc.html#2]
15
+ # 1. {Derivatives and Integrals}[link:rdoc/cheb_rdoc.html#3]
16
+ # 1. {Examples}[link:rdoc/cheb_rdoc.html#4]
17
17
  #
18
18
  # == {}[link:index.html"name="1] <tt>GSL::Cheb</tt> class
19
19
  #
@@ -26,7 +26,7 @@
26
26
  # ---
27
27
  # * GSL::Cheb#init(f, a, b)
28
28
  #
29
- # This computes the Chebyshev approximation the function <tt>f</tt> over the range (<tt>a,b</tt>) to the previously specified order. Where <tt>f</tt> is a {GSL::Function}[link:files/rdoc/function_rdoc.html] object. The computation of the Chebyshev approximation is an O(n^2) process, and requires <tt>n</tt> function evaluations.
29
+ # This computes the Chebyshev approximation the function <tt>f</tt> over the range (<tt>a,b</tt>) to the previously specified order. Where <tt>f</tt> is a {GSL::Function}[link:rdoc/function_rdoc.html] object. The computation of the Chebyshev approximation is an O(n^2) process, and requires <tt>n</tt> function evaluations.
30
30
  #
31
31
  # * ex: Approximate a step function defined in (0, 1) by a Chebyshev series of order 40.
32
32
  # f = GSL::Function.alloc { |x|
@@ -91,9 +91,9 @@
91
91
  #
92
92
  # See also the example scripts in <tt>examples/cheb/</tt>.
93
93
  #
94
- # {prev}[link:files/rdoc/diff_rdoc.html]
95
- # {next}[link:files/rdoc/sum_rdoc.html]
94
+ # {prev}[link:rdoc/diff_rdoc.html]
95
+ # {next}[link:rdoc/sum_rdoc.html]
96
96
  #
97
- # {Reference index}[link:files/rdoc/ref_rdoc.html]
98
- # {top}[link:files/rdoc/index_rdoc.html]
97
+ # {Reference index}[link:rdoc/ref_rdoc.html]
98
+ # {top}[link:index.html]
99
99
  #