gsl 1.15.3 → 1.16.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (446) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +24 -0
  4. data/AUTHORS +10 -2
  5. data/COPYING +341 -339
  6. data/ChangeLog +612 -554
  7. data/Gemfile +4 -0
  8. data/README.md +77 -0
  9. data/Rakefile +14 -93
  10. data/THANKS +1 -1
  11. data/examples/blas/blas.rb +1 -1
  12. data/examples/bspline.rb +3 -3
  13. data/examples/complex/functions.rb +4 -4
  14. data/examples/complex/mul.rb +1 -1
  15. data/examples/const/physconst.rb +4 -4
  16. data/examples/const/travel.rb +4 -4
  17. data/examples/eigen/nonsymmv.rb +1 -1
  18. data/examples/eigen/qhoscillator.rb +3 -3
  19. data/examples/fft/radix2.rb +1 -1
  20. data/examples/fft/real-halfcomplex.rb +3 -3
  21. data/examples/fft/real-halfcomplex2.rb +3 -3
  22. data/examples/fit/expfit.rb +1 -1
  23. data/examples/fit/multifit.rb +1 -1
  24. data/examples/fit/ndlinear.rb +44 -44
  25. data/examples/fit/nonlinearfit.rb +1 -1
  26. data/examples/fit/wlinear.rb +3 -3
  27. data/examples/function/function.rb +1 -1
  28. data/examples/function/min.rb +1 -1
  29. data/examples/function/synchrotron.rb +2 -2
  30. data/examples/gallery/koch.rb +1 -1
  31. data/examples/histogram/cauchy.rb +2 -2
  32. data/examples/histogram/exponential.rb +1 -1
  33. data/examples/histogram/histo3d.rb +1 -1
  34. data/examples/histogram/histogram-pdf.rb +2 -2
  35. data/examples/histogram/xexp.rb +1 -1
  36. data/examples/integration/ahmed.rb +2 -2
  37. data/examples/integration/cosmology.rb +7 -7
  38. data/examples/integration/friedmann.rb +4 -4
  39. data/examples/integration/qng.rb +1 -1
  40. data/examples/interp/demo.rb +2 -2
  41. data/examples/linalg/LQ_solve.rb +1 -1
  42. data/examples/linalg/LU.rb +1 -1
  43. data/examples/linalg/LU2.rb +1 -1
  44. data/examples/linalg/LU_narray.rb +1 -1
  45. data/examples/linalg/PTLQ.rb +1 -1
  46. data/examples/linalg/QRPT.rb +1 -1
  47. data/examples/linalg/chol.rb +1 -1
  48. data/examples/linalg/chol_narray.rb +1 -1
  49. data/examples/linalg/complex.rb +1 -1
  50. data/examples/math/elementary.rb +1 -1
  51. data/examples/math/functions.rb +1 -1
  52. data/examples/math/inf_nan.rb +1 -1
  53. data/examples/math/minmax.rb +1 -1
  54. data/examples/math/power.rb +1 -1
  55. data/examples/math/test.rb +1 -1
  56. data/examples/min.rb +1 -1
  57. data/examples/multimin/bundle.rb +1 -1
  58. data/examples/multimin/cqp.rb +17 -17
  59. data/examples/multiroot/fsolver3.rb +1 -1
  60. data/examples/odeiv/binarysystem.rb +12 -12
  61. data/examples/odeiv/demo.rb +3 -3
  62. data/examples/odeiv/frei1.rb +7 -7
  63. data/examples/odeiv/frei2.rb +4 -4
  64. data/examples/odeiv/oscillator.rb +1 -1
  65. data/examples/odeiv/sedov.rb +3 -3
  66. data/examples/odeiv/whitedwarf.rb +11 -11
  67. data/examples/permutation/ex1.rb +2 -2
  68. data/examples/permutation/permutation.rb +1 -1
  69. data/examples/poly/demo.rb +1 -1
  70. data/examples/random/diffusion.rb +1 -1
  71. data/examples/random/generator.rb +2 -2
  72. data/examples/random/randomwalk.rb +3 -3
  73. data/examples/random/rng.rb +1 -1
  74. data/examples/roots/bisection.rb +1 -1
  75. data/examples/roots/brent.rb +1 -1
  76. data/examples/roots/demo.rb +1 -1
  77. data/examples/roots/newton.rb +2 -2
  78. data/examples/roots/recombination.gp +0 -1
  79. data/examples/sf/hyperg.rb +1 -1
  80. data/examples/sf/sphbessel.rb +1 -1
  81. data/examples/sort/sort.rb +1 -1
  82. data/examples/tamu_anova.rb +4 -4
  83. data/examples/vector/add.rb +1 -1
  84. data/examples/vector/decimate.rb +1 -1
  85. data/examples/vector/gnuplot.rb +8 -8
  86. data/examples/vector/vector.rb +2 -2
  87. data/examples/wavelet/wavelet1.rb +1 -1
  88. data/ext/{alf.c → gsl_native/alf.c} +10 -10
  89. data/ext/{array.c → gsl_native/array.c} +70 -159
  90. data/ext/{array_complex.c → gsl_native/array_complex.c} +63 -66
  91. data/ext/{blas.c → gsl_native/blas.c} +2 -3
  92. data/ext/{blas1.c → gsl_native/blas1.c} +35 -36
  93. data/ext/{blas2.c → gsl_native/blas2.c} +57 -62
  94. data/ext/{blas3.c → gsl_native/blas3.c} +57 -58
  95. data/ext/{block.c → gsl_native/block.c} +14 -18
  96. data/ext/{block_source.c → gsl_native/block_source.h} +110 -112
  97. data/ext/gsl_native/bspline.c +122 -0
  98. data/ext/{bundle.c → gsl_native/bundle.c} +0 -0
  99. data/ext/{cdf.c → gsl_native/cdf.c} +79 -93
  100. data/ext/{cheb.c → gsl_native/cheb.c} +78 -89
  101. data/ext/{combination.c → gsl_native/combination.c} +11 -19
  102. data/ext/{common.c → gsl_native/common.c} +9 -41
  103. data/ext/{complex.c → gsl_native/complex.c} +116 -118
  104. data/ext/gsl_native/const.c +331 -0
  105. data/ext/{const_additional.c → gsl_native/const_additional.c} +13 -34
  106. data/ext/gsl_native/cqp.c +283 -0
  107. data/ext/{deriv.c → gsl_native/deriv.c} +25 -33
  108. data/ext/{dht.c → gsl_native/dht.c} +23 -31
  109. data/ext/{diff.c → gsl_native/diff.c} +26 -28
  110. data/ext/{dirac.c → gsl_native/dirac.c} +45 -46
  111. data/ext/{eigen.c → gsl_native/eigen.c} +1044 -1095
  112. data/ext/{error.c → gsl_native/error.c} +18 -18
  113. data/ext/gsl_native/extconf.rb +118 -0
  114. data/ext/{fft.c → gsl_native/fft.c} +197 -204
  115. data/ext/{fit.c → gsl_native/fit.c} +17 -18
  116. data/ext/gsl_native/fresnel.c +312 -0
  117. data/ext/{function.c → gsl_native/function.c} +37 -43
  118. data/ext/{geometry.c → gsl_native/geometry.c} +16 -16
  119. data/ext/{graph.c → gsl_native/graph.c} +39 -89
  120. data/ext/{gsl.c → gsl_native/gsl.c} +12 -33
  121. data/ext/{gsl_narray.c → gsl_native/gsl_narray.c} +20 -30
  122. data/ext/{histogram.c → gsl_native/histogram.c} +133 -160
  123. data/ext/{histogram2d.c → gsl_native/histogram2d.c} +78 -104
  124. data/ext/{histogram3d.c → gsl_native/histogram3d.c} +76 -76
  125. data/ext/{histogram3d_source.c → gsl_native/histogram3d_source.c} +196 -197
  126. data/ext/{histogram_find.c → gsl_native/histogram_find.c} +32 -34
  127. data/ext/{histogram_oper.c → gsl_native/histogram_oper.c} +43 -52
  128. data/ext/{ieee.c → gsl_native/ieee.c} +9 -21
  129. data/{include → ext/gsl_native/include}/rb_gsl.h +4 -26
  130. data/{include → ext/gsl_native/include}/rb_gsl_array.h +15 -39
  131. data/{include → ext/gsl_native/include}/rb_gsl_cheb.h +0 -2
  132. data/{include → ext/gsl_native/include}/rb_gsl_common.h +61 -61
  133. data/{include → ext/gsl_native/include}/rb_gsl_complex.h +1 -1
  134. data/{include → ext/gsl_native/include}/rb_gsl_const.h +0 -6
  135. data/ext/gsl_native/include/rb_gsl_dirac.h +6 -0
  136. data/{include → ext/gsl_native/include}/rb_gsl_eigen.h +1 -1
  137. data/{include → ext/gsl_native/include}/rb_gsl_fft.h +0 -13
  138. data/{include → ext/gsl_native/include}/rb_gsl_fit.h +0 -2
  139. data/{include → ext/gsl_native/include}/rb_gsl_function.h +0 -4
  140. data/{include → ext/gsl_native/include}/rb_gsl_graph.h +2 -4
  141. data/{include → ext/gsl_native/include}/rb_gsl_histogram.h +8 -8
  142. data/{include → ext/gsl_native/include}/rb_gsl_histogram3d.h +50 -50
  143. data/{include → ext/gsl_native/include}/rb_gsl_integration.h +1 -1
  144. data/{include → ext/gsl_native/include}/rb_gsl_interp.h +0 -5
  145. data/{include → ext/gsl_native/include}/rb_gsl_linalg.h +2 -6
  146. data/{include → ext/gsl_native/include}/rb_gsl_math.h +0 -6
  147. data/{include → ext/gsl_native/include}/rb_gsl_odeiv.h +0 -3
  148. data/{include → ext/gsl_native/include}/rb_gsl_poly.h +3 -7
  149. data/{include → ext/gsl_native/include}/rb_gsl_rational.h +1 -8
  150. data/{include → ext/gsl_native/include}/rb_gsl_rng.h +0 -1
  151. data/{include → ext/gsl_native/include}/rb_gsl_root.h +1 -1
  152. data/{include → ext/gsl_native/include}/rb_gsl_sf.h +39 -48
  153. data/{include → ext/gsl_native/include}/rb_gsl_statistics.h +1 -1
  154. data/{include → ext/gsl_native/include}/rb_gsl_tensor.h +0 -2
  155. data/{include → ext/gsl_native/include}/rb_gsl_with_narray.h +3 -1
  156. data/{include → ext/gsl_native/include}/templates_off.h +0 -0
  157. data/{include → ext/gsl_native/include}/templates_on.h +1 -1
  158. data/ext/{integration.c → gsl_native/integration.c} +164 -189
  159. data/ext/{interp.c → gsl_native/interp.c} +25 -38
  160. data/ext/gsl_native/jacobi.c +733 -0
  161. data/ext/{linalg.c → gsl_native/linalg.c} +462 -589
  162. data/ext/{linalg_complex.c → gsl_native/linalg_complex.c} +93 -106
  163. data/ext/{math.c → gsl_native/math.c} +48 -67
  164. data/ext/{matrix.c → gsl_native/matrix.c} +13 -16
  165. data/ext/{matrix_complex.c → gsl_native/matrix_complex.c} +119 -123
  166. data/ext/{matrix_double.c → gsl_native/matrix_double.c} +79 -82
  167. data/ext/{matrix_int.c → gsl_native/matrix_int.c} +53 -54
  168. data/ext/{matrix_source.c → gsl_native/matrix_source.h} +292 -318
  169. data/ext/{min.c → gsl_native/min.c} +45 -76
  170. data/ext/{monte.c → gsl_native/monte.c} +50 -64
  171. data/ext/{multifit.c → gsl_native/multifit.c} +142 -151
  172. data/ext/{multimin.c → gsl_native/multimin.c} +64 -92
  173. data/ext/{multimin_fsdf.c → gsl_native/multimin_fsdf.c} +16 -16
  174. data/ext/{multiroots.c → gsl_native/multiroots.c} +73 -76
  175. data/ext/{multiset.c → gsl_native/multiset.c} +4 -8
  176. data/ext/{ndlinear.c → gsl_native/ndlinear.c} +320 -321
  177. data/ext/{nmf.c → gsl_native/nmf.c} +11 -11
  178. data/ext/{nmf_wrap.c → gsl_native/nmf_wrap.c} +1 -1
  179. data/ext/{ntuple.c → gsl_native/ntuple.c} +23 -23
  180. data/ext/{odeiv.c → gsl_native/odeiv.c} +101 -116
  181. data/ext/gsl_native/ool.c +879 -0
  182. data/ext/{permutation.c → gsl_native/permutation.c} +39 -37
  183. data/ext/{poly.c → gsl_native/poly.c} +10 -13
  184. data/ext/{poly2.c → gsl_native/poly2.c} +16 -16
  185. data/ext/{poly_source.c → gsl_native/poly_source.h} +249 -293
  186. data/ext/{qrng.c → gsl_native/qrng.c} +9 -20
  187. data/ext/{randist.c → gsl_native/randist.c} +222 -247
  188. data/ext/{rational.c → gsl_native/rational.c} +12 -12
  189. data/ext/{rng.c → gsl_native/rng.c} +30 -47
  190. data/ext/{root.c → gsl_native/root.c} +47 -48
  191. data/ext/{sf.c → gsl_native/sf.c} +196 -244
  192. data/ext/{sf_airy.c → gsl_native/sf_airy.c} +2 -2
  193. data/ext/{sf_bessel.c → gsl_native/sf_bessel.c} +7 -7
  194. data/ext/{sf_clausen.c → gsl_native/sf_clausen.c} +1 -1
  195. data/ext/{sf_coulomb.c → gsl_native/sf_coulomb.c} +40 -40
  196. data/ext/{sf_coupling.c → gsl_native/sf_coupling.c} +30 -30
  197. data/ext/{sf_dawson.c → gsl_native/sf_dawson.c} +1 -1
  198. data/ext/{sf_debye.c → gsl_native/sf_debye.c} +1 -10
  199. data/ext/{sf_dilog.c → gsl_native/sf_dilog.c} +1 -1
  200. data/ext/{sf_elementary.c → gsl_native/sf_elementary.c} +3 -3
  201. data/ext/{sf_ellint.c → gsl_native/sf_ellint.c} +43 -43
  202. data/ext/{sf_elljac.c → gsl_native/sf_elljac.c} +3 -3
  203. data/ext/{sf_erfc.c → gsl_native/sf_erfc.c} +1 -5
  204. data/ext/{sf_exp.c → gsl_native/sf_exp.c} +3 -3
  205. data/ext/{sf_expint.c → gsl_native/sf_expint.c} +2 -12
  206. data/ext/{sf_fermi_dirac.c → gsl_native/sf_fermi_dirac.c} +1 -1
  207. data/ext/{sf_gamma.c → gsl_native/sf_gamma.c} +2 -6
  208. data/ext/{sf_gegenbauer.c → gsl_native/sf_gegenbauer.c} +1 -1
  209. data/ext/{sf_hyperg.c → gsl_native/sf_hyperg.c} +1 -1
  210. data/ext/{sf_laguerre.c → gsl_native/sf_laguerre.c} +4 -4
  211. data/ext/{sf_lambert.c → gsl_native/sf_lambert.c} +1 -1
  212. data/ext/{sf_legendre.c → gsl_native/sf_legendre.c} +1 -1
  213. data/ext/{sf_log.c → gsl_native/sf_log.c} +4 -4
  214. data/ext/gsl_native/sf_mathieu.c +235 -0
  215. data/ext/{sf_power.c → gsl_native/sf_power.c} +1 -1
  216. data/ext/{sf_psi.c → gsl_native/sf_psi.c} +3 -12
  217. data/ext/{sf_synchrotron.c → gsl_native/sf_synchrotron.c} +1 -1
  218. data/ext/{sf_transport.c → gsl_native/sf_transport.c} +1 -1
  219. data/ext/{sf_trigonometric.c → gsl_native/sf_trigonometric.c} +4 -4
  220. data/ext/{sf_zeta.c → gsl_native/sf_zeta.c} +1 -5
  221. data/ext/{signal.c → gsl_native/signal.c} +63 -68
  222. data/ext/{siman.c → gsl_native/siman.c} +45 -49
  223. data/ext/{sort.c → gsl_native/sort.c} +6 -7
  224. data/ext/{spline.c → gsl_native/spline.c} +28 -46
  225. data/ext/{stats.c → gsl_native/stats.c} +105 -118
  226. data/ext/{sum.c → gsl_native/sum.c} +34 -34
  227. data/ext/{tamu_anova.c → gsl_native/tamu_anova.c} +1 -1
  228. data/ext/{tensor.c → gsl_native/tensor.c} +8 -11
  229. data/ext/{tensor_source.c → gsl_native/tensor_source.h} +147 -148
  230. data/ext/{vector.c → gsl_native/vector.c} +11 -14
  231. data/ext/{vector_complex.c → gsl_native/vector_complex.c} +179 -184
  232. data/ext/{vector_double.c → gsl_native/vector_double.c} +178 -183
  233. data/ext/{vector_int.c → gsl_native/vector_int.c} +27 -29
  234. data/ext/{vector_source.c → gsl_native/vector_source.h} +428 -443
  235. data/ext/{wavelet.c → gsl_native/wavelet.c} +224 -246
  236. data/gsl.gemspec +29 -0
  237. data/lib/gsl.rb +8 -3
  238. data/lib/gsl/gnuplot.rb +3 -3
  239. data/lib/gsl/oper.rb +35 -60
  240. data/lib/gsl/version.rb +3 -0
  241. data/lib/rbgsl.rb +1 -3
  242. data/rdoc/alf.rdoc +5 -5
  243. data/rdoc/blas.rdoc +9 -9
  244. data/rdoc/bspline.rdoc +17 -17
  245. data/rdoc/changes.rdoc +4 -9
  246. data/rdoc/cheb.rdoc +25 -25
  247. data/rdoc/cholesky_complex.rdoc +21 -21
  248. data/rdoc/combi.rdoc +37 -37
  249. data/rdoc/complex.rdoc +22 -22
  250. data/rdoc/const.rdoc +47 -47
  251. data/rdoc/dht.rdoc +49 -49
  252. data/rdoc/diff.rdoc +42 -42
  253. data/rdoc/ehandling.rdoc +6 -6
  254. data/rdoc/eigen.rdoc +153 -153
  255. data/rdoc/fft.rdoc +146 -146
  256. data/rdoc/fit.rdoc +109 -109
  257. data/rdoc/function.rdoc +11 -11
  258. data/rdoc/graph.rdoc +17 -17
  259. data/rdoc/hist.rdoc +103 -103
  260. data/rdoc/hist2d.rdoc +42 -42
  261. data/rdoc/hist3d.rdoc +9 -9
  262. data/rdoc/integration.rdoc +110 -110
  263. data/rdoc/interp.rdoc +71 -71
  264. data/rdoc/intro.rdoc +8 -8
  265. data/rdoc/linalg.rdoc +188 -188
  266. data/rdoc/linalg_complex.rdoc +1 -1
  267. data/rdoc/math.rdoc +58 -58
  268. data/rdoc/matrix.rdoc +275 -275
  269. data/rdoc/min.rdoc +57 -57
  270. data/rdoc/monte.rdoc +22 -22
  271. data/rdoc/multimin.rdoc +95 -95
  272. data/rdoc/multiroot.rdoc +80 -80
  273. data/rdoc/narray.rdoc +32 -32
  274. data/rdoc/ndlinear.rdoc +54 -54
  275. data/rdoc/nonlinearfit.rdoc +100 -100
  276. data/rdoc/ntuple.rdoc +31 -31
  277. data/rdoc/odeiv.rdoc +88 -88
  278. data/rdoc/perm.rdoc +90 -90
  279. data/rdoc/poly.rdoc +66 -66
  280. data/rdoc/qrng.rdoc +21 -21
  281. data/rdoc/randist.rdoc +82 -82
  282. data/rdoc/ref.rdoc +57 -57
  283. data/rdoc/rng.rdoc +85 -85
  284. data/rdoc/roots.rdoc +57 -57
  285. data/rdoc/sf.rdoc +428 -428
  286. data/rdoc/siman.rdoc +19 -19
  287. data/rdoc/sort.rdoc +30 -30
  288. data/rdoc/start.rdoc +8 -8
  289. data/rdoc/stats.rdoc +52 -52
  290. data/rdoc/sum.rdoc +12 -12
  291. data/rdoc/tensor.rdoc +31 -31
  292. data/rdoc/tut.rdoc +1 -1
  293. data/rdoc/use.rdoc +39 -39
  294. data/rdoc/vector.rdoc +188 -188
  295. data/rdoc/vector_complex.rdoc +24 -24
  296. data/rdoc/wavelet.rdoc +46 -46
  297. data/test/gsl/blas_test.rb +79 -0
  298. data/test/gsl/bspline_test.rb +63 -0
  299. data/test/gsl/cdf_test.rb +1512 -0
  300. data/test/gsl/cheb_test.rb +80 -0
  301. data/test/gsl/combination_test.rb +100 -0
  302. data/test/gsl/complex_test.rb +20 -0
  303. data/test/gsl/const_test.rb +29 -0
  304. data/test/gsl/deriv_test.rb +62 -0
  305. data/test/gsl/dht_test.rb +79 -0
  306. data/test/gsl/diff_test.rb +53 -0
  307. data/test/gsl/eigen_test.rb +563 -0
  308. data/test/gsl/err_test.rb +23 -0
  309. data/test/gsl/fit_test.rb +101 -0
  310. data/test/gsl/histo_test.rb +14 -0
  311. data/test/gsl/index_test.rb +61 -0
  312. data/test/gsl/integration_test.rb +274 -0
  313. data/test/gsl/interp_test.rb +27 -0
  314. data/test/gsl/linalg_test.rb +463 -0
  315. data/test/gsl/matrix_nmf_test.rb +37 -0
  316. data/test/gsl/matrix_test.rb +98 -0
  317. data/test/gsl/min_test.rb +89 -0
  318. data/test/gsl/monte_test.rb +77 -0
  319. data/test/gsl/multifit_test.rb +753 -0
  320. data/test/gsl/multimin_test.rb +157 -0
  321. data/test/gsl/multiroot_test.rb +135 -0
  322. data/test/gsl/multiset_test.rb +52 -0
  323. data/test/gsl/odeiv_test.rb +275 -0
  324. data/test/gsl/oper_test.rb +98 -0
  325. data/test/gsl/poly_test.rb +338 -0
  326. data/test/gsl/qrng_test.rb +94 -0
  327. data/test/gsl/quartic_test.rb +28 -0
  328. data/test/gsl/randist_test.rb +122 -0
  329. data/test/gsl/rng_test.rb +303 -0
  330. data/test/gsl/roots_test.rb +78 -0
  331. data/test/gsl/sf_test.rb +2079 -0
  332. data/test/gsl/stats_test.rb +122 -0
  333. data/test/gsl/sum_test.rb +69 -0
  334. data/test/gsl/tensor_test.rb +396 -0
  335. data/test/gsl/vector_test.rb +223 -0
  336. data/test/gsl/wavelet_test.rb +130 -0
  337. data/test/gsl_test.rb +321 -0
  338. data/test/test_helper.rb +42 -0
  339. data/uncrustify.cfg +1693 -0
  340. metadata +337 -378
  341. data/README +0 -32
  342. data/VERSION +0 -1
  343. data/ext/bspline.c +0 -130
  344. data/ext/const.c +0 -673
  345. data/ext/cqp.c +0 -283
  346. data/ext/extconf.rb +0 -295
  347. data/ext/fcmp.c +0 -66
  348. data/ext/fresnel.c +0 -312
  349. data/ext/jacobi.c +0 -739
  350. data/ext/ool.c +0 -879
  351. data/ext/oper_complex_source.c +0 -253
  352. data/ext/sf_mathieu.c +0 -238
  353. data/include/rb_gsl_config.h +0 -62
  354. data/include/rb_gsl_dirac.h +0 -13
  355. data/rdoc/index.rdoc +0 -62
  356. data/rdoc/rngextra.rdoc +0 -11
  357. data/rdoc/screenshot.rdoc +0 -40
  358. data/setup.rb +0 -1585
  359. data/tests/blas/amax.rb +0 -14
  360. data/tests/blas/asum.rb +0 -16
  361. data/tests/blas/axpy.rb +0 -25
  362. data/tests/blas/copy.rb +0 -23
  363. data/tests/blas/dot.rb +0 -23
  364. data/tests/bspline.rb +0 -53
  365. data/tests/cdf.rb +0 -1388
  366. data/tests/cheb.rb +0 -112
  367. data/tests/combination.rb +0 -123
  368. data/tests/complex.rb +0 -17
  369. data/tests/const.rb +0 -24
  370. data/tests/deriv.rb +0 -85
  371. data/tests/dht/dht1.rb +0 -17
  372. data/tests/dht/dht2.rb +0 -23
  373. data/tests/dht/dht3.rb +0 -23
  374. data/tests/dht/dht4.rb +0 -23
  375. data/tests/diff.rb +0 -78
  376. data/tests/eigen/eigen.rb +0 -220
  377. data/tests/eigen/gen.rb +0 -105
  378. data/tests/eigen/genherm.rb +0 -66
  379. data/tests/eigen/gensymm.rb +0 -68
  380. data/tests/eigen/nonsymm.rb +0 -53
  381. data/tests/eigen/nonsymmv.rb +0 -53
  382. data/tests/eigen/symm-herm.rb +0 -74
  383. data/tests/err.rb +0 -58
  384. data/tests/fit.rb +0 -124
  385. data/tests/gsl_test.rb +0 -118
  386. data/tests/gsl_test2.rb +0 -110
  387. data/tests/histo.rb +0 -12
  388. data/tests/integration/integration1.rb +0 -72
  389. data/tests/integration/integration2.rb +0 -71
  390. data/tests/integration/integration3.rb +0 -71
  391. data/tests/integration/integration4.rb +0 -71
  392. data/tests/interp.rb +0 -45
  393. data/tests/linalg/HH.rb +0 -64
  394. data/tests/linalg/LU.rb +0 -47
  395. data/tests/linalg/QR.rb +0 -77
  396. data/tests/linalg/SV.rb +0 -24
  397. data/tests/linalg/TDN.rb +0 -116
  398. data/tests/linalg/TDS.rb +0 -122
  399. data/tests/linalg/bidiag.rb +0 -73
  400. data/tests/linalg/cholesky.rb +0 -20
  401. data/tests/linalg/linalg.rb +0 -158
  402. data/tests/matrix/matrix_complex_test.rb +0 -36
  403. data/tests/matrix/matrix_nmf_test.rb +0 -39
  404. data/tests/matrix/matrix_test.rb +0 -48
  405. data/tests/min.rb +0 -99
  406. data/tests/monte/miser.rb +0 -31
  407. data/tests/monte/vegas.rb +0 -45
  408. data/tests/multifit/test_2dgauss.rb +0 -112
  409. data/tests/multifit/test_brown.rb +0 -90
  410. data/tests/multifit/test_enso.rb +0 -246
  411. data/tests/multifit/test_filip.rb +0 -155
  412. data/tests/multifit/test_gauss.rb +0 -97
  413. data/tests/multifit/test_longley.rb +0 -110
  414. data/tests/multifit/test_multifit.rb +0 -52
  415. data/tests/multimin.rb +0 -139
  416. data/tests/multiroot.rb +0 -131
  417. data/tests/multiset.rb +0 -52
  418. data/tests/narray/blas_dnrm2.rb +0 -20
  419. data/tests/odeiv.rb +0 -353
  420. data/tests/poly/poly.rb +0 -290
  421. data/tests/poly/special.rb +0 -65
  422. data/tests/qrng.rb +0 -131
  423. data/tests/quartic.rb +0 -29
  424. data/tests/randist.rb +0 -134
  425. data/tests/rng.rb +0 -305
  426. data/tests/roots.rb +0 -76
  427. data/tests/run-test.sh +0 -17
  428. data/tests/sf/gsl_test_sf.rb +0 -249
  429. data/tests/sf/test_airy.rb +0 -83
  430. data/tests/sf/test_bessel.rb +0 -306
  431. data/tests/sf/test_coulomb.rb +0 -17
  432. data/tests/sf/test_dilog.rb +0 -25
  433. data/tests/sf/test_gamma.rb +0 -209
  434. data/tests/sf/test_hyperg.rb +0 -356
  435. data/tests/sf/test_legendre.rb +0 -227
  436. data/tests/sf/test_mathieu.rb +0 -59
  437. data/tests/sf/test_mode.rb +0 -19
  438. data/tests/sf/test_sf.rb +0 -839
  439. data/tests/stats.rb +0 -174
  440. data/tests/stats_mt.rb +0 -16
  441. data/tests/sum.rb +0 -98
  442. data/tests/sys.rb +0 -323
  443. data/tests/tensor.rb +0 -419
  444. data/tests/vector/vector_complex_test.rb +0 -101
  445. data/tests/vector/vector_test.rb +0 -141
  446. data/tests/wavelet.rb +0 -142
