gsl 1.12.108

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/README.rdoc +29 -0
  2. data/Rakefile +54 -0
  3. data/VERSION +2 -0
  4. data/ext/MANIFEST +119 -0
  5. data/ext/alf.c +206 -0
  6. data/ext/array.c +666 -0
  7. data/ext/array_complex.c +247 -0
  8. data/ext/blas.c +29 -0
  9. data/ext/blas1.c +731 -0
  10. data/ext/blas2.c +1093 -0
  11. data/ext/blas3.c +881 -0
  12. data/ext/block.c +44 -0
  13. data/ext/block_source.c +886 -0
  14. data/ext/bspline.c +130 -0
  15. data/ext/bundle.c +3 -0
  16. data/ext/cdf.c +754 -0
  17. data/ext/cheb.c +542 -0
  18. data/ext/combination.c +283 -0
  19. data/ext/common.c +325 -0
  20. data/ext/complex.c +1004 -0
  21. data/ext/const.c +673 -0
  22. data/ext/const_additional.c +120 -0
  23. data/ext/cqp.c +283 -0
  24. data/ext/deriv.c +195 -0
  25. data/ext/dht.c +361 -0
  26. data/ext/diff.c +166 -0
  27. data/ext/dirac.c +395 -0
  28. data/ext/eigen.c +2373 -0
  29. data/ext/error.c +194 -0
  30. data/ext/extconf.rb +281 -0
  31. data/ext/fcmp.c +66 -0
  32. data/ext/fft.c +1092 -0
  33. data/ext/fit.c +205 -0
  34. data/ext/fresnel.c +312 -0
  35. data/ext/function.c +524 -0
  36. data/ext/geometry.c +139 -0
  37. data/ext/graph.c +1638 -0
  38. data/ext/gsl.c +271 -0
  39. data/ext/gsl_narray.c +653 -0
  40. data/ext/histogram.c +1995 -0
  41. data/ext/histogram2d.c +1068 -0
  42. data/ext/histogram3d.c +884 -0
  43. data/ext/histogram3d_source.c +750 -0
  44. data/ext/histogram_find.c +101 -0
  45. data/ext/histogram_oper.c +159 -0
  46. data/ext/ieee.c +98 -0
  47. data/ext/integration.c +1138 -0
  48. data/ext/interp.c +512 -0
  49. data/ext/jacobi.c +739 -0
  50. data/ext/linalg.c +4047 -0
  51. data/ext/linalg_complex.c +741 -0
  52. data/ext/math.c +725 -0
  53. data/ext/matrix.c +39 -0
  54. data/ext/matrix_complex.c +1732 -0
  55. data/ext/matrix_double.c +560 -0
  56. data/ext/matrix_int.c +256 -0
  57. data/ext/matrix_source.c +2733 -0
  58. data/ext/min.c +250 -0
  59. data/ext/monte.c +992 -0
  60. data/ext/multifit.c +1879 -0
  61. data/ext/multimin.c +808 -0
  62. data/ext/multimin_fsdf.c +156 -0
  63. data/ext/multiroots.c +955 -0
  64. data/ext/ndlinear.c +321 -0
  65. data/ext/nmf.c +167 -0
  66. data/ext/nmf_wrap.c +72 -0
  67. data/ext/ntuple.c +469 -0
  68. data/ext/odeiv.c +959 -0
  69. data/ext/ool.c +879 -0
  70. data/ext/oper_complex_source.c +253 -0
  71. data/ext/permutation.c +596 -0
  72. data/ext/poly.c +42 -0
  73. data/ext/poly2.c +265 -0
  74. data/ext/poly_source.c +1885 -0
  75. data/ext/qrng.c +171 -0
  76. data/ext/randist.c +1873 -0
  77. data/ext/rational.c +480 -0
  78. data/ext/rng.c +612 -0
  79. data/ext/root.c +408 -0
  80. data/ext/sf.c +1494 -0
  81. data/ext/sf_airy.c +200 -0
  82. data/ext/sf_bessel.c +867 -0
  83. data/ext/sf_clausen.c +28 -0
  84. data/ext/sf_coulomb.c +206 -0
  85. data/ext/sf_coupling.c +118 -0
  86. data/ext/sf_dawson.c +29 -0
  87. data/ext/sf_debye.c +157 -0
  88. data/ext/sf_dilog.c +42 -0
  89. data/ext/sf_elementary.c +44 -0
  90. data/ext/sf_ellint.c +206 -0
  91. data/ext/sf_elljac.c +29 -0
  92. data/ext/sf_erfc.c +93 -0
  93. data/ext/sf_exp.c +164 -0
  94. data/ext/sf_expint.c +211 -0
  95. data/ext/sf_fermi_dirac.c +148 -0
  96. data/ext/sf_gamma.c +344 -0
  97. data/ext/sf_gegenbauer.c +96 -0
  98. data/ext/sf_hyperg.c +197 -0
  99. data/ext/sf_laguerre.c +112 -0
  100. data/ext/sf_lambert.c +47 -0
  101. data/ext/sf_legendre.c +367 -0
  102. data/ext/sf_log.c +104 -0
  103. data/ext/sf_mathieu.c +238 -0
  104. data/ext/sf_power.c +46 -0
  105. data/ext/sf_psi.c +98 -0
  106. data/ext/sf_synchrotron.c +48 -0
  107. data/ext/sf_transport.c +76 -0
  108. data/ext/sf_trigonometric.c +207 -0
  109. data/ext/sf_zeta.c +119 -0
  110. data/ext/signal.c +310 -0
  111. data/ext/siman.c +718 -0
  112. data/ext/sort.c +208 -0
  113. data/ext/spline.c +395 -0
  114. data/ext/stats.c +799 -0
  115. data/ext/sum.c +168 -0
  116. data/ext/tamu_anova.c +56 -0
  117. data/ext/tensor.c +38 -0
  118. data/ext/tensor_source.c +1123 -0
  119. data/ext/vector.c +38 -0
  120. data/ext/vector_complex.c +2236 -0
  121. data/ext/vector_double.c +1433 -0
  122. data/ext/vector_int.c +204 -0
  123. data/ext/vector_source.c +3329 -0
  124. data/ext/wavelet.c +937 -0
  125. data/include/rb_gsl.h +151 -0
  126. data/include/rb_gsl_array.h +238 -0
  127. data/include/rb_gsl_cheb.h +21 -0
  128. data/include/rb_gsl_common.h +343 -0
  129. data/include/rb_gsl_complex.h +25 -0
  130. data/include/rb_gsl_const.h +29 -0
  131. data/include/rb_gsl_dirac.h +13 -0
  132. data/include/rb_gsl_eigen.h +17 -0
  133. data/include/rb_gsl_fft.h +62 -0
  134. data/include/rb_gsl_fit.h +25 -0
  135. data/include/rb_gsl_function.h +27 -0
  136. data/include/rb_gsl_graph.h +70 -0
  137. data/include/rb_gsl_histogram.h +63 -0
  138. data/include/rb_gsl_histogram3d.h +97 -0
  139. data/include/rb_gsl_integration.h +17 -0
  140. data/include/rb_gsl_interp.h +46 -0
  141. data/include/rb_gsl_linalg.h +25 -0
  142. data/include/rb_gsl_math.h +26 -0
  143. data/include/rb_gsl_odeiv.h +21 -0
  144. data/include/rb_gsl_poly.h +71 -0
  145. data/include/rb_gsl_rational.h +37 -0
  146. data/include/rb_gsl_rng.h +21 -0
  147. data/include/rb_gsl_root.h +22 -0
  148. data/include/rb_gsl_sf.h +119 -0
  149. data/include/rb_gsl_statistics.h +17 -0
  150. data/include/rb_gsl_tensor.h +45 -0
  151. data/include/rb_gsl_with_narray.h +22 -0
  152. data/include/templates_off.h +87 -0
  153. data/include/templates_on.h +241 -0
  154. data/lib/gsl/gnuplot.rb +41 -0
  155. data/lib/gsl/oper.rb +68 -0
  156. data/lib/ool.rb +22 -0
  157. data/lib/ool/conmin.rb +30 -0
  158. metadata +224 -0
