numo-narray 0.9.0.7 → 0.9.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/ext/numo/narray/gen/def/bit.rb +1 -0
  3. data/ext/numo/narray/gen/def/dcomplex.rb +1 -0
  4. data/ext/numo/narray/gen/def/dfloat.rb +1 -0
  5. data/ext/numo/narray/gen/def/int16.rb +1 -0
  6. data/ext/numo/narray/gen/def/int32.rb +1 -0
  7. data/ext/numo/narray/gen/def/int64.rb +1 -0
  8. data/ext/numo/narray/gen/def/int8.rb +1 -0
  9. data/ext/numo/narray/gen/def/robject.rb +1 -0
  10. data/ext/numo/narray/gen/def/scomplex.rb +1 -0
  11. data/ext/numo/narray/gen/def/sfloat.rb +1 -0
  12. data/ext/numo/narray/gen/def/uint16.rb +1 -0
  13. data/ext/numo/narray/gen/def/uint32.rb +1 -0
  14. data/ext/numo/narray/gen/def/uint64.rb +1 -0
  15. data/ext/numo/narray/gen/def/uint8.rb +1 -0
  16. data/ext/numo/narray/gen/tmpl/accum_binary.c +19 -15
  17. data/ext/numo/narray/gen/tmpl/binary.c +50 -10
  18. data/ext/numo/narray/gen/tmpl/sort_index.c +6 -1
  19. data/ext/numo/narray/gen/tmpl/unary.c +29 -6
  20. data/ext/numo/narray/index.c +13 -12
  21. data/ext/numo/narray/narray.c +2 -0
  22. data/ext/numo/narray/ndloop.c +22 -21
  23. data/ext/numo/narray/numo/narray.h +3 -2
  24. data/ext/numo/narray/numo/template.h +14 -1
  25. data/ext/numo/narray/numo/types/complex_macro.h +21 -19
  26. data/ext/numo/narray/numo/types/int16.h +5 -2
  27. data/ext/numo/narray/numo/types/int32.h +5 -2
  28. data/ext/numo/narray/numo/types/int64.h +5 -2
  29. data/ext/numo/narray/numo/types/int8.h +5 -2
  30. data/ext/numo/narray/numo/types/int_macro.h +7 -1
  31. data/ext/numo/narray/numo/types/real_accum.h +37 -36
  32. data/ext/numo/narray/numo/types/uint16.h +5 -2
  33. data/ext/numo/narray/numo/types/uint32.h +5 -2
  34. data/ext/numo/narray/numo/types/uint64.h +5 -2
  35. data/ext/numo/narray/numo/types/uint8.h +5 -2
  36. data/spec/narray_spec.rb +3 -1
  37. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d0790c23a92e44538dfd0978899cdf87ccb5a36
4
- data.tar.gz: c08e683349d0a8fad66c124f4fc687d79381a7bf
3
+ metadata.gz: ed3756dc41da4cc17c42eb3d74b452c496ca2e69
4
+ data.tar.gz: 7c65512df44bde3bb57d6989ca5f0394cb7663cf
5
5
  SHA512:
6
- metadata.gz: 9f961ea396916fb91fc4e25cd93987786952397fbe75b9d7f11681e4abb3a764a8e12f9040ea2ed6a4164c4390535e01599ceba30351397617b4db39605b7bbe
7
- data.tar.gz: f269691e7a51587070e4b548272ce56aeb84c6f036e2f70482801d7b4d8a19dadc96bf13783b19302ff1f937f3436240f23ca680676d7d54ffa77ae1fe1d1b8a
6
+ metadata.gz: 805d2bf586831a5ffac8e75131bf085e5ed60f7cd72721ca022d94b51686e7771146f6063f96df89637ccbac8edd617356b5b3e8be3bed5afb57ceb08e696d3b
7
+ data.tar.gz: 8437d1379938785bdbe1a9f3b8421efcecb16987cf4107350b5dcec3673c99f54df3e6fbbad0a49f2eaa2fc2752f73d956b1c61e9f393ec364b8758a4d8b87c8
@@ -16,6 +16,7 @@ set is_object: false
16
16
  set is_real: false
17
17
  set is_comparable: false
18
18
  set is_double_precision: false
19
+ set need_align: false
19
20
 
20
21
  upcast_rb "Integer"
21
22
  upcast_rb "Float", "DFloat"
@@ -18,6 +18,7 @@ set is_complex: true
18
18
  set is_object: false
19
19
  set is_comparable: false
20
20
  set is_double_precision: true
21
+ set need_align: true
21
22
 
22
23
  upcast_rb "Integer"
23
24
  upcast_rb "Float"
@@ -16,6 +16,7 @@ set is_object: false
16
16
  set is_real: true
17
17
  set is_comparable: true
18
18
  set is_double_precision: true
19
+ set need_align: true
19
20
 
20
21
  upcast_rb "Integer"
21
22
  upcast_rb "Float"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: true
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: true
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: true
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: false
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -17,6 +17,7 @@ set is_complex: false
17
17
  set is_object: true
18
18
  set is_comparable: true
19
19
  set is_double_precision: false
20
+ set need_align: false
20
21
 
21
22
  upcast_rb "Integer"
22
23
  upcast_rb "Float"
@@ -18,6 +18,7 @@ set is_complex: true
18
18
  set is_object: false
19
19
  set is_comparable: false
20
20
  set is_double_precision: false
21
+ set need_align: true
21
22
 
22
23
  upcast_rb "Integer"
23
24
  upcast_rb "Float"
@@ -16,6 +16,7 @@ set is_object: false
16
16
  set is_real: true
17
17
  set is_comparable: true
18
18
  set is_double_precision: false
19
+ set need_align: true
19
20
 
20
21
  upcast_rb "Integer"
21
22
  upcast_rb "Float"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: true
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: true
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: true
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -15,6 +15,7 @@ set is_object: false
15
15
  set is_real: true
16
16
  set is_comparable: true
17
17
  set is_double_precision: false
18
+ set need_align: false
18
19
 
19
20
  upcast_rb "Integer"
20
21
  upcast_rb "Float", "DFloat"