@@ -9,11 +9,10 @@
9
9
  WITHOUT ANY WARRANTY.
10
10
  */
11
11
 
12
- #include "rb_gsl_config.h"
13
12
  #include <gsl/gsl_math.h>
14
- #include "rb_gsl_array.h"
15
- #include "rb_gsl_common.h"
16
- #include "rb_gsl_linalg.h"
13
+ #include "include/rb_gsl_array.h"
14
+ #include "include/rb_gsl_common.h"
15
+ #include "include/rb_gsl_linalg.h"
17
16
 
18
17
  static VALUE cgsl_matrix_LU;
19
18
  static VALUE cgsl_matrix_QR;
@@ -39,7 +38,40 @@ enum {
39
38
 
40
39
  #ifdef HAVE_NARRAY_H
41
40
  static VALUE rb_gsl_linalg_LU_decomp_narray(int argc, VALUE *argv, VALUE obj,
42
- int flag);
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
+ }
43
75
  #endif
44
76
 
45
77
  static VALUE rb_gsl_linalg_LU_decomposition(int argc, VALUE *argv, VALUE obj, int flag)
@@ -52,7 +84,7 @@ static VALUE rb_gsl_linalg_LU_decomposition(int argc, VALUE *argv, VALUE obj, in
52
84
  switch (TYPE(obj)) {
53
85
  case T_MODULE: case T_CLASS: case T_OBJECT:
54
86
  #ifdef HAVE_NARRAY_H
55
- if (NA_IsNArray(argv[0]))
87
+ if (NA_IsNArray(argv[0]))
56
88
  return rb_gsl_linalg_LU_decomp_narray(argc, argv, obj, flag);
57
89
  #endif
58
90
  if (MATRIX_COMPLEX_P(argv[0]))
@@ -71,7 +103,7 @@ static VALUE rb_gsl_linalg_LU_decomposition(int argc, VALUE *argv, VALUE obj, in
71
103
  Data_Get_Struct(omatrix, gsl_matrix, mtmp);
72
104
  if (flag == LINALG_DECOMP_BANG) {
73
105
  m = mtmp;
74
- RBASIC(omatrix)->klass = cgsl_matrix_LU;
106
+ RBGSL_SET_CLASS(omatrix, cgsl_matrix_LU);
75
107
  objm = omatrix;
76
108
  } else {
77
109
  m = make_matrix_clone(mtmp);
@@ -110,45 +142,6 @@ static VALUE rb_gsl_linalg_LU_decomp_bang(int argc, VALUE *argv, VALUE obj)
110
142
  return rb_gsl_linalg_LU_decomposition(argc, argv, obj, LINALG_DECOMP_BANG);
111
143
  }
112
144
 
113
- #ifdef HAVE_NARRAY_H
114
- static VALUE rb_gsl_linalg_LU_decomp_narray(int argc, VALUE *argv, VALUE obj,
115
- int flag)
116
- {
117
- struct NARRAY *na, *na2;
118
- VALUE m;
119
- gsl_matrix_view mv;
120
- gsl_permutation *p;
121
- int signum;
122
-
123
- if (argc != 1)
124
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
125
- GetNArray(argv[0], na);
126
- if (na->rank < 2) rb_raise(rb_eRuntimeError, "rank >= 2 required");
127
- if (na->shape[0] != na->shape[1])
128
- rb_raise(rb_eRuntimeError, "square matrix required");
129
- if (flag == LINALG_DECOMP) {
130
- m = na_make_object(NA_DFLOAT, 2, na->shape, CLASS_OF(argv[0]));
131
- GetNArray(m, na2);
132
- memcpy((double*)na2->ptr, (double*)na->ptr, sizeof(double)*na2->total);
133
- mv = gsl_matrix_view_array((double*)na2->ptr, na->shape[1], na->shape[0]);
134
- } else {
135
- mv = gsl_matrix_view_array((double*)na->ptr, na->shape[1], na->shape[0]);
136
- }
137
- p = gsl_permutation_alloc(mv.matrix.size1);
138
- gsl_linalg_LU_decomp(&mv.matrix, p, &signum);
139
- if (flag == LINALG_DECOMP) {
140
- return rb_ary_new3(3, m,
141
- Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p),
142
- INT2FIX(signum));
143
- } else {
144
- return rb_ary_new3(3, argv[0],
145
- Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p),
146
- INT2FIX(signum));
147
- }
148
-
149
- }
150
- #endif
151
-
152
145
  static gsl_matrix* get_matrix(VALUE obj, VALUE klass,int *flagm);
153
146
  static gsl_permutation* get_permutation(VALUE obj, size_t size, int *flagp);
154
147
  static gsl_vector* get_vector2(VALUE obj, int *flagv);
@@ -156,15 +149,13 @@ static gsl_vector* get_vector2(VALUE obj, int *flagv);
156
149
  static gsl_matrix* get_matrix(VALUE obj, VALUE klass, int *flagm)
157
150
  {
158
151
  gsl_matrix *mtmp = NULL, *m = NULL;
159
- #ifdef HAVE_NARRAY_H
160
- gsl_matrix_view mv;
161
- struct NARRAY *na;
162
- #endif
163
152
  if (CLASS_OF(obj) == klass) {
164
153
  Data_Get_Struct(obj, gsl_matrix, m);
165
154
  *flagm = 0;
166
155
  #ifdef HAVE_NARRAY_H
167
156
  } else if (NA_IsNArray(obj)) {
157
+ gsl_matrix_view mv;
158
+ struct NARRAY *na;
168
159
  GetNArray(obj, na);
169
160
  mv = gsl_matrix_view_array((double*)na->ptr, na->shape[1], na->shape[0]);
170
161
  m = &mv.matrix;
@@ -195,15 +186,13 @@ static gsl_permutation* get_permutation(VALUE obj, size_t size, int *flagp)
195
186
  static gsl_vector* get_vector2(VALUE obj, int *flagv)
196
187
  {
197
188
  gsl_vector *v = NULL;
198
- #ifdef HAVE_NARRAY_H
199
- gsl_vector_view vv;
200
- struct NARRAY *na;
201
- #endif
202
189
  if (TYPE(obj) == T_ARRAY) {
203
190
  v = make_cvector_from_rarray(obj);
204
191
  *flagv = 1;
205
192
  #ifdef HAVE_NARRAY_H
206
193
  } else if (NA_IsNArray(obj)) {
194
+ gsl_vector_view vv;
195
+ struct NARRAY *na;
207
196
  GetNArray(obj, na);
208
197
  vv = gsl_vector_view_array((double*) na->ptr, na->total);
209
198
  v = &vv.vector;
@@ -218,7 +207,36 @@ static gsl_vector* get_vector2(VALUE obj, int *flagv)
218
207
  }
219
208
 
220
209
  #ifdef HAVE_NARRAY_H
221
- 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
+ }
222
240
  #endif
223
241
 
224
242
  VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
@@ -231,19 +249,18 @@ VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
231
249
  VALUE bb;
232
250
  switch (TYPE(obj)) {
233
251
  case T_MODULE: case T_CLASS: case T_OBJECT:
234
- if (argc < 2 || argc > 4)
252
+ if (argc < 2 || argc > 4)
235
253
  rb_raise(rb_eArgError, "Usage: solve(m, b), solve(m, b, x), solve(lu, p, b), solve(lu, p, b, x)");
236
254
  #ifdef HAVE_NARRAY_H
237
- if (NA_IsNArray(argv[0]))
255
+ if (NA_IsNArray(argv[0]))
238
256
  return rb_gsl_linalg_LU_solve_narray(argc, argv, obj);
239
257
  #endif
240
258
  m = get_matrix(argv[0], cgsl_matrix_LU, &flagm);
241
259
  itmp = 1;
242
260
  break;
243
261
  default:
244
- if (argc < 1 || argc > 3)
262
+ if (argc < 1 || argc > 3)
245
263
  rb_raise(rb_eArgError, "Usage: LU_solve(b), LU_solve(p, b), LU_solve(b, x), solve(p, b, x)");
246
-
247
264
  m = get_matrix(obj, cgsl_matrix_LU, &flagm);
248
265
  itmp = 0;
249
266
  break;
@@ -253,7 +270,6 @@ VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
253
270
  p = get_permutation(argv[itmp], size, &flagp);
254
271
  if (flagp == 1 && flagm == 0) rb_raise(rb_eArgError, "permutation must be given");
255
272
  if (flagp == 0) itmp++;
256
-
257
273
  bb = argv[itmp];
258
274
  b = get_vector2(argv[itmp], &flagb);
259
275
  itmp++;
@@ -275,42 +291,27 @@ VALUE rb_gsl_linalg_LU_solve(int argc, VALUE *argv, VALUE obj)
275
291
  }
276
292
 
277
293
  #ifdef HAVE_NARRAY_H
278
- static VALUE rb_gsl_linalg_LU_solve_narray(int argc, VALUE *argv, VALUE obj)
294
+ static VALUE rb_gsl_linalg_LU_svx_narray(int argc, VALUE *argv, VALUE obj)
279
295
  {
280
296
  struct NARRAY *na, *b;
281
- VALUE ret;
282
297
  gsl_permutation *p;
283
298
  gsl_matrix_view mv;
284
- gsl_vector_view bv, xv;
285
- double *x;
286
- int shape[1];
287
- if (argc < 3)
288
- rb_raise(rb_eArgError,
289
- "wrong number of arguments %d(NArray, GSL::Permutation and NArray expected",
290
- 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);
291
304
  GetNArray(argv[0], na);
292
305
  mv = gsl_matrix_view_array((double*) na->ptr, na->shape[1], na->shape[0]);
293
306
  CHECK_PERMUTATION(argv[1]);
294
307
  Data_Get_Struct(argv[1], gsl_permutation, p);
295
308
  GetNArray(argv[2], b);
296
309
  bv = gsl_vector_view_array((double*) b->ptr, b->total);
297
- if (argc == 3) {
298
- shape[0] = b->total;
299
- ret = na_make_object(NA_DFLOAT, 1, shape, CLASS_OF(argv[0]));
300
- } else {
301
- ret = argv[3];
302
- }
303
- x = NA_PTR_TYPE(ret,double*);
304
- xv = gsl_vector_view_array(x, b->total);
305
- gsl_linalg_LU_solve(&mv.matrix, p, &bv.vector, &xv.vector);
306
- return ret;
310
+ gsl_linalg_LU_svx(&mv.matrix, p, &bv.vector);
311
+ return argv[2];
307
312
  }
308
313
  #endif
309
314
 
310
- #ifdef HAVE_NARRAY_H
311
- static VALUE rb_gsl_linalg_LU_svx_narray(int argc, VALUE *argv, VALUE obj);
312
- #endif
313
-
314
315
  /* bb must be Vector, it is replaced by the root of the system */
315
316
  static VALUE rb_gsl_linalg_LU_svx(int argc, VALUE *argv, VALUE obj)
316
317
  {
@@ -322,18 +323,18 @@ static VALUE rb_gsl_linalg_LU_svx(int argc, VALUE *argv, VALUE obj)
322
323
 
323
324
  switch (TYPE(obj)) {
324
325
  case T_MODULE: case T_CLASS: case T_OBJECT:
325
- if (argc < 2 || argc > 3)
326
+ if (argc < 2 || argc > 3)
326
327
  rb_raise(rb_eArgError, "Usage: svx(m, b), svx(lu, p, b)");
327
328
  #ifdef HAVE_NARRAY_H
328
- if (NA_IsNArray(argv[0]))
329
- return rb_gsl_linalg_LU_svx_narray(argc, argv, obj);
329
+ if (NA_IsNArray(argv[0]))
330
+ return rb_gsl_linalg_LU_svx_narray(argc, argv, obj);
330
331
  #endif
331
332
  m = get_matrix(argv[0], cgsl_matrix_LU, &flagm);
332
333
  itmp = 1;
333
334
  break;
334
335
  default:
335
- if (argc < 1 || argc > 2)
336
- rb_raise(rb_eArgError, "Usage: LU_svx(b), LU_svx(p, b)");
336
+ if (argc < 1 || argc > 2)
337
+ rb_raise(rb_eArgError, "Usage: LU_svx(b), LU_svx(p, b)");
337
338
  m = get_matrix(obj, cgsl_matrix_LU, &flagm);
338
339
  itmp = 0;
339
340
  break;
@@ -351,32 +352,10 @@ static VALUE rb_gsl_linalg_LU_svx(int argc, VALUE *argv, VALUE obj)
351
352
  return argv[itmp];
352
353
  }
353
354
 
354
- #ifdef HAVE_NARRAY_H
355
- static VALUE rb_gsl_linalg_LU_svx_narray(int argc, VALUE *argv, VALUE obj)
356
- {
357
- struct NARRAY *na, *b;
358
- gsl_permutation *p;
359
- gsl_matrix_view mv;
360
- gsl_vector_view bv;
361
- if (argc != 3)
362
- rb_raise(rb_eArgError,
363
- "wrong number of arguments %d(NArray, GSL::Permutation and NArray expected",
364
- argc);
365
- GetNArray(argv[0], na);
366
- mv = gsl_matrix_view_array((double*) na->ptr, na->shape[1], na->shape[0]);
367
- CHECK_PERMUTATION(argv[1]);
368
- Data_Get_Struct(argv[1], gsl_permutation, p);
369
- GetNArray(argv[2], b);
370
- bv = gsl_vector_view_array((double*) b->ptr, b->total);
371
- gsl_linalg_LU_svx(&mv.matrix, p, &bv.vector);
372
- return argv[2];
373
- }
374
- #endif
375
-
376
355
  /* singleton */
377
356
  static VALUE rb_gsl_linalg_LU_refine(VALUE obj, VALUE vm,
378
- VALUE lu, VALUE pp, VALUE bb,
379
- VALUE xx)
357
+ VALUE lu, VALUE pp, VALUE bb,
358
+ VALUE xx)
380
359
  {
381
360
  gsl_matrix *m = NULL, *mlu = NULL;
382
361
  gsl_permutation *p = NULL;
@@ -403,59 +382,6 @@ static VALUE rb_gsl_linalg_LU_refine(VALUE obj, VALUE vm,
403
382
  return rb_ary_new3(2, xx, vr);
404
383
  }
405
384
 
406
- #ifdef HAVE_NARRAY_H
407
- static VALUE rb_gsl_linalg_LU_invert_narray(int argc, VALUE *argv, VALUE obj);
408
- #endif
409
-
410
- static VALUE rb_gsl_linalg_LU_invert(int argc, VALUE *argv, VALUE obj)
411
- {
412
- gsl_matrix *m = NULL, *inverse = NULL;
413
- gsl_permutation *p = NULL;
414
- int signum, flagm = 0, flagp = 0, itmp;
415
- size_t size;
416
- switch (TYPE(obj)) {
417
- case T_MODULE: case T_CLASS: case T_OBJECT:
418
- #ifdef HAVE_NARRAY_H
419
- if (NA_IsNArray(argv[0]))
420
- return rb_gsl_linalg_LU_invert_narray(argc, argv, obj);
421
- #endif
422
- m = get_matrix(argv[0], cgsl_matrix_LU, &flagm);
423
- itmp = 1;
424
- break;
425
- default:
426
- m = get_matrix(obj, cgsl_matrix_LU, &flagm);
427
- itmp = 0;
428
- }
429
- size = m->size1;
430
-
431
- if (argc == itmp) {
432
- p = gsl_permutation_alloc(size);
433
- flagp = 1;
434
- } else {
435
- CHECK_PERMUTATION(argv[itmp]);
436
- p = get_permutation(argv[itmp], size, &flagp);
437
- }
438
- if (flagp == 1 && flagm == 0) rb_raise(rb_eArgError, "permutation must be given");
439
- if (flagp == 0) itmp++;
440
-
441
- if (flagm == 1 || flagp == 1) {
442
- gsl_linalg_LU_decomp(m, p, &signum);
443
- }
444
-
445
- if (argc-1 == itmp) {
446
- CHECK_MATRIX(argv[itmp]);
447
- Data_Get_Struct(argv[itmp], gsl_matrix, inverse);
448
- } else {
449
- inverse = gsl_matrix_alloc(size, size);
450
- }
451
- gsl_linalg_LU_invert(m, p, inverse);
452
- if (flagm == 1) gsl_matrix_free(m);
453
- if (flagp == 1) gsl_permutation_free(p);
454
- if (argc-1 == itmp) return argv[itmp];
455
- else return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, inverse);
456
-
457
- }
458
-
459
385
  #ifdef HAVE_NARRAY_H
460
386
  static VALUE rb_gsl_linalg_LU_invert_narray(int argc, VALUE *argv, VALUE obj)
461
387
  {
@@ -484,7 +410,7 @@ static VALUE rb_gsl_linalg_LU_det_narray(int argc, VALUE *argv, VALUE obj)
484
410
  switch (argc) {
485
411
  case 2:
486
412
  signum = FIX2INT(argv[1]);
487
- /* no break */
413
+ /* no break */
488
414
  case 1:
489
415
  GetNArray(argv[0], na);
490
416
  mv = gsl_matrix_view_array((double*)na->ptr, na->shape[1], na->shape[0]);
@@ -513,6 +439,51 @@ static VALUE rb_gsl_linalg_LU_lndet_narray(int argc, VALUE *argv, VALUE obj)
513
439
 
514
440
  #endif
515
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
+ }
516
487
  static VALUE rb_gsl_linalg_LU_det(int argc, VALUE *argv, VALUE obj)
517
488
  {
518
489
  gsl_matrix *m = NULL;
@@ -523,7 +494,7 @@ static VALUE rb_gsl_linalg_LU_det(int argc, VALUE *argv, VALUE obj)
523
494
  switch (TYPE(obj)) {
524
495
  case T_MODULE: case T_CLASS: case T_OBJECT:
525
496
  if (argc < 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
526
- argc);
497
+ argc);
527
498
  #ifdef HAVE_NARRAY_H
528
499
  if (NA_IsNArray(argv[0]))
529
500
  return rb_gsl_linalg_LU_det_narray(argc, argv, obj);
@@ -548,8 +519,8 @@ static VALUE rb_gsl_linalg_LU_det(int argc, VALUE *argv, VALUE obj)
548
519
  p = gsl_permutation_alloc(size);
549
520
  flagp = 1;
550
521
  }
551
- }
552
- if (flagm == 1) gsl_linalg_LU_decomp(m, p, &sign);
522
+ }
523
+ if (flagm == 1) gsl_linalg_LU_decomp(m, p, &sign);
553
524
  det = gsl_linalg_LU_det(m, sign);
554
525
  if (flagm == 1) gsl_matrix_free(m);
555
526
  if (flagp == 1) gsl_permutation_free(p);
@@ -566,7 +537,7 @@ static VALUE rb_gsl_linalg_LU_lndet(int argc, VALUE *argv, VALUE obj)
566
537
  switch (TYPE(obj)) {
567
538
  case T_MODULE: case T_CLASS: case T_OBJECT:
568
539
  if (argc < 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
569
- argc);
540
+ argc);
570
541
  #ifdef HAVE_NARRAY_H
571
542
  if (NA_IsNArray(argv[0]))
572
543
  return rb_gsl_linalg_LU_lndet_narray(argc, argv, obj);
@@ -580,7 +551,7 @@ static VALUE rb_gsl_linalg_LU_lndet(int argc, VALUE *argv, VALUE obj)
580
551
  }
581
552
  if (flagm == 1) {
582
553
  p = gsl_permutation_alloc(m->size1);
583
- gsl_linalg_LU_decomp(m, p, &sign);
554
+ gsl_linalg_LU_decomp(m, p, &sign);
584
555
  }
585
556
  lndet = gsl_linalg_LU_lndet(m);
586
557
  if (flagm == 1) {
@@ -607,7 +578,7 @@ static VALUE rb_gsl_linalg_LU_sgndet(int argc, VALUE *argv, VALUE obj)
607
578
  }
608
579
  if (flagm == 1) {
609
580
  p = gsl_permutation_alloc(m->size1);
610
- gsl_linalg_LU_decomp(m, p, &sign);
581
+ gsl_linalg_LU_decomp(m, p, &sign);
611
582
  } else {
612
583
  if (argc-itmp != 1) rb_raise(rb_eArgError, "sign must be given");
613
584
  sign = FIX2INT(argv[itmp]);
@@ -620,12 +591,11 @@ static VALUE rb_gsl_linalg_LU_sgndet(int argc, VALUE *argv, VALUE obj)
620
591
  return INT2FIX(signdet);
621
592
  }
622
593
 
623
- #ifdef GSL_1_6_LATER
624
594
  int gsl_linalg_LQ_solve_T(const gsl_matrix*, const gsl_vector*, const gsl_vector*, gsl_vector*);
625
595
  int gsl_linalg_LQ_svx_T (const gsl_matrix*, const gsl_vector*, gsl_vector*);
626
- int gsl_linalg_LQ_lssolve_T(const gsl_matrix * LQ, const gsl_vector * tau,
627
- const gsl_vector * b, gsl_vector * x,
628
- gsl_vector * residual);
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);
629
599
  int
