cumo 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/3rd_party/LICENSE.txt +60 -0
  4. data/3rd_party/mkmf-cu/lib/mkmf-cu/cli.rb +13 -1
  5. data/LICENSE.txt +1 -62
  6. data/README.md +33 -29
  7. data/bench/cumo_bench.rb +47 -25
  8. data/bench/numo_bench.rb +27 -25
  9. data/docs/src-tree.md +16 -0
  10. data/ext/cumo/cuda/cublas.c +69 -219
  11. data/ext/cumo/cuda/memory_pool_impl.hpp +1 -0
  12. data/ext/cumo/cuda/runtime.c +2 -14
  13. data/ext/cumo/cumo.c +16 -16
  14. data/ext/cumo/include/cumo.h +2 -2
  15. data/ext/cumo/include/cumo/cuda/cublas.h +6 -129
  16. data/ext/cumo/include/cumo/cuda/runtime.h +16 -0
  17. data/ext/cumo/include/cumo/indexer.h +46 -63
  18. data/ext/cumo/include/cumo/intern.h +58 -112
  19. data/ext/cumo/include/cumo/narray.h +214 -185
  20. data/ext/cumo/include/cumo/narray_kernel.h +66 -37
  21. data/ext/cumo/include/cumo/ndloop.h +42 -42
  22. data/ext/cumo/include/cumo/reduce_kernel.h +55 -71
  23. data/ext/cumo/include/cumo/template.h +56 -51
  24. data/ext/cumo/include/cumo/template_kernel.h +31 -31
  25. data/ext/cumo/include/cumo/types/bit.h +3 -3
  26. data/ext/cumo/include/cumo/types/bit_kernel.h +2 -2
  27. data/ext/cumo/include/cumo/types/complex.h +126 -126
  28. data/ext/cumo/include/cumo/types/complex_kernel.h +126 -126
  29. data/ext/cumo/include/cumo/types/complex_macro.h +28 -28
  30. data/ext/cumo/include/cumo/types/complex_macro_kernel.h +20 -20
  31. data/ext/cumo/include/cumo/types/dcomplex.h +5 -5
  32. data/ext/cumo/include/cumo/types/dcomplex_kernel.h +1 -1
  33. data/ext/cumo/include/cumo/types/int_macro.h +1 -1
  34. data/ext/cumo/include/cumo/types/int_macro_kernel.h +1 -1
  35. data/ext/cumo/include/cumo/types/robj_macro.h +30 -30
  36. data/ext/cumo/include/cumo/types/scomplex.h +5 -5
  37. data/ext/cumo/include/cumo/types/scomplex_kernel.h +1 -1
  38. data/ext/cumo/narray/array.c +143 -143
  39. data/ext/cumo/narray/data.c +184 -184
  40. data/ext/cumo/narray/gen/cogen.rb +5 -2
  41. data/ext/cumo/narray/gen/cogen_kernel.rb +5 -2
  42. data/ext/cumo/narray/gen/def/dcomplex.rb +1 -1
  43. data/ext/cumo/narray/gen/def/scomplex.rb +1 -1
  44. data/ext/cumo/narray/gen/erbln.rb +132 -0
  45. data/ext/cumo/narray/gen/erbpp2.rb +18 -13
  46. data/ext/cumo/narray/gen/narray_def.rb +3 -3
  47. data/ext/cumo/narray/gen/spec.rb +2 -2
  48. data/ext/cumo/narray/gen/tmpl/accum.c +15 -15
  49. data/ext/cumo/narray/gen/tmpl/accum_binary.c +22 -22
  50. data/ext/cumo/narray/gen/tmpl/accum_binary_kernel.cu +3 -3
  51. data/ext/cumo/narray/gen/tmpl/accum_index.c +30 -30
  52. data/ext/cumo/narray/gen/tmpl/accum_index_kernel.cu +2 -2
  53. data/ext/cumo/narray/gen/tmpl/accum_kernel.cu +3 -3
  54. data/ext/cumo/narray/gen/tmpl/alloc_func.c +14 -14
  55. data/ext/cumo/narray/gen/tmpl/allocate.c +11 -11
  56. data/ext/cumo/narray/gen/tmpl/aref.c +2 -2
  57. data/ext/cumo/narray/gen/tmpl/aref_cpu.c +4 -4
  58. data/ext/cumo/narray/gen/tmpl/aset.c +2 -2
  59. data/ext/cumo/narray/gen/tmpl/binary.c +28 -28
  60. data/ext/cumo/narray/gen/tmpl/binary2.c +18 -18
  61. data/ext/cumo/narray/gen/tmpl/binary2_kernel.cu +3 -3
  62. data/ext/cumo/narray/gen/tmpl/binary_kernel.cu +6 -6
  63. data/ext/cumo/narray/gen/tmpl/binary_s.c +13 -13
  64. data/ext/cumo/narray/gen/tmpl/binary_s_kernel.cu +3 -3
  65. data/ext/cumo/narray/gen/tmpl/bincount.c +23 -23
  66. data/ext/cumo/narray/gen/tmpl/cast.c +7 -7
  67. data/ext/cumo/narray/gen/tmpl/cast_array.c +3 -3
  68. data/ext/cumo/narray/gen/tmpl/clip.c +38 -38
  69. data/ext/cumo/narray/gen/tmpl/complex_accum_kernel.cu +2 -2
  70. data/ext/cumo/narray/gen/tmpl/cond_binary.c +19 -19
  71. data/ext/cumo/narray/gen/tmpl/cond_binary_kernel.cu +7 -7
  72. data/ext/cumo/narray/gen/tmpl/cond_unary.c +15 -15
  73. data/ext/cumo/narray/gen/tmpl/cum.c +15 -15
  74. data/ext/cumo/narray/gen/tmpl/each.c +9 -9
  75. data/ext/cumo/narray/gen/tmpl/each_with_index.c +9 -9
  76. data/ext/cumo/narray/gen/tmpl/ewcomp.c +15 -15
  77. data/ext/cumo/narray/gen/tmpl/ewcomp_kernel.cu +3 -3
  78. data/ext/cumo/narray/gen/tmpl/extract_cpu.c +5 -5
  79. data/ext/cumo/narray/gen/tmpl/extract_data.c +12 -12
  80. data/ext/cumo/narray/gen/tmpl/eye.c +9 -9
  81. data/ext/cumo/narray/gen/tmpl/eye_kernel.cu +3 -3
  82. data/ext/cumo/narray/gen/tmpl/fill.c +9 -9
  83. data/ext/cumo/narray/gen/tmpl/fill_kernel.cu +6 -6
  84. data/ext/cumo/narray/gen/tmpl/float_accum_kernel.cu +1 -1
  85. data/ext/cumo/narray/gen/tmpl/format.c +11 -11
  86. data/ext/cumo/narray/gen/tmpl/format_to_a.c +8 -8
  87. data/ext/cumo/narray/gen/tmpl/frexp.c +13 -13
  88. data/ext/cumo/narray/gen/tmpl/gemm.c +252 -108
  89. data/ext/cumo/narray/gen/tmpl/inspect.c +1 -1
  90. data/ext/cumo/narray/gen/tmpl/lib.c +2 -2
  91. data/ext/cumo/narray/gen/tmpl/logseq.c +7 -7
  92. data/ext/cumo/narray/gen/tmpl/logseq_kernel.cu +6 -6
  93. data/ext/cumo/narray/gen/tmpl/map_with_index.c +17 -17
  94. data/ext/cumo/narray/gen/tmpl/median.c +10 -10
  95. data/ext/cumo/narray/gen/tmpl/minmax.c +10 -10
  96. data/ext/cumo/narray/gen/tmpl/new_dim0.c +3 -3
  97. data/ext/cumo/narray/gen/tmpl/poly.c +6 -6
  98. data/ext/cumo/narray/gen/tmpl/pow.c +28 -28
  99. data/ext/cumo/narray/gen/tmpl/pow_kernel.cu +6 -6
  100. data/ext/cumo/narray/gen/tmpl/rand.c +10 -10
  101. data/ext/cumo/narray/gen/tmpl/rand_norm.c +7 -7
  102. data/ext/cumo/narray/gen/tmpl/real_accum_kernel.cu +6 -6
  103. data/ext/cumo/narray/gen/tmpl/seq.c +7 -7
  104. data/ext/cumo/narray/gen/tmpl/seq_kernel.cu +6 -6
  105. data/ext/cumo/narray/gen/tmpl/set2.c +20 -20
  106. data/ext/cumo/narray/gen/tmpl/sort.c +11 -11
  107. data/ext/cumo/narray/gen/tmpl/sort_index.c +18 -18
  108. data/ext/cumo/narray/gen/tmpl/store.c +6 -6
  109. data/ext/cumo/narray/gen/tmpl/store_array.c +19 -19
  110. data/ext/cumo/narray/gen/tmpl/store_array_kernel.cu +12 -12
  111. data/ext/cumo/narray/gen/tmpl/store_bit.c +23 -23
  112. data/ext/cumo/narray/gen/tmpl/store_bit_kernel.cu +28 -28
  113. data/ext/cumo/narray/gen/tmpl/store_from.c +16 -16
  114. data/ext/cumo/narray/gen/tmpl/store_from_kernel.cu +12 -12
  115. data/ext/cumo/narray/gen/tmpl/to_a.c +10 -10
  116. data/ext/cumo/narray/gen/tmpl/unary.c +25 -25
  117. data/ext/cumo/narray/gen/tmpl/unary2.c +17 -17
  118. data/ext/cumo/narray/gen/tmpl/unary_kernel.cu +15 -15
  119. data/ext/cumo/narray/gen/tmpl/unary_ret2.c +13 -13
  120. data/ext/cumo/narray/gen/tmpl/unary_s.c +17 -17
  121. data/ext/cumo/narray/gen/tmpl/unary_s_kernel.cu +12 -12
  122. data/ext/cumo/narray/gen/tmpl_bit/allocate.c +9 -9
  123. data/ext/cumo/narray/gen/tmpl_bit/aref.c +2 -2
  124. data/ext/cumo/narray/gen/tmpl_bit/aref_cpu.c +5 -5
  125. data/ext/cumo/narray/gen/tmpl_bit/aset.c +2 -2
  126. data/ext/cumo/narray/gen/tmpl_bit/binary.c +29 -29
  127. data/ext/cumo/narray/gen/tmpl_bit/bit_count.c +14 -14
  128. data/ext/cumo/narray/gen/tmpl_bit/bit_count_cpu.c +21 -21
  129. data/ext/cumo/narray/gen/tmpl_bit/bit_count_kernel.cu +28 -28
  130. data/ext/cumo/narray/gen/tmpl_bit/bit_reduce.c +29 -29
  131. data/ext/cumo/narray/gen/tmpl_bit/each.c +10 -10
  132. data/ext/cumo/narray/gen/tmpl_bit/each_with_index.c +10 -10
  133. data/ext/cumo/narray/gen/tmpl_bit/extract.c +8 -8
  134. data/ext/cumo/narray/gen/tmpl_bit/extract_cpu.c +8 -8
  135. data/ext/cumo/narray/gen/tmpl_bit/fill.c +17 -17
  136. data/ext/cumo/narray/gen/tmpl_bit/format.c +14 -14
  137. data/ext/cumo/narray/gen/tmpl_bit/format_to_a.c +11 -11
  138. data/ext/cumo/narray/gen/tmpl_bit/inspect.c +3 -3
  139. data/ext/cumo/narray/gen/tmpl_bit/mask.c +33 -33
  140. data/ext/cumo/narray/gen/tmpl_bit/store_array.c +19 -19
  141. data/ext/cumo/narray/gen/tmpl_bit/store_bit.c +22 -22
  142. data/ext/cumo/narray/gen/tmpl_bit/store_from.c +18 -18
  143. data/ext/cumo/narray/gen/tmpl_bit/to_a.c +12 -12
  144. data/ext/cumo/narray/gen/tmpl_bit/unary.c +24 -24
  145. data/ext/cumo/narray/gen/tmpl_bit/where.c +16 -16
  146. data/ext/cumo/narray/gen/tmpl_bit/where2.c +20 -20
  147. data/ext/cumo/narray/index.c +213 -213
  148. data/ext/cumo/narray/math.c +27 -27
  149. data/ext/cumo/narray/narray.c +484 -484
  150. data/ext/cumo/narray/ndloop.c +259 -258
  151. data/ext/cumo/narray/rand.c +3 -3
  152. data/ext/cumo/narray/step.c +70 -70
  153. data/ext/cumo/narray/struct.c +139 -139
  154. metadata +6 -7
  155. data/ext/cumo/include/cumo/intern_fwd.h +0 -38
  156. data/lib/erbpp.rb +0 -294
  157. data/lib/erbpp/line_number.rb +0 -137
  158. data/lib/erbpp/narray_def.rb +0 -381
@@ -3,166 +3,166 @@
3
3
 
4
4
  __host__ __device__ static inline dtype c_new(rtype r, rtype i) {
5
5
  dtype z;
6
- REAL(z) = r;
7
- IMAG(z) = i;
6
+ CUMO_REAL(z) = r;
7
+ CUMO_IMAG(z) = i;
8
8
  return z;
9
9
  }
10
10
 
11
11
  __host__ __device__ static inline dtype c_set_real(dtype x, rtype r) {
12
- REAL(x)=r;
12
+ CUMO_REAL(x)=r;
13
13
  return x;
14
14
  }
15
15
 
16
16
  __host__ __device__ static inline dtype c_set_imag(dtype x, rtype i) {
17
- IMAG(x)=i;
17
+ CUMO_IMAG(x)=i;
18
18
  return x;
19
19
  }
20
20
 
21
21
  //static inline VALUE COMP2NUM(dtype x) {
22
22
  // VALUE v;
23
23
  // v = rb_funcall(rb_intern("Kernel"), rb_intern("Complex"), 2,
24
- // rb_float_new(REAL(x)), rb_float_new(IMAG(x)));
24
+ // rb_float_new(CUMO_REAL(x)), rb_float_new(CUMO_IMAG(x)));
25
25
  // return v;
26
26
  //}
27
27
  //
28
28
  //static inline dtype NUM2COMP(VALUE v) {
29
29
  // dtype z;
30
- // REAL(z) = NUM2DBL(rb_funcall(v,id_real,0));
31
- // IMAG(z) = NUM2DBL(rb_funcall(v,id_imag,0));
30
+ // CUMO_REAL(z) = NUM2DBL(rb_funcall(v,cumo_id_real,0));
31
+ // CUMO_IMAG(z) = NUM2DBL(rb_funcall(v,cumo_id_imag,0));
32
32
  // return z;
33
33
  //}
34
34
 
35
- #define c_is_zero(x) (REAL(x)==0 && IMAG(x)==0)
36
- #define c_eq(x,y) (REAL(x)==REAL(y) && IMAG(x)==IMAG(y))
37
- #define c_ne(x,y) (REAL(x)!=REAL(y) || IMAG(x)!=IMAG(y))
38
- #define c_isnan(x) (isnan(REAL(x)) || isnan(IMAG(x)))
39
- #define c_isinf(x) (isinf(REAL(x)) || isinf(IMAG(x)))
40
- #define c_isposinf(x) ((isinf(REAL(x)) && signbit(REAL(x))==0) || \
41
- (isinf(IMAG(x)) && signbit(IMAG(x))==0))
42
- #define c_isneginf(x) ((isinf(REAL(x)) && signbit(REAL(x))) || \
43
- (isinf(IMAG(x)) && signbit(IMAG(x))))
44
- #define c_isfinite(x) (isfinite(REAL(x)) && isfinite(IMAG(x)))
35
+ #define c_is_zero(x) (CUMO_REAL(x)==0 && CUMO_IMAG(x)==0)
36
+ #define c_eq(x,y) (CUMO_REAL(x)==CUMO_REAL(y) && CUMO_IMAG(x)==CUMO_IMAG(y))
37
+ #define c_ne(x,y) (CUMO_REAL(x)!=CUMO_REAL(y) || CUMO_IMAG(x)!=CUMO_IMAG(y))
38
+ #define c_isnan(x) (isnan(CUMO_REAL(x)) || isnan(CUMO_IMAG(x)))
39
+ #define c_isinf(x) (isinf(CUMO_REAL(x)) || isinf(CUMO_IMAG(x)))
40
+ #define c_isposinf(x) ((isinf(CUMO_REAL(x)) && signbit(CUMO_REAL(x))==0) || \
41
+ (isinf(CUMO_IMAG(x)) && signbit(CUMO_IMAG(x))==0))
42
+ #define c_isneginf(x) ((isinf(CUMO_REAL(x)) && signbit(CUMO_REAL(x))) || \
43
+ (isinf(CUMO_IMAG(x)) && signbit(CUMO_IMAG(x))))
44
+ #define c_isfinite(x) (isfinite(CUMO_REAL(x)) && isfinite(CUMO_IMAG(x)))
45
45
 
46
46
  __host__ __device__ static inline dtype c_zero() {
47
47
  dtype z;
48
- REAL(z) = 0;
49
- IMAG(z) = 0;
48
+ CUMO_REAL(z) = 0;
49
+ CUMO_IMAG(z) = 0;
50
50
  return z;
51
51
  }
52
52
 
53
53
  __host__ __device__ static inline dtype c_one() {
54
54
  dtype z;
55
- REAL(z) = 1;
56
- IMAG(z) = 0;
55
+ CUMO_REAL(z) = 1;
56
+ CUMO_IMAG(z) = 0;
57
57
  return z;
58
58
  }
59
59
 
60
60
  __host__ __device__ static inline dtype c_minus(dtype x) {
61
61
  dtype z;
62
- REAL(z) = -REAL(x);
63
- IMAG(z) = -IMAG(x);
62
+ CUMO_REAL(z) = -CUMO_REAL(x);
63
+ CUMO_IMAG(z) = -CUMO_IMAG(x);
64
64
  return z;
65
65
  }
66
66
 
67
67
  __host__ __device__ static inline dtype c_im(dtype x) {
68
68
  dtype z;
69
- REAL(z) = -IMAG(x);
70
- IMAG(z) = REAL(x);
69
+ CUMO_REAL(z) = -CUMO_IMAG(x);
70
+ CUMO_IMAG(z) = CUMO_REAL(x);
71
71
  return z;
72
72
  }
73
73
 
74
74
  __host__ __device__ static inline dtype c_add(dtype x, dtype y) {
75
75
  dtype z;
76
- REAL(z) = REAL(x)+REAL(y);
77
- IMAG(z) = IMAG(x)+IMAG(y);
76
+ CUMO_REAL(z) = CUMO_REAL(x)+CUMO_REAL(y);
77
+ CUMO_IMAG(z) = CUMO_IMAG(x)+CUMO_IMAG(y);
78
78
  return z;
79
79
  }
80
80
 
81
81
  __host__ __device__ static inline dtype c_sub(dtype x, dtype y) {
82
82
  dtype z;
83
- REAL(z) = REAL(x)-REAL(y);
84
- IMAG(z) = IMAG(x)-IMAG(y);
83
+ CUMO_REAL(z) = CUMO_REAL(x)-CUMO_REAL(y);
84
+ CUMO_IMAG(z) = CUMO_IMAG(x)-CUMO_IMAG(y);
85
85
  return z;
86
86
  }
87
87
 
88
88
 
89
89
  __host__ __device__ static inline dtype c_mul(dtype x, dtype y) {
90
90
  dtype z;
91
- REAL(z) = REAL(x)*REAL(y)-IMAG(x)*IMAG(y);
92
- IMAG(z) = REAL(x)*IMAG(y)+IMAG(x)*REAL(y);
91
+ CUMO_REAL(z) = CUMO_REAL(x)*CUMO_REAL(y)-CUMO_IMAG(x)*CUMO_IMAG(y);
92
+ CUMO_IMAG(z) = CUMO_REAL(x)*CUMO_IMAG(y)+CUMO_IMAG(x)*CUMO_REAL(y);
93
93
  return z;
94
94
  }
95
95
 
