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,182 @@
1
+ /*
2
+ The names of routines in original mt19937ar.c are all prefixed with "ca_"
3
+ to avoid collision with ruby's runtime library.
4
+ */
5
+
6
+ #include "mt19937ar.h"
7
+
8
+ /*
9
+ A C-program for MT19937, with initialization improved 2002/1/26.
10
+ Coded by Takuji Nishimura and Makoto Matsumoto.
11
+
12
+ Before using, initialize the state by using init_genrand(seed)
13
+ or init_by_array(init_key, key_length).
14
+
15
+ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
16
+ All rights reserved.
17
+ Copyright (C) 2005, Mutsuo Saito,
18
+ All rights reserved.
19
+
20
+ Redistribution and use in source and binary forms, with or without
21
+ modification, are permitted provided that the following conditions
22
+ are met:
23
+
24
+ 1. Redistributions of source code must retain the above copyright
25
+ notice, this list of conditions and the following disclaimer.
26
+
27
+ 2. Redistributions in binary form must reproduce the above copyright
28
+ notice, this list of conditions and the following disclaimer in the
29
+ documentation and/or other materials provided with the distribution.
30
+
31
+ 3. The names of its contributors may not be used to endorse or promote
32
+ products derived from this software without specific prior written
33
+ permission.
34
+
35
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
39
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
41
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
42
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
+
47
+
48
+ Any feedback is very welcome.
49
+ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
50
+ email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
51
+ */
52
+
53
+ #include <stdio.h>
54
+ #include "mt19937ar.h"
55
+
56
+ /* Period parameters */
57
+ #define N 624
58
+ #define M 397
59
+ #define MATRIX_A 0x9908b0dfUL /* constant vector a */
60
+ #define UPPER_MASK 0x80000000UL /* most significant w-r bits */
61
+ #define LOWER_MASK 0x7fffffffUL /* least significant r bits */
62
+
63
+ static unsigned long mt[N]; /* the array for the state vector */
64
+ static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
65
+
66
+ /* initializes mt[N] with a seed */
67
+ void init_genrand(unsigned long s)
68
+ {
69
+ mt[0]= s & 0xffffffffUL;
70
+ for (mti=1; mti<N; mti++) {
71
+ mt[mti] =
72
+ (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
73
+ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
74
+ /* In the previous versions, MSBs of the seed affect */
75
+ /* only MSBs of the array mt[]. */
76
+ /* 2002/01/09 modified by Makoto Matsumoto */
77
+ mt[mti] &= 0xffffffffUL;
78
+ /* for >32 bit machines */
79
+ }
80
+ }
81
+
82
+ /* initialize by an array with array-length */
83
+ /* init_key is the array for initializing keys */
84
+ /* key_length is its length */
85
+ /* slight change for C++, 2004/2/26 */
86
+ void init_by_array(unsigned long init_key[], int key_length)
87
+ {
88
+ int i, j, k;
89
+ init_genrand(19650218UL);
90
+ i=1; j=0;
91
+ k = (N>key_length ? N : key_length);
92
+ for (; k; k--) {
93
+ mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
94
+ + init_key[j] + j; /* non linear */
95
+ mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
96
+ i++; j++;
97
+ if (i>=N) { mt[0] = mt[N-1]; i=1; }
98
+ if (j>=key_length) j=0;
99
+ }
100
+ for (k=N-1; k; k--) {
101
+ mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
102
+ - i; /* non linear */
103
+ mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
104
+ i++;
105
+ if (i>=N) { mt[0] = mt[N-1]; i=1; }
106
+ }
107
+
108
+ mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
109
+ }
110
+
111
+ /* generates a random number on [0,0xffffffff]-interval */
112
+ unsigned long genrand_int32(void)
113
+ {
114
+ unsigned long y;
115
+ static unsigned long mag01[2]={0x0UL, MATRIX_A};
116
+ /* mag01[x] = x * MATRIX_A for x=0,1 */
117
+
118
+ if (mti >= N) { /* generate N words at one time */
119
+ int kk;
120
+
121
+ if (mti == N+1) /* if init_genrand() has not been called, */
122
+ init_genrand(5489UL); /* a default initial seed is used */
123
+
124
+ for (kk=0;kk<N-M;kk++) {
125
+ y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
126
+ mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1UL];
127
+ }
128
+ for (;kk<N-1;kk++) {
129
+ y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
130
+ mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
131
+ }
132
+ y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
133
+ mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
134
+
135
+ mti = 0;
136
+ }
137
+
138
+ y = mt[mti++];
139
+
140
+ /* Tempering */
141
+ y ^= (y >> 11);
142
+ y ^= (y << 7) & 0x9d2c5680UL;
143
+ y ^= (y << 15) & 0xefc60000UL;
144
+ y ^= (y >> 18);
145
+
146
+ return y;
147
+ }
148
+
149
+ /* generates a random number on [0,0x7fffffff]-interval */
150
+ long genrand_int31(void)
151
+ {
152
+ return (long)(genrand_int32()>>1);
153
+ }
154
+
155
+ /* generates a random number on [0,1]-real-interval */
156
+ double genrand_real1(void)
157
+ {
158
+ return genrand_int32()*(1.0/4294967295.0);
159
+ /* divided by 2^32-1 */
160
+ }
161
+
162
+ /* generates a random number on [0,1)-real-interval */
163
+ double genrand_real2(void)
164
+ {
165
+ return genrand_int32()*(1.0/4294967296.0);
166
+ /* divided by 2^32 */
167
+ }
168
+
169
+ /* generates a random number on (0,1)-real-interval */
170
+ double genrand_real3(void)
171
+ {
172
+ return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
173
+ /* divided by 2^32 */
174
+ }
175
+
176
+ /* generates a random number on [0,1) with 53-bit resolution*/
177
+ double genrand_res53(void)
178
+ {
179
+ unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
180
+ return(a*67108864.0+b)*(1.0/9007199254740992.0);
181
+ }
182
+ /* These real versions are due to Isaku Wada, 2002/01/09 added */
@@ -0,0 +1,86 @@
1
+ /*
2
+ The names of routines in original mt19937ar.c are all prefixed with "ca_"
3
+ to avoid collision with ruby's runtime library.
4
+ */
5
+
6
+ #define init_genrand ca_init_genrand
7
+ #define init_by_array ca_init_by_array
8
+ #define genrand_int32 ca_genrand_int32
9
+ #define genrand_int31 ca_genrand_int31
10
+ #define genrand_real1 ca_genrand_real1
11
+ #define genrand_real2 ca_genrand_real2
12
+ #define genrand_real3 ca_genrand_real3
13
+ #define genrand_res53 ca_genrand_res53
14
+
15
+ /*
16
+ A C-program for MT19937, with initialization improved 2002/1/26.
17
+ Coded by Takuji Nishimura and Makoto Matsumoto.
18
+
19
+ Before using, initialize the state by using init_genrand(seed)
20
+ or init_by_array(init_key, key_length).
21
+
22
+ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
23
+ All rights reserved.
24
+ Copyright (C) 2005, Mutsuo Saito
25
+ All rights reserved.
26
+
27
+ Redistribution and use in source and binary forms, with or without
28
+ modification, are permitted provided that the following conditions
29
+ are met:
30
+
31
+ 1. Redistributions of source code must retain the above copyright
32
+ notice, this list of conditions and the following disclaimer.
33
+
34
+ 2. Redistributions in binary form must reproduce the above copyright
35
+ notice, this list of conditions and the following disclaimer in the
36
+ documentation and/or other materials provided with the distribution.
37
+
38
+ 3. The names of its contributors may not be used to endorse or promote
39
+ products derived from this software without specific prior written
40
+ permission.
41
+
42
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
46
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
47
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
48
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
49
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
50
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
51
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
52
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53
+
54
+
55
+ Any feedback is very welcome.
56
+ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
57
+ email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
58
+ */
59
+
60
+ /* initializes mt[N] with a seed */
61
+ void init_genrand(unsigned long s);
62
+
63
+ /* initialize by an array with array-length */
64
+ /* init_key is the array for initializing keys */
65
+ /* key_length is its length */
66
+ /* slight change for C++, 2004/2/26 */
67
+ void init_by_array(unsigned long init_key[], int key_length);
68
+
69
+ /* generates a random number on [0,0xffffffff]-interval */
70
+ unsigned long genrand_int32(void);
71
+
72
+ /* generates a random number on [0,0x7fffffff]-interval */
73
+ long genrand_int31(void);
74
+
75
+ /* These real versions are due to Isaku Wada, 2002/01/09 added */
76
+ /* generates a random number on [0,1]-real-interval */
77
+ double genrand_real1(void);
78
+
79
+ /* generates a random number on [0,1)-real-interval */
80
+ double genrand_real2(void);
81
+
82
+ /* generates a random number on (0,1)-real-interval */
83
+ double genrand_real3(void);
84
+
85
+ /* generates a random number on [0,1) with 53-bit resolution*/
86
+ double genrand_res53(void);
@@ -0,0 +1,27 @@
1
+ #
2
+ # Ruby/CArray
3
+ #
4
+ #
5
+ # CArray -
6
+ #
7
+ # : classes
8
+ #
9
+ # CArray
10
+ #
11
+ #
12
+ #
13
+ #
14
+ #
15
+ #
16
+ #
17
+ #
18
+
19
+
20
+ class Module # :nodoc:
21
+ end
22
+
23
+ class Class # :nodoc:
24
+ end
25
+
26
+ class Numeric # :nodoc:
27
+ end
@@ -0,0 +1,5 @@
1
+ #
2
+ #
3
+ #
4
+ #
5
+ #
@@ -0,0 +1,31 @@
1
+ class CArray
2
+
3
+ # Accumulates the all elements. The overflow is treated in
4
+ # the C-language way.
5
+ #
6
+ # a = CArray.int8(2) { [127,1] };
7
+ # a.sum
8
+ # => 128.0
9
+ # a.accumulate
10
+ # => -128
11
+ #
12
+ # a = CArray.uint32(2) { [0xffffffff,1] };
13
+ # a.sum
14
+ # => 4294967296.0
15
+ # a.accumulate
16
+ # => 0
17
+ #
18
+ # a = CArray.float(2) { [0xffffffff,1] };
19
+ # a.sum
20
+ # => 4294967297.0
21
+ # a.accumulate
22
+ # => 4294967296.0
23
+ #
24
+ # a = CArray.object(2) { [0xffffffff,1] };
25
+ # a.sum
26
+ # => 4294967296
27
+ # a.accumulate
28
+ # => 4294967296
29
+ def accumulate (options={})
30
+ end
31
+ end
@@ -0,0 +1,242 @@
1
+ /* ---------------------------------------------------------------------------
2
+
3
+ ruby_carray.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
+ #include "version.h"
15
+
16
+ VALUE rb_eCADataTypeError;
17
+ VALUE rb_mCA;
18
+
19
+ VALUE CA_NIL;
20
+
21
+ void Init_ccomplex ();
22
+ void Init_numeric_float_function ();
23
+
24
+ void Init_carray_core ();
25
+ void Init_carray_undef ();
26
+ void Init_carray_class ();
27
+ void Init_carray_test ();
28
+ void Init_carray_attribute ();
29
+ void Init_carray_loop ();
30
+ void Init_carray_mask ();
31
+ void Init_carray_access ();
32
+ void Init_carray_element ();
33
+ void Init_carray_iterator ();
34
+ void Init_carray_operator ();
35
+ void Init_carray_numeric ();
36
+ void Init_carray_math ();
37
+ void Init_carray_random ();
38
+ void Init_carray_utils ();
39
+ void Init_carray_order ();
40
+ void Init_carray_sort_addr ();
41
+ void Init_carray_stat ();
42
+ void Init_carray_stat_proc ();
43
+ void Init_carray_utils ();
44
+ void Init_carray_generate ();
45
+ void Init_carray_copy ();
46
+ void Init_carray_conversion ();
47
+ void Init_carray_cast ();
48
+
49
+ void Init_ca_obj_array ();
50
+ void Init_ca_obj_refer ();
51
+ void Init_ca_obj_farray ();
52
+ void Init_ca_obj_block ();
53
+ void Init_ca_obj_select ();
54
+ void Init_ca_obj_object ();
55
+ void Init_ca_obj_grid ();
56
+ void Init_ca_obj_window ();
57
+ void Init_ca_obj_shift ();
58
+ void Init_ca_obj_transpose ();
59
+ void Init_ca_obj_mapping ();
60
+ void Init_ca_obj_repeat ();
61
+ void Init_ca_obj_unbound_repeat ();
62
+ void Init_ca_obj_reduce ();
63
+ void Init_ca_obj_field ();
64
+ void Init_ca_obj_fake ();
65
+ void Init_ca_obj_bitarray ();
66
+ void Init_ca_obj_bitfield ();
67
+
68
+ void Init_carray_iterator ();
69
+ void Init_ca_iter_dimension ();
70
+ void Init_ca_iter_block ();
71
+ void Init_ca_iter_window ();
72
+
73
+ void
74
+ Init_carray_ext ()
75
+ {
76
+
77
+ /* Classes and Modules */
78
+
79
+ /* -- CArray class -- */
80
+
81
+ rb_cCArray = rb_define_class("CArray", rb_cObject);
82
+ rb_cCAWrap = rb_define_class("CAWrap", rb_cCArray);
83
+ rb_cCScalar = rb_define_class("CScalar", rb_cCArray);
84
+ rb_cCAVirtual = rb_define_class("CAVirtual", rb_cCArray);
85
+ rb_cCARefer = rb_define_class("CARefer", rb_cCAVirtual);
86
+ rb_cCABlock = rb_define_class("CABlock", rb_cCAVirtual);
87
+ rb_cCASelect = rb_define_class("CASelect", rb_cCAVirtual);
88
+ rb_cCAObject = rb_define_class("CAObject", rb_cCAVirtual);
89
+ rb_cCARepeat = rb_define_class("CARepeat", rb_cCAVirtual);
90
+ rb_cCAUnboundRepeat = rb_define_class("CAUnboundRepeat", rb_cCAVirtual);
91
+
92
+ /* -- Exception class -- */
93
+
94
+ rb_eCADataTypeError =
95
+ rb_define_class_under(rb_cCArray, "DataTypeError", rb_eStandardError);
96
+
97
+ /* rdoc:
98
+ class CArray::DataTypeError # :nodoc:
99
+ end
100
+ */
101
+
102
+ /* -- CA module -- */
103
+ /* a namespace for misc utilities related with CArray */
104
+
105
+ rb_mCA = rb_define_module("CA");
106
+
107
+ /* CArray constants */
108
+
109
+ /* -- version -- */
110
+
111
+ /* rdoc:
112
+ class CArray
113
+ VERSION = nil # :nodoc:
114
+ VERSION_CODE = nil # :nodoc:
115
+ VERSION_MAJOR = nil # :nodoc:
116
+ VERSION_MINOR = nil # :nodoc:
117
+ VERSION_TEENY = nil # :nodoc:
118
+ VERSION_DATE = nil # :nodoc:
119
+ end
120
+ */
121
+
122
+ rb_define_const(rb_cCArray, "VERSION", rb_str_new2(CA_VERSION));
123
+ rb_define_const(rb_cCArray, "VERSION_CODE", INT2NUM(CA_VERSION_CODE));
124
+ rb_define_const(rb_cCArray, "VERSION_MAJOR", INT2NUM(CA_VERSION_MAJOR));
125
+ rb_define_const(rb_cCArray, "VERSION_MINOR", INT2NUM(CA_VERSION_MINOR));
126
+ rb_define_const(rb_cCArray, "VERSION_TEENY", INT2NUM(CA_VERSION_TEENY));
127
+ rb_define_const(rb_cCArray, "VERSION_DATE", rb_str_new2(CA_VERSION_DATE));
128
+
129
+ /* -- system -- */
130
+ rb_define_const(rb_cObject, "CA_RANK_MAX", INT2NUM(CA_RANK_MAX));
131
+ CA_NIL = rb_funcall(rb_cObject, rb_intern("new"), 0);
132
+ rb_define_const(rb_cObject, "CA_NIL", CA_NIL);
133
+
134
+ #ifdef HAVE_COMPLEX_H
135
+ rb_define_const(rb_cCArray, "HAVE_COMPLEX", Qtrue);
136
+ #else
137
+ rb_define_const(rb_cCArray, "HAVE_COMPLEX", Qfalse);
138
+ #endif
139
+
140
+ /* -- data types -- */
141
+
142
+ rb_define_const(rb_cObject, "CA_FIXLEN", INT2NUM(CA_FIXLEN));
143
+ rb_define_const(rb_cObject, "CA_BOOLEAN", INT2NUM(CA_BOOLEAN));
144
+ rb_define_const(rb_cObject, "CA_INT8", INT2NUM(CA_INT8));
145
+ rb_define_const(rb_cObject, "CA_UINT8", INT2NUM(CA_UINT8));
146
+ rb_define_const(rb_cObject, "CA_INT16", INT2NUM(CA_INT16));
147
+ rb_define_const(rb_cObject, "CA_UINT16", INT2NUM(CA_UINT16));
148
+ rb_define_const(rb_cObject, "CA_INT32", INT2NUM(CA_INT32));
149
+ rb_define_const(rb_cObject, "CA_UINT32", INT2NUM(CA_UINT32));
150
+ rb_define_const(rb_cObject, "CA_INT64", INT2NUM(CA_INT64));
151
+ rb_define_const(rb_cObject, "CA_UINT64", INT2NUM(CA_UINT64));
152
+ rb_define_const(rb_cObject, "CA_FLOAT32", INT2NUM(CA_FLOAT32));
153
+ rb_define_const(rb_cObject, "CA_FLOAT64", INT2NUM(CA_FLOAT64));
154
+ rb_define_const(rb_cObject, "CA_FLOAT128", INT2NUM(CA_FLOAT128));
155
+ rb_define_const(rb_cObject, "CA_CMPLX64", INT2NUM(CA_CMPLX64));
156
+ rb_define_const(rb_cObject, "CA_CMPLX128", INT2NUM(CA_CMPLX128));
157
+ rb_define_const(rb_cObject, "CA_CMPLX256", INT2NUM(CA_CMPLX256));
158
+ rb_define_const(rb_cObject, "CA_OBJECT", INT2NUM(CA_OBJECT));
159
+
160
+ rb_define_const(rb_cObject, "CA_BYTE", INT2NUM(CA_BYTE));
161
+ rb_define_const(rb_cObject, "CA_SHORT", INT2NUM(CA_INT16));
162
+ rb_define_const(rb_cObject, "CA_INT", INT2NUM(CA_INT32));
163
+ rb_define_const(rb_cObject, "CA_FLOAT", INT2NUM(CA_FLOAT));
164
+ rb_define_const(rb_cObject, "CA_DOUBLE", INT2NUM(CA_DOUBLE));
165
+ rb_define_const(rb_cObject, "CA_COMPLEX", INT2NUM(CA_COMPLEX));
166
+ rb_define_const(rb_cObject, "CA_DCOMPLEX", INT2NUM(CA_DCOMPLEX));
167
+
168
+ rb_define_const(rb_cObject, "CA_ALIGN_VOIDP", INT2NUM(CA_ALIGN_VOIDP));
169
+ rb_define_const(rb_cObject, "CA_ALIGN_FIXLEN", INT2NUM(CA_ALIGN_INT8));
170
+ rb_define_const(rb_cObject, "CA_ALIGN_BOOLEAN", INT2NUM(CA_ALIGN_INT8));
171
+ rb_define_const(rb_cObject, "CA_ALIGN_INT8", INT2NUM(CA_ALIGN_INT8));
172
+ rb_define_const(rb_cObject, "CA_ALIGN_INT16", INT2NUM(CA_ALIGN_INT16));
173
+ rb_define_const(rb_cObject, "CA_ALIGN_INT32", INT2NUM(CA_ALIGN_INT32));
174
+ rb_define_const(rb_cObject, "CA_ALIGN_INT64", INT2NUM(CA_ALIGN_INT64));
175
+ rb_define_const(rb_cObject, "CA_ALIGN_FLOAT32", INT2NUM(CA_ALIGN_FLOAT32));
176
+ rb_define_const(rb_cObject, "CA_ALIGN_FLOAT64", INT2NUM(CA_ALIGN_FLOAT64));
177
+ rb_define_const(rb_cObject, "CA_ALIGN_FLOAT128", INT2NUM(CA_ALIGN_FLOAT128));
178
+ rb_define_const(rb_cObject, "CA_ALIGN_CMPLX64", INT2NUM(CA_ALIGN_CMPLX64));
179
+ rb_define_const(rb_cObject, "CA_ALIGN_CMPLX128", INT2NUM(CA_ALIGN_CMPLX128));
180
+ rb_define_const(rb_cObject, "CA_ALIGN_CMPLX256", INT2NUM(CA_ALIGN_CMPLX256));
181
+ rb_define_const(rb_cObject, "CA_ALIGN_OBJECT", INT2NUM(CA_ALIGN_OBJECT));
182
+
183
+ /* load modules in external files */
184
+
185
+ Init_carray_core(); /* Init_carray_core should be called first*/
186
+
187
+ #ifdef HAVE_COMPLEX_H
188
+ Init_ccomplex();
189
+ #endif
190
+
191
+ Init_numeric_float_function();
192
+
193
+ Init_carray_class();
194
+ Init_carray_test();
195
+ Init_carray_attribute();
196
+ Init_carray_undef();
197
+ Init_carray_mask();
198
+ Init_carray_loop();
199
+ Init_carray_access();
200
+ Init_carray_element();
201
+ Init_carray_operator();
202
+ Init_carray_math(); /* order of math, numeric should not be changed */
203
+ Init_carray_numeric(); /* order of math, numeric should not be changed */
204
+ Init_carray_random();
205
+ Init_carray_order();
206
+ Init_carray_sort_addr();
207
+ Init_carray_stat();
208
+ Init_carray_stat_proc();
209
+
210
+ Init_carray_utils();
211
+
212
+ Init_carray_generate();
213
+ Init_carray_copy();
214
+ Init_carray_conversion();
215
+ Init_carray_cast();
216
+
217
+ Init_ca_obj_array();
218
+ Init_ca_obj_refer();
219
+ Init_ca_obj_farray();
220
+ Init_ca_obj_block();
221
+ Init_ca_obj_select();
222
+ Init_ca_obj_object();
223
+ Init_ca_obj_grid();
224
+ Init_ca_obj_window();
225
+ Init_ca_obj_shift();
226
+ Init_ca_obj_transpose();
227
+ Init_ca_obj_mapping();
228
+ Init_ca_obj_repeat();
229
+ Init_ca_obj_unbound_repeat();
230
+ Init_ca_obj_reduce();
231
+ Init_ca_obj_field();
232
+ Init_ca_obj_fake();
233
+ Init_ca_obj_bitarray();
234
+ Init_ca_obj_bitfield();
235
+
236
+ Init_carray_iterator();
237
+
238
+ Init_ca_iter_dimension();
239
+ Init_ca_iter_block();
240
+ Init_ca_iter_window();
241
+ }
242
+