630
600
  gsl_linalg_LQ_Lsolve_T (const gsl_matrix * LQ, const gsl_vector * b, gsl_vector* x);
631
601
  int
@@ -633,9 +603,6 @@ gsl_linalg_LQ_Lsvx_T (const gsl_matrix * LQ, gsl_vector * x);
633
603
  int
634
604
  gsl_linalg_L_solve_T (const gsl_matrix * L, const gsl_vector * b, gsl_vector * x);
635
605
 
636
-
637
- #endif
638
-
639
606
  enum {
640
607
  LINALG_QR_DECOMP,
641
608
  LINALG_QR_DECOMP_BANG,
@@ -660,7 +627,7 @@ enum {
660
627
  };
661
628
 
662
629
  static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
663
- int flag)
630
+ int flag)
664
631
  {
665
632
  gsl_matrix *m = NULL, *mtmp = NULL;
666
633
  gsl_vector *tau = NULL;
@@ -680,7 +647,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
680
647
  break;
681
648
  }
682
649
  CHECK_MATRIX(omatrix);
683
- Data_Get_Struct(omatrix, gsl_matrix, mtmp);
650
+ Data_Get_Struct(omatrix, gsl_matrix, mtmp);
684
651
 
685
652
  switch (flag) {
686
653
  case LINALG_QR_DECOMP:
@@ -692,9 +659,8 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
692
659
  fdecomp = &gsl_linalg_QR_decomp;
693
660
  m = mtmp;
694
661
  mdecomp = omatrix;
695
- RBASIC(mdecomp)->klass = cgsl_matrix_QR;
662
+ RBGSL_SET_CLASS(mdecomp, cgsl_matrix_QR);
696
663
  break;
697
- #ifdef GSL_1_6_LATER
698
664
  case LINALG_LQ_DECOMP:
699
665
  fdecomp = &gsl_linalg_LQ_decomp;
700
666
  m = make_matrix_clone(mtmp);
@@ -704,9 +670,8 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
704
670
  fdecomp = &gsl_linalg_LQ_decomp;
705
671
  m = mtmp;
706
672
  mdecomp = omatrix;
707
- RBASIC(mdecomp)->klass = cgsl_matrix_LQ;
673
+ RBGSL_SET_CLASS(mdecomp, cgsl_matrix_LQ);
708
674
  break;
709
- #endif
710
675
  default:
711
676
  rb_raise(rb_eRuntimeError, "unknown operation");
712
677
  break;
@@ -731,16 +696,16 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
731
696
  vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
732
697
  return rb_ary_new3(2, mdecomp, vtau);
733
698
  } else {
734
- RBASIC(argv[itmp])->klass = cgsl_vector_tau;
699
+ RBGSL_SET_CLASS(argv[itmp], cgsl_vector_tau);
735
700
  return mdecomp;
736
701
  }