96
96
  __host__ __device__ static inline dtype c_mul_r(dtype x, rtype y) {
97
97
  dtype z;
98
- REAL(z) = REAL(x)*y;
99
- IMAG(z) = IMAG(x)*y;
98
+ CUMO_REAL(z) = CUMO_REAL(x)*y;
99
+ CUMO_IMAG(z) = CUMO_IMAG(x)*y;
100
100
  return z;
101
101
  }
102
102
 
103
103
  __host__ __device__ static inline dtype c_div(dtype x, dtype y) {
104
104
  dtype z;
105
105
  rtype s,yr,yi;
106
- s = r_hypot(REAL(y),IMAG(y));
107
- yr = REAL(y)/s;
108
- yi = IMAG(y)/s;
109
- REAL(z) = (REAL(x)*yr+IMAG(x)*yi)/s;
110
- IMAG(z) = (IMAG(x)*yr-REAL(x)*yi)/s;
106
+ s = r_hypot(CUMO_REAL(y),CUMO_IMAG(y));
107
+ yr = CUMO_REAL(y)/s;
108
+ yi = CUMO_IMAG(y)/s;
109
+ CUMO_REAL(z) = (CUMO_REAL(x)*yr+CUMO_IMAG(x)*yi)/s;
110
+ CUMO_IMAG(z) = (CUMO_IMAG(x)*yr-CUMO_REAL(x)*yi)/s;
111
111
  return z;
112
112
  }
113
113
 
114
114
  __host__ __device__ static inline dtype c_div_r(dtype x, rtype y) {
115
115
  dtype z;
116
- REAL(z) = REAL(x)/y;
117
- IMAG(z) = IMAG(x)/y;
116
+ CUMO_REAL(z) = CUMO_REAL(x)/y;
117
+ CUMO_IMAG(z) = CUMO_IMAG(x)/y;
118
118
  return z;
119
119
  }
120
120
 