@@ -0,0 +1,271 @@
1
+ /*
2
+ gsl.c
3
+ Ruby/GSL: Ruby extension library for GSL (GNU Scientific Library)
4
+ (C) Copyright 2001-2006 by Yoshiki Tsunesada
5
+
6
+ Ruby/GSL is free software: you can redistribute it and/or modify it
7
+ under the terms of the GNU General Public License.
8
+ This library is distributed in the hope that it will be useful, but
9
+ WITHOUT ANY WARRANTY.
10
+ */
11
+
12
+ #include "rb_gsl.h"
13
+ #include <gsl/gsl_machine.h>
14
+
15
+ ID rb_gsl_id_beg, rb_gsl_id_end, rb_gsl_id_excl, rb_gsl_id_to_a;
16
+ static ID rb_gsl_id_name, rb_gsl_id_size;
17
+ VALUE cGSL_Object;
18
+ static void rb_gsl_define_intern(VALUE module);
19
+ static void rb_gsl_define_const(VALUE module);
20
+ static void rb_gsl_define_methods(VALUE module);
21
+
22
+ static VALUE rb_gsl_object_inspect(VALUE obj)
23
+ {
24
+ char buf[256];
25
+ sprintf(buf, "%s", rb_class2name(CLASS_OF(obj)));
26
+ return rb_str_new2(buf);
27
+ }
28
+
29
+ static VALUE rb_gsl_call_rescue(VALUE obj)
30
+ {
31
+ return Qfalse;
32
+ }
33
+
34
+ static VALUE rb_gsl_call_name(VALUE obj)
35
+ {
36
+ return rb_funcall(obj, rb_gsl_id_name, 0);
37
+ }
38
+
39
+ static VALUE rb_gsl_call_size(VALUE obj)
40
+ {
41
+ return rb_funcall(obj, rb_gsl_id_size, 0);
42
+ }
43
+
44
+ static VALUE rb_gsl_object_info(VALUE obj)
45
+ {
46
+ char buf[256];
47
+ VALUE s;
48
+ sprintf(buf, "Class: %s\n", rb_class2name(CLASS_OF(obj)));
49
+ #ifdef RUBY_1_9_LATER
50
+ sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS_SUPER(CLASS_OF(obj))));
51
+ #else
52
+ sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS(CLASS_OF(obj))->super));
53
+ #endif
54
+ s = rb_rescue(rb_gsl_call_name, obj, rb_gsl_call_rescue, obj);
55
+ if (s) sprintf(buf, "%sType: %s\n", buf, STR2CSTR(s));
56
+ s = rb_rescue(rb_gsl_call_size, obj, rb_gsl_call_rescue, obj);
57
+ if (s) sprintf(buf, "%sSize: %d\n", buf, (int) FIX2INT(s));
58
+ return rb_str_new2(buf);
59
+ }
60
+
61
+ static VALUE rb_gsl_not_implemeted(VALUE obj)
62
+ {
63
+ rb_raise(rb_eNotImpError, "%s#dup is not implemented", rb_class2name(CLASS_OF(obj)));
64
+ return Qnil;
65
+ }
66
+
67
+ void Init_rb_gsl()
68
+ {
69
+ VALUE mgsl;
70
+
71
+ mgsl = rb_define_module("GSL");
72
+ cGSL_Object = rb_define_class_under(mgsl, "Object", rb_cObject);
73
+ rb_define_method(cGSL_Object, "inspect", rb_gsl_object_inspect, 0);
74
+ rb_define_method(cGSL_Object, "info", rb_gsl_object_info, 0);
75
+ // Override Object#dup to prevent invalid dup-ing of GSL_Objects.
76
+ // Subclasses (e.g. GSL::Vector) must provide their own implementation of
77
+ // #dup if desired.
78
+ rb_define_method(cGSL_Object, "dup", rb_gsl_not_implemeted, 0);
79
+
80
+ rb_gsl_define_intern(mgsl);
81
+
82
+ Init_gsl_error(mgsl);
83
+
84
+ Init_gsl_math(mgsl);
85
+ Init_gsl_complex(mgsl);
86
+
87
+ Init_gsl_array(mgsl);
88
+
89
+ Init_gsl_blas(mgsl);
90
+
91
+ Init_gsl_sort(mgsl);
92
+
93
+ Init_gsl_poly(mgsl); /* this must be called after the Vector class defined */
94
+ Init_gsl_poly_int(mgsl);
95
+ Init_gsl_poly2(mgsl);
96
+ Init_gsl_rational(mgsl);
97
+
98
+ Init_gsl_sf(mgsl);
99
+
100
+ Init_gsl_linalg(mgsl); /* Init_gsl_linalg_complex() is called in Init_gsl_linalg() */
101
+
102
+ Init_gsl_eigen(mgsl);
103
+
104
+ Init_gsl_fft(mgsl);
105
+ Init_gsl_signal(mgsl);
106
+ Init_gsl_function(mgsl);
107
+ Init_gsl_integration(mgsl);
108
+
109
+ Init_gsl_rng(mgsl);
110
+ Init_gsl_qrng(mgsl);
111
+ Init_gsl_ran(mgsl);
112
+ #ifdef GSL_1_4_LATER
113
+ Init_gsl_cdf(mgsl);
114
+ #endif
115
+ Init_gsl_stats(mgsl);
116
+
117
+ Init_gsl_histogram(mgsl);
118
+ Init_gsl_histogram2d(mgsl);
119
+ Init_gsl_histogram3d(mgsl);
120
+ Init_gsl_ntuple(mgsl);
121
+ Init_gsl_monte(mgsl);
122
+ Init_gsl_siman(mgsl);
123
+
124
+ Init_gsl_odeiv(mgsl);
125
+ Init_gsl_interp(mgsl);
126
+ Init_gsl_spline(mgsl);
127
+ Init_gsl_diff(mgsl);
128
+ #ifdef GSL_1_4_9_LATER
129
+ Init_gsl_deriv(mgsl);
130
+ #endif
131
+
132
+ Init_gsl_cheb(mgsl);
133
+ Init_gsl_sum(mgsl);
134
+ Init_gsl_dht(mgsl);
135
+
136
+ Init_gsl_root(mgsl);
137
+ Init_gsl_multiroot(mgsl);
138
+ Init_gsl_min(mgsl);
139
+ Init_gsl_multimin(mgsl);
140
+ Init_gsl_fit(mgsl);
141
+ Init_gsl_multifit(mgsl);
142
+
143
+ Init_gsl_const(mgsl);
144
+
145
+ Init_gsl_ieee(mgsl);
146
+
147
+ #ifdef HAVE_NARRAY_H
148
+ Init_gsl_narray(mgsl);
149
+ #endif
150
+
151
+ Init_wavelet(mgsl);
152
+
153
+ rb_gsl_define_const(mgsl);
154
+
155
+ #ifdef HAVE_TENSOR_TENSOR_H
156
+ Init_tensor_init(mgsl);
157
+ Init_tensor_int_init(mgsl);
158
+ #endif
159
+
160
+ Init_gsl_graph(mgsl);
161
+ Init_gsl_dirac(mgsl);
162
+
163
+ #ifdef HAVE_TAMU_ANOVA_TAMU_ANOVA_H
164
+ Init_tamu_anova(mgsl);
165
+ #endif
166
+
167
+ #ifdef HAVE_OOL_OOL_VERSION_H
168
+ Init_ool(mgsl);
169
+ #endif
170
+
171
+ #ifdef HAVE_JACOBI_H
172
+ Init_jacobi(mgsl);
173
+ #endif
174
+
175
+ #ifdef HAVE_GSL_GSL_CQP_H
176
+ Init_cqp(mgsl);
177
+ #endif
178
+
179
+ Init_fresnel(mgsl);
180
+
181
+ #ifdef GSL_1_9_LATER
182
+ Init_bspline(mgsl);
183
+ #endif
184
+
185
+ #ifdef HAVE_ALF_ALF_H
186
+ Init_alf(mgsl);
187
+ #endif
188
+
189
+ Init_geometry(mgsl);
190
+
191
+ rb_gsl_define_methods(mgsl);
192
+ }
193
+
194
+ /**********/
195
+
196
+ static void rb_gsl_define_intern(VALUE module)
197
+ {
198
+ rb_gsl_id_beg = rb_intern("begin");
199
+ rb_gsl_id_end = rb_intern("end");
200
+ rb_gsl_id_excl = rb_intern("excl");
201
+ rb_gsl_id_to_a = rb_intern("to_a");
202
+ rb_gsl_id_name = rb_intern("name");
203
+ rb_gsl_id_size = rb_intern("size");
204
+ }
205
+
206
+ static void rb_gsl_define_const(VALUE module)
207
+ {
208
+ rb_define_const(module, "MODE_DEFAULT", INT2FIX(GSL_MODE_DEFAULT));
209
+ rb_define_const(module, "PREC_DOUBLE", INT2FIX(GSL_PREC_DOUBLE));
210
+ rb_define_const(module, "PREC_SINGLE", INT2FIX(GSL_PREC_SINGLE));
211
+ rb_define_const(module, "PREC_APPROX", INT2FIX(GSL_PREC_APPROX));
212
+ #ifdef GSL_VERSION
213
+ rb_define_const(module, "VERSION", rb_str_new2(GSL_VERSION));
214
+ rb_define_const(module, "GSL_VERSION", rb_str_new2(GSL_VERSION));
215
+ #endif
216
+ #ifdef RUBY_GSL_VERSION
217
+ rb_define_const(module, "RUBY_GSL_VERSION", rb_str_new2(RUBY_GSL_VERSION));
218
+ rb_define_const(module, "RB_GSL_VERSION", rb_str_new2(RUBY_GSL_VERSION));
219
+ #endif
220
+
221
+ rb_define_const(module, "DBL_EPSILON", rb_float_new(GSL_DBL_EPSILON));
222
+ rb_define_const(module, "FLT_EPSILON", rb_float_new(GSL_FLT_EPSILON));
223
+ rb_define_const(module, "MACH_EPS", rb_float_new(GSL_MACH_EPS));
224
+ rb_define_const(module, "SQRT_DBL_EPSILON", rb_float_new(GSL_SQRT_DBL_EPSILON));
225
+ rb_define_const(module, "ROOT3_DBL_EPSILON", rb_float_new(GSL_ROOT3_DBL_EPSILON));
226
+ rb_define_const(module, "ROOT4_DBL_EPSILON", rb_float_new(GSL_ROOT4_DBL_EPSILON));
227
+ rb_define_const(module, "ROOT5_DBL_EPSILON", rb_float_new(GSL_ROOT5_DBL_EPSILON));
228
+ rb_define_const(module, "ROOT6_DBL_EPSILON", rb_float_new(GSL_ROOT6_DBL_EPSILON));
229
+ rb_define_const(module, "LOG_DBL_EPSILON", rb_float_new(GSL_LOG_DBL_EPSILON));
230
+
231
+ rb_define_const(module, "DBL_MAX", rb_float_new(GSL_DBL_MAX));
232
+ rb_define_const(module, "SQRT_DBL_MAX", rb_float_new(GSL_SQRT_DBL_MAX));
233
+ rb_define_const(module, "ROOT3_DBL_MAX", rb_float_new(GSL_ROOT3_DBL_MAX));
234
+ rb_define_const(module, "ROOT4_DBL_MAX", rb_float_new(GSL_ROOT4_DBL_MAX));
235
+ rb_define_const(module, "ROOT5_DBL_MAX", rb_float_new(GSL_ROOT5_DBL_MAX));
236
+ rb_define_const(module, "ROOT6_DBL_MAX", rb_float_new(GSL_ROOT6_DBL_MAX));
237
+ rb_define_const(module, "LOG_DBL_MAX", rb_float_new(GSL_LOG_DBL_MAX));
238
+
239
+ rb_define_const(module, "DBL_MIN", rb_float_new(GSL_DBL_MIN));
240
+ rb_define_const(module, "SQRT_DBL_MIN", rb_float_new(GSL_SQRT_DBL_MIN));
241
+ rb_define_const(module, "ROOT3_DBL_MIN", rb_float_new(GSL_ROOT3_DBL_MIN));
242
+ rb_define_const(module, "ROOT4_DBL_MIN", rb_float_new(GSL_ROOT4_DBL_MIN));
243
+ rb_define_const(module, "ROOT5_DBL_MIN", rb_float_new(GSL_ROOT5_DBL_MIN));
244
+ rb_define_const(module, "ROOT6_DBL_MIN", rb_float_new(GSL_ROOT6_DBL_MIN));
245
+ rb_define_const(module, "LOG_DBL_MIN", rb_float_new(GSL_LOG_DBL_MIN));
246
+
247
+ }
248
+
249
+ static VALUE rb_gsl_have_tensor(VALUE module)
250
+ {
251
+ #ifdef HAVE_TENSOR_TENSOR_H
252
+ return Qtrue;
253
+ #else
254
+ return Qfalse;
255
+ #endif
256
+ }
257
+
258
+ static VALUE rb_gsl_have_narray(VALUE module)
259
+ {
260
+ #ifdef HAVE_NARRAY_H
261
+ return Qtrue;
262
+ #else
263
+ return Qfalse;
264
+ #endif
265
+ }
266
+
267
+ static void rb_gsl_define_methods(VALUE module)
268
+ {
269
+ rb_define_singleton_method(module, "have_tensor?", rb_gsl_have_tensor, 0);
270
+ rb_define_singleton_method(module, "have_narray?", rb_gsl_have_narray, 0);
271
+ }
@@ -0,0 +1,653 @@
1
+ /*
2
+ narray.c
3
+
4
+ Written by Yoshiki Tsunesada Dec/2001
5
+ Modified by Seiya Nishizawa 14/Apr/2004
6
+ */
7
+
8
+ #include "rb_gsl_config.h"
9
+ #ifdef HAVE_NARRAY_H
10
+ #include "rb_gsl_array.h"
11
+ #include "narray.h"
12
+ #include "rb_gsl_with_narray.h"
13
+
14
+ static VALUE rb_gsl_na_to_gsl_matrix_method(VALUE nna);
15
+ static VALUE rb_gsl_na_to_gsl_matrix_int_method(VALUE nna);
16
+ static VALUE rb_gsl_na_to_gsl_vector_int_method(VALUE na);
17
+ static VALUE rb_gsl_vector_int_to_na(VALUE obj);
18
+ static VALUE rb_gsl_na_to_gsl_vector_int(VALUE obj, VALUE na);
19
+
20
+ /* GSL::Vector -> NArray */
21
+ static VALUE rb_gsl_vector_to_narray(VALUE obj, VALUE klass)
22
+ {
23
+ gsl_vector *v = NULL;
24
+ VALUE nary;
25
+ int shape[1];
26
+ Data_Get_Struct(obj, gsl_vector, v);
27
+ shape[0] = v->size;
28
+ nary = na_make_object(NA_DFLOAT, 1, shape, klass);
29
+ if (v->stride == 1) {
30
+ memcpy(NA_PTR_TYPE(nary,double*), v->data, shape[0]*sizeof(double));
31
+ } else {
32
+ int i;
33
+ struct NARRAY *na;
34
+ GetNArray(nary, na);
35
+ for(i=0; i < v->size; i++) {
36
+ (NA_PTR_TYPE(nary,double*))[i] = gsl_vector_get(v, i);
37
+ }
38
+ }
39
+ return nary;
40
+ }
41
+
42
+ static VALUE rb_gsl_vector_to_na(VALUE obj)
43
+ {
44
+ return rb_gsl_vector_to_narray(obj, cNArray);
45
+ }
46
+
47
+ static VALUE rb_gsl_vector_to_nvector(VALUE obj)
48
+ {
49
+ return rb_gsl_vector_to_narray(obj, cNVector);
50
+ }
51
+
52
+ static struct NARRAY* rb_gsl_na_view_alloc(int rank, int total, int type)
53
+ {
54
+ struct NARRAY *na;
55
+ na = (struct NARRAY*) malloc(sizeof(struct NARRAY));
56
+ na->rank = rank;
57
+ na->total = total;
58
+ na->type = type;
59
+ na->ref = Qtrue; /* to initialize */
60
+ na->shape = (int *) malloc(sizeof(int)*rank);
61
+ return na;
62
+ }
63
+
64
+ static void rb_gsl_na_view_free(struct NARRAY *na)
65
+ {
66
+ free((int *) na->shape);
67
+ free((struct NARRAY *) na);
68
+ }
69
+
70
+ static VALUE rb_gsl_vector_to_narray_ref(VALUE obj, VALUE klass)
71
+ {
72
+ gsl_vector *v = NULL;
73
+ gsl_vector_int *vi = NULL;
74
+ VALUE nary;
75
+ struct NARRAY *na;
76
+ if (VECTOR_P(obj)) {
77
+ Data_Get_Struct(obj, gsl_vector, v);
78
+ if (v->stride != 1) {
79
+ rb_raise(rb_eRuntimeError, "Cannot make a reference obj: stride!=1");
80
+ }
81
+ na = rb_gsl_na_view_alloc(1, v->size, NA_DFLOAT);
82
+ na->shape[0] = v->size;
83
+ na->ptr = (char *) v->data;
84
+ } else if (VECTOR_INT_P(obj)) {
85
+ Data_Get_Struct(obj, gsl_vector_int, vi);
86
+ if (vi->stride != 1) {
87
+ rb_raise(rb_eRuntimeError, "Cannot make a reference obj: stride!=1");
88
+ }
89
+ na = rb_gsl_na_view_alloc(1, vi->size, NA_LINT);
90
+ na->shape[0] = vi->size;
91
+ na->ptr = (char *) vi->data;
92
+ } else {
93
+ rb_raise(rb_eRuntimeError, "???");
94
+ }
95
+ nary = Data_Wrap_Struct(klass, 0, rb_gsl_na_view_free, na);
96
+ return nary;
97
+ }
98
+
99
+ static VALUE rb_gsl_vector_to_na_ref(VALUE obj)
100
+ {
101
+ return rb_gsl_vector_to_narray_ref(obj, cNArray);
102
+ }
103
+
104
+ static VALUE rb_gsl_vector_to_nvector_ref(VALUE obj)
105
+ {
106
+ return rb_gsl_vector_to_narray_ref(obj, cNVector);
107
+ }
108
+
109
+ static VALUE rb_gsl_vector_int_to_narray(VALUE obj, VALUE klass)
110
+ {
111
+ gsl_vector_int *v = NULL;
112
+ VALUE nary;
113
+ int shape[1];
114
+ Data_Get_Struct(obj, gsl_vector_int, v);
115
+ shape[0] = v->size;
116
+ nary = na_make_object(NA_LINT, 1, shape, klass);
117
+ if (v->stride == 1) {
118
+ memcpy(NA_PTR_TYPE(nary,int*), v->data, shape[0]*sizeof(int));
119
+ } else {
120
+ int i;
121
+ struct NARRAY *na;
122
+ GetNArray(nary, na);
123
+ for(i=0; i < v->size; i++) {
124
+ (NA_PTR_TYPE(nary,int*))[i] = gsl_vector_int_get(v, i);
125
+ }
126
+ }
127
+ return nary;
128
+ }
129
+
130
+ static VALUE rb_gsl_vector_int_to_na(VALUE obj)
131
+ {
132
+ return rb_gsl_vector_int_to_narray(obj, cNArray);
133
+ }
134
+
135
+ static VALUE rb_gsl_vector_int_to_nvector(VALUE obj)
136
+ {
137
+ return rb_gsl_vector_int_to_narray(obj, cNVector);
138
+ }
139
+
140
+ /* singleton method */
141
+ static VALUE rb_gsl_na_to_gsl_vector(VALUE obj, VALUE na)
142
+ {
143
+ return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free,
144
+ na_to_gv(na));
145
+ }
146
+
147
+ static VALUE rb_gsl_na_to_gsl_vector_view(VALUE obj, VALUE na)
148
+ {
149
+ return Data_Wrap_Struct(cgsl_vector_view, 0, gsl_vector_view_free,
150
+ na_to_gv_view(na));
151
+ }
152
+
153
+ static VALUE rb_gsl_na_to_gsl_vector_int(VALUE obj, VALUE na)
154
+ {
155
+ return Data_Wrap_Struct(cgsl_vector_int, 0, gsl_vector_int_free,
156
+ na_to_gv_int(na));
157
+ }
158
+
159
+ static VALUE rb_gsl_na_to_gsl_vector_int_view(VALUE obj, VALUE na)
160
+ {
161
+ return Data_Wrap_Struct(cgsl_vector_int_view, 0, rb_gsl_vector_int_view_free,
162
+ na_to_gv_int_view(na));
163
+ }
164
+
165
+ static VALUE rb_gsl_na_to_gsl_vector_method(VALUE na)
166
+ {
167
+ return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free,
168
+ na_to_gv(na));
169
+ }
170
+
171
+ static VALUE rb_gsl_na_to_gsl_vector_view_method(VALUE na)
172
+ {
173
+ return Data_Wrap_Struct(cgsl_vector_view, 0, gsl_vector_view_free,
174
+ na_to_gv_view(na));
175
+ }
176
+
177
+ static VALUE rb_gsl_na_to_gsl_vector_int_method(VALUE na)
178
+ {
179
+ return Data_Wrap_Struct(cgsl_vector_int, 0, gsl_vector_int_free,
180
+ na_to_gv_int(na));
181
+ }
182
+
183
+ static VALUE rb_gsl_na_to_gsl_vector_int_view_method(VALUE na)
184
+ {
185
+ return Data_Wrap_Struct(cgsl_vector_int_view, 0, rb_gsl_vector_int_view_free,
186
+ na_to_gv_int_view(na));
187
+ }
188
+
189
+ gsl_vector* na_to_gv(VALUE na)
190
+ {
191
+ gsl_vector *v = NULL;
192
+ VALUE nary;
193
+ v = gsl_vector_alloc(NA_TOTAL(na));
194
+ nary = na_change_type(na, NA_DFLOAT);
195
+ memcpy(v->data, NA_PTR_TYPE(nary,double*), v->size*sizeof(double));
196
+ return v;
197
+ }
198
+
199
+ gsl_vector_view* na_to_gv_view(VALUE na)
200
+ {
201
+ gsl_vector_view *v = NULL;
202
+ VALUE ary2;
203
+ v = gsl_vector_view_alloc();
204
+ ary2 = na_change_type(na, NA_DFLOAT);
205
+ v->vector.data = NA_PTR_TYPE(ary2,double*);
206
+ v->vector.size = NA_TOTAL(na);
207
+ v->vector.stride = 1;
208
+ v->vector.owner = 0;
209
+ return v;
210
+ }
211
+
212
+ gsl_vector_int* na_to_gv_int(VALUE na)
213
+ {
214
+ gsl_vector_int *v = NULL;
215
+ VALUE nary;
216
+ v = gsl_vector_int_alloc(NA_TOTAL(na));
217
+ nary = na_change_type(na, NA_LINT);
218
+ memcpy(v->data, NA_PTR_TYPE(nary,int*), v->size*sizeof(int));
219
+ return v;
220
+ }
221
+
222
+ gsl_vector_int_view* na_to_gv_int_view(VALUE na)
223
+ {
224
+ gsl_vector_int_view *v = NULL;
225
+ VALUE ary2;
226
+ v = rb_gsl_vector_int_view_alloc(NA_TOTAL(na));
227
+ ary2 = na_change_type(na, NA_LINT);
228
+ v->vector.data = NA_PTR_TYPE(ary2,int*);
229
+ v->vector.size = NA_TOTAL(na);
230
+ v->vector.stride = 1;
231
+ v->vector.owner = 0;
232
+ return v;
233
+ }
234
+
235
+ static VALUE rb_gsl_matrix_to_narray(VALUE obj, VALUE klass)
236
+ {
237
+ gsl_matrix *m = NULL;
238
+ VALUE nary;
239
+ int shape[2];
240
+ size_t i;
241
+ Data_Get_Struct(obj, gsl_matrix, m);
242
+ shape[0] = m->size2;
243
+ shape[1] = m->size1;
244
+ nary = na_make_object(NA_DFLOAT, 2, shape, klass);
245
+ for (i = 0; i < shape[1]; i++) {
246
+ memcpy(NA_PTR_TYPE(nary,double*)+(i*shape[0]), m->data+(i*m->tda),
247
+ shape[0]*sizeof(double));
248
+ }
249
+ return nary;
250
+ }
251
+
252
+ static VALUE rb_gsl_matrix_to_na(VALUE obj, VALUE klass)
253
+ {
254
+ return rb_gsl_matrix_to_narray(obj, cNArray);
255
+ }
256
+
257
+ static VALUE rb_gsl_matrix_to_nmatrix(VALUE obj, VALUE klass)
258
+ {
259
+ return rb_gsl_matrix_to_narray(obj, cNMatrix);
260
+ }
261
+
262
+ static VALUE rb_gsl_matrix_int_to_narray(VALUE obj, VALUE klass)
263
+ {
264
+ gsl_matrix_int *m = NULL;
265
+ VALUE nary;
266
+ int shape[2];
267
+ size_t i;
268
+ Data_Get_Struct(obj, gsl_matrix_int, m);
269
+ shape[0] = m->size2;
270
+ shape[1] = m->size1;
271
+ nary = na_make_object(NA_LINT, 2, shape, klass);
272
+ for (i = 0; i < shape[1]; i++) {
273
+ memcpy(NA_PTR_TYPE(nary,int*)+(i*shape[0]), m->data+(i*m->tda),
274
+ shape[0]*sizeof(int));
275
+ }
276
+ return nary;
277
+ }
278
+
279
+ static VALUE rb_gsl_matrix_int_to_na(VALUE obj)
280
+ {
281
+ return rb_gsl_matrix_int_to_narray(obj, cNArray);
282
+ }
283
+
284
+ static VALUE rb_gsl_matrix_int_to_nmatrix(VALUE obj)
285
+ {
286
+ return rb_gsl_matrix_int_to_narray(obj, cNMatrix);
287
+ }
288
+
289
+ static VALUE rb_gsl_matrix_to_narray_ref(VALUE obj, VALUE klass)
290
+ {
291
+ gsl_matrix *m = NULL;
292
+ VALUE nary;
293
+ struct NARRAY *na;
294
+ Data_Get_Struct(obj, gsl_matrix, m);
295
+ if (m->tda != m->size2) {
296
+ rb_raise(rb_eRuntimeError, "Cannot make a reference obj: non-contiguous");
297
+ }
298
+ na = rb_gsl_na_view_alloc(2, m->size2 * m->size1, NA_DFLOAT);
299
+ na->shape[0] = m->size2;
300
+ na->shape[1] = m->size1;
301
+ na->ptr = (char *) m->data;
302
+ nary = Data_Wrap_Struct(klass, 0, rb_gsl_na_view_free, na);
303
+ return nary;
304
+ }
305
+
306
+ static VALUE rb_gsl_matrix_to_na_ref(VALUE obj)
307
+ {
308
+ return rb_gsl_matrix_to_narray_ref(obj, cNArray);
309
+ }
310
+
311
+ static VALUE rb_gsl_matrix_to_nmatrix_ref(VALUE obj)
312
+ {
313
+ return rb_gsl_matrix_to_narray_ref(obj, cNMatrix);
314
+ }
315
+
316
+ static VALUE rb_gsl_matrix_int_to_narray_ref(VALUE obj, VALUE klass)
317
+ {
318
+ gsl_matrix_int *m = NULL;
319
+ VALUE nary;
320
+ struct NARRAY *na;
321
+ Data_Get_Struct(obj, gsl_matrix_int, m);
322
+ if (m->tda != m->size2) {
323
+ rb_raise(rb_eRuntimeError, "Cannot make a reference obj: non-contiguous");
324
+ }
325
+ na = rb_gsl_na_view_alloc(2, m->size2 * m->size1, NA_LINT);
326
+ na->shape[0] = m->size2;
327
+ na->shape[1] = m->size1;
328
+ na->ptr = (char *) m->data;
329
+ nary = Data_Wrap_Struct(klass, 0, rb_gsl_na_view_free, na);
330
+ return nary;
331
+ }
332
+
333
+ static VALUE rb_gsl_matrix_int_to_na_ref(VALUE obj)
334
+ {
335
+ return rb_gsl_matrix_int_to_narray_ref(obj, cNArray);
336
+ }
337
+
338
+ static VALUE rb_gsl_matrix_int_to_nmatrix_ref(VALUE obj)
339
+ {
340
+ return rb_gsl_matrix_int_to_narray_ref(obj, cNMatrix);
341
+ }
342
+
343
+ /* NArray -> GSL::Matrix */
344
+ VALUE rb_gsl_na_to_gsl_matrix(VALUE obj, VALUE nna)
345
+ {
346
+ gsl_matrix *m = NULL;
347
+ m = na_to_gm(nna);
348
+ return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, m);
349
+ }
350
+
351
+ VALUE rb_gsl_na_to_gsl_matrix_view(VALUE obj, VALUE nna)
352
+ {
353
+ gsl_matrix_view *m = NULL;
354
+ m = na_to_gm_view(nna);
355
+ return Data_Wrap_Struct(cgsl_matrix_view, 0, gsl_matrix_view_free, m);
356
+ }
357
+
358
+ VALUE rb_gsl_na_to_gsl_matrix_int(VALUE obj, VALUE nna)
359
+ {
360
+ gsl_matrix_int *m = NULL;
361
+ m = na_to_gm_int(nna);
362
+ return Data_Wrap_Struct(cgsl_matrix_int, 0, gsl_matrix_int_free, m);
363
+ }
364
+
365
+ VALUE rb_gsl_na_to_gsl_matrix_int_view(VALUE obj, VALUE nna)
366
+ {
367
+ gsl_matrix_int_view *m = NULL;
368
+ m = na_to_gm_int_view(nna);
369
+ return Data_Wrap_Struct(cgsl_matrix_int_view, 0, rb_gsl_matrix_int_view_free, m);
370
+ }
371
+
372
+ static VALUE rb_gsl_na_to_gsl_matrix_method(VALUE nna)
373
+ {
374
+ gsl_matrix *m = NULL;
375
+ m = na_to_gm(nna);
376
+ return Data_Wrap_Struct(cgsl_matrix, 0, gsl_matrix_free, m);
377
+ }
378
+
379
+ static VALUE rb_gsl_na_to_gsl_matrix_view_method(VALUE nna)
380
+ {
381
+ gsl_matrix_view *m = NULL;
382
+ m = na_to_gm_view(nna);
383
+ return Data_Wrap_Struct(cgsl_matrix_view, 0, gsl_matrix_view_free, m);
384
+ }
385
+
386
+ static VALUE rb_gsl_na_to_gsl_matrix_int_method(VALUE nna)
387
+ {
388
+ gsl_matrix_int *m = NULL;
389
+ m = na_to_gm_int(nna);
390
+ return Data_Wrap_Struct(cgsl_matrix_int, 0, gsl_matrix_int_free, m);
391
+ }
392
+
393
+ static VALUE rb_gsl_na_to_gsl_matrix_int_view_method(VALUE nna)
394
+ {
395
+ gsl_matrix_int_view *m = NULL;
396
+ m = na_to_gm_int_view(nna);
397
+ return Data_Wrap_Struct(cgsl_matrix_int_view, 0, rb_gsl_matrix_int_view_free, m);
398
+ }
399
+
400
+ gsl_matrix* na_to_gm(VALUE nna)
401
+ {
402
+ gsl_matrix *m = NULL;
403
+ VALUE ary2;
404
+ struct NARRAY *na = NULL;
405
+ GetNArray(nna, na);
406
+ m = gsl_matrix_alloc(na->shape[1], na->shape[0]);
407
+ ary2 = na_change_type(nna, NA_DFLOAT);
408
+ memcpy(m->data, NA_PTR_TYPE(ary2,double*), m->size1*m->size2*sizeof(double));
409
+ return m;
410
+ }
411
+
412
+ gsl_matrix_view* na_to_gm_view(VALUE nna)
413
+ {
414
+ gsl_matrix_view *m = NULL;
415
+ VALUE ary2;
416
+ struct NARRAY *na = NULL;
417
+ GetNArray(nna, na);
418
+ m = gsl_matrix_view_alloc();
419
+ ary2 = na_change_type(nna, NA_DFLOAT);
420
+ m->matrix.data = NA_PTR_TYPE(ary2,double*);
421
+ m->matrix.size1 = na->shape[1];
422
+ m->matrix.size2 = na->shape[0];
423
+ m->matrix.tda = m->matrix.size2;
424
+ m->matrix.owner = 0;
425
+ return m;
426
+ }
427
+
428
+ gsl_matrix_int* na_to_gm_int(VALUE nna)
429
+ {
430
+ gsl_matrix_int *m = NULL;
431
+ VALUE ary2;
432
+ struct NARRAY *na = NULL;
433
+ GetNArray(nna, na);
434
+ m = gsl_matrix_int_alloc(na->shape[1], na->shape[0]);
435
+ ary2 = na_change_type(nna, NA_LINT);
436
+ memcpy(m->data, NA_PTR_TYPE(ary2,int*), m->size1*m->size2*sizeof(int));
437
+ return m;
438
+ }
439
+
440
+ gsl_matrix_int_view* na_to_gm_int_view(VALUE nna)
441
+ {
442
+ gsl_matrix_int_view *m = NULL;
443
+ VALUE ary2;
444
+ struct NARRAY *na = NULL;
445
+ GetNArray(nna, na);
446
+ m = rb_gsl_matrix_int_view_alloc(na->shape[1], na->shape[0]);
447
+ ary2 = na_change_type(nna, NA_LINT);
448
+ m->matrix.data = NA_PTR_TYPE(ary2,int*);
449
+ m->matrix.size1 = na->shape[1];
450
+ m->matrix.size2 = na->shape[0];
451
+ m->matrix.tda = m->matrix.size2;
452
+ m->matrix.owner = 0;
453
+ return m;
454
+ }
455
+
456
+ #ifdef HAVE_NARRAY_H
457
+ #include "narray.h"
458
+ #include <gsl/gsl_histogram.h>
459
+ EXTERN VALUE cgsl_histogram;
460
+ static VALUE rb_gsl_narray_histogram(int argc, VALUE *argv, VALUE obj)
461
+ {
462
+ double *ptr, *ptr_range;
463
+ gsl_histogram *h;
464
+ gsl_vector *ranges;
465
+ gsl_vector_view v;
466
+ double min, max;
467
+ size_t i, n, size, stride;
468
+ ptr = get_vector_ptr(obj, &stride, &size);
469
+ v.vector.data = ptr;
470
+ v.vector.size = size;
471
+ v.vector.size = stride;
472
+ switch (argc) {
473
+ case 1:
474
+ if (rb_obj_is_kind_of(argv[0], rb_cRange))
475
+ argv[0] = rb_gsl_range2ary(argv[0]);
476
+ switch (TYPE(argv[0])) {
477
+ case T_FIXNUM:
478
+ n = NUM2INT(argv[0]);
479
+ min = gsl_vector_min(&v.vector) - 4*GSL_DBL_EPSILON;
480
+ max = gsl_vector_max(&v.vector) + 4*GSL_DBL_EPSILON;
481
+ h = gsl_histogram_alloc(n);
482
+ gsl_histogram_set_ranges_uniform(h, min, max);
483
+ break;
484
+ case T_ARRAY:
485
+ // n = RARRAY(argv[0])->len - 1;
486
+ n = RARRAY_LEN(argv[0]) - 1;
487
+ h = gsl_histogram_alloc(n);
488
+ for (i = 0; i <= n; i++) h->range[i] = NUM2DBL(rb_ary_entry(argv[0], i));
489
+ break;
490
+ default:
491
+ if (VECTOR_P(argv[0])) {
492
+ Data_Get_Struct(argv[0], gsl_vector, ranges);
493
+ n = ranges->size - 1;
494
+ h = gsl_histogram_alloc(n);
495
+ gsl_histogram_set_ranges(h, ranges->data, ranges->size);
496
+ } else if (NA_IsNArray(argv[0])) {
497
+ ptr_range = get_vector_ptr(argv[0], &stride, &n);
498
+ h = gsl_histogram_alloc(n);
499
+ gsl_histogram_set_ranges(h, ptr_range, n);
500
+ }
501
+ break;
502
+ }
503
+ break;
504
+ case 2:
505
+ n = NUM2INT(argv[0]);
506
+ switch (TYPE(argv[1])) {
507
+ case T_ARRAY:
508
+ min = NUM2DBL(rb_ary_entry(argv[1], 0));
509
+ max = NUM2DBL(rb_ary_entry(argv[1], 1));
510
+ break;
511
+ default:
512
+ rb_raise(rb_eTypeError, "wrong argument type %s (Array expected)",
513
+ rb_class2name(CLASS_OF(argv[1])));
514
+ break;
515
+ }
516
+ h = gsl_histogram_alloc(n);
517
+ gsl_histogram_set_ranges_uniform(h, min, max);
518
+ break;
519
+ case 3:
520
+ n = NUM2INT(argv[0]);
521
+ min = NUM2DBL(argv[1]); max = NUM2DBL(argv[2]);
522
+ h = gsl_histogram_alloc(n);
523
+ gsl_histogram_set_ranges_uniform(h, min, max);
524
+ break;
525
+ default:
526
+ rb_raise(rb_eArgError, "wrong number of arguments %d", argc);
527
+ break;
528
+ }
529
+ for (i = 0; i < size; i++)
530
+ gsl_histogram_increment(h, ptr[i*stride]);
531
+ return Data_Wrap_Struct(cgsl_histogram, 0, gsl_histogram_free, h);
532
+ }
533
+ #endif
534
+
535
+ /*void rb_gsl_with_narray_define_methods()*/
536
+ void Init_gsl_narray(VALUE module)
537
+ {
538
+ rb_define_method(cgsl_vector, "to_na", rb_gsl_vector_to_na, 0);
539
+ rb_define_alias(cgsl_vector, "to_narray", "to_na");
540
+ rb_define_method(cgsl_vector, "to_na2", rb_gsl_vector_to_na_ref, 0);
541
+ rb_define_alias(cgsl_vector, "to_narray_ref", "to_na2");
542
+ rb_define_alias(cgsl_vector, "to_na_ref", "to_na2");
543
+
544
+ rb_define_method(cgsl_vector, "to_nv", rb_gsl_vector_to_nvector, 0);
545
+ rb_define_alias(cgsl_vector, "to_nvector", "to_nv");
546
+ rb_define_method(cgsl_vector, "to_nv_ref", rb_gsl_vector_to_nvector_ref, 0);
547
+ rb_define_alias(cgsl_vector, "to_nvector_ref", "to_nv_ref");
548
+
549
+ rb_define_singleton_method(cgsl_vector, "to_gslv", rb_gsl_na_to_gsl_vector, 1);
550
+ rb_define_singleton_method(cgsl_vector, "to_gv", rb_gsl_na_to_gsl_vector, 1);
551
+
552
+ rb_define_singleton_method(cgsl_vector, "na_to_gslv", rb_gsl_na_to_gsl_vector, 1);
553
+ rb_define_singleton_method(cgsl_vector, "na_to_gv", rb_gsl_na_to_gsl_vector, 1);
554
+ rb_define_singleton_method(cgsl_vector, "to_gslv_view", rb_gsl_na_to_gsl_vector_view, 1);
555
+
556
+ rb_define_singleton_method(cgsl_vector, "to_gv_view", rb_gsl_na_to_gsl_vector_view, 1);
557
+
558
+ rb_define_singleton_method(cgsl_vector, "na_to_gslv_view", rb_gsl_na_to_gsl_vector_view, 1);
559
+ rb_define_singleton_method(cgsl_vector, "na_to_gv_view", rb_gsl_na_to_gsl_vector, 1);
560
+
561
+ rb_define_method(cNArray, "to_gv", rb_gsl_na_to_gsl_vector_method, 0);
562
+ rb_define_alias(cNArray, "to_gslv", "to_gv");
563
+ rb_define_method(cNArray, "to_gv_view", rb_gsl_na_to_gsl_vector_view_method, 0);
564
+ rb_define_alias(cNArray, "to_gslv_view", "to_gv_view");
565
+ rb_define_alias(cNArray, "to_gv2", "to_gv_view");
566
+ rb_define_alias(cNArray, "to_gv_ref", "to_gv_view");
567
+ /*****/
568
+ rb_define_method(cgsl_vector_int, "to_na", rb_gsl_vector_int_to_na, 0);
569
+ rb_define_alias(cgsl_vector_int, "to_narray", "to_na");
570
+ rb_define_method(cgsl_vector_int, "to_nv", rb_gsl_vector_int_to_nvector, 0);
571
+ rb_define_alias(cgsl_vector_int, "to_nvector", "to_nv");
572
+ rb_define_method(cgsl_vector_int, "to_na2", rb_gsl_vector_to_na_ref, 0);
573
+ rb_define_alias(cgsl_vector_int, "to_na_ref", "to_na2");
574
+ rb_define_alias(cgsl_vector_int, "to_narray_ref", "to_na2");
575
+ rb_define_method(cgsl_vector_int, "to_nv_ref", rb_gsl_vector_to_nvector_ref, 0);
576
+ rb_define_alias(cgsl_vector_int, "to_nvector_ref", "to_nv_ref");
577
+
578
+ rb_define_singleton_method(cgsl_vector_int, "to_gslv", rb_gsl_na_to_gsl_vector_int, 1);
579
+ rb_define_singleton_method(cgsl_vector_int, "to_gv", rb_gsl_na_to_gsl_vector_int, 1);
580
+
581
+ rb_define_singleton_method(cgsl_vector_int, "na_to_gslv", rb_gsl_na_to_gsl_vector_int, 1);
582
+ rb_define_singleton_method(cgsl_vector_int, "na_to_gv", rb_gsl_na_to_gsl_vector_int, 1);
583
+
584
+ rb_define_singleton_method(cgsl_vector_int, "to_gslv_view", rb_gsl_na_to_gsl_vector_int_view, 1);
585
+ rb_define_singleton_method(cgsl_vector_int, "to_gv_view", rb_gsl_na_to_gsl_vector_int_view, 1);
586
+
587
+ rb_define_singleton_method(cgsl_vector_int, "na_to_gslv_view", rb_gsl_na_to_gsl_vector_int, 1);
588
+ rb_define_singleton_method(cgsl_vector_int, "na_to_gv_view", rb_gsl_na_to_gsl_vector_int_view, 1);
589
+
590
+ rb_define_method(cNArray, "to_gv_int", rb_gsl_na_to_gsl_vector_int_method, 0);
591
+ rb_define_alias(cNArray, "to_gslv_int", "to_gv_int");
592
+ rb_define_method(cNArray, "to_gv_int_view", rb_gsl_na_to_gsl_vector_int_view_method, 0);
593
+ rb_define_alias(cNArray, "to_gslv_int_view", "to_gv_int_view");
594
+ /*****/
595
+
596
+ rb_define_method(cgsl_matrix, "to_na", rb_gsl_matrix_to_na, 0);
597
+ rb_define_alias(cgsl_matrix, "to_narray", "to_na");
598
+ rb_define_method(cgsl_matrix, "to_nm", rb_gsl_matrix_to_nmatrix, 0);
599
+ rb_define_alias(cgsl_matrix, "to_nmatrix", "to_nm");
600
+ rb_define_method(cgsl_matrix, "to_na2", rb_gsl_matrix_to_na_ref, 0);
601
+ rb_define_alias(cgsl_matrix, "to_na_ref", "to_na2");
602
+ rb_define_alias(cgsl_matrix, "to_narray_ref", "to_na2");
603
+ rb_define_method(cgsl_matrix, "to_nm_ref", rb_gsl_matrix_to_nmatrix_ref, 0);
604
+ rb_define_alias(cgsl_matrix, "to_nmatrix_ref", "to_nm_ref");
605
+
606
+ rb_define_singleton_method(cgsl_matrix, "to_gslm", rb_gsl_na_to_gsl_matrix, 1);
607
+ rb_define_singleton_method(cgsl_matrix, "to_gm", rb_gsl_na_to_gsl_matrix, 1);
608
+
609
+ rb_define_singleton_method(cgsl_matrix, "na_to_gslm", rb_gsl_na_to_gsl_matrix, 1);
610
+ rb_define_singleton_method(cgsl_matrix, "na_to_gm", rb_gsl_na_to_gsl_matrix, 1);
611
+
612
+ rb_define_singleton_method(cgsl_matrix, "to_gslm_view", rb_gsl_na_to_gsl_matrix_view, 1);
613
+ rb_define_singleton_method(cgsl_matrix, "to_gm_view", rb_gsl_na_to_gsl_matrix_view, 1);
614
+
615
+ rb_define_singleton_method(cgsl_matrix, "na_to_gslm_view", rb_gsl_na_to_gsl_matrix_view, 1);
616
+ rb_define_singleton_method(cgsl_matrix, "na_to_gm_view", rb_gsl_na_to_gsl_matrix_view, 1);
617
+
618
+ rb_define_method(cNArray, "to_gslm", rb_gsl_na_to_gsl_matrix_method, 0);
619
+ rb_define_alias(cNArray, "to_gm", "to_gslm");
620
+ rb_define_method(cNArray, "to_gslm_view", rb_gsl_na_to_gsl_matrix_view_method, 0);
621
+ rb_define_alias(cNArray, "to_gm_view", "to_gslm_view");
622
+
623
+ /*****/
624
+ rb_define_method(cgsl_matrix_int, "to_na", rb_gsl_matrix_int_to_na, 0);
625
+ rb_define_alias(cgsl_matrix_int, "to_narray", "to_na");
626
+ rb_define_method(cgsl_matrix_int, "to_nm", rb_gsl_matrix_int_to_nmatrix, 0);
627
+ rb_define_alias(cgsl_matrix_int, "to_nmatrix", "to_nm");
628
+
629
+ rb_define_method(cgsl_matrix_int, "to_na2", rb_gsl_matrix_int_to_na_ref, 0);
630
+ rb_define_alias(cgsl_matrix_int, "to_na_ref", "to_na2");
631
+ rb_define_alias(cgsl_matrix_int, "to_narray_ref", "to_na2");
632
+ rb_define_method(cgsl_matrix_int, "to_nm_ref", rb_gsl_matrix_int_to_nmatrix_ref, 0);
633
+ rb_define_alias(cgsl_matrix_int, "to_nmatrix_ref", "to_nm_ref");
634
+
635
+ rb_define_singleton_method(cgsl_matrix_int, "to_gslm", rb_gsl_na_to_gsl_matrix_int, 1);
636
+ rb_define_singleton_method(cgsl_matrix_int, "to_gm", rb_gsl_na_to_gsl_matrix_int, 1);
637
+ rb_define_singleton_method(cgsl_matrix_int, "na_to_gslm", rb_gsl_na_to_gsl_matrix_int, 1);
638
+ rb_define_singleton_method(cgsl_matrix_int, "na_to_gm", rb_gsl_na_to_gsl_matrix_int, 1);
639
+
640
+ rb_define_singleton_method(cgsl_matrix_int, "to_gslm_view", rb_gsl_na_to_gsl_matrix_int_view, 1);
641
+ rb_define_singleton_method(cgsl_matrix_int, "to_gm_view", rb_gsl_na_to_gsl_matrix_int_view, 1);
642
+ rb_define_singleton_method(cgsl_matrix_int, "na_to_gslm_view", rb_gsl_na_to_gsl_matrix_int_view, 1);
643
+ rb_define_singleton_method(cgsl_matrix_int, "na_to_gm_view", rb_gsl_na_to_gsl_matrix_int_view, 1);
644
+
645
+ rb_define_method(cNArray, "to_gm_int", rb_gsl_na_to_gsl_matrix_int_method, 0);
646
+ rb_define_alias(cNArray, "to_gslm_int", "to_gm_int");
647
+ rb_define_method(cNArray, "to_gm_int_view", rb_gsl_na_to_gsl_matrix_int_view_method, 0);
648
+ rb_define_alias(cNArray, "to_gslm_int_view", "to_gm_int_view");
649
+
650
+ rb_define_method(cNArray, "histogram", rb_gsl_narray_histogram, -1);
651
+ }
652
+
653
+ #endif