737
702
  break;
738
703
  case LINALG_QR_DECOMP_BANG:
739
704
  case LINALG_LQ_DECOMP_BANG:
740
- if (argc == itmp) {
705
+ if (argc == itmp) {
741
706
  return Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
742
707
  } else {
743
- RBASIC(argv[itmp])->klass = cgsl_vector_tau;
708
+ RBGSL_SET_CLASS(argv[itmp], cgsl_vector_tau);
744
709
  return INT2FIX(status);
745
710
  }
746
711
  break;
@@ -752,7 +717,88 @@ static VALUE rb_gsl_linalg_QR_LQ_decomposition(int argc, VALUE *argv, VALUE obj,
752
717
  }
753
718
 
754
719
  #ifdef HAVE_NARRAY_H
755
- 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
+
756
802
  #endif
757
803
 
758
804
  static VALUE rb_gsl_linalg_QR_decomp(int argc, VALUE *argv, VALUE obj)
@@ -769,7 +815,6 @@ static VALUE rb_gsl_linalg_QR_decomp_bang(int argc, VALUE *argv, VALUE obj)
769
815
  return rb_gsl_linalg_QR_LQ_decomposition(argc, argv, obj, LINALG_QR_DECOMP_BANG);
770
816
  }
771
817
 
772
- #ifdef GSL_1_6_LATER
773
818
  static VALUE rb_gsl_linalg_LQ_decomp(int argc, VALUE *argv, VALUE obj)
774
819
  {
775
820
  return rb_gsl_linalg_QR_LQ_decomposition(argc, argv, obj, LINALG_LQ_DECOMP);
@@ -779,7 +824,6 @@ static VALUE rb_gsl_linalg_LQ_decomp_bang(int argc, VALUE *argv, VALUE obj)
779
824
  {
780
825
  return rb_gsl_linalg_QR_LQ_decomposition(argc, argv, obj, LINALG_LQ_DECOMP_BANG);
781
826
  }
782
- #endif
783
827
 
784
828
  static VALUE rb_gsl_linalg_QR_LQ_solve(int argc, VALUE *argv, VALUE obj, int flag)
785
829
  {
@@ -811,13 +855,11 @@ static VALUE rb_gsl_linalg_QR_LQ_solve(int argc, VALUE *argv, VALUE obj, int fla
811
855
  fdecomp = &gsl_linalg_QR_decomp;
812
856
  fsolve = &gsl_linalg_QR_solve;
813
857
  break;
814
- #ifdef GSL_1_6_LATER
815
858
  case LINALG_LQ_SOLVE:
816
859
  m = get_matrix(omatrix, cgsl_matrix_LQ, &flagm);
817
860
  fdecomp = &gsl_linalg_LQ_decomp;
818
861
  fsolve = &gsl_linalg_LQ_solve_T;
819
862
  break;
820
- #endif
821
863
  default:
822
864
  rb_raise(rb_eRuntimeError, "unknown operatioin");
823
865
  break;
@@ -879,7 +921,7 @@ static VALUE rb_gsl_linalg_QR_LQ_svx(int argc, VALUE *argv, VALUE obj, int flag)
879
921
  itmp = 0;
880
922
  break;
881
923
  }
882
- if (argc-itmp < 1 || argc-itmp > 2)
924
+ if (argc-itmp < 1 || argc-itmp > 2)
883
925
  rb_raise(rb_eArgError, "wrong number of arguments");
884
926
  CHECK_MATRIX(omatrix);
885
927
  switch (flag) {
@@ -888,13 +930,11 @@ static VALUE rb_gsl_linalg_QR_LQ_svx(int argc, VALUE *argv, VALUE obj, int flag)
888
930
  fdecomp = &gsl_linalg_QR_decomp;
889
931
  fsvx = &gsl_linalg_QR_svx;
890
932
  break;
891
- #ifdef GSL_1_6_LATER
892
933
  case LINALG_LQ_SOLVE:
893
934
  m = get_matrix(omatrix, cgsl_matrix_LQ, &flagm);
894
935
  fdecomp = &gsl_linalg_LQ_decomp;
895
936
  fsvx = &gsl_linalg_LQ_svx_T;
896
937
  break;
897
- #endif
898
938
  default:
899
939
  rb_raise(rb_eRuntimeError, "unknown operatioin");
900
940
  break;
@@ -933,7 +973,7 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
933
973
  size_t size;
934
974
  int (*fdecomp)(gsl_matrix*, gsl_vector*);
935
975
  int (*flssolve)(const gsl_matrix*, const gsl_vector*, const gsl_vector*, gsl_vector*,
936
- gsl_vector*);
976
+ gsl_vector*);
937
977
 
938
978
  switch (TYPE(obj)) {
939
979
  case T_MODULE: case T_CLASS: case T_OBJECT:
@@ -955,13 +995,11 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
955
995
  fdecomp = &gsl_linalg_QR_decomp;
956
996
  flssolve = &gsl_linalg_QR_lssolve;
957
997
  break;
958
- #ifdef GSL_1_6_LATER
959
998
  case LINALG_LQ_SOLVE:
960
999
  m = get_matrix(omatrix, cgsl_matrix_LQ, &flagm);
961
1000
  fdecomp = &gsl_linalg_LQ_decomp;
962
1001
  flssolve = &gsl_linalg_LQ_lssolve_T;
963
1002
  break;
964
- #endif
965
1003
  default:
966
1004
  rb_raise(rb_eRuntimeError, "unknown operatioin");
967
1005
  break;
@@ -1010,7 +1048,6 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
1010
1048
  if (flagm == 1) gsl_matrix_free(m);
1011
1049
  if (flagt == 1) gsl_vector_free(tau);
1012
1050
  if (flagb == 1) gsl_vector_free(b);
1013
-
1014
1051
  switch (argc - itmp) {
1015
1052
  case 2:
1016
1053
  return INT2FIX(status);
@@ -1020,16 +1057,11 @@ static VALUE rb_gsl_linalg_QR_LQ_lssolve(int argc, VALUE *argv, VALUE obj, int f
1020
1057
  break;
1021
1058
  default:
1022
1059
  return rb_ary_new3(2, Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, x),
1023
- Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, r));
1060
+ Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, r));
1024
1061
  }
1025
1062
  return Qnil;
1026
1063
  }
1027
1064
 
1028
- #ifdef HAVE_NARRAY_H
1029
- static VALUE rb_gsl_linalg_QR_solve_narray(int argc, VALUE *argv, VALUE obj);
1030
- static VALUE rb_gsl_linalg_QR_svx_narray(int argc, VALUE *argv, VALUE obj);
1031
- #endif
1032
-
1033
1065
  static VALUE rb_gsl_linalg_QR_solve(int argc, VALUE *argv, VALUE obj)
1034
1066
  {
1035
1067
  #ifdef HAVE_NARRAY_H
@@ -1053,7 +1085,6 @@ static VALUE rb_gsl_linalg_QR_lssolve(int argc, VALUE *argv, VALUE obj)
1053
1085
  return rb_gsl_linalg_QR_LQ_lssolve(argc, argv, obj, LINALG_QR_SOLVE);
1054
1086
  }
1055
1087
 
1056
- #ifdef GSL_1_6_LATER
1057
1088
  static VALUE rb_gsl_linalg_LQ_solve(int argc, VALUE *argv, VALUE obj)
1058
1089
  {
1059
1090
  return rb_gsl_linalg_QR_LQ_solve(argc, argv, obj, LINALG_LQ_SOLVE);
@@ -1068,18 +1099,17 @@ static VALUE rb_gsl_linalg_LQ_lssolve(int argc, VALUE *argv, VALUE obj)
1068
1099
  {
1069
1100
  return rb_gsl_linalg_QR_LQ_lssolve(argc, argv, obj, LINALG_LQ_SOLVE);
1070
1101
  }
1071
- #endif
1072
1102
 
1073
1103
  static VALUE rb_gsl_linalg_QRLQ_QTvec(int argc, VALUE *argv, VALUE obj,
1074
- int flag)
1104
+ int flag)
1075
1105
  {
1076
1106
  gsl_matrix *QR = NULL;
1077
1107
  gsl_vector *tau = NULL, *v = NULL;
1078
1108
  VALUE ret;
1079
1109
  switch (TYPE(obj)) {
1080
1110
  case T_MODULE: case T_CLASS: case T_OBJECT:
1081
- if (argc != 3) rb_raise(rb_eArgError,
1082
- "wrong number of arguments (%d for 3)", argc);
1111
+ if (argc != 3) rb_raise(rb_eArgError,
1112
+ "wrong number of arguments (%d for 3)", argc);
1083
1113
  CHECK_MATRIX(argv[0]); CHECK_VECTOR(argv[1]); CHECK_VECTOR(argv[2]);
1084
1114
  Data_Get_Struct(argv[0], gsl_matrix, QR);
1085
1115
  Data_Get_Struct(argv[1], gsl_vector, tau);
@@ -1087,8 +1117,8 @@ static VALUE rb_gsl_linalg_QRLQ_QTvec(int argc, VALUE *argv, VALUE obj,
1087
1117
  ret = argv[2];
1088
1118
  break;
1089
1119
  default:
1090
- if (argc != 2) rb_raise(rb_eArgError,
1091
- "wrong number of arguments (%d for 2)", argc);
1120
+ if (argc != 2) rb_raise(rb_eArgError,
1121
+ "wrong number of arguments (%d for 2)", argc);
1092
1122
  CHECK_VECTOR(argv[2]); CHECK_VECTOR(argv[1]);
1093
1123
  Data_Get_Struct(obj, gsl_matrix, QR);
1094
1124
  Data_Get_Struct(argv[0], gsl_vector, tau);
@@ -1103,14 +1133,12 @@ static VALUE rb_gsl_linalg_QRLQ_QTvec(int argc, VALUE *argv, VALUE obj,
1103
1133
  case LINALG_QR_Qvec:
1104
1134
  gsl_linalg_QR_Qvec(QR, tau, v);
1105
1135
  break;
1106
- #ifdef GSL_1_6_LATER
1107
1136
  case LINALG_LQ_vecQ:
1108
1137
  gsl_linalg_LQ_vecQ(QR, tau, v);
1109
1138
  break;
1110
1139
  case LINALG_LQ_vecQT:
1111
1140
  gsl_linalg_LQ_vecQT(QR, tau, v);
1112
1141
  break;
1113
- #endif
1114
1142
  default:
1115
1143
  break;
1116
1144
  }
@@ -1127,7 +1155,6 @@ static VALUE rb_gsl_linalg_QR_Qvec(int argc, VALUE *argv, VALUE obj)
1127
1155
  return rb_gsl_linalg_QRLQ_QTvec(argc, argv, obj, LINALG_QR_Qvec);
1128
1156
  }
1129
1157
 
1130
- #ifdef GSL_1_6_LATER
1131
1158
  static VALUE rb_gsl_linalg_LQ_vecQT(int argc, VALUE *argv, VALUE obj)
1132
1159
  {
1133
1160
  return rb_gsl_linalg_QRLQ_QTvec(argc, argv, obj, LINALG_LQ_vecQT);
@@ -1137,10 +1164,9 @@ static VALUE rb_gsl_linalg_LQ_vecQ(int argc, VALUE *argv, VALUE obj)
1137
1164
  {
1138
1165
  return rb_gsl_linalg_QRLQ_QTvec(argc, argv, obj, LINALG_LQ_vecQ);
1139
1166
  }
1140
- #endif
1141
1167
 
1142
1168
  static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
1143
- int flag)
1169
+ int flag)
1144
1170
  {
1145
1171
  gsl_matrix *QR = NULL, *Q = NULL, *R = NULL;
1146
1172
  gsl_vector *tau = NULL;
@@ -1159,14 +1185,14 @@ static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
1159
1185
  }
1160
1186
  switch (TYPE(obj)) {
1161
1187
  case T_MODULE: case T_CLASS: case T_OBJECT:
1162
- if (argc != 2) rb_raise(rb_eArgError,
1163
- "wrong number of arguments (%d for 2)", argc);
1188
+ if (argc != 2) rb_raise(rb_eArgError,
1189
+ "wrong number of arguments (%d for 2)", argc);
1164
1190
  vtmp = argv[0];
1165
1191
  itmp = 1;
1166
1192
  break;
1167
1193
  default:
1168
- if (argc != 1) rb_raise(rb_eArgError,
1169
- "wrong number of arguments (%d for 1)", argc);
1194
+ if (argc != 1) rb_raise(rb_eArgError,
1195
+ "wrong number of arguments (%d for 1)", argc);
1170
1196
  vtmp = obj;
1171
1197
  itmp = 0;
1172
1198
  break;
@@ -1187,13 +1213,11 @@ static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
1187
1213
  vQ = Data_Wrap_Struct(cgsl_matrix_Q, 0, gsl_matrix_free, Q);
1188
1214
  vR = Data_Wrap_Struct(cgsl_matrix_R, 0, gsl_matrix_free, R);
1189
1215
  break;
1190
- #ifdef GSL_1_6_LATER
1191
1216
  case LINALG_LQ_UNPACK:
1192
- gsl_linalg_LQ_unpack(QR, tau, Q, R);
1193
- vQ = Data_Wrap_Struct(cgsl_matrix_L, 0, gsl_matrix_free, Q);
1194
- vR = Data_Wrap_Struct(cgsl_matrix_Q, 0, gsl_matrix_free, R);
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);
1195
1220
  break;
1196
- #endif
1197
1221
  default:
1198
1222
  rb_raise(rb_eRuntimeError, "unknown operation");
1199
1223
  break;
@@ -1201,10 +1225,6 @@ static VALUE rb_gsl_linalg_QRLQ_unpack(int argc, VALUE *argv, VALUE obj,
1201
1225
  return rb_ary_new3(2, vQ, vR);
1202
1226
  }
1203
1227
 
1204
- #ifdef HAVE_NARRAY_H
1205
- static VALUE rb_gsl_linalg_QR_unpack_narray(int argc, VALUE *argv, VALUE obj);
1206
- #endif
1207
-
1208
1228
  static VALUE rb_gsl_linalg_QR_unpack(int argc, VALUE *argv, VALUE obj)
1209
1229
  {
1210
1230
  #ifdef HAVE_NARRAY_H
@@ -1214,16 +1234,14 @@ static VALUE rb_gsl_linalg_QR_unpack(int argc, VALUE *argv, VALUE obj)
1214
1234
  return rb_gsl_linalg_QRLQ_unpack(argc, argv, obj, LINALG_QR_UNPACK);
1215
1235
  }
1216
1236
 
1217
- #ifdef GSL_1_6_LATER
1218
1237
  static VALUE rb_gsl_linalg_LQ_unpack(int argc, VALUE *argv, VALUE obj)
1219
1238
  {
1220
1239
  return rb_gsl_linalg_QRLQ_unpack(argc, argv, obj, LINALG_LQ_UNPACK);
1221
1240
  }
1222
- #endif
1223
1241
 
1224
1242
  /* singleton */
1225
1243
  static VALUE rb_gsl_linalg_QRLQ_QRLQsolve(int argc, VALUE *argv, VALUE obj,
1226
- int flag)
1244
+ int flag)
1227
1245
  {
1228
1246
  gsl_matrix *Q = NULL, *R = NULL;
1229
1247
  gsl_vector *b = NULL, *x = NULL;
@@ -1252,21 +1270,19 @@ static VALUE rb_gsl_linalg_QRLQ_QRLQsolve(int argc, VALUE *argv, VALUE obj,
1252
1270
  }
1253
1271
  switch (flag) {
1254
1272
  case LINALG_QR_DECOMP:
1255
- if (CLASS_OF(argv[0]) != cgsl_matrix_Q)
1273
+ if (CLASS_OF(argv[0]) != cgsl_matrix_Q)
1256
1274
  rb_raise(rb_eTypeError, "not a Q matrix");
1257
- if (CLASS_OF(argv[1]) != cgsl_matrix_R)
1275
+ if (CLASS_OF(argv[1]) != cgsl_matrix_R)
1258
1276
  rb_raise(rb_eTypeError, "not a R matrix");
1259
1277
  fsolve = &gsl_linalg_QR_QRsolve;
1260
1278
  break;
1261
- #ifdef GSL_1_6_LATER
1262
1279
  case LINALG_LQ_DECOMP:
1263
- /* if (CLASS_OF(argv[0]) != cgsl_matrix_L)
1280
+ /* if (CLASS_OF(argv[0]) != cgsl_matrix_L)
1264
1281
  rb_raise(rb_eTypeError, "not a L matrix");
1265
- if (CLASS_OF(argv[1]) != cgsl_matrix_Q)
1282
+ if (CLASS_OF(argv[1]) != cgsl_matrix_Q)
1266
1283
  rb_raise(rb_eTypeError, "not a Q matrix");*/
1267
1284
  fsolve = &gsl_linalg_LQ_LQsolve;
1268
1285
  break;
1269
- #endif
1270
1286
  default:
1271
1287
  rb_raise(rb_eRuntimeError, "unknown operation");
1272
1288
  break;
@@ -1285,7 +1301,7 @@ static VALUE rb_gsl_linalg_QRLQ_QRLQsolve(int argc, VALUE *argv, VALUE obj,
1285
1301
 
1286
1302
  /*****/
1287
1303
  static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
1288
- int flag)
1304
+ int flag)
1289
1305
  {
1290
1306
  gsl_matrix *QR = NULL, *mtmp;
1291
1307
  gsl_vector *b = NULL, *x = NULL, *tau = NULL;
@@ -1339,7 +1355,6 @@ static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
1339
1355
  }
1340
1356
  fsolve = &gsl_linalg_R_solve;
1341
1357
  break;
1342
- #ifdef GSL_1_6_LATER
1343
1358
  case LINALG_LQ_LSOLVE:
1344
1359
  if (CLASS_OF(omatrix) != cgsl_matrix_LQ) {
1345
1360
  QR = make_matrix_clone(mtmp);
@@ -1358,7 +1373,6 @@ static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
1358
1373
  }
1359
1374
  fsolve = &gsl_linalg_L_solve_T;
1360
1375
  break;
1361
- #endif
1362
1376
  default:
1363
1377
  rb_raise(rb_eRuntimeError, "unknown operation");
1364
1378
  break;
@@ -1380,7 +1394,7 @@ static VALUE rb_gsl_linalg_QRLQ_RLsolve(int argc, VALUE *argv, VALUE obj,
1380
1394
  }
1381
1395
 
1382
1396
  static VALUE rb_gsl_linalg_QRLQ_RLsvx(int argc, VALUE *argv, VALUE obj,
1383
- int flag)
1397
+ int flag)
1384
1398
  {
1385
1399
  gsl_matrix *QR = NULL, *mtmp;
1386
1400
  gsl_vector *x = NULL, *tau = NULL;
@@ -1425,18 +1439,17 @@ static VALUE rb_gsl_linalg_QRLQ_RLsvx(int argc, VALUE *argv, VALUE obj,
1425
1439
  }
1426
1440
  fsolve = &gsl_linalg_QR_Rsvx;
1427
1441
  break;
1428
- /*
1429
- case LINALG_R_SVX:
1430
- if (CLASS_OF(omatrix) != cgsl_matrix_QR) {
1431
- QR = make_matrix_clone(mtmp);
1432
- tau = gsl_vector_alloc(QR->size1);
1433
- gsl_linalg_QR_decomp(QR, tau);
1434
- flagq = 1;
1435
- }
1436
- fsolve = &gsl_linalg_R_svx;
1437
- break;
1438
- */
1439
- #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
+ */
1440
1453
  case LINALG_LQ_LSVX:
1441
1454
  if (CLASS_OF(omatrix) != cgsl_matrix_LQ) {
1442
1455
  QR = make_matrix_clone(mtmp);
@@ -1446,7 +1459,6 @@ static VALUE rb_gsl_linalg_QRLQ_RLsvx(int argc, VALUE *argv, VALUE obj,
1446
1459
  }
1447
1460
  fsolve = &gsl_linalg_LQ_Lsvx_T;
1448
1461
  break;
1449
- #endif
1450
1462
  default:
1451
1463
  rb_raise(rb_eRuntimeError, "unknown operation");
1452
1464
  break;
@@ -1476,12 +1488,11 @@ static VALUE rb_gsl_linalg_R_solve(int argc, VALUE *argv, VALUE obj)
1476
1488
 
1477
1489
  /* singleton */
1478
1490
  static VALUE rb_gsl_linalg_QR_QRsolve(int argc, VALUE *argv, VALUE obj,
1479
- int flag)
1491
+ int flag)
1480
1492
  {
1481
1493
  return rb_gsl_linalg_QRLQ_QRLQsolve(argc, argv, obj, LINALG_QR_DECOMP);
1482
1494
  }
1483
1495
 
1484
- #ifdef GSL_1_6_LATER
1485
1496
  static VALUE rb_gsl_linalg_LQ_Lsolve(int argc, VALUE *argv, VALUE obj)
1486
1497
  {
1487
1498
  return rb_gsl_linalg_QRLQ_RLsolve(argc, argv, obj, LINALG_LQ_LSOLVE);
@@ -1499,14 +1510,13 @@ static VALUE rb_gsl_linalg_L_solve(int argc, VALUE *argv, VALUE obj)
1499
1510
 
1500
1511
  /* singleton */
1501
1512
  static VALUE rb_gsl_linalg_LQ_LQsolve(int argc, VALUE *argv, VALUE obj,
1502
- int flag)
1513
+ int flag)
1503
1514
  {
1504
1515
  return rb_gsl_linalg_QRLQ_QRLQsolve(argc, argv, obj, LINALG_LQ_DECOMP);
1505
1516
  }
1506
- #endif
1507
1517
 
1508
1518
  static VALUE rb_gsl_linalg_QRLQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
1509
- VALUE vv, int flag)
1519
+ VALUE vv, int flag)
1510
1520
  {
1511
1521
  gsl_matrix *Q = NULL, *R = NULL;
1512
1522
  gsl_vector *w = NULL, *v = NULL;
@@ -1521,11 +1531,9 @@ static VALUE rb_gsl_linalg_QRLQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
1521
1531
  case LINALG_QR_DECOMP:
1522
1532
  status = gsl_linalg_QR_update(Q, R, w, v);
1523
1533
  break;
1524
- #ifdef GSL_1_6_LATER
1525
1534
  case LINALG_LQ_DECOMP:
1526
1535
  status = gsl_linalg_LQ_update(Q, R, w, v);
1527
1536
  break;
1528
- #endif
1529
1537
  default:
1530
1538
  rb_raise(rb_eRuntimeError, "unknown operation");
1531
1539
  break;
@@ -1535,18 +1543,16 @@ static VALUE rb_gsl_linalg_QRLQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
1535
1543
 
1536
1544
  /* singleton */
1537
1545
  static VALUE rb_gsl_linalg_QR_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
1538
- VALUE vv)
1546
+ VALUE vv)
1539
1547
  {
1540
1548
  return rb_gsl_linalg_QRLQ_update(obj, qq, rr, ww, vv, LINALG_QR_DECOMP);
1541
1549
  }