121
121
  __host__ __device__ static inline dtype c_reciprocal(dtype x) {
122
122
  dtype z;
123
- if ( r_abs(REAL(x)) > r_abs(IMAG(x)) ) {
124
- IMAG(z) = IMAG(x)/REAL(x);
125
- REAL(z) = (1+IMAG(z)*IMAG(z))*REAL(x);
126
- IMAG(z) /= -REAL(z);
127
- REAL(z) = 1/REAL(z);
123
+ if ( r_abs(CUMO_REAL(x)) > r_abs(CUMO_IMAG(x)) ) {
124
+ CUMO_IMAG(z) = CUMO_IMAG(x)/CUMO_REAL(x);
125
+ CUMO_REAL(z) = (1+CUMO_IMAG(z)*CUMO_IMAG(z))*CUMO_REAL(x);
126
+ CUMO_IMAG(z) /= -CUMO_REAL(z);
127
+ CUMO_REAL(z) = 1/CUMO_REAL(z);
128
128
  } else {
129
- REAL(z) = REAL(x)/IMAG(x);
130
- IMAG(z) = (1+REAL(z)*REAL(z))*IMAG(x);
131
- REAL(z) /= IMAG(z);
132
- IMAG(z) = -1/IMAG(z);
129
+ CUMO_REAL(z) = CUMO_REAL(x)/CUMO_IMAG(x);
130
+ CUMO_IMAG(z) = (1+CUMO_REAL(z)*CUMO_REAL(z))*CUMO_IMAG(x);
131
+ CUMO_REAL(z) /= CUMO_IMAG(z);
132
+ CUMO_IMAG(z) = -1/CUMO_IMAG(z);
133
133
  }
134
134
  return z;
135
135
  }
136
136
 
137
137
  __host__ __device__ static inline dtype c_square(dtype x) {
138
138
  dtype z;
139
- REAL(z) = REAL(x)*REAL(x)-IMAG(x)*IMAG(x);
140
- IMAG(z) = 2*REAL(x)*IMAG(x);
139
+ CUMO_REAL(z) = CUMO_REAL(x)*CUMO_REAL(x)-CUMO_IMAG(x)*CUMO_IMAG(x);
140
+ CUMO_IMAG(z) = 2*CUMO_REAL(x)*CUMO_IMAG(x);
141
141
  return z;
142
142
  }
143
143
 
144
144
  __host__ __device__ static inline dtype c_sqrt(dtype x) {
145
145
  dtype z;
146
146
  rtype xr, xi, r;
147
- xr = REAL(x)/2;
148
- xi = IMAG(x)/2;
147
+ xr = CUMO_REAL(x)/2;
148
+ xi = CUMO_IMAG(x)/2;
149
149
  r = r_hypot(xr,xi);
150
150
  if (xr>0) {
151
- REAL(z) = sqrt(r+xr);
152
- IMAG(z) = xi/REAL(z);
151
+ CUMO_REAL(z) = sqrt(r+xr);
152
+ CUMO_IMAG(z) = xi/CUMO_REAL(z);
153
153
  } else if ( (r-=xr)!=0 ) {
154
- IMAG(z) = (xi>=0) ? sqrt(r):-sqrt(r);
155
- REAL(z) = xi/IMAG(z);
154
+ CUMO_IMAG(z) = (xi>=0) ? sqrt(r):-sqrt(r);
155
+ CUMO_REAL(z) = xi/CUMO_IMAG(z);
156
156
  } else {
157
- REAL(z) = IMAG(z) = 0;
157
+ CUMO_REAL(z) = CUMO_IMAG(z) = 0;
158
158
  }
159
159
  return z;
160
160
  }
161
161
 
162
162
  __host__ __device__ static inline dtype c_log(dtype x) {
163
163
  dtype z;
164
- REAL(z) = r_log(r_hypot(REAL(x),IMAG(x)));
165
- IMAG(z) = r_atan2(IMAG(x),REAL(x));
164
+ CUMO_REAL(z) = r_log(r_hypot(CUMO_REAL(x),CUMO_IMAG(x)));
165
+ CUMO_IMAG(z) = r_atan2(CUMO_IMAG(x),CUMO_REAL(x));
166
166
  return z;
167
167
  }
168
168
 
@@ -182,73 +182,73 @@ __host__ __device__ static inline dtype c_log10(dtype x) {
182
182
 
183
183
  __host__ __device__ static inline dtype c_exp(dtype x) {
184
184
  dtype z;
185
- rtype a = r_exp(REAL(x));
186
- REAL(z) = a*r_cos(IMAG(x));
187
- IMAG(z) = a*r_sin(IMAG(x));
185
+ rtype a = r_exp(CUMO_REAL(x));
186
+ CUMO_REAL(z) = a*r_cos(CUMO_IMAG(x));
187
+ CUMO_IMAG(z) = a*r_sin(CUMO_IMAG(x));
188
188
  return z;
189
189
  }
190
190
 
191
191
  __host__ __device__ static inline dtype c_exp2(dtype x) {
192
192
  dtype z;
193
- rtype a = r_exp(REAL(x)*M_LN2);
194
- REAL(z) = a*r_cos(IMAG(x));
195
- IMAG(z) = a*r_sin(IMAG(x));
193
+ rtype a = r_exp(CUMO_REAL(x)*M_LN2);
194
+ CUMO_REAL(z) = a*r_cos(CUMO_IMAG(x));
195
+ CUMO_IMAG(z) = a*r_sin(CUMO_IMAG(x));
196
196
  return z;
197
197
  }
198
198
 
199
199
  __host__ __device__ static inline dtype c_exp10(dtype x) {
200
200
  dtype z;
201
- rtype a = r_exp(REAL(x)*M_LN10);
202
- REAL(z) = a*r_cos(IMAG(x));
203
- IMAG(z) = a*r_sin(IMAG(x));
201
+ rtype a = r_exp(CUMO_REAL(x)*M_LN10);
202
+ CUMO_REAL(z) = a*r_cos(CUMO_IMAG(x));
203
+ CUMO_IMAG(z) = a*r_sin(CUMO_IMAG(x));
204
204
  return z;
205
205
  }
206
206
 
207
207
  __host__ __device__ static inline dtype c_sin(dtype x) {
208
208
  dtype z;
209
- REAL(z) = r_sin(REAL(x))*r_cosh(IMAG(x));
210
- IMAG(z) = r_cos(REAL(x))*r_sinh(IMAG(x));
209
+ CUMO_REAL(z) = r_sin(CUMO_REAL(x))*r_cosh(CUMO_IMAG(x));
210
+ CUMO_IMAG(z) = r_cos(CUMO_REAL(x))*r_sinh(CUMO_IMAG(x));
211
211
  return z;
212
212
  }
213
213
 
214
214
  __host__ __device__ static inline dtype c_sinh(dtype x) {
215
215
  dtype z;
216
- REAL(z) = r_sinh(REAL(x))*r_cos(IMAG(x));
217
- IMAG(z) = r_cosh(REAL(x))*r_sin(IMAG(x));
216
+ CUMO_REAL(z) = r_sinh(CUMO_REAL(x))*r_cos(CUMO_IMAG(x));
217
+ CUMO_IMAG(z) = r_cosh(CUMO_REAL(x))*r_sin(CUMO_IMAG(x));
218
218
  return z;
219
219
  }
220
220
 
221
221
  __host__ __device__ static inline dtype c_cos(dtype x) {
222
222
  dtype z;
223
- REAL(z) = r_cos(REAL(x))*r_cosh(IMAG(x));
224
- IMAG(z) = -r_sin(REAL(x))*r_sinh(IMAG(x));
223
+ CUMO_REAL(z) = r_cos(CUMO_REAL(x))*r_cosh(CUMO_IMAG(x));
224
+ CUMO_IMAG(z) = -r_sin(CUMO_REAL(x))*r_sinh(CUMO_IMAG(x));
225
225
  return z;
226
226
  }
227
227
 
228
228
  __host__ __device__ static inline dtype c_cosh(dtype x) {
229
229
  dtype z;
230
- REAL(z) = r_cosh(REAL(x))*r_cos(IMAG(x));
231
- IMAG(z) = r_sinh(REAL(x))*r_sin(IMAG(x));
230
+ CUMO_REAL(z) = r_cosh(CUMO_REAL(x))*r_cos(CUMO_IMAG(x));
231
+ CUMO_IMAG(z) = r_sinh(CUMO_REAL(x))*r_sin(CUMO_IMAG(x));
232
232
  return z;
233
233
  }
234
234
 
235
235
  __host__ __device__ static inline dtype c_tan(dtype x) {
236
236
  dtype z;
237
237
  rtype c, d;
238
- if (r_abs(IMAG(x))<1) {
239
- c = r_cos(REAL(x));
240
- d = r_sinh(IMAG(x));
238
+ if (r_abs(CUMO_IMAG(x))<1) {
239
+ c = r_cos(CUMO_REAL(x));
240
+ d = r_sinh(CUMO_IMAG(x));
241
241
  d = c*c + d*d;
242
- REAL(z) = 0.5*r_sin(2*REAL(x))/d;
243
- IMAG(z) = 0.5*r_sinh(2*IMAG(x))/d;
242
+ CUMO_REAL(z) = 0.5*r_sin(2*CUMO_REAL(x))/d;
243
+ CUMO_IMAG(z) = 0.5*r_sinh(2*CUMO_IMAG(x))/d;
244
244
  } else {
245
- d = r_exp(-IMAG(x));
245
+ d = r_exp(-CUMO_IMAG(x));
246
246
  c = 2*d/(1-d*d);
247
247
  c = c*c;
248
- d = r_cos(REAL(x));
248
+ d = r_cos(CUMO_REAL(x));
249
249
  d = 1.0 + d*d*c;
250
- REAL(z) = 0.5*r_sin(2*REAL(x))*c/d;
251
- IMAG(z) = 1/r_tanh(IMAG(x))/d;
250
+ CUMO_REAL(z) = 0.5*r_sin(2*CUMO_REAL(x))*c/d;
251
+ CUMO_IMAG(z) = 1/r_tanh(CUMO_IMAG(x))/d;
252
252
  }
253
253
  return z;
254
254
  }
@@ -256,17 +256,17 @@ __host__ __device__ static inline dtype c_tan(dtype x) {
256
256
  __host__ __device__ static inline dtype c_tanh(dtype x) {
257
257
  dtype z;
258
258
  rtype c, d, s;
259
- c = r_cos(IMAG(x));
260
- s = r_sinh(REAL(x));
259
+ c = r_cos(CUMO_IMAG(x));
260
+ s = r_sinh(CUMO_REAL(x));
261
261
  d = c*c + s*s;
262
- if (r_abs(REAL(x))<1) {
263
- REAL(z) = s*r_cosh(REAL(x))/d;
264
- IMAG(z) = 0.5*r_sin(2*IMAG(x))/d;
262
+ if (r_abs(CUMO_REAL(x))<1) {
263
+ CUMO_REAL(z) = s*r_cosh(CUMO_REAL(x))/d;
264
+ CUMO_IMAG(z) = 0.5*r_sin(2*CUMO_IMAG(x))/d;
265
265
  } else {
266
266
  c = c / s;
267
267
  c = 1 + c*c;
268
- REAL(z) = 1/(r_tanh(REAL(x))*c);
269
- IMAG(z) = 0.5*r_sin(2*IMAG(x))/d;
268
+ CUMO_REAL(z) = 1/(r_tanh(CUMO_REAL(x))*c);
269
+ CUMO_IMAG(z) = 0.5*r_sin(2*CUMO_IMAG(x))/d;
270
270
  }
271
271
  return z;
272
272
  }
@@ -274,24 +274,24 @@ __host__ __device__ static inline dtype c_tanh(dtype x) {
274
274
  __host__ __device__ static inline dtype c_asin(dtype x) {
275
275
  dtype z, y;
276
276
  y = c_square(x);
277
- REAL(y) = 1-REAL(y);
278
- IMAG(y) = -IMAG(y);
277
+ CUMO_REAL(y) = 1-CUMO_REAL(y);
278
+ CUMO_IMAG(y) = -CUMO_IMAG(y);
279
279
  y = c_sqrt(y);
280
- REAL(y) -= IMAG(x);
281
- IMAG(y) += REAL(x);
280
+ CUMO_REAL(y) -= CUMO_IMAG(x);
281
+ CUMO_IMAG(y) += CUMO_REAL(x);
282
282
  y = c_log(y);
283
- REAL(z) = IMAG(y);
284
- IMAG(z) = -REAL(y);
283
+ CUMO_REAL(z) = CUMO_IMAG(y);
284
+ CUMO_IMAG(z) = -CUMO_REAL(y);
285
285
  return z;
286
286
  }
287
287
 
288
288
  __host__ __device__ static inline dtype c_asinh(dtype x) {
289
289
  dtype z, y;
290
290
  y = c_square(x);
291
- REAL(y) += 1;
291
+ CUMO_REAL(y) += 1;
292
292
  y = c_sqrt(y);
293
- REAL(y) += REAL(x);
294
- IMAG(y) += IMAG(x);
293
+ CUMO_REAL(y) += CUMO_REAL(x);
294
+ CUMO_IMAG(y) += CUMO_IMAG(x);
295
295
  z = c_log(y);
296
296
  return z;
297
297
  }
@@ -299,51 +299,51 @@ __host__ __device__ static inline dtype c_asinh(dtype x) {
299
299
  __host__ __device__ static inline dtype c_acos(dtype x) {
300
300
  dtype z, y;
301
301
  y = c_square(x);
302
- REAL(y) = 1-REAL(y);
303
- IMAG(y) = -IMAG(y);
302
+ CUMO_REAL(y) = 1-CUMO_REAL(y);
303
+ CUMO_IMAG(y) = -CUMO_IMAG(y);
304
304
  y = c_sqrt(y);
305
- REAL(z) = REAL(x)-IMAG(y);
306
- IMAG(z) = IMAG(x)+REAL(y);
305
+ CUMO_REAL(z) = CUMO_REAL(x)-CUMO_IMAG(y);
306
+ CUMO_IMAG(z) = CUMO_IMAG(x)+CUMO_REAL(y);
307
307
  y = c_log(z);
308
- REAL(z) = IMAG(y);
309
- IMAG(z) = -REAL(y);
308
+ CUMO_REAL(z) = CUMO_IMAG(y);
309
+ CUMO_IMAG(z) = -CUMO_REAL(y);
310
310
  return z;
311
311
  }
312
312
 
313
313
  __host__ __device__ static inline dtype c_acosh(dtype x) {
314
314
  dtype z, y;
315
315
  y = c_square(x);
316
- REAL(y) -= 1;
316
+ CUMO_REAL(y) -= 1;
317
317
  y = c_sqrt(y);
318
- REAL(y) += REAL(x);
319
- IMAG(y) += IMAG(x);
318
+ CUMO_REAL(y) += CUMO_REAL(x);
319
+ CUMO_IMAG(y) += CUMO_IMAG(x);
320
320
  z = c_log(y);
321
321
  return z;
322
322
  }
323
323
 
324
324
  __host__ __device__ static inline dtype c_atan(dtype x) {
325
325
  dtype z, y;
326
- REAL(y) = -REAL(x);
327
- IMAG(y) = 1-IMAG(x);
328
- REAL(z) = REAL(x);
329
- IMAG(z) = 1+IMAG(x);
326
+ CUMO_REAL(y) = -CUMO_REAL(x);
327
+ CUMO_IMAG(y) = 1-CUMO_IMAG(x);
328
+ CUMO_REAL(z) = CUMO_REAL(x);
329
+ CUMO_IMAG(z) = 1+CUMO_IMAG(x);
330
330
  y = c_div(z,y);
331
331
  y = c_log(y);
332
- REAL(z) = -IMAG(y)/2;
333
- IMAG(z) = REAL(y)/2;
332
+ CUMO_REAL(z) = -CUMO_IMAG(y)/2;
333
+ CUMO_IMAG(z) = CUMO_REAL(y)/2;
334
334
  return z;
335
335
  }
336
336
 
337
337
  __host__ __device__ static inline dtype c_atanh(dtype x) {
338
338
  dtype z, y;
339
- REAL(y) = 1-REAL(x);
340
- IMAG(y) = -IMAG(x);
341
- REAL(z) = 1+REAL(x);
342
- IMAG(z) = IMAG(x);
339
+ CUMO_REAL(y) = 1-CUMO_REAL(x);
340
+ CUMO_IMAG(y) = -CUMO_IMAG(x);
341
+ CUMO_REAL(z) = 1+CUMO_REAL(x);
342
+ CUMO_IMAG(z) = CUMO_IMAG(x);
343
343
  y = c_div(z,y);
344
344
  y = c_log(y);
345
- REAL(z) = REAL(y)/2;
346
- IMAG(z) = IMAG(y)/2;
345
+ CUMO_REAL(z) = CUMO_REAL(y)/2;
346
+ CUMO_IMAG(z) = CUMO_IMAG(y)/2;
347
347
  return z;
348
348
  }
349
349
 
@@ -352,7 +352,7 @@ __host__ __device__ static inline dtype c_pow(dtype x, dtype y)
352
352
  dtype z;
353
353
  if (c_is_zero(y)) {
354
354
  z = c_one();
355
- } else if (c_is_zero(x) && REAL(y)>0 && IMAG(y)==0) {
355
+ } else if (c_is_zero(x) && CUMO_REAL(y)>0 && CUMO_IMAG(y)==0) {
356
356
  z = c_zero();
357
357
  } else {
358
358
  z = c_log(x);
@@ -396,11 +396,11 @@ __host__ __device__ static inline dtype c_cbrt(dtype x) {
396
396
  }
397
397
 
398
398
  __host__ __device__ static inline rtype c_abs(dtype x) {
399
- return r_hypot(REAL(x),IMAG(x));
399
+ return r_hypot(CUMO_REAL(x),CUMO_IMAG(x));
400
400
  }
401
401
 
402
402
  __host__ __device__ static inline rtype c_abs_square(dtype x) {
403
- return REAL(x)*REAL(x)+IMAG(x)*IMAG(x);
403
+ return CUMO_REAL(x)*CUMO_REAL(x)+CUMO_IMAG(x)*CUMO_IMAG(x);
404
404
  }
405
405
 
406
406