carray 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +56 -0
  3. data/GPL +340 -0
  4. data/Gemfile +9 -0
  5. data/Gemfile.lock +33 -0
  6. data/LEGAL +50 -0
  7. data/NOTE +73 -0
  8. data/Rakefile +20 -0
  9. data/TODO +5 -0
  10. data/ca_iter_block.c +242 -0
  11. data/ca_iter_dimension.c +287 -0
  12. data/ca_iter_window.c +202 -0
  13. data/ca_obj_array.c +1189 -0
  14. data/ca_obj_bitarray.c +523 -0
  15. data/ca_obj_bitfield.c +636 -0
  16. data/ca_obj_block.c +885 -0
  17. data/ca_obj_fake.c +405 -0
  18. data/ca_obj_farray.c +482 -0
  19. data/ca_obj_field.c +625 -0
  20. data/ca_obj_grid.c +738 -0
  21. data/ca_obj_mapping.c +614 -0
  22. data/ca_obj_object.c +777 -0
  23. data/ca_obj_reduce.c +299 -0
  24. data/ca_obj_refer.c +627 -0
  25. data/ca_obj_repeat.c +640 -0
  26. data/ca_obj_select.c +558 -0
  27. data/ca_obj_shift.c +952 -0
  28. data/ca_obj_transpose.c +582 -0
  29. data/ca_obj_unbound_repeat.c +557 -0
  30. data/ca_obj_window.c +1023 -0
  31. data/carray.h +1381 -0
  32. data/carray_access.c +1798 -0
  33. data/carray_attribute.c +903 -0
  34. data/carray_call_cfunc.c +1107 -0
  35. data/carray_cast.c +1155 -0
  36. data/carray_cast_func.rb +498 -0
  37. data/carray_class.c +132 -0
  38. data/carray_conversion.c +518 -0
  39. data/carray_copy.c +453 -0
  40. data/carray_core.c +1307 -0
  41. data/carray_element.c +572 -0
  42. data/carray_generate.c +681 -0
  43. data/carray_iterator.c +630 -0
  44. data/carray_loop.c +462 -0
  45. data/carray_mask.c +1174 -0
  46. data/carray_math.rb +834 -0
  47. data/carray_numeric.c +257 -0
  48. data/carray_operator.c +582 -0
  49. data/carray_order.c +1040 -0
  50. data/carray_random.c +529 -0
  51. data/carray_sort_addr.c +261 -0
  52. data/carray_stat.c +2102 -0
  53. data/carray_stat_proc.rb +1990 -0
  54. data/carray_test.c +602 -0
  55. data/carray_undef.c +69 -0
  56. data/carray_utils.c +740 -0
  57. data/ext/calculus/carray_calculus.c +792 -0
  58. data/ext/calculus/carray_interp.c +355 -0
  59. data/ext/calculus/extconf.rb +12 -0
  60. data/ext/calculus/lib/autoload/autoload_math_calculus.rb +2 -0
  61. data/ext/calculus/lib/math/calculus.rb +119 -0
  62. data/ext/calculus/lib/math/interp/adapter_interp1d.rb +31 -0
  63. data/ext/dataframe/API.txt +11 -0
  64. data/ext/dataframe/extconf.rb +3 -0
  65. data/ext/dataframe/lib/carray/autoload/autoload_dataframe_dataframe.rb +14 -0
  66. data/ext/dataframe/lib/carray/dataframe/dataframe.rb +1104 -0
  67. data/ext/dataframe/sample/test_uniq_sort.rb +5 -0
  68. data/ext/fortio/extconf.rb +3 -0
  69. data/ext/fortio/lib/carray/autoload/autoload_fortran_format.rb +5 -0
  70. data/ext/fortio/lib/carray/io/fortran_format.rb +43 -0
  71. data/ext/fortio/lib/fortio.rb +3 -0
  72. data/ext/fortio/lib/fortio/fortran_format.rb +603 -0
  73. data/ext/fortio/lib/fortio/fortran_format.tab.rb +536 -0
  74. data/ext/fortio/lib/fortio/fortran_format.y +215 -0
  75. data/ext/fortio/lib/fortio/fortran_namelist.rb +151 -0
  76. data/ext/fortio/lib/fortio/fortran_namelist.tab.rb +470 -0
  77. data/ext/fortio/lib/fortio/fortran_namelist.y +213 -0
  78. data/ext/fortio/lib/fortio/fortran_sequential.rb +345 -0
  79. data/ext/fortio/ruby_fortio.c +182 -0
  80. data/ext/fortio/test/test_H.rb +5 -0
  81. data/ext/fortio/test/test_T.rb +7 -0
  82. data/ext/fortio/test/test_fortran_format.rb +86 -0
  83. data/ext/fortio/test/test_namelist.rb +25 -0
  84. data/ext/fortio/test/test_sequential.rb +13 -0
  85. data/ext/fortio/test/test_sequential2.rb +13 -0
  86. data/ext/fortio/work/test.rb +10 -0
  87. data/ext/fortio/work/test_e.rb +19 -0
  88. data/ext/fortio/work/test_ep.rb +10 -0
  89. data/ext/fortio/work/test_parse.rb +12 -0
  90. data/ext/imagemap/carray_imagemap.c +495 -0
  91. data/ext/imagemap/doc/call_graph.dot +28 -0
  92. data/ext/imagemap/draw.c +567 -0
  93. data/ext/imagemap/extconf.rb +13 -0
  94. data/ext/imagemap/lib/autoload/autoload_graphics_imagemap.rb +1 -0
  95. data/ext/imagemap/lib/graphics/imagemap.rb +273 -0
  96. data/ext/imagemap/lib/image_map.rb +4 -0
  97. data/ext/imagemap/test/swath_index.rb +83 -0
  98. data/ext/imagemap/test/swath_warp.rb +99 -0
  99. data/ext/imagemap/test/test.rb +23 -0
  100. data/ext/imagemap/test/test_image.rb +42 -0
  101. data/ext/imagemap/test/test_line.rb +14 -0
  102. data/ext/imagemap/test/test_rotate.rb +17 -0
  103. data/ext/imagemap/test/test_triangle.rb +20 -0
  104. data/ext/imagemap/test/test_warp.rb +26 -0
  105. data/ext/mathfunc/carray_mathfunc.c +321 -0
  106. data/ext/mathfunc/extconf.rb +18 -0
  107. data/ext/mathfunc/lib/autoload/autoload_math_mathfunc.rb +1 -0
  108. data/ext/mathfunc/lib/math/mathfunc.rb +15 -0
  109. data/ext/mathfunc/test/test_hypot.rb +5 -0
  110. data/ext/mathfunc/test/test_j0.rb +22 -0
  111. data/ext/mathfunc/test/test_jn.rb +8 -0
  112. data/ext/mathfunc/test/test_sph.rb +9 -0
  113. data/ext/narray/README +22 -0
  114. data/ext/narray/ca_wrap_narray.c +491 -0
  115. data/ext/narray/carray_narray.c +21 -0
  116. data/ext/narray/extconf.rb +57 -0
  117. data/ext/narray/lib/autoload/autoload_math_narray.rb +1 -0
  118. data/ext/narray/lib/autoload/autoload_math_narray_miss.rb +11 -0
  119. data/ext/narray/lib/math/narray.rb +17 -0
  120. data/ext/narray/lib/math/narray_miss.rb +45 -0
  121. data/extconf.rb +3 -25
  122. data/lib/carray.rb +28 -0
  123. data/lib/carray/autoload/autoload_base.rb +23 -0
  124. data/lib/carray/autoload/autoload_graphics_gnuplot.rb +2 -0
  125. data/lib/carray/autoload/autoload_io_csv.rb +14 -0
  126. data/lib/carray/autoload/autoload_io_excel.rb +5 -0
  127. data/lib/carray/autoload/autoload_io_imagemagick.rb +6 -0
  128. data/lib/carray/autoload/autoload_io_pg.rb +6 -0
  129. data/lib/carray/autoload/autoload_io_sqlite3.rb +12 -0
  130. data/lib/carray/autoload/autoload_io_table.rb +1 -0
  131. data/lib/carray/autoload/autoload_math_histogram.rb +5 -0
  132. data/lib/carray/autoload/autoload_math_interp.rb +4 -0
  133. data/lib/carray/autoload/autoload_math_recurrence.rb +6 -0
  134. data/lib/carray/autoload/autoload_object_iterator.rb +1 -0
  135. data/lib/carray/autoload/autoload_object_link.rb +1 -0
  136. data/lib/carray/autoload/autoload_object_pack.rb +2 -0
  137. data/lib/carray/base/autoload.rb +94 -0
  138. data/lib/carray/base/basic.rb +1051 -0
  139. data/lib/carray/base/inspect.rb +252 -0
  140. data/lib/carray/base/iterator.rb +367 -0
  141. data/lib/carray/base/math.rb +403 -0
  142. data/lib/carray/base/obsolete.rb +93 -0
  143. data/lib/carray/base/serialize.rb +260 -0
  144. data/lib/carray/base/struct.rb +634 -0
  145. data/lib/carray/graphics/gnuplot.rb +2116 -0
  146. data/lib/carray/info.rb +112 -0
  147. data/lib/carray/io/csv.rb +560 -0
  148. data/lib/carray/io/excel.rb +26 -0
  149. data/lib/carray/io/imagemagick.rb +231 -0
  150. data/lib/carray/io/pg.rb +101 -0
  151. data/lib/carray/io/sqlite3.rb +202 -0
  152. data/lib/carray/io/table.rb +77 -0
  153. data/lib/carray/math/histogram.rb +179 -0
  154. data/lib/carray/math/interp.rb +57 -0
  155. data/lib/carray/math/interp/adapter_gsl_spline.rb +47 -0
  156. data/lib/carray/math/recurrence.rb +95 -0
  157. data/lib/carray/mkmf.rb +145 -0
  158. data/lib/carray/object/ca_obj_iterator.rb +52 -0
  159. data/lib/carray/object/ca_obj_link.rb +52 -0
  160. data/lib/carray/object/ca_obj_pack.rb +101 -0
  161. data/mkmath.rb +731 -0
  162. data/mt19937ar.c +182 -0
  163. data/mt19937ar.h +86 -0
  164. data/rdoc_main.rb +27 -0
  165. data/rdoc_math.rb +5 -0
  166. data/rdoc_stat.rb +31 -0
  167. data/ruby_carray.c +242 -0
  168. data/ruby_ccomplex.c +497 -0
  169. data/ruby_float_func.c +83 -0
  170. data/spec/CABlockIterator/CABlockIterator_spec.rb +113 -0
  171. data/spec/CArray/bug/store_spec.rb +27 -0
  172. data/spec/CArray/index/repeat_spec.rb +10 -0
  173. data/spec/CArray/method/eq_spec.rb +80 -0
  174. data/spec/CArray/method/is_nan_spec.rb +12 -0
  175. data/spec/CArray/method/ne_spec.rb +18 -0
  176. data/spec/CArray/method/round_spec.rb +11 -0
  177. data/spec/CArray/object/_attribute_spec.rb +32 -0
  178. data/spec/CArray/object/s_new_spec.rb +31 -0
  179. data/spec/CArray/serialize/Serialization_spec.rb +89 -0
  180. data/spec/spec_all.rb +11 -0
  181. data/test/test_ALL.rb +50 -0
  182. data/test/test_CABitfield.rb +59 -0
  183. data/test/test_CABlock.rb +208 -0
  184. data/test/test_CAField.rb +40 -0
  185. data/test/test_CAGrid.rb +76 -0
  186. data/test/test_CAMapping.rb +106 -0
  187. data/test/test_CAMmap.rb +11 -0
  188. data/test/test_CARefer.rb +94 -0
  189. data/test/test_CARepeat.rb +66 -0
  190. data/test/test_CASelect.rb +23 -0
  191. data/test/test_CAShift.rb +17 -0
  192. data/test/test_CATranspose.rb +61 -0
  193. data/test/test_CAVirtual.rb +214 -0
  194. data/test/test_CAWindow.rb +55 -0
  195. data/test/test_CAWrap.rb +9 -0
  196. data/test/test_CArray.rb +228 -0
  197. data/test/test_CComplex.rb +83 -0
  198. data/test/test_CScalar.rb +91 -0
  199. data/test/test_attribute.rb +281 -0
  200. data/test/test_block_iterator.rb +17 -0
  201. data/test/test_boolean.rb +99 -0
  202. data/test/test_cast.rb +33 -0
  203. data/test/test_class.rb +85 -0
  204. data/test/test_complex.rb +43 -0
  205. data/test/test_composite.rb +125 -0
  206. data/test/test_convert.rb +79 -0
  207. data/test/test_copy.rb +141 -0
  208. data/test/test_creation.rb +85 -0
  209. data/test/test_element.rb +146 -0
  210. data/test/test_extream.rb +55 -0
  211. data/test/test_generate.rb +75 -0
  212. data/test/test_index.rb +71 -0
  213. data/test/test_mask.rb +578 -0
  214. data/test/test_math.rb +98 -0
  215. data/test/test_narray.rb +64 -0
  216. data/test/test_order.rb +147 -0
  217. data/test/test_random.rb +15 -0
  218. data/test/test_ref_store.rb +211 -0
  219. data/test/test_stat.rb +414 -0
  220. data/test/test_struct.rb +72 -0
  221. data/test/test_virtual.rb +49 -0
  222. data/utils/ca_ase.rb +21 -0
  223. data/utils/ca_methods.rb +15 -0
  224. data/utils/cast_checker.rb +30 -0
  225. data/utils/create_rdoc.sh +9 -0
  226. data/utils/diff_method.rb +52 -0
  227. data/utils/extract_rdoc.rb +27 -0
  228. data/utils/make_tgz.sh +3 -0
  229. data/utils/remove_resource_fork.sh +5 -0
  230. data/version.h +3 -3
  231. metadata +266 -1