1542
1550
 
1543
- #ifdef GSL_1_6_LATER
1544
1551
  static VALUE rb_gsl_linalg_LQ_update(VALUE obj, VALUE qq, VALUE rr, VALUE ww,
1545
- VALUE vv)
1552
+ VALUE vv)
1546
1553
  {
1547
1554
  return rb_gsl_linalg_QRLQ_update(obj, qq, rr, ww, vv, LINALG_LQ_DECOMP);
1548
1555
  }
1549
- #endif
1550
1556
 
1551
1557
  /******/
1552
1558
  enum {
@@ -1565,7 +1571,7 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp(int argc, VALUE *argv, VALUE obj, int f
1565
1571
  switch (TYPE(obj)) {
1566
1572
  case T_MODULE: case T_CLASS: case T_OBJECT:
1567
1573
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
1568
- argc);
1574
+ argc);
1569
1575
  vA = argv[0];
1570
1576
  break;
1571
1577
  default:
@@ -1586,14 +1592,12 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp(int argc, VALUE *argv, VALUE obj, int f
1586
1592
  vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
1587
1593
  gsl_linalg_QRPT_decomp(QR, tau, p, &signum, norm);
1588
1594
  break;
1589
- #ifdef GSL_1_6_LATER
1590
1595
  case LINALG_PTLQ:
1591
1596
  vQR = Data_Wrap_Struct(cgsl_matrix_PTLQ, 0, gsl_matrix_free, QR);
1592
1597
  vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
1593
1598
  vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
1594
1599
  gsl_linalg_PTLQ_decomp(QR, tau, p, &signum, norm);
1595
1600
  break;
1596
- #endif
1597
1601
  default:
1598
1602
  rb_raise(rb_eRuntimeError, "unknown operation");
1599
1603
  break;
@@ -1613,7 +1617,7 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp_bang(int argc, VALUE *argv, VALUE obj,
1613
1617
  switch (TYPE(obj)) {
1614
1618
  case T_MODULE: case T_CLASS: case T_OBJECT:
1615
1619
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
1616
- argc);
1620
+ argc);
1617
1621
  vA = argv[0];
1618
1622
  break;
1619
1623
  default:
@@ -1628,19 +1632,17 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp_bang(int argc, VALUE *argv, VALUE obj,
1628
1632
  norm = gsl_vector_alloc(size0);
1629
1633
  switch (flag) {
1630
1634
  case LINALG_QRPT:
1631
- RBASIC(vA)->klass = cgsl_matrix_QRPT;
1635
+ RBGSL_SET_CLASS(vA, cgsl_matrix_QRPT);
1632
1636
  vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
1633
1637
  vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
1634
1638
  gsl_linalg_QRPT_decomp(A, tau, p, &signum, norm);
1635
1639
  break;
1636
- #ifdef GSL_1_6_LATER
1637
1640
  case LINALG_PTLQ:
1638
- RBASIC(vA)->klass = cgsl_matrix_PTLQ;
1641
+ RBGSL_SET_CLASS(vA, cgsl_matrix_PTLQ);
1639
1642
  vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
1640
1643
  vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
1641
1644
  gsl_linalg_PTLQ_decomp(A, tau, p, &signum, norm);
1642
1645
  break;
1643
- #endif
1644
1646
  default:
1645
1647
  rb_raise(rb_eRuntimeError, "unknown operation");
1646
1648
  break;
@@ -1659,7 +1661,6 @@ static VALUE rb_gsl_linalg_QRPT_decomp_bang(int argc, VALUE *argv, VALUE obj)
1659
1661
  return rb_gsl_linalg_QRLQPT_decomp_bang(argc, argv, obj, LINALG_QRPT);
1660
1662
  }
1661
1663
 
1662
- #ifdef GSL_1_6_LATER
1663
1664
  static VALUE rb_gsl_linalg_PTLQ_decomp(int argc, VALUE *argv, VALUE obj)
1664
1665
  {
1665
1666
  return rb_gsl_linalg_QRLQPT_decomp(argc, argv, obj, LINALG_PTLQ);
@@ -1669,7 +1670,6 @@ static VALUE rb_gsl_linalg_PTLQ_decomp_bang(int argc, VALUE *argv, VALUE obj)
1669
1670
  {
1670
1671
  return rb_gsl_linalg_QRLQPT_decomp_bang(argc, argv, obj, LINALG_PTLQ);
1671
1672
  }
1672
- #endif
1673
1673
 
1674
1674
  static VALUE rb_gsl_linalg_QRLQPT_decomp2(int argc, VALUE *argv, VALUE obj,int flag)
1675
1675
  {
@@ -1707,13 +1707,11 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp2(int argc, VALUE *argv, VALUE obj,int f
1707
1707
  vR = Data_Wrap_Struct(cgsl_matrix_R, 0, gsl_matrix_free, R);
1708
1708
  gsl_linalg_QRPT_decomp2(A, Q, R, tau, p, &signum, norm);
1709
1709
  break;
1710
- #ifdef GSL_1_6_LATER
1711
1710
  case LINALG_PTLQ:
1712
1711
  vR = Data_Wrap_Struct(cgsl_matrix_L, 0, gsl_matrix_free, R);
1713
1712
  vQ = Data_Wrap_Struct(cgsl_matrix_Q, 0, gsl_matrix_free, Q);
1714
1713
  gsl_linalg_PTLQ_decomp2(A, Q, R, tau, p, &signum, norm);
1715
1714
  break;
1716
- #endif
1717
1715
  default:
1718
1716
  rb_raise(rb_eRuntimeError, "unknown operation");
1719
1717
  }
@@ -1726,33 +1724,29 @@ static VALUE rb_gsl_linalg_QRPT_decomp2(int argc, VALUE *argv, VALUE obj)
1726
1724
  return rb_gsl_linalg_QRLQPT_decomp2(argc, argv, obj, LINALG_QRPT);
1727
1725
  }
1728
1726
 
1729
- #ifdef GSL_1_6_LATER
1730
1727
  static VALUE rb_gsl_linalg_PTLQ_decomp2(int argc, VALUE *argv, VALUE obj)
1731
1728
  {
1732
1729
  return rb_gsl_linalg_QRLQPT_decomp2(argc, argv, obj, LINALG_PTLQ);
1733
1730
  }
1734
- #endif
1735
1731
 
1736
- #ifdef GSL_1_6_LATER
1737
1732
  int gsl_linalg_PTLQ_solve_T(const gsl_matrix * QR, const gsl_vector * tau,
1738
- const gsl_permutation * p, const gsl_vector * b,
1739
- gsl_vector * x);
1733
+ const gsl_permutation * p, const gsl_vector * b,
1734
+ gsl_vector * x);
1740
1735
  int gsl_linalg_PTLQ_svx_T(const gsl_matrix * LQ,
1741
- const gsl_vector * tau,
1742
- const gsl_permutation * p,
1743
- gsl_vector * x);
1736
+ const gsl_vector * tau,
1737
+ const gsl_permutation * p,
1738
+ gsl_vector * x);
1744
1739
  int gsl_linalg_PTLQ_LQsolve_T (const gsl_matrix * Q, const gsl_matrix * L,
1745
- const gsl_permutation * p,
1746
- const gsl_vector * b,
1747
- gsl_vector * x);
1740
+ const gsl_permutation * p,
1741
+ const gsl_vector * b,
1742
+ gsl_vector * x);
1748
1743
  int gsl_linalg_PTLQ_Lsolve_T (const gsl_matrix * LQ,
1749
- const gsl_permutation * p,
1750
- const gsl_vector * b,
1751
- gsl_vector * x);
1744
+ const gsl_permutation * p,
1745
+ const gsl_vector * b,
1746
+ gsl_vector * x);
1752
1747
  int gsl_linalg_PTLQ_Lsvx_T (const gsl_matrix * LQ,
1753
- const gsl_permutation * p,
1754
- gsl_vector * x);
1755
- #endif
1748
+ const gsl_permutation * p,
1749
+ gsl_vector * x);
1756
1750
 
1757
1751
  static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int flag)
1758
1752
  {
@@ -1763,21 +1757,19 @@ static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int fl
1763
1757
  VALUE vtmp, klass;
1764
1758
  size_t size0;
1765
1759
  int (*fdecomp)(gsl_matrix*, gsl_vector*, gsl_permutation*, int *, gsl_vector*);
1766
- int (*fsolve)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
1767
- const gsl_vector*, gsl_vector *);
1760
+ int (*fsolve)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
1761
+ const gsl_vector*, gsl_vector *);
1768
1762
  switch (flag) {
1769
1763
  case LINALG_QRPT:
1770
1764
  klass = cgsl_matrix_QRPT;
1771
1765
  fdecomp = &gsl_linalg_QRPT_decomp;
1772
1766
  fsolve = &gsl_linalg_QRPT_solve;
1773
1767
  break;
1774
- #ifdef GSL_1_6_LATER
1775
1768
  case LINALG_PTLQ:
1776
1769
  klass = cgsl_matrix_PTLQ;
1777
1770
  fdecomp = &gsl_linalg_PTLQ_decomp;
1778
1771
  fsolve = &gsl_linalg_PTLQ_solve_T;
1779
1772
  break;
1780
- #endif
1781
1773
  default:
1782
1774
  rb_raise(rb_eRuntimeError, "unknown operation");
1783
1775
  break;
@@ -1795,11 +1787,11 @@ static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int fl
1795
1787
  }
1796
1788
  CHECK_MATRIX(vtmp);
1797
1789
  if (CLASS_OF(vtmp) == klass) {
1798
- if (argc-itmp != 3) rb_raise(rb_eArgError,
1799
- "wrong number of arguments (%d for %d)",
1800
- argc, 4-itmp);
1790
+ if (argc-itmp != 3) rb_raise(rb_eArgError,
1791
+ "wrong number of arguments (%d for %d)",
1792
+ argc, 4-itmp);
1801
1793
  CHECK_VECTOR(argv[itmp]);
1802
- if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
1794
+ if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
1803
1795
  rb_raise(rb_eTypeError, "not a tau vector");
1804
1796
  CHECK_PERMUTATION(argv[itmp+1]);
1805
1797
  Data_Get_Struct(argv[itmp], gsl_vector, tau);
@@ -1808,8 +1800,8 @@ static VALUE rb_gsl_linalg_QRLQPT_solve(int argc, VALUE *argv, VALUE obj, int fl
1808
1800
  size0 = GSL_MIN(QR->size1, QR->size2);
1809
1801
  itmp += 2;
1810
1802
  } else {
1811
- if (argc-itmp != 1) rb_raise(rb_eArgError,
1812
- "wrong number of arguments (%d for %d)", argc, 2-itmp);
1803
+ if (argc-itmp != 1) rb_raise(rb_eArgError,
1804
+ "wrong number of arguments (%d for %d)", argc, 2-itmp);
1813
1805
  Data_Get_Struct(vtmp, gsl_matrix, A);
1814
1806
  QR = make_matrix_clone(A);
1815
1807
  size0 = GSL_MIN(QR->size1, QR->size2);
@@ -1843,12 +1835,10 @@ static VALUE rb_gsl_linalg_QRPT_solve(int argc, VALUE *argv, VALUE obj)
1843
1835
  return rb_gsl_linalg_QRLQPT_solve(argc, argv, obj, LINALG_QRPT);
1844
1836
  }
1845
1837
 
1846
- #ifdef GSL_1_6_LATER
1847
1838
  static VALUE rb_gsl_linalg_PTLQ_solve(int argc, VALUE *argv, VALUE obj)
1848
1839
  {
1849
1840
  return rb_gsl_linalg_QRLQPT_solve(argc, argv, obj, LINALG_PTLQ);
1850
1841
  }
1851
- #endif
1852
1842
 
1853
1843
  static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag)
1854
1844
  {
@@ -1859,21 +1849,19 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
1859
1849
  VALUE vtmp, klass;
1860
1850
  size_t size0;
1861
1851
  int (*fdecomp)(gsl_matrix*, gsl_vector*, gsl_permutation*, int *, gsl_vector*);
1862
- int (*fsvx)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
1863
- gsl_vector *);
1852
+ int (*fsvx)(const gsl_matrix*, const gsl_vector*, const gsl_permutation*,
1853
+ gsl_vector *);
1864
1854
  switch (flag) {
1865
1855
  case LINALG_QRPT:
1866
1856
  klass = cgsl_matrix_QRPT;
1867
1857
  fdecomp = &gsl_linalg_QRPT_decomp;
1868
1858
  fsvx = &gsl_linalg_QRPT_svx;
1869
1859
  break;
1870
- #ifdef GSL_1_6_LATER
1871
1860
  case LINALG_PTLQ:
1872
1861
  klass = cgsl_matrix_PTLQ;
1873
1862
  fdecomp = &gsl_linalg_PTLQ_decomp;
1874
1863
  fsvx = &gsl_linalg_PTLQ_svx_T;
1875
1864
  break;
1876
- #endif
1877
1865
  default:
1878
1866
  rb_raise(rb_eRuntimeError, "unknown operation");
1879
1867
  break;
@@ -1882,7 +1870,7 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
1882
1870
  switch (TYPE(obj)) {
1883
1871
  case T_MODULE: case T_CLASS: case T_OBJECT:
1884
1872
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
1885
- argc);
1873
+ argc);
1886
1874
  vtmp = argv[0];
1887
1875
  itmp = 1;
1888
1876
  break;
@@ -1893,11 +1881,11 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
1893
1881
  }
1894
1882
  CHECK_MATRIX(vtmp);
1895
1883
  if (CLASS_OF(vtmp) == klass) {
1896
- if (argc-itmp != 3) rb_raise(rb_eArgError,
1897
- "wrong number of arguments (%d for %d)",
1898
- argc, 3+itmp);
1884
+ if (argc-itmp != 3) rb_raise(rb_eArgError,
1885
+ "wrong number of arguments (%d for %d)",
1886
+ argc, 3+itmp);
1899
1887
  CHECK_VECTOR(argv[itmp]);
1900
- if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
1888
+ if (CLASS_OF(argv[itmp]) != cgsl_vector_tau)
1901
1889
  rb_raise(rb_eTypeError, "not a tau vector");
1902
1890
  CHECK_PERMUTATION(argv[itmp+1]);
1903
1891
  Data_Get_Struct(argv[itmp], gsl_vector, tau);
@@ -1906,8 +1894,8 @@ static VALUE rb_gsl_linalg_QRLQPT_svx(int argc, VALUE *argv, VALUE obj, int flag
1906
1894
  size0 = GSL_MIN(QR->size1, QR->size2);
1907
1895
  itmp += 2;
1908
1896
  } else {
1909
- if (argc-itmp != 1) rb_raise(rb_eArgError,
1910
- "wrong number of arguments (%d for %d)", argc, 2+itmp);
1897
+ if (argc-itmp != 1) rb_raise(rb_eArgError,
1898
+ "wrong number of arguments (%d for %d)", argc, 2+itmp);
1911
1899
  Data_Get_Struct(vtmp, gsl_matrix, A);
1912
1900
  QR = make_matrix_clone(A);
1913
1901
  size0 = GSL_MIN(QR->size1, QR->size2);
@@ -1934,36 +1922,32 @@ static VALUE rb_gsl_linalg_QRPT_svx(int argc, VALUE *argv, VALUE obj)
1934
1922
  return rb_gsl_linalg_QRLQPT_svx(argc, argv, obj, LINALG_QRPT);
1935
1923
  }
1936
1924
 
1937
- #ifdef GSL_1_6_LATER
1938
1925
  static VALUE rb_gsl_linalg_PTLQ_svx(int argc, VALUE *argv, VALUE obj)
1939
1926
  {
1940
1927
  return rb_gsl_linalg_QRLQPT_svx(argc, argv, obj, LINALG_PTLQ);
1941
1928
  }
1942
- #endif
1943
1929
 
1944
1930
  /* singleton */
1945
- static VALUE rb_gsl_linalg_QRLQPT_QRLQsolve(VALUE obj, VALUE qq, VALUE rr,
1946
- VALUE pp, VALUE bb, int flag)
1931
+ static VALUE rb_gsl_linalg_QRLQPT_QRLQsolve(VALUE obj, VALUE qq, VALUE rr,
1932
+ VALUE pp, VALUE bb, int flag)
1947
1933
  {
1948
1934
  gsl_matrix *Q = NULL, *R = NULL;
1949
1935
  gsl_vector *b = NULL, *x = NULL;
1950
1936
  gsl_permutation *p = NULL;
1951
1937
  int flagb = 0;
1952
- int (*fsolve)(const gsl_matrix*, const gsl_matrix*, const gsl_permutation*,
1953
- const gsl_vector*, gsl_vector*);
1938
+ int (*fsolve)(const gsl_matrix*, const gsl_matrix*, const gsl_permutation*,
1939
+ const gsl_vector*, gsl_vector*);
1954
1940
  switch (flag) {
1955
1941
  case LINALG_QRPT:
1956
1942
  if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
1957
1943
  if (CLASS_OF(rr) != cgsl_matrix_R) rb_raise(rb_eTypeError, "not a R matrix");
1958
1944
  fsolve = &gsl_linalg_QRPT_QRsolve;
1959
1945
  break;
1960
- #ifdef GSL_1_6_LATER
1961
1946
  case LINALG_PTLQ:
1962
1947
  if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
1963
1948
  if (CLASS_OF(rr) != cgsl_matrix_L) rb_raise(rb_eTypeError, "not a L matrix");
1964
1949
  fsolve = &gsl_linalg_PTLQ_LQsolve_T;
1965
1950
  break;
1966
- #endif
1967
1951
  default:
1968
1952
  rb_raise(rb_eRuntimeError, "unknown operation");
1969
1953
  break;
@@ -1985,23 +1969,21 @@ static VALUE rb_gsl_linalg_QRLQPT_QRLQsolve(VALUE obj, VALUE qq, VALUE rr,
1985
1969
  return Data_Wrap_Struct(cgsl_vector_col, 0, gsl_vector_free, x);
1986
1970
  }
1987
1971
 
1988
- static VALUE rb_gsl_linalg_QRPT_QRsolve(VALUE obj, VALUE qq, VALUE rr,
1989
- VALUE pp, VALUE bb)
1972
+ static VALUE rb_gsl_linalg_QRPT_QRsolve(VALUE obj, VALUE qq, VALUE rr,
1973
+ VALUE pp, VALUE bb)
1990
1974
  {
1991
1975
  return rb_gsl_linalg_QRLQPT_QRLQsolve(obj, qq, rr, pp, bb, LINALG_QRPT);
1992
1976
  }
1993
1977
 
1994
- #ifdef GSL_1_6_LATER
1995
- static VALUE rb_gsl_linalg_PTLQ_LQsolve(VALUE obj, VALUE qq, VALUE rr,
1996
- VALUE pp, VALUE bb)
1978
+ static VALUE rb_gsl_linalg_PTLQ_LQsolve(VALUE obj, VALUE qq, VALUE rr,
1979
+ VALUE pp, VALUE bb)
1997
1980
  {
1998
1981
  return rb_gsl_linalg_QRLQPT_QRLQsolve(obj, qq, rr, pp, bb, LINALG_PTLQ);
1999
1982
  }
2000
- #endif
2001
1983
 
2002
1984
  /* singleton */
2003
- static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
2004
- VALUE pp, VALUE ww, VALUE vv, int flag)
1985
+ static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
1986
+ VALUE pp, VALUE ww, VALUE vv, int flag)
2005
1987
  {
2006
1988
  gsl_matrix *Q = NULL, *R = NULL;
2007
1989
  gsl_vector *w = NULL, *v = NULL;
@@ -2011,12 +1993,10 @@ static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
2011
1993
  if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
2012
1994
  if (CLASS_OF(rr) != cgsl_matrix_R) rb_raise(rb_eTypeError, "not a R matrix");
2013
1995
  break;
2014
- #ifdef GSL_1_6_LATER
2015
1996
  case LINALG_PTLQ:
2016
1997
  if (CLASS_OF(qq) != cgsl_matrix_Q) rb_raise(rb_eTypeError, "not a Q matrix");
2017
1998
  if (CLASS_OF(rr) != cgsl_matrix_L) rb_raise(rb_eTypeError, "not a L matrix");
2018
1999
  break;
2019
- #endif
2020
2000
  }
2021
2001
  CHECK_PERMUTATION(pp);
2022
2002
  Data_Get_Struct(qq, gsl_matrix, Q);
@@ -2028,28 +2008,24 @@ static VALUE rb_gsl_linalg_QRLQPT_update(VALUE obj, VALUE qq, VALUE rr,
2028
2008
  case LINALG_QRPT:
2029
2009
  gsl_linalg_QRPT_update(Q, R, p, w, v);
2030
2010
  break;
2031
- #ifdef GSL_1_6_LATER
2032
2011
  case LINALG_PTLQ:
2033
2012
  gsl_linalg_PTLQ_update(Q, R, p, w, v);
2034
2013
  break;
2035
- #endif
2036
2014
  }
2037
2015
  return obj;
2038
2016
  }
2039
2017
 
2040
- static VALUE rb_gsl_linalg_QRPT_update(VALUE obj, VALUE qq, VALUE rr,
2041
- VALUE pp, VALUE ww, VALUE vv)
2018
+ static VALUE rb_gsl_linalg_QRPT_update(VALUE obj, VALUE qq, VALUE rr,
2019
+ VALUE pp, VALUE ww, VALUE vv)
2042
2020
  {
2043
2021
  return rb_gsl_linalg_QRLQPT_update(obj, qq, rr, pp, ww, vv, LINALG_QRPT);
2044
2022
  }
2045
2023
 
2046
- #ifdef GSL_1_6_LATER
2047
- static VALUE rb_gsl_linalg_PTLQ_update(VALUE obj, VALUE qq, VALUE rr,
2048
- 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)
2049
2026
  {
2050
2027
  return rb_gsl_linalg_QRLQPT_update(obj, qq, rr, pp, ww, vv, LINALG_PTLQ);
2051
2028
  }
2052
- #endif
2053
2029
 
2054
2030
  static VALUE rb_gsl_linalg_QRLQPT_RLsolve(int argc, VALUE *argv, VALUE obj, int flag)
