numo-narray 0.9.1.5 → 0.9.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/Rakefile +4 -63
- data/ext/numo/narray/array.c +19 -26
- data/ext/numo/narray/data.c +2 -8
- data/ext/numo/narray/depend.erb +6 -10
- data/ext/numo/narray/extconf.rb +23 -21
- data/ext/numo/narray/gen/cogen.rb +2 -2
- data/ext/numo/narray/gen/narray_def.rb +1 -1
- data/ext/numo/narray/gen/spec.rb +12 -6
- data/ext/numo/narray/gen/tmpl/accum_binary.c +4 -0
- data/ext/numo/narray/gen/tmpl/alloc_func.c +4 -1
- data/ext/numo/narray/gen/tmpl/allocate.c +1 -0
- data/ext/numo/narray/gen/tmpl/cast.c +7 -0
- data/ext/numo/narray/gen/tmpl/lib.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/allocate.c +1 -0
- data/ext/numo/narray/gen/tmpl_bit/binary.c +6 -0
- data/ext/numo/narray/gen/tmpl_bit/store_bit.c +6 -2
- data/ext/numo/narray/gen/tmpl_bit/unary.c +4 -0
- data/ext/numo/narray/index.c +5 -11
- data/ext/numo/narray/math.c +1 -1
- data/ext/numo/narray/narray.c +108 -11
- data/ext/numo/narray/ndloop.c +3 -3
- data/ext/numo/narray/numo/intern.h +1 -1
- data/ext/numo/narray/numo/narray.h +16 -12
- data/ext/numo/narray/numo/ndloop.h +1 -1
- data/ext/numo/narray/numo/template.h +8 -10
- data/ext/numo/narray/numo/types/complex.h +1 -1
- data/ext/numo/narray/numo/types/complex_macro.h +1 -1
- data/ext/numo/narray/numo/types/float_macro.h +1 -1
- data/ext/numo/narray/numo/types/int16.h +5 -2
- data/ext/numo/narray/numo/types/int32.h +0 -1
- data/ext/numo/narray/numo/types/int64.h +0 -1
- data/ext/numo/narray/numo/types/int8.h +1 -2
- data/ext/numo/narray/numo/types/uint16.h +5 -2
- data/ext/numo/narray/numo/types/uint32.h +0 -1
- data/ext/numo/narray/numo/types/uint64.h +0 -1
- data/ext/numo/narray/numo/types/uint8.h +1 -2
- data/ext/numo/narray/numo/types/xint_macro.h +2 -0
- data/ext/numo/narray/step.c +1 -1
- data/ext/numo/narray/struct.c +2 -2
- data/lib/numo/narray.rb +1 -7
- data/lib/numo/narray/extra.rb +42 -1
- data/numo-narray.gemspec +3 -8
- metadata +14 -34
@@ -94,7 +94,11 @@ static VALUE
|
|
94
94
|
return <%=c_func%>_self(argc, argv, self);
|
95
95
|
} else {
|
96
96
|
v = rb_funcall(klass, id_cast, 1, self);
|
97
|
+
//<% if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.7.0') %>
|
97
98
|
return rb_funcall2(v, rb_intern("<%=name%>"), argc, argv);
|
99
|
+
//<% else %>
|
100
|
+
return rb_funcallv_kw(v, rb_intern("<%=name%>"), argc, argv, RB_PASS_CALLED_KEYWORDS);
|
101
|
+
//<% end %>
|
98
102
|
}
|
99
103
|
//<% end %>
|
100
104
|
}
|
@@ -29,7 +29,9 @@ static void
|
|
29
29
|
assert(na->base.type == NARRAY_DATA_T);
|
30
30
|
|
31
31
|
if (na->ptr != NULL) {
|
32
|
-
|
32
|
+
if (na->owned) {
|
33
|
+
xfree(na->ptr);
|
34
|
+
}
|
33
35
|
na->ptr = NULL;
|
34
36
|
}
|
35
37
|
if (na->base.size > 0) {
|
@@ -103,5 +105,6 @@ static VALUE
|
|
103
105
|
na->base.shape = NULL;
|
104
106
|
na->base.reduce = INT2FIX(0);
|
105
107
|
na->ptr = NULL;
|
108
|
+
na->owned = FALSE;
|
106
109
|
return TypedData_Wrap_Struct(klass, &<%=type_name%>_data_type, (void*)na);
|
107
110
|
}
|
@@ -35,6 +35,13 @@ static VALUE
|
|
35
35
|
}
|
36
36
|
return v;
|
37
37
|
}
|
38
|
+
if (rb_respond_to(obj,id_to_a)) {
|
39
|
+
obj = rb_funcall(obj,id_to_a,0);
|
40
|
+
if (TYPE(obj)!=T_ARRAY) {
|
41
|
+
rb_raise(rb_eTypeError, "`to_a' did not return Array");
|
42
|
+
}
|
43
|
+
return <%=find_tmpl("cast_array").c_func%>(obj);
|
44
|
+
}
|
38
45
|
<% if is_object %>
|
39
46
|
return robject_new_dim0(obj);
|
40
47
|
<% else %>
|
@@ -2,7 +2,7 @@ static void
|
|
2
2
|
<%=c_iter%>(na_loop_t *const lp)
|
3
3
|
{
|
4
4
|
size_t n;
|
5
|
-
|
5
|
+
ssize_t p1, p3;
|
6
6
|
ssize_t s1, s3;
|
7
7
|
size_t *idx1, *idx3;
|
8
8
|
int o1, l1, r1, len;
|
@@ -18,6 +18,10 @@ static void
|
|
18
18
|
STORE_BIT_STEP(a3, p3, s3, idx3, x);
|
19
19
|
}
|
20
20
|
} else {
|
21
|
+
a1 += p1/NB;
|
22
|
+
p1 %= NB;
|
23
|
+
a3 += p3/NB;
|
24
|
+
p3 %= NB;
|
21
25
|
o1 = p1-p3;
|
22
26
|
l1 = NB+o1;
|
23
27
|
r1 = NB-o1;
|
@@ -26,7 +30,7 @@ static void
|
|
26
30
|
if ((int)n<len) len=n;
|
27
31
|
if (o1>=0) x = *a1>>o1;
|
28
32
|
else x = *a1<<-o1;
|
29
|
-
if (p1+len>NB) x |= *(a1+1)<<r1;
|
33
|
+
if (p1+len>(ssize_t)NB) x |= *(a1+1)<<r1;
|
30
34
|
a1++;
|
31
35
|
*a3 = (x & (SLB(len)<<p3)) | (*a3 & ~(SLB(len)<<p3));
|
32
36
|
a3++;
|
data/ext/numo/narray/index.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
index.c
|
3
3
|
Ruby/Numo::NArray - Numerical Array class for Ruby
|
4
|
-
Copyright (C) 1999-
|
4
|
+
Copyright (C) 1999-2020 Masahiro TANAKA
|
5
5
|
*/
|
6
6
|
//#define NARRAY_C
|
7
7
|
|
@@ -1050,11 +1050,8 @@ static VALUE na_slice(int argc, VALUE *argv, VALUE self)
|
|
1050
1050
|
# [10, 11, 99, 13, 14],
|
1051
1051
|
# [15, 16, 99, 18, 19]]
|
1052
1052
|
*/
|
1053
|
-
|
1054
|
-
|
1055
|
-
// implemented in subclasses
|
1056
|
-
return rb_f_notimplement(argc,argv,self);
|
1057
|
-
}
|
1053
|
+
// implemented in subclasses
|
1054
|
+
#define na_aref rb_f_notimplement
|
1058
1055
|
|
1059
1056
|
/*
|
1060
1057
|
Multi-dimensional element assignment.
|
@@ -1094,11 +1091,8 @@ static VALUE na_aref(int argc, VALUE *argv, VALUE self)
|
|
1094
1091
|
# [8, 9, 10, 11]]
|
1095
1092
|
|
1096
1093
|
*/
|
1097
|
-
|
1098
|
-
|
1099
|
-
// implemented in subclasses
|
1100
|
-
return rb_f_notimplement(argc,argv,self);
|
1101
|
-
}
|
1094
|
+
// implemented in subclasses
|
1095
|
+
#define na_aset rb_f_notimplement
|
1102
1096
|
|
1103
1097
|
/*
|
1104
1098
|
Multi-dimensional array indexing.
|
data/ext/numo/narray/math.c
CHANGED
data/ext/numo/narray/narray.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
narray.c
|
3
3
|
Ruby/Numo::NArray - Numerical Array class for Ruby
|
4
|
-
Copyright (C) 1999-
|
4
|
+
Copyright (C) 1999-2020 Masahiro TANAKA
|
5
5
|
*/
|
6
6
|
#define NARRAY_C
|
7
7
|
#include <ruby.h>
|
@@ -34,6 +34,7 @@ static ID id_count_false;
|
|
34
34
|
static ID id_axis;
|
35
35
|
static ID id_nan;
|
36
36
|
static ID id_keepdims;
|
37
|
+
static ID id_source;
|
37
38
|
|
38
39
|
VALUE cPointer;
|
39
40
|
|
@@ -605,6 +606,87 @@ na_s_eye(int argc, VALUE *argv, VALUE klass)
|
|
605
606
|
#define READ 1
|
606
607
|
#define WRITE 2
|
607
608
|
|
609
|
+
static void
|
610
|
+
na_set_pointer(VALUE self, char *ptr, size_t byte_size)
|
611
|
+
{
|
612
|
+
VALUE obj;
|
613
|
+
narray_t *na;
|
614
|
+
|
615
|
+
if (OBJ_FROZEN(self)) {
|
616
|
+
rb_raise(rb_eRuntimeError, "cannot write to frozen NArray.");
|
617
|
+
}
|
618
|
+
|
619
|
+
GetNArray(self,na);
|
620
|
+
|
621
|
+
switch(NA_TYPE(na)) {
|
622
|
+
case NARRAY_DATA_T:
|
623
|
+
if (NA_SIZE(na) > 0) {
|
624
|
+
if (NA_DATA_PTR(na) != NULL && NA_DATA_OWNED(na)) {
|
625
|
+
xfree(NA_DATA_PTR(na));
|
626
|
+
}
|
627
|
+
NA_DATA_PTR(na) = ptr;
|
628
|
+
NA_DATA_OWNED(na) = FALSE;
|
629
|
+
}
|
630
|
+
return;
|
631
|
+
case NARRAY_VIEW_T:
|
632
|
+
obj = NA_VIEW_DATA(na);
|
633
|
+
if (OBJ_FROZEN(obj)) {
|
634
|
+
rb_raise(rb_eRuntimeError, "cannot write to frozen NArray.");
|
635
|
+
}
|
636
|
+
GetNArray(obj,na);
|
637
|
+
switch(NA_TYPE(na)) {
|
638
|
+
case NARRAY_DATA_T:
|
639
|
+
if (NA_SIZE(na) > 0) {
|
640
|
+
if (NA_DATA_PTR(na) != NULL && NA_DATA_OWNED(na)) {
|
641
|
+
xfree(NA_DATA_PTR(na));
|
642
|
+
}
|
643
|
+
NA_DATA_PTR(na) = ptr;
|
644
|
+
NA_DATA_OWNED(na) = FALSE;
|
645
|
+
}
|
646
|
+
return;
|
647
|
+
default:
|
648
|
+
rb_raise(rb_eRuntimeError,"invalid NA_TYPE of view: %d",NA_TYPE(na));
|
649
|
+
}
|
650
|
+
default:
|
651
|
+
rb_raise(rb_eRuntimeError,"invalid NA_TYPE: %d",NA_TYPE(na));
|
652
|
+
}
|
653
|
+
}
|
654
|
+
|
655
|
+
static void
|
656
|
+
na_pointer_copy_on_write(VALUE self)
|
657
|
+
{
|
658
|
+
narray_t *na;
|
659
|
+
void *ptr;
|
660
|
+
VALUE velmsz;
|
661
|
+
size_t byte_size;
|
662
|
+
|
663
|
+
GetNArray(self,na);
|
664
|
+
if (NA_TYPE(na) == NARRAY_VIEW_T) {
|
665
|
+
self = NA_VIEW_DATA(na);
|
666
|
+
GetNArray(self,na);
|
667
|
+
}
|
668
|
+
|
669
|
+
ptr = NA_DATA_PTR(na);
|
670
|
+
if (ptr == NULL) {
|
671
|
+
return;
|
672
|
+
}
|
673
|
+
|
674
|
+
if (NA_DATA_OWNED(na)) {
|
675
|
+
return;
|
676
|
+
}
|
677
|
+
|
678
|
+
velmsz = rb_const_get(rb_obj_class(self), id_element_byte_size);
|
679
|
+
if (FIXNUM_P(velmsz)) {
|
680
|
+
byte_size = NA_SIZE(na) * NUM2SIZET(velmsz);
|
681
|
+
} else {
|
682
|
+
byte_size = ceil(NA_SIZE(na) * NUM2DBL(velmsz));
|
683
|
+
}
|
684
|
+
NA_DATA_PTR(na) = NULL;
|
685
|
+
rb_funcall(self, id_allocate, 0);
|
686
|
+
memcpy(NA_DATA_PTR(na), ptr, byte_size);
|
687
|
+
rb_ivar_set(self, id_source, Qnil);
|
688
|
+
}
|
689
|
+
|
608
690
|
static char *
|
609
691
|
na_get_pointer_for_rw(VALUE self, int flag)
|
610
692
|
{
|
@@ -620,6 +702,9 @@ na_get_pointer_for_rw(VALUE self, int flag)
|
|
620
702
|
|
621
703
|
switch(NA_TYPE(na)) {
|
622
704
|
case NARRAY_DATA_T:
|
705
|
+
if (flag & WRITE) {
|
706
|
+
na_pointer_copy_on_write(self);
|
707
|
+
}
|
623
708
|
ptr = NA_DATA_PTR(na);
|
624
709
|
if (NA_SIZE(na) > 0 && ptr == NULL) {
|
625
710
|
if (flag & READ) {
|
@@ -636,6 +721,9 @@ na_get_pointer_for_rw(VALUE self, int flag)
|
|
636
721
|
if ((flag & WRITE) && OBJ_FROZEN(obj)) {
|
637
722
|
rb_raise(rb_eRuntimeError, "cannot write to frozen NArray.");
|
638
723
|
}
|
724
|
+
if (flag & WRITE) {
|
725
|
+
na_pointer_copy_on_write(self);
|
726
|
+
}
|
639
727
|
GetNArray(obj,na);
|
640
728
|
switch(NA_TYPE(na)) {
|
641
729
|
case NARRAY_DATA_T:
|
@@ -1260,7 +1348,6 @@ nary_s_from_binary(int argc, VALUE *argv, VALUE type)
|
|
1260
1348
|
{
|
1261
1349
|
size_t len, str_len, byte_size;
|
1262
1350
|
size_t *shape;
|
1263
|
-
char *ptr;
|
1264
1351
|
int i, nd, narg;
|
1265
1352
|
VALUE vstr, vshape, vna;
|
1266
1353
|
VALUE velmsz;
|
@@ -1278,8 +1365,8 @@ nary_s_from_binary(int argc, VALUE *argv, VALUE type)
|
|
1278
1365
|
break;
|
1279
1366
|
case T_ARRAY:
|
1280
1367
|
nd = RARRAY_LEN(vshape);
|
1281
|
-
if (nd
|
1282
|
-
|
1368
|
+
if (nd > NA_MAX_DIMENSION) {
|
1369
|
+
rb_raise(nary_eDimensionError,"shape exceeds max dimension");
|
1283
1370
|
}
|
1284
1371
|
shape = ALLOCA_N(size_t,nd);
|
1285
1372
|
len = 1;
|
@@ -1315,9 +1402,13 @@ nary_s_from_binary(int argc, VALUE *argv, VALUE type)
|
|
1315
1402
|
}
|
1316
1403
|
|
1317
1404
|
vna = nary_new(type, nd, shape);
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1405
|
+
if (OBJ_FROZEN(vstr)) {
|
1406
|
+
na_set_pointer(vna, RSTRING_PTR(vstr), byte_size);
|
1407
|
+
rb_ivar_set(vna, id_source, vstr);
|
1408
|
+
} else {
|
1409
|
+
void *ptr = na_get_pointer_for_write(vna);
|
1410
|
+
memcpy(ptr, RSTRING_PTR(vstr), byte_size);
|
1411
|
+
}
|
1321
1412
|
|
1322
1413
|
return vna;
|
1323
1414
|
}
|
@@ -1333,7 +1424,6 @@ static VALUE
|
|
1333
1424
|
nary_store_binary(int argc, VALUE *argv, VALUE self)
|
1334
1425
|
{
|
1335
1426
|
size_t size, str_len, byte_size, offset;
|
1336
|
-
char *ptr;
|
1337
1427
|
int narg;
|
1338
1428
|
VALUE vstr, voffset;
|
1339
1429
|
VALUE velmsz;
|
@@ -1363,8 +1453,13 @@ nary_store_binary(int argc, VALUE *argv, VALUE self)
|
|
1363
1453
|
rb_raise(rb_eArgError, "string is too short to store");
|
1364
1454
|
}
|
1365
1455
|
|
1366
|
-
|
1367
|
-
|
1456
|
+
if (OBJ_FROZEN(vstr)) {
|
1457
|
+
na_set_pointer(self, RSTRING_PTR(vstr)+offset, byte_size);
|
1458
|
+
rb_ivar_set(self, id_source, vstr);
|
1459
|
+
} else {
|
1460
|
+
void *ptr = na_get_pointer_for_write(self);
|
1461
|
+
memcpy(ptr, RSTRING_PTR(vstr)+offset, byte_size);
|
1462
|
+
}
|
1368
1463
|
|
1369
1464
|
return SIZET2NUM(byte_size);
|
1370
1465
|
}
|
@@ -1436,7 +1531,7 @@ static VALUE na_inplace( VALUE self );
|
|
1436
1531
|
/*
|
1437
1532
|
Load marshal data.
|
1438
1533
|
@overload marshal_load(data)
|
1439
|
-
@
|
1534
|
+
@param [Array] Array containing marshal data.
|
1440
1535
|
@return [nil]
|
1441
1536
|
*/
|
1442
1537
|
static VALUE
|
@@ -1470,6 +1565,7 @@ nary_marshal_load(VALUE self, VALUE a)
|
|
1470
1565
|
ptr = na_get_pointer_for_write(self);
|
1471
1566
|
memcpy(ptr, RARRAY_PTR(v), NA_SIZE(na)*sizeof(VALUE));
|
1472
1567
|
} else {
|
1568
|
+
rb_str_freeze(v);
|
1473
1569
|
nary_store_binary(1,&v,self);
|
1474
1570
|
if (TEST_BYTE_SWAPPED(self)) {
|
1475
1571
|
rb_funcall(na_inplace(self),id_to_host,0);
|
@@ -2009,6 +2105,7 @@ Init_narray()
|
|
2009
2105
|
id_axis = rb_intern("axis");
|
2010
2106
|
id_nan = rb_intern("nan");
|
2011
2107
|
id_keepdims = rb_intern("keepdims");
|
2108
|
+
id_source = rb_intern("source");
|
2012
2109
|
|
2013
2110
|
sym_reduce = ID2SYM(rb_intern("reduce"));
|
2014
2111
|
sym_option = ID2SYM(rb_intern("option"));
|
data/ext/numo/narray/ndloop.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
ndloop.c
|
3
3
|
Ruby/Numo::NArray - Numerical Array class for Ruby
|
4
|
-
Copyright (C) 1999-
|
4
|
+
Copyright (C) 1999-2020 Masahiro TANAKA
|
5
5
|
*/
|
6
6
|
|
7
7
|
#include <ruby.h>
|
@@ -164,7 +164,7 @@ print_ndloop(na_md_loop_t *lp) {
|
|
164
164
|
for (i=0; i<lp->user.ndim; i++) {
|
165
165
|
printf(" &user.args[%d].iter[%d] = 0x%"SZF"x\n", j,i, (size_t)&lp->user.args[j].iter[i]);
|
166
166
|
printf(" user.args[%d].iter[%d].pos = %"SZF"u\n", j,i, lp->user.args[j].iter[i].pos);
|
167
|
-
printf(" user.args[%d].iter[%d].step = %"SZF"
|
167
|
+
printf(" user.args[%d].iter[%d].step = %"SZF"d\n", j,i, lp->user.args[j].iter[i].step);
|
168
168
|
printf(" user.args[%d].iter[%d].idx = 0x%"SZF"x\n", j,i, (size_t)lp->user.args[j].iter[i].idx);
|
169
169
|
}
|
170
170
|
}
|
@@ -174,7 +174,7 @@ print_ndloop(na_md_loop_t *lp) {
|
|
174
174
|
for (i=0; i<=nd; i++) {
|
175
175
|
printf(" &xargs[%d].iter[%d] = 0x%"SZF"x\n", j,i, (size_t)&LITER(lp,i,j));
|
176
176
|
printf(" xargs[%d].iter[%d].pos = %"SZF"u\n", j,i, LITER(lp,i,j).pos);
|
177
|
-
printf(" xargs[%d].iter[%d].step = %"SZF"
|
177
|
+
printf(" xargs[%d].iter[%d].step = %"SZF"d\n", j,i, LITER(lp,i,j).step);
|
178
178
|
printf(" xargs[%d].iter[%d].idx = 0x%"SZF"x\n", j,i, (size_t)LITER(lp,i,j).idx);
|
179
179
|
}
|
180
180
|
printf(" xargs[%d].bufcp = 0x%"SZF"x\n", j, (size_t)lp->xargs[j].bufcp);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
narray.h
|
3
3
|
Ruby/Numo::NArray - Numerical Array class for Ruby
|
4
|
-
Copyright (C) 1999-
|
4
|
+
Copyright (C) 1999-2020 Masahiro TANAKA
|
5
5
|
*/
|
6
6
|
#ifndef NARRAY_H
|
7
7
|
#define NARRAY_H
|
@@ -13,8 +13,8 @@ extern "C" {
|
|
13
13
|
#endif
|
14
14
|
#endif
|
15
15
|
|
16
|
-
#define NARRAY_VERSION "0.9.
|
17
|
-
#define NARRAY_VERSION_CODE
|
16
|
+
#define NARRAY_VERSION "0.9.2.0"
|
17
|
+
#define NARRAY_VERSION_CODE 920
|
18
18
|
|
19
19
|
#include <math.h>
|
20
20
|
#include "numo/compat.h"
|
@@ -81,6 +81,8 @@ extern "C" {
|
|
81
81
|
# ifndef PRIu64
|
82
82
|
# define PRIu64 "llu"
|
83
83
|
# endif
|
84
|
+
#else
|
85
|
+
# error ---->> numo/narray requires 8-byte integer. <<----
|
84
86
|
#endif
|
85
87
|
|
86
88
|
#if SIZEOF_LONG==4
|
@@ -96,22 +98,22 @@ extern "C" {
|
|
96
98
|
# endif
|
97
99
|
#elif SIZEOF_INT==4
|
98
100
|
# define NUM2INT32(x) NUM2INT(x)
|
99
|
-
# define INT322NUM(x) INT2NUM(x)
|
100
101
|
# define NUM2UINT32(x) NUM2UINT(x)
|
101
|
-
#
|
102
|
+
# if SIZEOF_LONG > 4
|
103
|
+
# define INT322NUM(x) INT2FIX(x)
|
104
|
+
# define UINT322NUM(x) INT2FIX(x)
|
105
|
+
# else
|
106
|
+
# define INT322NUM(x) INT2NUM(x)
|
107
|
+
# define UINT322NUM(x) UINT2NUM(x)
|
108
|
+
# endif
|
102
109
|
# ifndef PRId32
|
103
110
|
# define PRId32 "d"
|
104
111
|
# endif
|
105
112
|
# ifndef PRIu32
|
106
113
|
# define PRIu32 "u"
|
107
114
|
# endif
|
108
|
-
#
|
109
|
-
|
110
|
-
#if SIZEOF_VALUE > 4
|
111
|
-
# undef INT322NUM
|
112
|
-
# undef UINT322NUM
|
113
|
-
# define INT322NUM(x) INT2FIX(x)
|
114
|
-
# define UINT322NUM(x) INT2FIX(x)
|
115
|
+
#else
|
116
|
+
# error ---->> numo/narray requires 4-byte integer. <<----
|
115
117
|
#endif
|
116
118
|
|
117
119
|
#ifndef HAVE_TYPE_BOOL
|
@@ -195,6 +197,7 @@ typedef struct RNArray {
|
|
195
197
|
typedef struct RNArrayData {
|
196
198
|
narray_t base;
|
197
199
|
char *ptr;
|
200
|
+
bool owned;
|
198
201
|
} narray_data_t;
|
199
202
|
|
200
203
|
|
@@ -323,6 +326,7 @@ _na_get_narray_t(VALUE obj, unsigned char na_type)
|
|
323
326
|
#define NA_DATA(na) ((narray_data_t*)(na))
|
324
327
|
#define NA_VIEW(na) ((narray_view_t*)(na))
|
325
328
|
#define NA_DATA_PTR(na) (NA_DATA(na)->ptr)
|
329
|
+
#define NA_DATA_OWNED(na) (NA_DATA(na)->owned)
|
326
330
|
#define NA_VIEW_DATA(na) (NA_VIEW(na)->data)
|
327
331
|
#define NA_VIEW_OFFSET(na) (NA_VIEW(na)->offset)
|
328
332
|
#define NA_VIEW_STRIDX(na) (NA_VIEW(na)->stridx)
|