@@ -0,0 +1,1107 @@
1
+ /* ---------------------------------------------------------------------------
2
+
3
+ carray_math_call.c
4
+
5
+ This file is part of Ruby/CArray extension library.
6
+ You can redistribute it and/or modify it under the terms of
7
+ the Ruby Licence.
8
+
9
+ Copyright (C) 2005 Hiroki Motoyoshi
10
+
11
+ ---------------------------------------------------------------------------- */
12
+
13
+ #include "carray.h"
14
+
15
+ VALUE
16
+ ca_call_cfunc_1 (void (*func)(void *p0), const char *fsync,
17
+ VALUE rcx0)
18
+ {
19
+ CArray *cx0;
20
+ int32_t n;
21
+
22
+ if ( strlen(fsync) != 1 ) {
23
+ rb_raise(rb_eRuntimeError,
24
+ "[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
25
+ }
26
+
27
+ Data_Get_Struct(rcx0, CArray, cx0);
28
+
29
+ ca_attach(cx0);
30
+
31
+ {
32
+ char *p0;
33
+ char *q0;
34
+ int32_t s0;
35
+ int32_t k;
36
+ n = ca_set_iterator(1, cx0, &q0, &s0);
37
+ s0 *= cx0->bytes;
38
+ #ifdef _OPENMP
39
+ #pragma omp parallel for private(p0)
40
+ #endif
41
+ for (k=0; k<n; k++) {
42
+ p0 = q0 + k*s0;
43
+ func(p0);
44
+ }
45
+ }
46
+
47
+ ca_sync(cx0);
48
+ ca_detach(cx0);
49
+
50
+ return rcx0;
51
+ }
52
+
53
+
54
+ VALUE
55
+ ca_call_cfunc_2 (void (*func)(void *p0, void *p1), const char *fsync,
56
+ VALUE rcx0, VALUE rcx1)
57
+ {
58
+ CArray *cx0, *cx1;
59
+ boolean8_t *m0 = NULL, *m;
60
+ int32_t n;
61
+
62
+ if ( strlen(fsync) != 2 ) {
63
+ rb_raise(rb_eRuntimeError,
64
+ "[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
65
+ }
66
+
67
+ Data_Get_Struct(rcx0, CArray, cx0);
68
+ Data_Get_Struct(rcx1, CArray, cx1);
69
+
70
+ ca_attach_n(2, cx0, cx1);
71
+
72
+ {
73
+ CArray *cx[2];
74
+ int i = 0;
75
+ if ( fsync[0] == '0' ) cx[i++] = cx0;
76
+ if ( fsync[1] == '0' ) cx[i++] = cx1;
77
+ m = m0 = ca_allocate_mask_iterator_n(i, cx);
78
+ if ( fsync[0] == '1' ) ca_copy_mask_overwrite_n(cx0, cx0->elements, i, cx);
79
+ if ( fsync[1] == '1' ) ca_copy_mask_overwrite_n(cx1, cx1->elements, i, cx);
80
+ }
81
+
82
+ {
83
+ char *p0, *p1;
84
+ char *q0, *q1;
85
+ int32_t s0, s1;
86
+ int32_t k;
87
+
88
+ n = ca_set_iterator(2, cx0, &q0, &s0,
89
+ cx1, &q1, &s1);
90
+ s0 *= cx0->bytes;
91
+ s1 *= cx1->bytes;
92
+
93
+ if ( m0 ) {
94
+ #ifdef _OPENMP
95
+ #pragma omp parallel for private(p0,p1)
96
+ #endif
97
+ for (k=0; k<n; k++) {
98
+ m = m0 + k;
99
+ if ( ! *m ) {
100
+ p0 = q0 + k*s0;
101
+ p1 = q1 + k*s1;
102
+ func(p0, p1);
103
+ }
104
+ }
105
+ }
106
+ else {
107
+ #ifdef _OPENMP
108
+ #pragma omp parallel for private(p0,p1)
109
+ #endif
110
+ for (k=0; k<n; k++) {
111
+ p0 = q0 + k*s0;
112
+ p1 = q1 + k*s1;
113
+ func(p0, p1);
114
+ }
115
+ }
116
+ }
117
+ if ( fsync[0] == '1' ) ca_sync(cx0);
118
+ if ( fsync[1] == '1' ) ca_sync(cx1);
119
+ ca_detach_n(2, cx0, cx1);
120
+
121
+ free(m0);
122
+
123
+ return rcx0;
124
+ }
125
+
126
+ VALUE
127
+ ca_call_cfunc_3 (void (*func)(void *p0, void *p1, void *p2), const char *fsync,
128
+ VALUE rcx0, VALUE rcx1, VALUE rcx2)
129
+ {
130
+ CArray *cx0, *cx1, *cx2;
131
+ boolean8_t *m0 = NULL, *m;
132
+ int32_t n;
133
+
134
+ if ( strlen(fsync) != 3 ) {
135
+ rb_raise(rb_eRuntimeError,
136
+ "[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
137
+ }
138
+
139
+ Data_Get_Struct(rcx0, CArray, cx0);
140
+ Data_Get_Struct(rcx1, CArray, cx1);
141
+ Data_Get_Struct(rcx2, CArray, cx2);
142
+
143
+ ca_attach_n(3, cx0, cx1, cx2);
144
+
145
+ {
146
+ CArray *cx[3];
147
+ int i = 0;
148
+ if ( fsync[0] == '0' ) cx[i++] = cx0;
149
+ if ( fsync[1] == '0' ) cx[i++] = cx1;
150
+ if ( fsync[2] == '0' ) cx[i++] = cx2;
151
+ m = m0 = ca_allocate_mask_iterator_n(i, cx);
152
+ if ( fsync[0] == '1' ) ca_copy_mask_overwrite_n(cx0, cx0->elements, i, cx);
153
+ if ( fsync[1] == '1' ) ca_copy_mask_overwrite_n(cx1, cx1->elements, i, cx);
154
+ if ( fsync[2] == '1' ) ca_copy_mask_overwrite_n(cx2, cx2->elements, i, cx);
155
+ }
156
+
157
+ {
158
+ char *p0, *p1, *p2;
159
+ char *q0, *q1, *q2;
160
+ int32_t s0, s1, s2;
161
+ int32_t k;
162
+
163
+ n = ca_set_iterator(3, cx0, &q0, &s0,
164
+ cx1, &q1, &s1,
165
+ cx2, &q2, &s2);
166
+ s0 *= cx0->bytes;
167
+ s1 *= cx1->bytes;
168
+ s2 *= cx2->bytes;
169
+
170
+ if ( m0 ) {
171
+ #ifdef _OPENMP
172
+ #pragma omp parallel for private(p0,p1,p2)
173
+ #endif
174
+ for (k=0; k<n; k++) {
175
+ m = m0 + k;
176
+ if ( ! *m ) {
177
+ p0 = q0 + k*s0;
178
+ p1 = q1 + k*s1;
179
+ p2 = q2 + k*s2;
180
+ func(p0, p1, p2);
181
+ }
182
+ }
183
+ }
184
+ else {
185
+ #ifdef _OPENMP
186
+ #pragma omp parallel for private(p0,p1,p2)
187
+ #endif
188
+ for (k=0; k<n; k++) {
189
+ p0 = q0 + k*s0;
190
+ p1 = q1 + k*s1;
191
+ p2 = q2 + k*s2;
192
+ func(p0, p1, p2);
193
+ }
194
+ }
195
+ }
196
+ if ( fsync[0] == '1' ) ca_sync(cx0);
197
+ if ( fsync[1] == '1' ) ca_sync(cx1);
198
+ if ( fsync[2] == '1' ) ca_sync(cx2);
199
+ ca_detach_n(3, cx0, cx1, cx2);
200
+
201
+ free(m0);
202
+
203
+ return rcx0;
204
+ }
205
+
206
+ VALUE
207
+ ca_call_cfunc_4 (void (*func)(void *p0, void *p1, void *p2, void *p3), const char *fsync,
208
+ VALUE rcx0, VALUE rcx1, VALUE rcx2, VALUE rcx3)
209
+ {
210
+ CArray *cx0, *cx1, *cx2, *cx3;
211
+ boolean8_t *m0 = NULL, *m;
212
+ int32_t n;
213
+
214
+ if ( strlen(fsync) != 4 ) {
215
+ rb_raise(rb_eRuntimeError,
216
+ "[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
217
+ }
218
+
219
+ Data_Get_Struct(rcx0, CArray, cx0);
220
+ Data_Get_Struct(rcx1, CArray, cx1);
221
+ Data_Get_Struct(rcx2, CArray, cx2);
222
+ Data_Get_Struct(rcx3, CArray, cx3);
223
+
224
+ ca_attach_n(4, cx0, cx1, cx2, cx3);
225
+
226
+ {
227
+ CArray *cx[4];
228
+ int i = 0;
229
+ if ( fsync[0] == '0' ) cx[i++] = cx0;
230
+ if ( fsync[1] == '0' ) cx[i++] = cx1;
231
+ if ( fsync[2] == '0' ) cx[i++] = cx2;
232
+ if ( fsync[3] == '0' ) cx[i++] = cx3;
233
+ m = m0 = ca_allocate_mask_iterator_n(i, cx);
234
+ if ( fsync[0] == '1' ) ca_copy_mask_overwrite_n(cx0, cx0->elements, i, cx);
235
+ if ( fsync[1] == '1' ) ca_copy_mask_overwrite_n(cx1, cx1->elements, i, cx);
236
+ if ( fsync[2] == '1' ) ca_copy_mask_overwrite_n(cx2, cx2->elements, i, cx);
237
+ if ( fsync[3] == '1' ) ca_copy_mask_overwrite_n(cx3, cx3->elements, i, cx);
238
+ }
239
+
240
+ {
241
+ char *p0, *p1, *p2, *p3;
242
+ char *q0, *q1, *q2, *q3;
243
+ int32_t s0, s1, s2, s3;
244
+ int32_t k;
245
+
246
+ n = ca_set_iterator(4, cx0, &q0, &s0,
247
+ cx1, &q1, &s1,
248
+ cx2, &q2, &s2,
249
+ cx3, &q3, &s3);
250
+
251
+ s0 *= cx0->bytes;
252
+ s1 *= cx1->bytes;
253
+ s2 *= cx2->bytes;
254
+ s3 *= cx3->bytes;
255
+
256
+ if ( m0 ) {
257
+ #ifdef _OPENMP
258
+ #pragma omp parallel for private(p0,p1,p2,p3)
259
+ #endif
260
+ for (k=0; k<n; k++) {
261
+ m = m0 + k;
262
+ if ( ! *m ) {
263
+ p0 = q0 + k*s0;
264
+ p1 = q1 + k*s1;
265
+ p2 = q2 + k*s2;
266
+ p3 = q3 + k*s3;
267
+ func(p0, p1, p2, p3);
268
+ }
269
+ }
270
+ }
271
+ else {
272
+ #ifdef _OPENMP
273
+ #pragma omp parallel for private(p0,p1,p2,p3)
274
+ #endif
275
+ for (k=0; k<n; k++) {
276
+ p0 = q0 + k*s0;
277
+ p1 = q1 + k*s1;
278
+ p2 = q2 + k*s2;
279
+ p3 = q3 + k*s3;
280
+ func(p0, p1, p2, p3);
281
+ }
282
+ }
283
+ }
284
+ if ( fsync[0] == '1' ) ca_sync(cx0);
285
+ if ( fsync[1] == '1' ) ca_sync(cx1);
286
+ if ( fsync[2] == '1' ) ca_sync(cx2);
287
+ if ( fsync[3] == '1' ) ca_sync(cx3);
288
+ ca_detach_n(4, cx0, cx1, cx2, cx3);
289
+
290
+ free(m0);
291
+
292
+ return rcx0;
293
+ }
294
+
295
+ VALUE
296
+ ca_call_cfunc_5 (void (*func)(void*,void*,void*,void*,void*), const char *fsync,
297
+ VALUE rcx0, VALUE rcx1, VALUE rcx2, VALUE rcx3, VALUE rcx4)
298
+ {
299
+ CArray *cx0, *cx1, *cx2, *cx3, *cx4;
300
+ boolean8_t *m0 = NULL, *m;
301
+ int32_t n;
302
+
303
+ if ( strlen(fsync) != 5 ) {
304
+ rb_raise(rb_eRuntimeError,
305
+ "[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
306
+ }
307
+
308
+ Data_Get_Struct(rcx0, CArray, cx0);
309
+ Data_Get_Struct(rcx1, CArray, cx1);
310
+ Data_Get_Struct(rcx2, CArray, cx2);
311
+ Data_Get_Struct(rcx3, CArray, cx3);
312
+ Data_Get_Struct(rcx4, CArray, cx4);
313
+
314
+ ca_attach_n(5, cx0, cx1, cx2, cx3, cx4);
315
+
316
+ {
317
+ CArray *cx[5];
318
+ int i = 0;
319
+ if ( fsync[0] == '0' ) cx[i++] = cx0;
320
+ if ( fsync[1] == '0' ) cx[i++] = cx1;
321
+ if ( fsync[2] == '0' ) cx[i++] = cx2;
322
+ if ( fsync[3] == '0' ) cx[i++] = cx3;
323
+ if ( fsync[4] == '0' ) cx[i++] = cx4;
324
+ m = m0 = ca_allocate_mask_iterator_n(i, cx);
325
+ if ( fsync[0] == '1' ) ca_copy_mask_overwrite_n(cx0, cx0->elements, i, cx);
326
+ if ( fsync[1] == '1' ) ca_copy_mask_overwrite_n(cx1, cx1->elements, i, cx);
327
+ if ( fsync[2] == '1' ) ca_copy_mask_overwrite_n(cx2, cx2->elements, i, cx);
328
+ if ( fsync[3] == '1' ) ca_copy_mask_overwrite_n(cx3, cx3->elements, i, cx);
329
+ if ( fsync[4] == '1' ) ca_copy_mask_overwrite_n(cx4, cx4->elements, i, cx);
330
+ }
331
+
332
+ {
333
+ char *p0, *p1, *p2, *p3, *p4;
334
+ char *q0, *q1, *q2, *q3, *q4;
335
+ int32_t s0, s1, s2, s3, s4;
336
+ int32_t k;
337
+
338
+ n = ca_set_iterator(5, cx0, &q0, &s0,
339
+ cx1, &q1, &s1,
340
+ cx2, &q2, &s2,
341
+ cx3, &q3, &s3,
342
+ cx4, &q4, &s4);
343
+
344
+ s0 *= cx0->bytes;
345
+ s1 *= cx1->bytes;
346
+ s2 *= cx2->bytes;
347
+ s3 *= cx3->bytes;
348
+ s4 *= cx4->bytes;
349
+
350
+ if ( m0 ) {
351
+ #ifdef _OPENMP
352
+ #pragma omp parallel for private(p0,p1,p2,p3,p4)
353
+ #endif
354
+ for (k=0; k<n; k++) {
355
+ m = m0 + k;
356
+ if ( ! *m ) {
357
+ p0 = q0 + k*s0;
358
+ p1 = q1 + k*s1;
359
+ p2 = q2 + k*s2;
360
+ p3 = q3 + k*s3;
361
+ p4 = q4 + k*s4;
362
+ func(p0, p1, p2, p3, p4);
363
+ }
364
+ }
365
+ }
366
+ else {
367
+ #ifdef _OPENMP
368
+ #pragma omp parallel for private(p0,p1,p2,p3,p4)
369
+ #endif
370
+ for (k=0; k<n; k++) {
371
+ p0 = q0 + k*s0;
372
+ p1 = q1 + k*s1;
373
+ p2 = q2 + k*s2;
374
+ p3 = q3 + k*s3;
375
+ p4 = q4 + k*s4;
376
+ func(p0, p1, p2, p3, p4);
377
+ }
378
+ }
379
+ }
380
+ if ( fsync[0] == '1' ) ca_sync(cx0);
381
+ if ( fsync[1] == '1' ) ca_sync(cx1);
382
+ if ( fsync[2] == '1' ) ca_sync(cx2);
383
+ if ( fsync[3] == '1' ) ca_sync(cx3);
384
+ if ( fsync[4] == '1' ) ca_sync(cx4);
385
+ ca_detach_n(5, cx0, cx1, cx2, cx3, cx4);
386
+
387
+ free(m0);
388
+
389
+ return rcx0;
390
+ }
391
+
392
+ VALUE
393
+ ca_call_cfunc_6 (void (*func)(void*,void*,void*,void*,void*,void*), const char *fsync,
394
+ VALUE rcx0, VALUE rcx1, VALUE rcx2, VALUE rcx3, VALUE rcx4, VALUE rcx5)
395
+ {
396
+ CArray *cx0, *cx1, *cx2, *cx3, *cx4, *cx5;
397
+ boolean8_t *m0 = NULL, *m;
398
+ int32_t n;
399
+
400
+ if ( strlen(fsync) != 6 ) {
401
+ rb_raise(rb_eRuntimeError,
402
+ "[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
403
+ }
404
+
405
+ Data_Get_Struct(rcx0, CArray, cx0);
406
+ Data_Get_Struct(rcx1, CArray, cx1);
407
+ Data_Get_Struct(rcx2, CArray, cx2);
408
+ Data_Get_Struct(rcx3, CArray, cx3);
409
+ Data_Get_Struct(rcx4, CArray, cx4);
410
+ Data_Get_Struct(rcx5, CArray, cx5);
411
+
412
+ ca_attach_n(6, cx0, cx1, cx2, cx3, cx4, cx5);
413
+
414
+ {
415
+ CArray *cx[6];
416
+ int i = 0;
417
+ if ( fsync[0] == '0' ) cx[i++] = cx0;
418
+ if ( fsync[1] == '0' ) cx[i++] = cx1;
419
+ if ( fsync[2] == '0' ) cx[i++] = cx2;
420
+ if ( fsync[3] == '0' ) cx[i++] = cx3;
421
+ if ( fsync[4] == '0' ) cx[i++] = cx4;
422
+ if ( fsync[5] == '0' ) cx[i++] = cx5;
423
+ m = m0 = ca_allocate_mask_iterator_n(i, cx);
424
+ if ( fsync[0] == '1' ) ca_copy_mask_overwrite_n(cx0, cx0->elements, i, cx);
425
+ if ( fsync[1] == '1' ) ca_copy_mask_overwrite_n(cx1, cx1->elements, i, cx);
426
+ if ( fsync[2] == '1' ) ca_copy_mask_overwrite_n(cx2, cx2->elements, i, cx);
427
+ if ( fsync[3] == '1' ) ca_copy_mask_overwrite_n(cx3, cx3->elements, i, cx);
428
+ if ( fsync[4] == '1' ) ca_copy_mask_overwrite_n(cx4, cx4->elements, i, cx);
429
+ if ( fsync[5] == '1' ) ca_copy_mask_overwrite_n(cx5, cx5->elements, i, cx);
430
+ }
431
+
432
+ {
433
+ char *p0, *p1, *p2, *p3, *p4, *p5;
434
+ char *q0, *q1, *q2, *q3, *q4, *q5;
435
+ int32_t s0, s1, s2, s3, s4, s5;
436
+ int32_t k;
437
+
438
+ n = ca_set_iterator(6, cx0, &q0, &s0,
439
+ cx1, &q1, &s1,
440
+ cx2, &q2, &s2,
441
+ cx3, &q3, &s3,
442
+ cx4, &q4, &s4,
443
+ cx5, &q5, &s5);
444
+
445
+ s0 *= cx0->bytes;
446
+ s1 *= cx1->bytes;
447
+ s2 *= cx2->bytes;
448
+ s3 *= cx3->bytes;
449
+ s4 *= cx4->bytes;
450
+ s5 *= cx5->bytes;
451
+
452
+ if ( m0 ) {
453
+ #ifdef _OPENMP
454
+ #pragma omp parallel for private(p0,p1,p2,p3,p4,p5)
455
+ #endif
456
+ for (k=0; k<n; k++) {
457
+ m = m0 + k;
458
+ if ( ! *m ) {
459
+ p0 = q0 + k*s0;
460
+ p1 = q1 + k*s1;
461
+ p2 = q2 + k*s2;
462
+ p3 = q3 + k*s3;
463
+ p4 = q4 + k*s4;
464
+ p5 = q5 + k*s5;
465
+ func(p0, p1, p2, p3, p4, p5);
466
+ }
467
+ }
468
+ }
469
+ else {
470
+ #ifdef _OPENMP
471
+ #pragma omp parallel for private(p0,p1,p2,p3,p4,p5)
472
+ #endif
473
+ for (k=0; k<n; k++) {
474
+ p0 = q0 + k*s0;
475
+ p1 = q1 + k*s1;
476
+ p2 = q2 + k*s2;
477
+ p3 = q3 + k*s3;
478
+ p4 = q4 + k*s4;
479
+ p5 = q5 + k*s5;
480
+ func(p0, p1, p2, p3, p4, p5);
481
+ }
482
+ }
483
+ }
484
+ if ( fsync[0] == '1' ) ca_sync(cx0);
485
+ if ( fsync[1] == '1' ) ca_sync(cx1);
486
+ if ( fsync[2] == '1' ) ca_sync(cx2);
487
+ if ( fsync[3] == '1' ) ca_sync(cx3);
488
+ if ( fsync[4] == '1' ) ca_sync(cx4);
489
+ if ( fsync[5] == '1' ) ca_sync(cx5);
490
+ ca_detach_n(6, cx0, cx1, cx2, cx3, cx4, cx5);
491
+
492
+ free(m0);
493
+
494
+ return rcx0;
495
+ }
496
+
497
+ VALUE
498
+ ca_call_cfunc_7 (void (*func)(void*,void*,void*,void*,void*,void*,void*), const char *fsync,
499
+ VALUE rcx0, VALUE rcx1, VALUE rcx2, VALUE rcx3, VALUE rcx4, VALUE rcx5, VALUE rcx6)
500
+ {
501
+ CArray *cx0, *cx1, *cx2, *cx3, *cx4, *cx5, *cx6;
502
+ boolean8_t *m0 = NULL, *m;
503
+ int32_t n;
504
+
505
+ if ( strlen(fsync) != 7 ) {
506
+ rb_raise(rb_eRuntimeError,
507
+ "[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
508
+ }
509
+
510
+ Data_Get_Struct(rcx0, CArray, cx0);
511
+ Data_Get_Struct(rcx1, CArray, cx1);
512
+ Data_Get_Struct(rcx2, CArray, cx2);
513
+ Data_Get_Struct(rcx3, CArray, cx3);
514
+ Data_Get_Struct(rcx4, CArray, cx4);
515
+ Data_Get_Struct(rcx5, CArray, cx5);
516
+ Data_Get_Struct(rcx6, CArray, cx6);
517
+
518
+ ca_attach_n(7, cx0, cx1, cx2, cx3, cx4, cx5, cx6);
519
+
520
+ {
521
+ CArray *cx[7];
522
+ int i = 0;
523
+ if ( fsync[0] == '0' ) cx[i++] = cx0;
524
+ if ( fsync[1] == '0' ) cx[i++] = cx1;
525
+ if ( fsync[2] == '0' ) cx[i++] = cx2;
526
+ if ( fsync[3] == '0' ) cx[i++] = cx3;
527
+ if ( fsync[4] == '0' ) cx[i++] = cx4;
528
+ if ( fsync[5] == '0' ) cx[i++] = cx5;
529
+ if ( fsync[6] == '0' ) cx[i++] = cx6;
530
+ m = m0 = ca_allocate_mask_iterator_n(i, cx);
531
+ if ( fsync[0] == '1' ) ca_copy_mask_overwrite_n(cx0, cx0->elements, i, cx);
532
+ if ( fsync[1] == '1' ) ca_copy_mask_overwrite_n(cx1, cx1->elements, i, cx);
533
+ if ( fsync[2] == '1' ) ca_copy_mask_overwrite_n(cx2, cx2->elements, i, cx);
534
+ if ( fsync[3] == '1' ) ca_copy_mask_overwrite_n(cx3, cx3->elements, i, cx);
535
+ if ( fsync[4] == '1' ) ca_copy_mask_overwrite_n(cx4, cx4->elements, i, cx);
536
+ if ( fsync[5] == '1' ) ca_copy_mask_overwrite_n(cx5, cx5->elements, i, cx);
537
+ if ( fsync[6] == '1' ) ca_copy_mask_overwrite_n(cx6, cx6->elements, i, cx);
538
+ }
539
+
540
+ {
541
+ char *p0, *p1, *p2, *p3, *p4, *p5, *p6;
542
+ char *q0, *q1, *q2, *q3, *q4, *q5, *q6;
543
+ int32_t s0, s1, s2, s3, s4, s5, s6;
544
+ int32_t k;
545
+
546
+ n = ca_set_iterator(7, cx0, &q0, &s0,
547
+ cx1, &q1, &s1,
548
+ cx2, &q2, &s2,
549
+ cx3, &q3, &s3,
550
+ cx4, &q4, &s4,
551
+ cx5, &q5, &s5,
552
+ cx6, &q6, &s6);
553
+
554
+ s0 *= cx0->bytes;
555
+ s1 *= cx1->bytes;
556
+ s2 *= cx2->bytes;
557
+ s3 *= cx3->bytes;
558
+ s4 *= cx4->bytes;
559
+ s5 *= cx5->bytes;
560
+ s6 *= cx6->bytes;
561
+
562
+ if ( m0 ) {
563
+ #ifdef _OPENMP
564
+ #pragma omp parallel for private(p0,p1,p2,p3,p4,p5,p6)
565
+ #endif
566
+ for (k=0; k<n; k++) {
567
+ m = m0 + k;
568
+ if ( ! *m ) {
569
+ p0 = q0 + k*s0;
570
+ p1 = q1 + k*s1;
571
+ p2 = q2 + k*s2;
572
+ p3 = q3 + k*s3;
573
+ p4 = q4 + k*s4;
574
+ p5 = q5 + k*s5;
575
+ p6 = q6 + k*s6;
576
+ func(p0, p1, p2, p3, p4, p5, p6);
577
+ }
578
+ }
579
+ }
580
+ else {
581
+ #ifdef _OPENMP
582
+ #pragma omp parallel for private(p0,p1,p2,p3,p4,p5,p6)
583
+ #endif
584
+ for (k=0; k<n; k++) {
585
+ p0 = q0 + k*s0;
586
+ p1 = q1 + k*s1;
587
+ p2 = q2 + k*s2;
588
+ p3 = q3 + k*s3;
589
+ p4 = q4 + k*s4;
590
+ p5 = q5 + k*s5;
591
+ p6 = q6 + k*s6;
592
+ func(p0, p1, p2, p3, p4, p5, p6);
593
+ }
594
+ }
595
+
596
+ }
597
+ if ( fsync[0] == '1' ) ca_sync(cx0);
598
+ if ( fsync[1] == '1' ) ca_sync(cx1);
599
+ if ( fsync[2] == '1' ) ca_sync(cx2);
600
+ if ( fsync[3] == '1' ) ca_sync(cx3);
601
+ if ( fsync[4] == '1' ) ca_sync(cx4);
602
+ if ( fsync[5] == '1' ) ca_sync(cx5);
603
+ if ( fsync[6] == '1' ) ca_sync(cx6);
604
+ ca_detach_n(7, cx0, cx1, cx2, cx3, cx4, cx5, cx6);
605
+
606
+ free(m0);
607
+
608
+ return rcx0;
609
+ }
610
+
611
+ /* -------------------------------------------------------------------- */
612
+
613
+ VALUE
614
+ ca_call_cfunc_1_1 (int8_t dty, int8_t dtx,
615
+ void (*mathfunc)(void*,void*), VALUE rx)
616
+ {
617
+ volatile VALUE ry;
618
+ rx = rb_ca_wrap_readonly(rx, INT2NUM(dtx));
619
+ if ( dty != dtx ) {
620
+ ry = rb_ca_template(rb_ca_wrap_readonly(rx, INT2NUM(dty)));
621
+ }
622
+ else {
623
+ ry = rb_ca_template(rx);
624
+ }
625
+ ca_call_cfunc_2(mathfunc, "10", ry, rx);
626
+ if ( rb_ca_is_scalar(ry) ) {
627
+ return rb_ca_fetch_addr(ry, 0);
628
+ }
629
+ else {
630
+ return ry;
631
+ }
632
+ }
633
+
634
+ VALUE
635
+ ca_call_cfunc_1_2 (int8_t dty,
636
+ int8_t dtx1,
637
+ int8_t dtx2,
638
+ void (*mathfunc)(void*,void*,void*),
639
+ volatile VALUE rx1,
640
+ volatile VALUE rx2)
641
+ {
642
+ volatile VALUE ry = Qnil;
643
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
644
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
645
+ if ( dty != dtx1 || dty != dtx2 ) {
646
+ ry = rb_ca_template_n(2,
647
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty)),
648
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty)));
649
+ }
650
+ else {
651
+ ry = rb_ca_template_n(2, rx1, rx2);
652
+ }
653
+ ca_call_cfunc_3(mathfunc, "100", ry, rx1, rx2);
654
+ if ( rb_ca_is_scalar(ry) ) {
655
+ return rb_ca_fetch_addr(ry, 0);
656
+ }
657
+ else {
658
+ return ry;
659
+ }
660
+ }
661
+
662
+
663
+ VALUE
664
+ ca_call_cfunc_1_3 (int8_t dty,
665
+ int8_t dtx1,
666
+ int8_t dtx2,
667
+ int8_t dtx3,
668
+ void (*mathfunc)(void*,void*,void*,void*),
669
+ volatile VALUE rx1,
670
+ volatile VALUE rx2,
671
+ volatile VALUE rx3)
672
+ {
673
+ volatile VALUE ry;
674
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
675
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
676
+ rx3 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx3));
677
+ ry = rb_ca_template_n(3,
678
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty)),
679
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty)),
680
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty)));
681
+ ca_call_cfunc_4(mathfunc, "1000", ry, rx1, rx2, rx3);
682
+ if ( rb_ca_is_scalar(ry) ) {
683
+ return rb_ca_fetch_addr(ry, 0);
684
+ }
685
+ else {
686
+ return ry;
687
+ }
688
+ }
689
+
690
+ VALUE
691
+ ca_call_cfunc_1_4 (int8_t dty,
692
+ int8_t dtx1,
693
+ int8_t dtx2,
694
+ int8_t dtx3,
695
+ int8_t dtx4,
696
+ void (*mathfunc)(void*,void*,void*,void*,void*),
697
+ volatile VALUE rx1,
698
+ volatile VALUE rx2,
699
+ volatile VALUE rx3,
700
+ volatile VALUE rx4)
701
+ {
702
+ volatile VALUE ry;
703
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
704
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
705
+ rx3 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx3));
706
+ rx4 = rb_ca_wrap_readonly(rx4, INT2NUM(dtx4));
707
+ ry = rb_ca_template_n(4,
708
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty)),
709
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty)),
710
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty)),
711
+ rb_ca_wrap_readonly(rx4, INT2NUM(dty)));
712
+ ca_call_cfunc_5(mathfunc, "10000", ry, rx1, rx2, rx3, rx4);
713
+ if ( rb_ca_is_scalar(ry) ) {
714
+ return rb_ca_fetch_addr(ry, 0);
715
+ }
716
+ else {
717
+ return ry;
718
+ }
719
+ }
720
+
721
+ VALUE
722
+ ca_call_cfunc_1_5 (int8_t dty,
723
+ int8_t dtx1,
724
+ int8_t dtx2,
725
+ int8_t dtx3,
726
+ int8_t dtx4,
727
+ int8_t dtx5,
728
+ void (*mathfunc)(void*,void*,void*,void*,void*,void*),
729
+ volatile VALUE rx1,
730
+ volatile VALUE rx2,
731
+ volatile VALUE rx3,
732
+ volatile VALUE rx4,
733
+ volatile VALUE rx5)
734
+ {
735
+ volatile VALUE ry;
736
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
737
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
738
+ rx3 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx3));
739
+ rx4 = rb_ca_wrap_readonly(rx4, INT2NUM(dtx4));
740
+ rx5 = rb_ca_wrap_readonly(rx5, INT2NUM(dtx5));
741
+ ry = rb_ca_template_n(5,
742
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty)),
743
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty)),
744
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty)),
745
+ rb_ca_wrap_readonly(rx4, INT2NUM(dty)),
746
+ rb_ca_wrap_readonly(rx5, INT2NUM(dty)));
747
+ ca_call_cfunc_6(mathfunc, "10000", ry, rx1, rx2, rx3, rx4, rx5);
748
+ if ( rb_ca_is_scalar(ry) ) {
749
+ return rb_ca_fetch_addr(ry, 0);
750
+ }
751
+ else {
752
+ return ry;
753
+ }
754
+ }
755
+
756
+ VALUE
757
+ ca_call_cfunc_1_6 (int8_t dty,
758
+ int8_t dtx1,
759
+ int8_t dtx2,
760
+ int8_t dtx3,
761
+ int8_t dtx4,
762
+ int8_t dtx5,
763
+ int8_t dtx6,
764
+ void (*mathfunc)(void*,void*,void*,void*,void*,void*,void*),
765
+ volatile VALUE rx1,
766
+ volatile VALUE rx2,
767
+ volatile VALUE rx3,
768
+ volatile VALUE rx4,
769
+ volatile VALUE rx5,
770
+ volatile VALUE rx6)
771
+ {
772
+ volatile VALUE ry;
773
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
774
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
775
+ rx3 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx3));
776
+ rx4 = rb_ca_wrap_readonly(rx4, INT2NUM(dtx4));
777
+ rx5 = rb_ca_wrap_readonly(rx5, INT2NUM(dtx5));
778
+ rx6 = rb_ca_wrap_readonly(rx5, INT2NUM(dtx6));
779
+ ry = rb_ca_template_n(5,
780
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty)),
781
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty)),
782
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty)),
783
+ rb_ca_wrap_readonly(rx4, INT2NUM(dty)),
784
+ rb_ca_wrap_readonly(rx5, INT2NUM(dty)),
785
+ rb_ca_wrap_readonly(rx6, INT2NUM(dty)));
786
+ ca_call_cfunc_7(mathfunc, "100000", ry, rx1, rx2, rx3, rx4, rx5, rx6);
787
+ if ( rb_ca_is_scalar(ry) ) {
788
+ return rb_ca_fetch_addr(ry, 0);
789
+ }
790
+ else {
791
+ return ry;
792
+ }
793
+ }
794
+
795
+ VALUE
796
+ ca_call_cfunc_2_1 (int8_t dty1,
797
+ int8_t dty2,
798
+ int8_t dtx1,
799
+ void (*mathfunc)(void*,void*,void*),
800
+ volatile VALUE rx1)
801
+ {
802
+ volatile VALUE ry1 = Qnil, ry2 = Qnil;
803
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
804
+ if ( dty1 != dtx1 ) {
805
+ ry1 = rb_ca_template_n(1,
806
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty1)));
807
+ }
808
+ else {
809
+ ry1 = rb_ca_template_n(1, rx1);
810
+ }
811
+ if ( dty2 != dtx1 ) {
812
+ ry2 = rb_ca_template_n(1,
813
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty2)));
814
+ }
815
+ else {
816
+ ry2 = rb_ca_template_n(1, rx1);
817
+ }
818
+ ca_call_cfunc_3(mathfunc, "110", ry1, ry2, rx1);
819
+ if ( rb_ca_is_scalar(ry1) ) {
820
+ ry1 = rb_ca_fetch_addr(ry1, 0);
821
+ }
822
+ if ( rb_ca_is_scalar(ry2) ) {
823
+ ry2 = rb_ca_fetch_addr(ry2, 0);
824
+ }
825
+ return rb_ary_new3(2, ry1, ry2);
826
+ }
827
+
828
+
829
+ VALUE
830
+ ca_call_cfunc_2_2 (int8_t dty1,
831
+ int8_t dty2,
832
+ int8_t dtx1,
833
+ int8_t dtx2,
834
+ void (*mathfunc)(void*,void*,void*,void*),
835
+ volatile VALUE rx1,
836
+ volatile VALUE rx2)
837
+ {
838
+ volatile VALUE ry1 = Qnil, ry2 = Qnil;
839
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
840
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
841
+ if ( dty1 != dtx1 || dty1 != dtx2 ) {
842
+ ry1 = rb_ca_template_n(2,
843
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty1)),
844
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty1)));
845
+ }
846
+ else {
847
+ ry1 = rb_ca_template_n(2, rx1, rx2);
848
+ }
849
+ if ( dty2 != dtx1 || dty2 != dtx2 ) {
850
+ ry2 = rb_ca_template_n(2,
851
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty2)),
852
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty2)));
853
+ }
854
+ else {
855
+ ry2 = rb_ca_template_n(2, rx1, rx2);
856
+ }
857
+ ca_call_cfunc_4(mathfunc, "1100", ry1, ry2, rx1, rx2);
858
+ if ( rb_ca_is_scalar(ry1) ) {
859
+ ry1 = rb_ca_fetch_addr(ry1, 0);
860
+ }
861
+ if ( rb_ca_is_scalar(ry2) ) {
862
+ ry2 = rb_ca_fetch_addr(ry2, 0);
863
+ }
864
+ return rb_ary_new3(2, ry1, ry2);
865
+ }
866
+
867
+ VALUE
868
+ ca_call_cfunc_2_3 (int8_t dty1,
869
+ int8_t dty2,
870
+ int8_t dtx1,
871
+ int8_t dtx2,
872
+ int8_t dtx3,
873
+ void (*mathfunc)(void*,void*,void*,void*,void*),
874
+ volatile VALUE rx1,
875
+ volatile VALUE rx2,
876
+ volatile VALUE rx3)
877
+ {
878
+ volatile VALUE ry1 = Qnil, ry2 = Qnil;
879
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
880
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
881
+ rx3 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx3));
882
+ if ( dty1 != dtx1 || dty1 != dtx2 || dty1 != dtx3 ) {
883
+ ry1 = rb_ca_template_n(3,
884
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty1)),
885
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty1)),
886
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty1)));
887
+ }
888
+ else {
889
+ ry1 = rb_ca_template_n(3, rx1, rx2, rx3);
890
+ }
891
+ if ( dty2 != dtx1 || dty2 != dtx2 || dty2 != dtx3 ) {
892
+ ry2 = rb_ca_template_n(3,
893
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty2)),
894
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty2)),
895
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty2)));
896
+ }
897
+ else {
898
+ ry2 = rb_ca_template_n(3, rx1, rx2, rx3);
899
+ }
900
+ ca_call_cfunc_5(mathfunc, "11000", ry1, ry2, rx1, rx2, rx3);
901
+ if ( rb_ca_is_scalar(ry1) ) {
902
+ ry1 = rb_ca_fetch_addr(ry1, 0);
903
+ }
904
+ if ( rb_ca_is_scalar(ry2) ) {
905
+ ry2 = rb_ca_fetch_addr(ry2, 0);
906
+ }
907
+ return rb_ary_new3(2, ry1, ry2);
908
+ }
909
+
910
+ VALUE
911
+ ca_call_cfunc_2_4 (int8_t dty1,
912
+ int8_t dty2,
913
+ int8_t dtx1,
914
+ int8_t dtx2,
915
+ int8_t dtx3,
916
+ int8_t dtx4,
917
+ void (*mathfunc)(void*,void*,void*,void*,void*,void*),
918
+ volatile VALUE rx1,
919
+ volatile VALUE rx2,
920
+ volatile VALUE rx3,
921
+ volatile VALUE rx4)
922
+ {
923
+ volatile VALUE ry1 = Qnil, ry2 = Qnil;
924
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
925
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
926
+ rx3 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx3));
927
+ rx4 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx4));
928
+ if ( dty1 != dtx1 || dty1 != dtx2 || dty1 != dtx3 || dty1 != dtx4 ) {
929
+ ry1 = rb_ca_template_n(4,
930
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty1)),
931
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty1)),
932
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty1)),
933
+ rb_ca_wrap_readonly(rx4, INT2NUM(dty1)));
934
+ }
935
+ else {
936
+ ry1 = rb_ca_template_n(4, rx1, rx2, rx3, rx4);
937
+ }
938
+ if ( dty2 != dtx1 || dty2 != dtx2 || dty2 != dtx3 || dty2 != dtx4 ) {
939
+ ry2 = rb_ca_template_n(4,
940
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty2)),
941
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty2)),
942
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty2)),
943
+ rb_ca_wrap_readonly(rx4, INT2NUM(dty2)));
944
+ }
945
+ else {
946
+ ry2 = rb_ca_template_n(4, rx1, rx2, rx3, rx4);
947
+ }
948
+ ca_call_cfunc_6(mathfunc, "110000", ry1, ry2, rx1, rx2, rx3, rx4);
949
+ if ( rb_ca_is_scalar(ry1) ) {
950
+ ry1 = rb_ca_fetch_addr(ry1, 0);
951
+ }
952
+ if ( rb_ca_is_scalar(ry2) ) {
953
+ ry2 = rb_ca_fetch_addr(ry2, 0);
954
+ }
955
+ return rb_ary_new3(2, ry1, ry2);
956
+ }
957
+
958
+ VALUE
959
+ ca_call_cfunc_3_1 (int8_t dty1,
960
+ int8_t dty2,
961
+ int8_t dty3,
962
+ int8_t dtx1,
963
+ void (*mathfunc)(void*,void*,void*,void*),
964
+ volatile VALUE rx1)
965
+ {
966
+ volatile VALUE ry1 = Qnil, ry2 = Qnil, ry3 = Qnil;
967
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
968
+ if ( dty1 != dtx1 ) {
969
+ ry1 = rb_ca_template_n(1,
970
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty1)));
971
+ }
972
+ else {
973
+ ry1 = rb_ca_template_n(1, rx1);
974
+ }
975
+ if ( dty2 != dtx1 ) {
976
+ ry2 = rb_ca_template_n(1,
977
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty2)));
978
+ }
979
+ else {
980
+ ry2 = rb_ca_template_n(1, rx1);
981
+ }
982
+ if ( dty3 != dtx1 ) {
983
+ ry3 = rb_ca_template_n(1,
984
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty3)));
985
+ }
986
+ else {
987
+ ry3 = rb_ca_template_n(1, rx1);
988
+ }
989
+ ca_call_cfunc_4(mathfunc, "1110", ry1, ry2, ry3, rx1);
990
+ if ( rb_ca_is_scalar(ry1) ) {
991
+ ry1 = rb_ca_fetch_addr(ry1, 0);
992
+ }
993
+ if ( rb_ca_is_scalar(ry2) ) {
994
+ ry2 = rb_ca_fetch_addr(ry2, 0);
995
+ }
996
+ if ( rb_ca_is_scalar(ry3) ) {
997
+ ry3 = rb_ca_fetch_addr(ry3, 0);
998
+ }
999
+ return rb_ary_new3(3, ry1, ry2, ry3);
1000
+ }
1001
+
1002
+ VALUE
1003
+ ca_call_cfunc_3_2 (int8_t dty1,
1004
+ int8_t dty2,
1005
+ int8_t dty3,
1006
+ int8_t dtx1,
1007
+ int8_t dtx2,
1008
+ void (*mathfunc)(void*,void*,void*,void*,void*),
1009
+ volatile VALUE rx1,
1010
+ volatile VALUE rx2)
1011
+ {
1012
+ volatile VALUE ry1 = Qnil, ry2 = Qnil, ry3 = Qnil;
1013
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
1014
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
1015
+ if ( dty1 != dtx1 || dty1 != dtx2 ) {
1016
+ ry1 = rb_ca_template_n(2,
1017
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty1)),
1018
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty1)));
1019
+ }
1020
+ else {
1021
+ ry1 = rb_ca_template_n(2, rx1, rx2);
1022
+ }
1023
+ if ( dty2 != dtx1 || dty2 != dtx2 ) {
1024
+ ry2 = rb_ca_template_n(2,
1025
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty2)),
1026
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty2)));
1027
+ }
1028
+ else {
1029
+ ry2 = rb_ca_template_n(2, rx1, rx2);
1030
+ }
1031
+ if ( dty3 != dtx1 || dty3 != dtx2 ) {
1032
+ ry3 = rb_ca_template_n(2,
1033
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty3)),
1034
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty3)));
1035
+ }
1036
+ else {
1037
+ ry3 = rb_ca_template_n(2, rx1, rx2);
1038
+ }
1039
+ ca_call_cfunc_5(mathfunc, "11100", ry1, ry2, ry3, rx1, rx2);
1040
+ if ( rb_ca_is_scalar(ry1) ) {
1041
+ ry1 = rb_ca_fetch_addr(ry1, 0);
1042
+ }
1043
+ if ( rb_ca_is_scalar(ry2) ) {
1044
+ ry2 = rb_ca_fetch_addr(ry2, 0);
1045
+ }
1046
+ if ( rb_ca_is_scalar(ry3) ) {
1047
+ ry3 = rb_ca_fetch_addr(ry3, 0);
1048
+ }
1049
+ return rb_ary_new3(3, ry1, ry2, ry3);
1050
+ }
1051
+
1052
+ VALUE
1053
+ ca_call_cfunc_3_3 (int8_t dty1,
1054
+ int8_t dty2,
1055
+ int8_t dty3,
1056
+ int8_t dtx1,
1057
+ int8_t dtx2,
1058
+ int8_t dtx3,
1059
+ void (*mathfunc)(void*,void*,void*,void*,void*,void*),
1060
+ volatile VALUE rx1,
1061
+ volatile VALUE rx2,
1062
+ volatile VALUE rx3)
1063
+ {
1064
+ volatile VALUE ry1 = Qnil, ry2 = Qnil, ry3 = Qnil;
1065
+ rx1 = rb_ca_wrap_readonly(rx1, INT2NUM(dtx1));
1066
+ rx2 = rb_ca_wrap_readonly(rx2, INT2NUM(dtx2));
1067
+ rx3 = rb_ca_wrap_readonly(rx3, INT2NUM(dtx3));
1068
+ if ( dty1 != dtx1 || dty1 != dtx2 || dty1 != dtx3 ) {
1069
+ ry1 = rb_ca_template_n(3,
1070
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty1)),
1071
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty1)),
1072
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty1)));
1073
+ }
1074
+ else {
1075
+ ry1 = rb_ca_template_n(3, rx1, rx2, rx3);
1076
+ }
1077
+ if ( dty2 != dtx1 || dty2 != dtx2 || dty2 != dtx3 ) {
1078
+ ry2 = rb_ca_template_n(3,
1079
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty2)),
1080
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty2)),
1081
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty2)));
1082
+ }
1083
+ else {
1084
+ ry2 = rb_ca_template_n(3, rx1, rx2, rx3);
1085
+ }
1086
+ if ( dty3 != dtx1 || dty3 != dtx2 || dty3 != dtx3 ) {
1087
+ ry3 = rb_ca_template_n(3,
1088
+ rb_ca_wrap_readonly(rx1, INT2NUM(dty3)),
1089
+ rb_ca_wrap_readonly(rx2, INT2NUM(dty3)),
1090
+ rb_ca_wrap_readonly(rx3, INT2NUM(dty3)));
1091
+ }
1092
+ else {
1093
+ ry3 = rb_ca_template_n(3, rx1, rx2, rx3);
1094
+ }
1095
+
1096
+ ca_call_cfunc_6(mathfunc, "111000", ry1, ry2, ry3, rx1, rx2, rx3);
1097
+ if ( rb_ca_is_scalar(ry1) ) {
1098
+ ry1 = rb_ca_fetch_addr(ry1, 0);
1099
+ }
1100
+ if ( rb_ca_is_scalar(ry2) ) {
1101
+ ry2 = rb_ca_fetch_addr(ry2, 0);
1102
+ }
1103
+ if ( rb_ca_is_scalar(ry3) ) {
1104
+ ry3 = rb_ca_fetch_addr(ry3, 0);
1105
+ }
1106
+ return rb_ary_new3(3, ry1, ry2, ry3);
1107
+ }