2055
2031
  {
@@ -2058,19 +2034,17 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsolve(int argc, VALUE *argv, VALUE obj, int
2058
2034
  gsl_permutation *p = NULL;
2059
2035
  int itmp, flagb = 0;
2060
2036
  VALUE vtmp, klass;
2061
- int (*fsolve)(const gsl_matrix*, const gsl_permutation*, const gsl_vector*,
2062
- gsl_vector*);
2037
+ int (*fsolve)(const gsl_matrix*, const gsl_permutation*, const gsl_vector*,
2038
+ gsl_vector*);
2063
2039
  switch (flag) {
2064
2040
  case LINALG_QRPT:
2065
2041
  klass = cgsl_matrix_QRPT;
2066
2042
  fsolve = &gsl_linalg_QRPT_Rsolve;
2067
2043
  break;
2068
- #ifdef GSL_1_6_LATER
2069
2044
  case LINALG_PTLQ:
2070
2045
  klass = cgsl_matrix_PTLQ;
2071
2046
  fsolve = &gsl_linalg_PTLQ_Lsolve_T;
2072
2047
  break;
2073
- #endif
2074
2048
  default:
2075
2049
  rb_raise(rb_eRuntimeError, "unknown operation");
2076
2050
  break;
@@ -2078,7 +2052,7 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsolve(int argc, VALUE *argv, VALUE obj, int
2078
2052
  switch (TYPE(obj)) {
2079
2053
  case T_MODULE: case T_CLASS: case T_OBJECT:
2080
2054
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
2081
- argc);
2055
+ argc);
2082
2056
  vtmp = argv[0];
2083
2057
  itmp = 1;
2084
2058
  break;
@@ -2114,12 +2088,11 @@ static VALUE rb_gsl_linalg_QRPT_Rsolve(int argc, VALUE *argv, VALUE obj)
2114
2088
  {
2115
2089
  return rb_gsl_linalg_QRLQPT_RLsolve(argc, argv, obj, LINALG_QRPT);
2116
2090
  }
2117
- #ifdef GSL_1_6_LATER
2091
+
2118
2092
  static VALUE rb_gsl_linalg_PTLQ_Lsolve(int argc, VALUE *argv, VALUE obj)
2119
2093
  {
2120
2094
  return rb_gsl_linalg_QRLQPT_RLsolve(argc, argv, obj, LINALG_PTLQ);
2121
2095
  }
2122
- #endif
2123
2096
 
2124
2097
  static VALUE rb_gsl_linalg_QRLQPT_RLsvx(int argc, VALUE *argv, VALUE obj, int flag)
2125
2098
  {
@@ -2134,11 +2107,9 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsvx(int argc, VALUE *argv, VALUE obj, int fl
2134
2107
  klass = cgsl_matrix_QRPT;
2135
2108
  fsvx = &gsl_linalg_QRPT_Rsvx;
2136
2109
  break;
2137
- #ifdef GSL_1_6_LATER
2138
2110
  case LINALG_PTLQ:
2139
2111
  klass = cgsl_matrix_PTLQ;
2140
2112
  fsvx = &gsl_linalg_PTLQ_Lsvx_T;
2141
- #endif
2142
2113
  default:
2143
2114
  rb_raise(rb_eRuntimeError, "unknown operation");
2144
2115
  break;
@@ -2146,7 +2117,7 @@ static VALUE rb_gsl_linalg_QRLQPT_RLsvx(int argc, VALUE *argv, VALUE obj, int fl
2146
2117
  switch (TYPE(obj)) {
2147
2118
  case T_MODULE: case T_CLASS: case T_OBJECT:
2148
2119
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
2149
- argc);
2120
+ argc);
2150
2121
  vtmp = argv[0];
2151
2122
  itmp = 1;
2152
2123
  break;
@@ -2179,12 +2150,11 @@ static VALUE rb_gsl_linalg_QRPT_Rsvx(int argc, VALUE *argv, VALUE obj)
2179
2150
  {
2180
2151
  return rb_gsl_linalg_QRLQPT_RLsvx(argc, argv, obj, LINALG_QRPT);
2181
2152
  }
2182
- #ifdef GSL_1_6_LATER
2153
+
2183
2154
  static VALUE rb_gsl_linalg_PTLQ_Lsvx(int argc, VALUE *argv, VALUE obj)
2184
2155
  {
2185
2156
  return rb_gsl_linalg_QRLQPT_RLsvx(argc, argv, obj, LINALG_PTLQ);
2186
2157
  }
2187
- #endif
2188
2158
 
2189
2159
  /*******/
2190
2160
  #ifdef HAVE_NARRAY_H
@@ -2267,11 +2237,11 @@ static VALUE rb_gsl_linalg_SV_decomp(int argc, VALUE *argv, VALUE obj)
2267
2237
  CHECK_VECTOR(argv[1]);
2268
2238
  Data_Get_Struct(argv[1], gsl_vector, w);
2269
2239
  flag = 0;
2270
- /* no break, do next */
2240
+ /* no break, do next */
2271
2241
  case 1:
2272
2242
  #ifdef HAVE_NARRAY_H
2273
2243
  if (NA_IsNArray(argv[0]))
2274
- return rb_gsl_linalg_SV_decomp_narray(argc, argv, obj);
2244
+ return rb_gsl_linalg_SV_decomp_narray(argc, argv, obj);
2275
2245
  #endif
2276
2246
  CHECK_MATRIX(argv[0]);
2277
2247
  Data_Get_Struct(argv[0], gsl_matrix, A);
@@ -2318,7 +2288,7 @@ static VALUE rb_gsl_linalg_SV_decomp_mod(int argc, VALUE *argv, VALUE obj)
2318
2288
  switch (TYPE(obj)) {
2319
2289
  case T_MODULE: case T_CLASS: case T_OBJECT:
2320
2290
  if (argc != 1) rb_raise(rb_eArgError,
2321
- "wrong number of argument (%d for 1)", argc);
2291
+ "wrong number of argument (%d for 1)", argc);
2322
2292
  CHECK_MATRIX(argv[0]);
2323
2293
  Data_Get_Struct(argv[0], gsl_matrix, A);
2324
2294
  break;
@@ -2348,10 +2318,10 @@ static VALUE rb_gsl_linalg_SV_decomp_jacobi(int argc, VALUE *argv, VALUE obj)
2348
2318
  switch (TYPE(obj)) {
2349
2319
  case T_MODULE: case T_CLASS: case T_OBJECT:
2350
2320
  if (argc != 1) rb_raise(rb_eArgError,
2351
- "wrong number of argument (%d for 1)", argc);
2321
+ "wrong number of argument (%d for 1)", argc);
2352
2322
  #ifdef HAVE_NARRAY_H
2353
- if (NA_IsNArray(argv[0]))
2354
- return rb_gsl_linalg_SV_decomp_jacobi_narray(argc, argv, obj);
2323
+ if (NA_IsNArray(argv[0]))
2324
+ return rb_gsl_linalg_SV_decomp_jacobi_narray(argc, argv, obj);
2355
2325
  #endif
2356
2326
  CHECK_MATRIX(argv[0]);
2357
2327
  Data_Get_Struct(argv[0], gsl_matrix, A);
@@ -2375,7 +2345,7 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
2375
2345
  gsl_matrix *A = NULL, *U = NULL, *V = NULL;
2376
2346
  gsl_vector *S = NULL, *b = NULL, *x = NULL;
2377
2347
  int flagb = 0, flagv = 0;
2378
-
2348
+
2379
2349
  switch (TYPE(obj)) {
2380
2350
  case T_MODULE: case T_CLASS: case T_OBJECT:
2381
2351
  if (argc < 1) rb_raise(rb_eArgError, "too few arguments.");
@@ -2386,35 +2356,35 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
2386
2356
 
2387
2357
  CHECK_MATRIX(argv[0]);
2388
2358
  if (CLASS_OF(argv[0]) == cgsl_matrix_U) {
2389
- if (argc != 4) rb_raise(rb_eArgError,
2390
- "wrong number of arguments (%d for 4)", argc);
2359
+ if (argc != 4) rb_raise(rb_eArgError,
2360
+ "wrong number of arguments (%d for 4)", argc);
2391
2361
  Data_Get_Struct(argv[0], gsl_matrix, U);
2392
2362
  CHECK_MATRIX(argv[1]);
2393
- if (CLASS_OF(argv[1]) != cgsl_matrix_V)
2394
- rb_raise(rb_eTypeError, "not a V matrix");
2363
+ if (CLASS_OF(argv[1]) != cgsl_matrix_V)
2364
+ rb_raise(rb_eTypeError, "not a V matrix");
2395
2365
  Data_Get_Struct(argv[1], gsl_matrix, V);
2396
2366
  CHECK_VECTOR(argv[2]);
2397
- if (CLASS_OF(argv[2]) != cgsl_vector_S)
2398
- rb_raise(rb_eTypeError, "not a S vector");
2367
+ if (CLASS_OF(argv[2]) != cgsl_vector_S)
2368
+ rb_raise(rb_eTypeError, "not a S vector");
2399
2369
  Data_Get_Struct(argv[2], gsl_vector, S);
2400
2370
  if (TYPE(argv[3]) == T_ARRAY) {
2401
- b = make_cvector_from_rarray(argv[3]);
2402
- flagb = 1;
2371
+ b = make_cvector_from_rarray(argv[3]);
2372
+ flagb = 1;
2403
2373
  } else {
2404
- CHECK_VECTOR(argv[3]);
2405
- Data_Get_Struct(argv[3], gsl_vector, b);
2374
+ CHECK_VECTOR(argv[3]);
2375
+ Data_Get_Struct(argv[3], gsl_vector, b);
2406
2376
  }
2407
2377
  } else {
2408
- if (argc != 2) rb_raise(rb_eArgError,
2409
- "wrong number of arguments (%d for 2)", argc);
2378
+ if (argc != 2) rb_raise(rb_eArgError,
2379
+ "wrong number of arguments (%d for 2)", argc);
2410
2380
  Data_Get_Struct(argv[0], gsl_matrix, A);
2411
2381
  U = make_matrix_clone(A);
2412
2382
  if (TYPE(argv[1]) == T_ARRAY) {
2413
- b = make_cvector_from_rarray(argv[1]);
2414
- flagb = 1;
2383
+ b = make_cvector_from_rarray(argv[1]);
2384
+ flagb = 1;
2415
2385
  } else {
2416
- CHECK_VECTOR(argv[1]);
2417
- Data_Get_Struct(argv[1], gsl_vector, b);
2386
+ CHECK_VECTOR(argv[1]);
2387
+ Data_Get_Struct(argv[1], gsl_vector, b);
2418
2388
  }
2419
2389
  S = gsl_vector_alloc(A->size2); /* see manual p 123 */
2420
2390
  V = gsl_matrix_alloc(A->size2, A->size2);
@@ -2423,8 +2393,8 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
2423
2393
  }
2424
2394
  break;
2425
2395
  default:
2426
- if (argc != 1) rb_raise(rb_eArgError,
2427
- "wrong number of arguments (%d for 1)", argc);
2396
+ if (argc != 1) rb_raise(rb_eArgError,
2397
+ "wrong number of arguments (%d for 1)", argc);
2428
2398
  Data_Get_Struct(obj, gsl_matrix, A);
2429
2399
  U = make_matrix_clone(A);
2430
2400
  if (TYPE(argv[0]) == T_ARRAY) {
@@ -2440,7 +2410,7 @@ static VALUE rb_gsl_linalg_SV_solve(int argc, VALUE *argv, VALUE obj)
2440
2410
  flagv = 1;
2441
2411
  break;
2442
2412
  }
2443
- // x = gsl_vector_alloc(b->size);
2413
+ // x = gsl_vector_alloc(b->size);
2444
2414
  // Bug report #25842
2445
2415
  x = gsl_vector_alloc(S->size);
2446
2416
  gsl_linalg_SV_solve(U, V, S, b, x);
@@ -2487,8 +2457,8 @@ static VALUE rb_gsl_linalg_cholesky_solve_narray(int argc, VALUE *argv, VALUE ob
2487
2457
  x = argv[2];
2488
2458
  break;
2489
2459
  default:
2490
- rb_raise(rb_eArgError,
2491
- "Usage: Cholesky.solve(chol, b) or Cholesky.solve(chol, b, x)");
2460
+ rb_raise(rb_eArgError,
2461
+ "Usage: Cholesky.solve(chol, b) or Cholesky.solve(chol, b, x)");
2492
2462
  break;
2493
2463
  }
2494
2464
  mv = gsl_matrix_view_array((double*)nm->ptr, nm->shape[1], nm->shape[0]);
@@ -2518,7 +2488,7 @@ static VALUE rb_gsl_linalg_cholesky_decomp(int argc, VALUE *argv, VALUE obj)
2518
2488
  switch(TYPE(obj)) {
2519
2489
  case T_MODULE: case T_CLASS: case T_OBJECT:
2520
2490
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
2521
- argc);
2491
+ argc);
2522
2492
  #ifdef HAVE_NARRAY_H
2523
2493
  if (NA_IsNArray(argv[0]))
2524
2494
  return rb_gsl_linalg_cholesky_decomp_narray(argc, argv, obj);
@@ -2545,7 +2515,7 @@ static VALUE rb_gsl_linalg_cholesky_solve(int argc, VALUE *argv, VALUE obj)
2545
2515
  switch(TYPE(obj)) {
2546
2516
  case T_MODULE: case T_CLASS: case T_OBJECT:
2547
2517
  if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
2548
- argc);
2518
+ argc);
2549
2519
  #ifdef HAVE_NARRAY_H
2550
2520
  if (NA_IsNArray(argv[0]))
2551
2521
  return rb_gsl_linalg_cholesky_solve_narray(argc, argv, obj);
@@ -2555,7 +2525,7 @@ static VALUE rb_gsl_linalg_cholesky_solve(int argc, VALUE *argv, VALUE obj)
2555
2525
  break;
2556
2526
  default:
2557
2527
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
2558
- argc);
2528
+ argc);
2559
2529
  vA = obj;
2560
2530
  vb = argv[0];
2561
2531
  break;
@@ -2593,7 +2563,7 @@ static VALUE rb_gsl_linalg_cholesky_svx(int argc, VALUE *argv, VALUE obj)
2593
2563
  switch(TYPE(obj)) {
2594
2564
  case T_MODULE: case T_CLASS: case T_OBJECT:
2595
2565
  if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
2596
- argc);
2566
+ argc);
2597
2567
  #ifdef HAVE_NARRAY_H
2598
2568
  if (NA_IsNArray(argv[0]))
2599
2569
  return rb_gsl_linalg_cholesky_svx_narray(argc, argv, obj);
@@ -2603,7 +2573,7 @@ static VALUE rb_gsl_linalg_cholesky_svx(int argc, VALUE *argv, VALUE obj)
2603
2573
  break;
2604
2574
  default:
2605
2575
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
2606
- argc);
2576
+ argc);
2607
2577
  vA = obj;
2608
2578
  vb = argv[0];
2609
2579
  break;
@@ -2632,7 +2602,7 @@ static VALUE rb_gsl_linalg_symmtd_decomp(int argc, VALUE *argv, VALUE obj)
2632
2602
  switch (TYPE(obj)) {
2633
2603
  case T_MODULE: case T_CLASS: case T_OBJECT:
2634
2604
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
2635
- argc);
2605
+ argc);
2636
2606
  CHECK_MATRIX(argv[0]);
2637
2607
  Data_Get_Struct(argv[0], gsl_matrix, Atmp);
2638
2608
  break;
@@ -2657,7 +2627,7 @@ static VALUE rb_gsl_linalg_symmtd_decomp2(int argc, VALUE *argv, VALUE obj)
2657
2627
  switch (TYPE(obj)) {
2658
2628
  case T_MODULE: case T_CLASS: case T_OBJECT:
2659
2629
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
2660
- argc);
2630
+ argc);
2661
2631
  CHECK_MATRIX(argv[0]);
2662
2632
  Data_Get_Struct(argv[0], gsl_matrix, A);
2663
2633
  break;
@@ -2679,14 +2649,14 @@ static VALUE rb_gsl_linalg_symmtd_unpack(int argc, VALUE *argv, VALUE obj)
2679
2649
  switch (TYPE(obj)) {
2680
2650
  case T_MODULE: case T_CLASS: case T_OBJECT:
2681
2651
  if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
2682
- argc);
2652
+ argc);
2683
2653
  CHECK_MATRIX(argv[0]);
2684
2654
  Data_Get_Struct(argv[0], gsl_matrix, A);
2685
2655
  Data_Get_Struct(argv[1], gsl_vector, tau);
2686
2656
  break;
2687
2657
  default:
2688
2658
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
2689
- argc);
2659
+ argc);
2690
2660
  CHECK_MATRIX(obj);
2691
2661
  Data_Get_Struct(obj, gsl_matrix, A);
2692
2662
  Data_Get_Struct(argv[0], gsl_vector, tau);
@@ -2712,7 +2682,7 @@ static VALUE rb_gsl_linalg_symmtd_unpack_T(int argc, VALUE *argv, VALUE obj)
2712
2682
  switch (TYPE(obj)) {
2713
2683
  case T_MODULE: case T_CLASS: case T_OBJECT:
2714
2684
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
2715
- argc);
2685
+ argc);
2716
2686
  CHECK_MATRIX(argv[0]);
2717
2687
  Data_Get_Struct(argv[0], gsl_matrix, A);
2718
2688
  break;
@@ -2740,7 +2710,7 @@ static VALUE rb_gsl_linalg_hermtd_decomp(int argc, VALUE *argv, VALUE obj)
2740
2710
  switch (TYPE(obj)) {
2741
2711
  case T_MODULE: case T_CLASS: case T_OBJECT:
2742
2712
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
2743
- argc);
2713
+ argc);
2744
2714
  CHECK_MATRIX_COMPLEX(argv[0]);
2745
2715
  Data_Get_Struct(argv[0], gsl_matrix_complex, Atmp);
2746
2716
  break;
@@ -2764,7 +2734,7 @@ static VALUE rb_gsl_linalg_hermtd_decomp2(int argc, VALUE *argv, VALUE obj)
2764
2734
  switch (TYPE(obj)) {
2765
2735
  case T_MODULE: case T_CLASS: case T_OBJECT:
2766
2736
  if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",