@@ -1,27 +1,31 @@
1
- <% (is_float ? ["","_nan"] : [""]).each do |j| %>
1
+ //<% (is_float ? ["","_nan"] : [""]).each do |j| %>
2
2
  static void
3
3
  <%=c_iter%><%=j%>(na_loop_t *const lp)
4
4
  {
5
- size_t i;
5
+ size_t i, n;
6
6
  char *p1, *p2, *p3;
7
7
  ssize_t s1, s2, s3;
8
- dtype x, y, z;
9
8
 
10
- INIT_COUNTER(lp, i);
9
+ INIT_COUNTER(lp, n);
11
10
  INIT_PTR(lp, 0, p1, s1);
12
11
  INIT_PTR(lp, 1, p2, s2);
13
12
  INIT_PTR(lp, 2, p3, s3);
13
+
14
14
  if (s3==0) {
15
+ dtype z;
15
16
  // Reduce loop
16
17
  GET_DATA(p3,dtype,z);
17
- for (; i--;) {
18
+ for (i=0; i<n; i++) {
19
+ dtype x, y;
18
20
  GET_DATA_STRIDE(p1,s1,dtype,x);
19
21
  GET_DATA_STRIDE(p2,s2,dtype,y);
20
22
  m_<%=name%><%=j%>(x,y,z);
21
23
  }
22
24
  SET_DATA(p3,dtype,z);
25
+ return;
23
26
  } else {
24
- for (; i--;) {
27
+ for (i=0; i<n; i++) {
28
+ dtype x, y, z;
25
29
  GET_DATA_STRIDE(p1,s1,dtype,x);
26
30
  GET_DATA_STRIDE(p2,s2,dtype,y);
27
31
  GET_DATA(p3,dtype,z);
@@ -30,7 +34,7 @@ static void
30
34
  }
31
35
  }
32
36
  }
33
- <% end %>
37
+ //<% end %>
34
38
 
35
39
  static VALUE
36
40
  <%=c_func%>_self(int argc, VALUE *argv, VALUE self)
@@ -47,11 +51,11 @@ static VALUE
47
51
  // should fix below: [self.ndim,other.ndim].max or?
48
52
  naryv[0] = self;
49
53
  naryv[1] = argv[0];
50
- <% if is_float %>
54
+ //<% if is_float %>
51
55
  reduce = na_reduce_dimension(argc-1, argv+1, 2, naryv, &ndf, <%=c_iter%>_nan);
52
- <% else %>
56
+ //<% else %>
53
57
  reduce = na_reduce_dimension(argc-1, argv+1, 2, naryv, &ndf, 0);
54
- <% end %>
58
+ //<% end %>
55
59
 
56
60
  v = na_ndloop(&ndf, 4, self, argv[0], reduce, m_<%=name%>_init);
57
61
  return <%=type_name%>_extract(v);
@@ -76,15 +80,15 @@ static VALUE
76
80
  static VALUE
77
81
  <%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
78
82
  {
79
- <% if !is_object %>
83
+ //<% if !is_object %>
80
84
  VALUE klass, v;
81
- <% end %>
85
+ //<% end %>
82
86
  if (argc < 1) {
83
87
  rb_raise(rb_eArgError,"wrong number of arguments (%d for >=1)",argc);
84
88
  }
85
- <% if is_object %>
89
+ //<% if is_object %>
86
90
  return <%=c_func%>_self(argc, argv, self);
87
- <% else %>
91
+ //<% else %>
88
92
  klass = na_upcast(CLASS_OF(self),CLASS_OF(argv[0]));
89
93
  if (klass==cT) {
90
94
  return <%=c_func%>_self(argc, argv, self);
@@ -92,5 +96,5 @@ static VALUE
92
96
  v = rb_funcall(klass, id_cast, 1, self);
93
97
  return rb_funcall2(v, rb_intern("<%=name%>"), argc, argv);
94
98
  }
95
- <% end %>
99
+ //<% end %>
96
100
  }
@@ -1,27 +1,66 @@
1
+ <% if is_int and %w[div mod divmod].include? name %>
2
+ #define check_intdivzero(y) \
3
+ if ((y)==0) { \
4
+ lp->err_type = rb_eZeroDivError; \
5
+ return; \
6
+ }
7
+ <% else %>
8
+ #define check_intdivzero(y) {}
9
+ <% end %>
10
+
1
11
  static void
2
12
  <%=c_iter%>(na_loop_t *const lp)
3
13
  {
4
14
  size_t i, n;
5
15
  char *p1, *p2, *p3;
6
16
  ssize_t s1, s2, s3;
7
- dtype x, y;
17
+
8
18
  INIT_COUNTER(lp, n);
9
19
  INIT_PTR(lp, 0, p1, s1);
10
20
  INIT_PTR(lp, 1, p2, s2);
11
21
  INIT_PTR(lp, 2, p3, s3);
12
- for (i=n; i--;) {
13
- GET_DATA_STRIDE(p1,s1,dtype,x);
14
- GET_DATA_STRIDE(p2,s2,dtype,y);
15
- <% if is_int and %w[div mod divmod].include? name %>
16
- if (y==0) {
17
- lp->err_type = rb_eZeroDivError;
22
+
23
+ //<% if need_align %>
24
+ if (is_aligned(p1,sizeof(dtype)) &&
25
+ is_aligned(p2,sizeof(dtype)) &&
26
+ is_aligned(p3,sizeof(dtype)) ) {
27
+
28
+ if (s1 == sizeof(dtype) &&
29
+ s2 == sizeof(dtype) &&
30
+ s3 == sizeof(dtype) ) {
31
+
32
+ for (i=0; i<n; i++) {
33
+ check_intdivzero(*(dtype*)p2);
34
+ ((dtype*)p3)[i] = m_<%=name%>(((dtype*)p1)[i],((dtype*)p2)[i]);
35
+ }
18
36
  return;
19
37
  }
20
- <% end %>
21
- x = m_<%=name%>(x,y);
22
- SET_DATA_STRIDE(p3,s3,dtype,x);
38
+ if (is_aligned_step(s1,sizeof(dtype)) &&
39
+ is_aligned_step(s2,sizeof(dtype)) &&
40
+ is_aligned_step(s3,sizeof(dtype)) ) {
41
+ //<% end %>
42
+ for (i=0; i<n; i++) {
43
+ check_intdivzero(*(dtype*)p2);
44
+ *(dtype*)p3 = m_<%=name%>(*(dtype*)p1,*(dtype*)p2);
45
+ p1 += s1;
46
+ p2 += s2;
47
+ p3 += s3;
48
+ }
49
+ return;
50
+ //<% if need_align %>
51
+ }
23
52
  }
53
+ for (i=0; i<n; i++) {
54
+ dtype x, y, z;
55
+ GET_DATA_STRIDE(p1,s1,dtype,x);
56
+ GET_DATA_STRIDE(p2,s2,dtype,y);
57
+ check_intdivzero(y);
58
+ z = m_<%=name%>(x,y);
59
+ SET_DATA_STRIDE(p3,s3,dtype,z);
60
+ }
61
+ //<% end %>
24
62
  }
63
+ #undef check_intdivzero
25
64
 
26
65
  static VALUE
27
66
  <%=c_func%>_self(VALUE self, VALUE other)
@@ -46,6 +85,7 @@ static VALUE
46
85
  return <%=c_func%>_self(self, other);
47
86
  <% else %>
48
87
  VALUE klass, v;
88
+
49
89
  klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
50
90
  if (klass==cT) {
51
91
  return <%=c_func%>_self(self, other);
@@ -18,6 +18,11 @@ static void
18
18
 
19
19
  //printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld, o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
20
20
 
21
+ if (n==1) {
22
+ *(idx_t*)o_ptr = *(idx_t*)(i_ptr);
23
+ return;
24
+ }
25
+
21
26
  for (i=0; i<n; i++) {
22
27
  ptr[i] = d_ptr + d_step * i;
23
28
  //printf("(%ld,%.3f)",i,*(double*)ptr[i]);
@@ -94,7 +99,7 @@ static VALUE
94
99
  }
95
100
  rb_funcall(idx, rb_intern("seq"), 0);
96
101
 
97
- size = na->size*sizeof(void*);
102
+ size = na->size*sizeof(void*); // max capa
98
103
  buf = rb_alloc_tmp_buffer(&tmp, size);
99
104
  res = na_ndloop3(&ndf, buf, 3, self, idx, reduce);
100
105
  rb_free_tmp_buffer(&tmp);
@@ -1,25 +1,25 @@
1
1
  static void
2
2
  <%=c_iter%>(na_loop_t *const lp)
3
3
  {
4
- size_t i;
4
+ size_t i, n;
5
5
  char *p1, *p2;
6
6
  ssize_t s1, s2;
7
7
  size_t *idx1, *idx2;
8
8
  dtype x;
9
9
 
10
- INIT_COUNTER(lp, i);
10
+ INIT_COUNTER(lp, n);
11
11
  INIT_PTR_IDX(lp, 0, p1, s1, idx1);
12
12
  INIT_PTR_IDX(lp, 1, p2, s2, idx2);
13
13
 
14
14
  if (idx1) {
15
15
  if (idx2) {
16
- for (; i--;) {
16
+ for (i=0; i<n; i++) {
17
17
  GET_DATA_INDEX(p1,idx1,dtype,x);
18
18
  x = m_<%=name%>(x);
19
19
  SET_DATA_INDEX(p2,idx2,dtype,x);
20
20
  }
21
21
  } else {
22
- for (; i--;) {
22
+ for (i=0; i<n; i++) {
23
23
  GET_DATA_INDEX(p1,idx1,dtype,x);
24
24
  x = m_<%=name%>(x);
25
25
  SET_DATA_STRIDE(p2,s2,dtype,x);
@@ -27,17 +27,40 @@ static void
27
27
  }
28
28
  } else {
29
29
  if (idx2) {
30
- for (; i--;) {
30
+ for (i=0; i<n; i++) {
31
31
  GET_DATA_STRIDE(p1,s1,dtype,x);
32
32
  x = m_<%=name%>(x);
33
33
  SET_DATA_INDEX(p2,idx2,dtype,x);
34
34
  }
35
35
  } else {
36
- for (; i--;) {
36
+ //<% if need_align %>
37
+ if (is_aligned(p1,sizeof(dtype)) &&
38
+ is_aligned(p2,sizeof(dtype)) ) {
39
+ if (s1 == sizeof(dtype) &&
40
+ s2 == sizeof(dtype) ) {
41
+ for (i=0; i<n; i++) {
42
+ ((dtype*)p2)[i] = m_<%=name%>(((dtype*)p1)[i]);
43
+ }
44
+ return;
45
+ }
46
+ if (is_aligned_step(s1,sizeof(dtype)) &&
47
+ is_aligned_step(s2,sizeof(dtype)) ) {
48
+ //<% end %>
49
+ for (i=0; i<n; i++) {
50
+ *(dtype*)p2 = m_<%=name%>(*(dtype*)p1);
51
+ p1 += s1;
52
+ p2 += s2;
53
+ }
54
+ return;
55
+ //<% if need_align %>
56
+ }
57
+ }
58
+ for (i=0; i<n; i++) {
37
59
  GET_DATA_STRIDE(p1,s1,dtype,x);
38
60
  x = m_<%=name%>(x);
39
61
  SET_DATA_STRIDE(p2,s2,dtype,x);
40
62
  }
63
+ //<% end %>
41
64
  }
42
65
  }
43
66
  }
@@ -173,26 +173,27 @@ static void
173
173
  na_parse_range(VALUE range, ssize_t step, int orig_dim, ssize_t size, na_index_arg_t *q)
174
174
  {
175
175
  int n;
176
- ssize_t beg, end;
176
+ VALUE excl_end;
177
+ ssize_t beg, end, beg_orig, end_orig;
178
+ const char *dot = "..", *edot = "...";
177
179
 
178
- beg = NUM2LONG(rb_funcall(range,id_beg,0));
179
- if (beg<0) {
180
+ beg = beg_orig = NUM2SSIZET(rb_funcall(range,id_beg,0));
181
+ if (beg < 0) {
180
182
  beg += size;
181
183
  }
182
-
183
- end = NUM2LONG(rb_funcall(range,id_end,0));
184
- if (end<0) {
184
+ end = end_orig = NUM2SSIZET(rb_funcall(range,id_end,0));
185
+ if (end < 0) {
185
186
  end += size;
186
187
  }
187
-
188
- if (RTEST(rb_funcall(range,id_exclude_end,0))) {
188
+ excl_end = rb_funcall(range,id_exclude_end,0);
189
+ if (RTEST(excl_end)) {
189
190
  end--;
191
+ dot = edot;
190
192
  }
191
- if (beg < -size || beg >= size ||
192
- end < -size || end >= size) {
193
+ if (beg < 0 || beg >= size || end < 0 || end >= size) {
193
194
  rb_raise(rb_eRangeError,
194
- "beg=%"SZF"d,end=%"SZF"d is out of array size (%"SZF"d)",
195
- beg, end, size);
195
+ "%"SZF"d%s%"SZF"d is out of range for size=%"SZF"d",
196
+ beg_orig, dot, end_orig, size);
196
197
  }
197
198
  n = (end-beg)/step+1;
198
199
  if (n<0) n=0;
@@ -14,6 +14,7 @@ VALUE nary_eCastError;
14
14
  VALUE nary_eShapeError;
15
15
  VALUE nary_eOperationError;
16
16
  VALUE nary_eDimensionError;
17
+ VALUE nary_eValueError;
17
18
 
18
19
  static ID id_contiguous_stride;
19
20
  static ID id_allocate;
@@ -1851,6 +1852,7 @@ Init_narray()
1851
1852
  nary_eShapeError = rb_define_class_under(cNArray, "ShapeError", rb_eStandardError);
1852
1853
  nary_eOperationError = rb_define_class_under(cNArray, "OperationError", rb_eStandardError);
1853
1854
  nary_eDimensionError = rb_define_class_under(cNArray, "DimensionError", rb_eStandardError);
1855
+ nary_eValueError = rb_define_class_under(cNArray, "ValueError", rb_eStandardError);
1854
1856
 
1855
1857
  rb_define_singleton_method(cNArray, "debug=", na_debug_set, 1);
1856
1858
  rb_define_singleton_method(cNArray, "profile", na_profile, 0);
@@ -43,7 +43,7 @@ typedef struct NA_MD_LOOP {
43
43
  int nin;
44
44
  int ndim; // n of total dimention
45
45
  unsigned int copy_flag; // set i-th bit if i-th arg is cast
46
- size_t *n_ptr; // memory for n
46
+ void *ptr; // memory for n
47
47
  na_loop_iter_t *iter_ptr; // memory for iter
48
48
  size_t *n; // n of elements for each dim
49
49
  na_loop_t user; // loop in user function
@@ -337,6 +337,9 @@ ndloop_alloc(na_md_loop_t *lp, ndfunc_t *nf, VALUE args,
337
337
  int narg;
338
338
  int max_nd;
339
339
 
340
+ char *buf;
341
+ size_t n1, n2, n3, n4, n5;
342
+
340
343
  long args_len;
341
344
 
342
345
  na_loop_iter_t *iter;
@@ -364,23 +367,28 @@ ndloop_alloc(na_md_loop_t *lp, ndfunc_t *nf, VALUE args,
364
367
  lp->writeback = -1;
365
368
  lp->init_aidx = -1;
366
369
 
367
- lp->n = NULL;
368
- lp->n_ptr = NULL;
369
- lp->xargs = NULL;
370
- lp->user.args = NULL;
370
+ lp->ptr = NULL;
371
371
  lp->user.n = NULL;
372
- lp->iter_ptr = NULL;
373
- lp->trans_map = NULL;
374
372
 
375
373
  ndloop_find_max_dimension(lp, nf, args);
376
374
  narg = lp->nin + nf->nout;
377
375
  max_nd = lp->ndim + lp->user.ndim;
378
376
 
379
- lp->n = lp->n_ptr = ALLOC_N(size_t, max_nd+1);
380
- lp->xargs = ALLOC_N(na_loop_xargs_t, narg);
381
- lp->user.args = ALLOC_N(na_loop_args_t, narg);
382
- iter = ALLOC_N(na_loop_iter_t, narg*(max_nd+1));
383
- lp->iter_ptr = iter;
377
+ n1 = sizeof(size_t)*(max_nd+1);
378
+ n2 = sizeof(na_loop_xargs_t)*narg;
379
+ n2 = ((n2-1)/8+1)*8;
380
+ n3 = sizeof(na_loop_args_t)*narg;
381
+ n3 = ((n3-1)/8+1)*8;
382
+ n4 = sizeof(na_loop_iter_t)*narg*(max_nd+1);
383
+ n4 = ((n4-1)/8+1)*8;
384
+ n5 = sizeof(int)*(max_nd+1);
385
+
386
+ lp->ptr = buf = (char*)xmalloc(n1+n2+n3+n4+n5);
387
+ lp->n = (size_t*)buf; buf+=n1;
388
+ lp->xargs = (na_loop_xargs_t*)buf; buf+=n2;
389
+ lp->user.args = (na_loop_args_t*)buf; buf+=n3;
390
+ lp->iter_ptr = iter = (na_loop_iter_t*)buf; buf+=n4;
391
+ lp->trans_map = (int*)buf;
384
392
 
385
393
  for (j=0; j<narg; j++) {
386
394
  LARG(lp,j).value = Qnil;
@@ -389,7 +397,7 @@ ndloop_alloc(na_md_loop_t *lp, ndfunc_t *nf, VALUE args,
389
397
  LARG(lp,j).ndim = 0;
390
398
  lp->xargs[j].iter = &(iter[(max_nd+1)*j]);
391
399
  lp->xargs[j].bufcp = NULL;
392
- lp->xargs[j].flag = (j<nf->nin) ? NDL_READ : NDL_WRITE;
400
+ lp->xargs[j].flag = (j<lp->nin) ? NDL_READ : NDL_WRITE;
393
401
  lp->xargs[j].free_user_iter = 0;
394
402
  }
395
403
 
@@ -406,7 +414,6 @@ ndloop_alloc(na_md_loop_t *lp, ndfunc_t *nf, VALUE args,
406
414
  // array loop
407
415
  // [*,+,*,+,*] => [*,*,*,+,+]
408
416
  // trans_map=[0,3,1,4,2] <= [0,1,2,3,4]
409
- lp->trans_map = ALLOC_N(int, max_nd+1);
410
417
  if (NDF_TEST(nf,NDF_FLAT_REDUCE) && RTEST(lp->reduce)) {
411
418
  trans_dim = 0;
412
419
  for (i=0; i<max_nd; i++) {
@@ -450,7 +457,6 @@ ndloop_release(VALUE vlp)
450
457
  na_release_lock(v);
451
458
  }
452
459
  }
453
- //xfree(lp);
454
460
  for (j=0; j<lp->narg; j++) {
455
461
  //printf("lp->xargs[%d].bufcp=%lx\n",j,(size_t)(lp->xargs[j].bufcp));
456
462
  if (lp->xargs[j].bufcp) {
@@ -463,12 +469,7 @@ ndloop_release(VALUE vlp)
463
469
  }
464
470
  }
465
471
  }
466
- if (lp->trans_map) xfree(lp->trans_map);
467
- xfree(lp->xargs);
468
- xfree(lp->iter_ptr);
469
- xfree(lp->user.args);
470
- xfree(lp->n_ptr);
471
- //rb_gc_force_recycle(vlp);
472
+ xfree(lp->ptr);
472
473
  return Qnil;
473
474
  }
474
475
 
@@ -13,8 +13,8 @@ extern "C" {
13
13
  #endif
14
14
  #endif
15
15
 
16
- #define NARRAY_VERSION "0.9.0.7"
17
- #define NARRAY_VERSION_CODE 907
16
+ #define NARRAY_VERSION "0.9.0.8"
17
+ #define NARRAY_VERSION_CODE 908
18
18
 
19
19
  #include <math.h>
20
20
  #include "numo/compat.h"
@@ -133,6 +133,7 @@ extern VALUE nary_eCastError;
133
133
  extern VALUE nary_eShapeError;
134
134
  extern VALUE nary_eOperationError;
135
135
  extern VALUE nary_eDimensionError;
136
+ extern VALUE nary_eValueError;
136
137
  extern const rb_data_type_t na_data_type;
137
138
 
138
139
  //EXTERN const int na_sizeof[NA_NTYPES+1];
@@ -133,4 +133,17 @@
133
133
  }
134
134
  // val -> val&1 ??
135
135
 
136
- #endif /* ifndef NARRAY_H */
136
+ static inline int
137
+ is_aligned(const void *ptr, const size_t alignment)
138
+ {
139
+ return ((size_t)(ptr) & ((alignment)-1)) == 0;
140
+ }
141
+
142
+ static inline int
143
+ is_aligned_step(const ssize_t step, const size_t alignment)
144
+ {
145
+ return ((step) & ((alignment)-1)) == 0;
146
+ }
147
+
148
+
149
+ #endif /* ifndef TEMPLATE_H */
@@ -117,26 +117,28 @@ static inline dtype c_from_dcomplex(dcomplex x) {
117
117
  #define m_sum_init INT2FIX(0)
118
118
  #define m_mulsum_init INT2FIX(0)
119
119
 
120
+ #define not_nan(x) (REAL(x)==REAL(x) && IMAG(x)==IMAG(x))
121
+
120
122
  #define m_mulsum(x,y,z) {z = m_add(m_mul(x,y),z);}
121
- #define m_mulsum_nan(x,y,z) { \
122
- if(!m_isnan(x) && !m_isnan(y)) { \
123
- z = m_add(m_mul(x,y),z); \
123
+ #define m_mulsum_nan(x,y,z) { \
124
+ if(not_nan(x) && not_nan(y)) { \
125
+ z = m_add(m_mul(x,y),z); \
124
126
  }}
125
127
 
126
128
  #define m_cumsum(x,y) {(x)=m_add(x,y);}
127
- #define m_cumsum_nan(x,y) { \
128
- if (m_isnan(x)) { \
129
- (x) = (y); \
130
- } else if (!m_isnan(y)) { \
131
- (x) = m_add(x,y); \
129
+ #define m_cumsum_nan(x,y) { \
130
+ if (!not_nan(x)) { \
131
+ (x) = (y); \
132
+ } else if (not_nan(y)) { \
133
+ (x) = m_add(x,y); \
132
134
  }}
133
135
 
134
136
  #define m_cumprod(x,y) {(x)=m_mul(x,y);}
135
- #define m_cumprod_nan(x,y) { \
136
- if (m_isnan(x)) { \
137
- (x) = (y); \
138
- } else if (!m_isnan(y)) { \
139
- (x) = m_mul(x,y); \
137
+ #define m_cumprod_nan(x,y) { \
138
+ if (!not_nan(x)) { \
139
+ (x) = (y); \
140
+ } else if (not_nan(y)) { \
141
+ (x) = m_mul(x,y); \
140
142
  }}
141
143
 
142
144
  static inline dtype f_sum(size_t n, char *p, ssize_t stride)
@@ -161,7 +163,7 @@ static inline dtype f_sum_nan(size_t n, char *p, ssize_t stride)
161
163
  y = c_zero();
162
164
  for (; i--;) {
163
165
  x = *(dtype*)p;
164
- if (!c_isnan(x)) {
166
+ if (not_nan(x)) {
165
167
  y = c_add(x,y);
166
168
  }
167
169
  p += stride;
@@ -205,7 +207,7 @@ static inline dtype f_kahan_sum_nan(size_t n, char *p, ssize_t stride)
205
207
  r = c_zero();
206
208
  for (; i--;) {
207
209
  x = *(dtype*)p;
208
- if (!c_isnan(x)) {
210
+ if (not_nan(x)) {
209
211
  if (fabs(REAL(x)) > fabs(REAL(y))) {
210
212
  double z=REAL(x); REAL(x)=REAL(y); REAL(y)=z;
211
213
  }
@@ -245,7 +247,7 @@ static inline dtype f_prod_nan(size_t n, char *p, ssize_t stride)
245
247
  y = c_one();
246
248
  for (; i--;) {
247
249
  x = *(dtype*)p;
248
- if (!c_isnan(x)) {
250
+ if (not_nan(x)) {
249
251
  y = c_mul(x,y);
250
252
  }
251
253
  p += stride;
@@ -278,7 +280,7 @@ static inline dtype f_mean_nan(size_t n, char *p, ssize_t stride)
278
280
  y = c_zero();
279
281
  for (; i--;) {
280
282
  x = *(dtype*)p;
281
- if (!c_isnan(x)) {
283
+ if (not_nan(x)) {
282
284
  y = c_add(x,y);
283
285
  count++;
284
286
  }
@@ -316,7 +318,7 @@ static inline rtype f_var_nan(size_t n, char *p, ssize_t stride)
316
318
 
317
319
  for (; i--;) {
318
320
  x = *(dtype*)p;
319
- if (!c_isnan(x)) {
321
+ if (not_nan(x)) {
320
322
  y += c_abs_square(c_sub(x,m));
321
323
  count++;
322
324
  }
@@ -360,7 +362,7 @@ static inline rtype f_rms_nan(size_t n, char *p, ssize_t stride)
360
362
 
361
363
  for (; i--;) {
362
364
  x = *(dtype*)p;
363
- if (!c_isnan(x)) {
365
+ if (not_nan(x)) {
364
366
  y += c_abs_square(x);
365
367
  count++;
366
368
  }
@@ -8,8 +8,6 @@ typedef int16_t rtype;
8
8
  #define m_extract(x) INT2NUM((int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%d",(int)(x))
10
10
 
11
- #include "int_macro.h"
12
-
13
11
  #ifndef INT16_MIN
14
12
  #define INT16_MIN (-32767-1)
15
13
  #endif
@@ -17,5 +15,10 @@ typedef int16_t rtype;
17
15
  #define INT16_MAX (32767)
18
16
  #endif
19
17
 
18
+ #define DATA_MIN INT16_MIN
19
+ #define DATA_MAX INT16_MAX
20
+
20
21
  #define M_MIN m_data_to_num(INT16_MIN)
21
22
  #define M_MAX m_data_to_num(INT16_MAX)
23
+
24
+ #include "int_macro.h"
@@ -8,8 +8,6 @@ typedef int32_t rtype;
8
8
  #define m_extract(x) INT322NUM((int32_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRId32,(int32_t)(x))
10
10
 
11
- #include "int_macro.h"
12
-
13
11
  #ifndef INT32_MIN
14
12
  #define INT32_MIN (-2147483647-1)
15
13
  #endif
@@ -17,5 +15,10 @@ typedef int32_t rtype;
17
15
  #define INT32_MAX (2147483647)
18
16
  #endif
19
17
 
18
+ #define DATA_MIN INT32_MIN
19
+ #define DATA_MAX INT32_MAX
20
+
20
21
  #define M_MIN m_data_to_num(INT32_MIN)
21
22
  #define M_MAX m_data_to_num(INT32_MAX)
23
+
24
+ #include "int_macro.h"
@@ -8,8 +8,6 @@ typedef int64_t rtype;
8
8
  #define m_extract(x) INT642NUM((int64_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRId64,(int64_t)(x))
10
10
 
11
- #include "int_macro.h"
12
-
13
11
  #ifndef INT64_MIN
14
12
  #define INT64_MIN (-9223372036854775807l-1)
15
13
  #endif
@@ -17,5 +15,10 @@ typedef int64_t rtype;
17
15
  #define INT64_MAX (9223372036854775807l)
18
16
  #endif
19
17
 
18
+ #define DATA_MIN INT64_MIN
19
+ #define DATA_MAX INT64_MAX
20
+
20
21
  #define M_MIN m_data_to_num(INT64_MIN)
21
22
  #define M_MAX m_data_to_num(INT64_MAX)
23
+
24
+ #include "int_macro.h"
@@ -8,8 +8,6 @@ typedef int8_t rtype;
8
8
  #define m_extract(x) INT2NUM((int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%d",(int)(x))
10
10
 
11
- #include "int_macro.h"
12
-
13
11
  #ifndef INT8_MIN
14
12
  #define INT8_MIN (-127-1)
15
13
  #endif
@@ -17,5 +15,10 @@ typedef int8_t rtype;
17
15
  #define INT8_MAX (127)
18
16
  #endif
19
17
 
18
+ #define DATA_MIN INT8_MIN
19
+ #define DATA_MAX INT8_MAX
20
+
20
21
  #define M_MIN INT2FIX(INT8_MIN)
21
22
  #define M_MAX INT2FIX(INT8_MAX)
23
+
24
+ #include "int_macro.h"
@@ -1,8 +1,14 @@
1
1
  #include "xint_macro.h"
2
2
 
3
- #define m_abs(x) ((x<0)?-x:x)
4
3
  #define m_sign(x) (((x)==0) ? 0 : (((x)>0) ? 1 : -1))
5
4
 
5
+ static inline dtype m_abs(dtype x) {
6
+ if (x==DATA_MIN) {
7
+ rb_raise(nary_eValueError, "cannot convert the minimum integer");
8
+ }
9
+ return (x<0)?-x:x;
10
+ }
11
+
6
12
  static inline dtype int_reciprocal(dtype x) {
7
13
  switch (x) {
8
14
  case 1:
@@ -1,24 +1,25 @@
1
+ #define not_nan(x) ((x)==(x))
1
2
 
2
3
  #define m_mulsum(x,y,z) {z = m_add(m_mul(x,y),z);}
3
- #define m_mulsum_nan(x,y,z) { \
4
- if(!m_isnan(x) && !m_isnan(y)) { \
5
- z = m_add(m_mul(x,y),z); \
4
+ #define m_mulsum_nan(x,y,z) { \
5
+ if(not_nan(x) && not_nan(y)) { \
6
+ z = m_add(m_mul(x,y),z); \
6
7
  }}
7
8
 
8
9
  #define m_cumsum(x,y) {(x)=m_add(x,y);}
9
- #define m_cumsum_nan(x,y) { \
10
- if (m_isnan(x)) { \
11
- (x) = (y); \
12
- } else if (!m_isnan(y)) { \
13
- (x) = m_add(x,y); \
10
+ #define m_cumsum_nan(x,y) { \
11
+ if (!not_nan(x)) { \
12
+ (x) = (y); \
13
+ } else if (not_nan(y)) { \
14
+ (x) = m_add(x,y); \
14
15
  }}
15
16
 
16
17
  #define m_cumprod(x,y) {(x)=m_mul(x,y);}
17
- #define m_cumprod_nan(x,y) { \
18
- if (m_isnan(x)) { \
19
- (x) = (y); \
20
- } else if (!m_isnan(y)) { \
21
- (x) = m_mul(x,y); \
18
+ #define m_cumprod_nan(x,y) { \
19
+ if (!not_nan(x)) { \
20
+ (x) = (y); \
21
+ } else if (not_nan(y)) { \
22
+ (x) = m_mul(x,y); \
22
23
  }}
23
24
 
24
25
  static inline dtype f_sum(size_t n, char *p, ssize_t stride)
@@ -28,8 +29,8 @@ static inline dtype f_sum(size_t n, char *p, ssize_t stride)
28
29
 
29
30
  for (; i--;) {
30
31
  x = *(dtype*)p;
31
- p += stride;
32
32
  y = m_add(x,y);
33
+ p += stride;
33
34
  }
34
35
  return y;
35
36
  }
@@ -42,7 +43,7 @@ static inline dtype f_sum_nan(size_t n, char *p, ssize_t stride)
42
43
  for (; i--;) {
43
44
  x = *(dtype*)p;
44
45
  p += stride;
45
- if (!m_isnan(x)) {
46
+ if (not_nan(x)) {
46
47
  y = m_add(x,y);
47
48
  }
48
49
  }
@@ -71,7 +72,7 @@ static inline dtype f_prod_nan(size_t n, char *p, ssize_t stride)
71
72
  for (; i--;) {
72
73
  x = *(dtype*)p;
73
74
  p += stride;
74
- if (!m_isnan(x)) {
75
+ if (not_nan(x)) {
75
76
  y = m_mul(x,y);
76
77
  }
77
78
  }
@@ -102,7 +103,7 @@ static inline dtype f_mean_nan(size_t n, char *p, ssize_t stride)
102
103
  for (; i--;) {
103
104
  x = *(dtype*)p;
104
105
  p += stride;
105
- if (!m_isnan(x)) {
106
+ if (not_nan(x)) {
106
107
  y = m_add(x,y);
107
108
  count++;
108
109
  }
@@ -141,7 +142,7 @@ static inline dtype f_var_nan(size_t n, char *p, ssize_t stride)
141
142
  for (; i--;) {
142
143
  x = *(dtype*)p;
143
144
  p += stride;
144
- if (!m_isnan(x)) {
145
+ if (not_nan(x)) {
145
146
  a = m_abs(m_sub(x,m));
146
147
  y = m_add(y,m_square(a));
147
148
  count++;
@@ -184,7 +185,7 @@ static inline dtype f_rms_nan(size_t n, char *p, ssize_t stride)
184
185
  for (; i--;) {
185
186
  x = *(dtype*)p;
186
187
  p += stride;
187
- if (!m_isnan(x)) {
188
+ if (not_nan(x)) {
188
189
  y = m_add(y,m_square(m_abs(x)));
189
190
  count++;
190
191
  }
@@ -201,11 +202,11 @@ static inline dtype f_min_nan(size_t n, char *p, ssize_t stride)
201
202
 
202
203
  y = *(dtype*)p;
203
204
  p += stride;
204
- if (m_isnan(y)) {return y;}
205
+ if (!not_nan(y)) {return y;}
205
206
  for (i--; i--;) {
206
207
  x = *(dtype*)p;
207
208
  p += stride;
208
- if (m_isnan(x)) {return x;}
209
+ if (!not_nan(x)) {return x;}
209
210
  if (m_lt(x,y)) {
210
211
  y = x;
211
212
  }
@@ -221,7 +222,7 @@ static inline dtype f_min(size_t n, char *p, ssize_t stride)
221
222
  for (; i--; ) {
222
223
  y = *(dtype*)p;
223
224
  p += stride;
224
- if (!m_isnan(y)) {
225
+ if (not_nan(y)) {
225
226
  for (; i--;) {
226
227
  x = *(dtype*)p;
227
228
  p += stride;
@@ -242,11 +243,11 @@ static inline dtype f_max_nan(size_t n, char *p, ssize_t stride)
242
243
 
243
244
  y = *(dtype*)p;
244
245
  p += stride;
245
- if (m_isnan(y)) {return y;}
246
+ if (!not_nan(y)) {return y;}
246
247
  for (i--; i--;) {
247
248
  x = *(dtype*)p;
248
249
  p += stride;
249
- if (m_isnan(x)) {return x;}
250
+ if (!not_nan(x)) {return x;}
250
251
  if (m_gt(x,y)) {
251
252
  y = x;
252
253
  }
@@ -262,7 +263,7 @@ static inline dtype f_max(size_t n, char *p, ssize_t stride)
262
263
  for (; i--; ) {
263
264
  y = *(dtype*)p;
264
265
  p += stride;
265
- if (!m_isnan(y)) {
266
+ if (not_nan(y)) {
266
267
  for (; i--;) {
267
268
  x = *(dtype*)p;
268
269
  p += stride;
@@ -283,11 +284,11 @@ static inline size_t f_min_index_nan(size_t n, char *p, ssize_t stride)
283
284
 
284
285
  y = *(dtype*)p;
285
286
  p += stride;
286
- if (m_isnan(y)) {return j;}
287
+ if (!not_nan(y)) {return j;}
287
288
  for (i=1; i<n; i++) {
288
289
  x = *(dtype*)p;
289
290
  p += stride;
290
- if (m_isnan(x)) {return i;}
291
+ if (!not_nan(x)) {return i;}
291
292
  if (m_lt(x,y)) {
292
293
  y = x;
293
294
  j = i;
@@ -304,8 +305,8 @@ static inline size_t f_min_index(size_t n, char *p, ssize_t stride)
304
305
  for (i=0; i<n; i++) {
305
306
  y = *(dtype*)p;
306
307
  p += stride;
307
- if (!m_isnan(y)) {
308
- j = i;
308
+ if (not_nan(y)) {
309
+ j = i; i++;
309
310
  for (; i<n; i++) {
310
311
  x = *(dtype*)p;
311
312
  p += stride;
@@ -327,11 +328,11 @@ static inline size_t f_max_index_nan(size_t n, char *p, ssize_t stride)
327
328
 
328
329
  y = *(dtype*)p;
329
330
  p += stride;
330
- if (m_isnan(y)) {return j;}
331
+ if (!not_nan(y)) {return j;}
331
332
  for (i=1; i<n; i++) {
332
333
  x = *(dtype*)p;
333
334
  p += stride;
334
- if (m_isnan(x)) {return i;}
335
+ if (!not_nan(x)) {return i;}
335
336
  if (m_gt(x,y)) {
336
337
  y = x;
337
338
  j = i;
@@ -348,8 +349,8 @@ static inline size_t f_max_index(size_t n, char *p, ssize_t stride)
348
349
  for (i=0; i<n; i++) {
349
350
  y = *(dtype*)p;
350
351
  p += stride;
351
- if (!m_isnan(y)) {
352
- j = i;
352
+ if (not_nan(y)) {
353
+ j = i; i++;
353
354
  for (; i<n; i++) {
354
355
  x = *(dtype*)p;
355
356
  p += stride;
@@ -372,14 +373,14 @@ f_minmax_nan(size_t n, char *p, ssize_t stride, dtype *amin, dtype *amax)
372
373
 
373
374
  min = max = *(dtype*)p;
374
375
  p += stride;
375
- if (m_isnan(min)) {
376
+ if (!not_nan(min)) {
376
377
  *amin = *amax = min;
377
378
  return;
378
379
  }
379
380
  for (i--; i--;) {
380
381
  x = *(dtype*)p;
381
382
  p += stride;
382
- if (m_isnan(x)) {
383
+ if (!not_nan(x)) {
383
384
  *amin = *amax = x;
384
385
  return;
385
386
  }
@@ -412,7 +413,7 @@ f_minmax(size_t n, char *p, ssize_t stride, dtype *amin, dtype *amax)
412
413
  for (; i--; ) {
413
414
  min = *(dtype*)p;
414
415
  p += stride;
415
- if (!m_isnan(min)) {
416
+ if (not_nan(min)) {
416
417
  max = min;
417
418
  for (; i--;) {
418
419
  x = *(dtype*)p;
@@ -8,11 +8,14 @@ typedef u_int16_t rtype;
8
8
  #define m_extract(x) UINT2NUM((unsigned int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%u",(unsigned int)(x))
10
10
 
11
- #include "uint_macro.h"
12
-
13
11
  #ifndef UINT16_MAX
14
12
  #define UINT16_MAX (65535)
15
13
  #endif
16
14
 
15
+ #define DATA_MIN UINT16_MIN
16
+ #define DATA_MAX UINT16_MAX
17
+
17
18
  #define M_MIN INT2FIX(0)
18
19
  #define M_MAX m_data_to_num(UINT16_MAX)
20
+
21
+ #include "uint_macro.h"
@@ -8,11 +8,14 @@ typedef u_int32_t rtype;
8
8
  #define m_extract(x) UINT322NUM((u_int32_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRIu32,(u_int32_t)(x))
10
10
 
11
- #include "uint_macro.h"
12
-
13
11
  #ifndef UINT32_MAX
14
12
  #define UINT32_MAX (4294967295u)
15
13
  #endif
16
14
 
15
+ #define DATA_MIN UINT32_MIN
16
+ #define DATA_MAX UINT32_MAX
17
+
17
18
  #define M_MIN INT2FIX(0)
18
19
  #define M_MAX m_data_to_num(UINT32_MAX)
20
+
21
+ #include "uint_macro.h"
@@ -8,11 +8,14 @@ typedef u_int64_t rtype;
8
8
  #define m_extract(x) UINT642NUM((u_int64_t)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%"PRIu64,(u_int64_t)(x))
10
10
 
11
- #include "uint_macro.h"
12
-
13
11
  #ifndef UINT64_MAX
14
12
  #define UINT64_MAX (18446744073709551615ul)
15
13
  #endif
16
14
 
15
+ #define DATA_MIN UINT64_MIN
16
+ #define DATA_MAX UINT64_MAX
17
+
17
18
  #define M_MIN INT2FIX(0)
18
19
  #define M_MAX m_data_to_num(UINT64_MAX)
20
+
21
+ #include "uint_macro.h"
@@ -8,11 +8,14 @@ typedef u_int8_t rtype;
8
8
  #define m_extract(x) UINT2NUM((unsigned int)*(dtype*)(x))
9
9
  #define m_sprintf(s,x) sprintf(s,"%u",(unsigned int)(x))
10
10
 
11
- #include "uint_macro.h"
12
-
13
11
  #ifndef UINT8_MAX
14
12
  #define UINT8_MAX (255)
15
13
  #endif
16
14
 
15
+ #define DATA_MIN UINT8_MIN
16
+ #define DATA_MAX UINT8_MAX
17
+
17
18
  #define M_MIN INT2FIX(0)
18
19
  #define M_MAX m_data_to_num(UINT8_MAX)
20
+
21
+ #include "uint_macro.h"
data/spec/narray_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
- require File.join(File.dirname(__FILE__), "../ext/numo/narray/narray")
1
+ d=File.dirname(__FILE__)
2
+ require File.join(d, "../ext/numo/narray/narray")
3
+ require File.join(d, "../lib/numo/narray/extra")
2
4
  #Numo::NArray.debug = true
3
5
 
4
6
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-narray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.7
4
+ version: 0.9.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-28 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler