numo-narray 0.9.1.5 → 0.9.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2723cec3e04deedc561c54a0d4f6af799dd93fc8a32079d06a074f00f07f466c
4
- data.tar.gz: 5548cfa23b0ac7227b62ab8edd00ba040805c0563befeb32591179dc090eff66
3
+ metadata.gz: a2232329c5ed735d60a1b661d6a0db1b9522cc9cad8f98eb8fc1c6db9026b2cb
4
+ data.tar.gz: ef322c74597e29f8e10c62887feceedc400bbadaa6858ffe80f60949ca31f56d
5
5
  SHA512:
6
- metadata.gz: 19a91712b943da6f57f2cda4fa178adcb5a0c845c2b0ce8190f46c5c1a0d83a331fd32d71e9b2b85c960222f4a01940926bacba63eb882ea1b27aebb7a09c7a3
7
- data.tar.gz: 4ee3a88369439ccf964fd23358a84530973c5355d4c71b35eda516bd655966ce127d494159c942bf0a82045b3f05a6be7ed16f4d9d30b96916df651c9a5ec0cb
6
+ metadata.gz: 9a745b45d333641210bd942a39609b32df1a18638fdbe03c50fd884c5b31c186816019e2a02532ed23b719b24869054434ea227c0a0a9254155d0dc4d9fd1be4
7
+ data.tar.gz: 288ea51ef740d909a6f66f5506de47112071d7d6fb7fe6e9bf6e2c04f470ac397cfc3b1edd8da1fd1228ffc5b3ef31eecc6f7265867ec51d03f40ebe88c2d35d
data/Rakefile CHANGED
@@ -1,76 +1,14 @@
1
1
  require "bundler/gem_tasks"
2
- begin
3
2
 
4
3
  task :doc do
5
4
  dir = "ext/numo/narray"
6
5
  src = %w[array.c data.c index.c math.c narray.c rand.c struct.c].
7
6
  map{|s| File.join(dir,s)} +
8
- [File.join(dir,"types/*.c"), "lib/numo/narray/extra.rb"]
7
+ [File.join(dir,"t_*.c"), "lib/numo/narray/extra.rb"]
9
8
  sh "cd ext/numo/narray; ruby extconf.rb; make src"
10
9
  sh "rm -rf yard .yardoc; yard doc -o yard -m markdown -r README.md #{src.join(' ')}"
11
10
  end
12
11
 
13
- require "rake/extensiontask"
14
- require "rake_compiler_dock"
15
- require "shellwords"
16
-
17
- spec = Bundler::GemHelper.gemspec
18
-
19
- cross_platforms = ["x86-mingw32", "x64-mingw32"]
20
- Rake::ExtensionTask.new("numo/narray", spec) do |ext|
21
- ext.cross_compile = true
22
- ext.cross_platform = cross_platforms
23
- end
24
-
25
- pkg_dir = "pkg"
26
- windows_gem_paths = cross_platforms.collect do |platform|
27
- File.join(pkg_dir, "#{spec.full_name}-#{platform}.gem")
28
- end
29
-
30
- namespace :build do
31
- directory pkg_dir
32
-
33
- desc "Build gems for Windows into the pkg directory"
34
- task :windows => pkg_dir do
35
- build_dir = "tmp/windows"
36
- rm_rf build_dir
37
- mkdir_p build_dir
38
-
39
- commands = [
40
- ["git", "clone", "file://#{Dir.pwd}/.git", build_dir],
41
- ["cd", build_dir],
42
- ["bundle"],
43
- [
44
- "rake",
45
- "RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6",
46
- "cross",
47
- "native",
48
- "gem",
49
- ],
50
- ]
51
- raw_commands = commands.collect do |command|
52
- Shellwords.join(command)
53
- end
54
- raw_command_line = raw_commands.join(" && ")
55
-
56
- RakeCompilerDock.sh(raw_command_line)
57
-
58
- cp(Dir.glob("#{build_dir}/#{pkg_dir}/*.gem"),
59
- "#{pkg_dir}/")
60
- end
61
- end
62
-
63
- namespace :release do
64
- task :windows => "build:windows" do
65
- windows_gem_paths.each do |path|
66
- ruby("-S", "gem", "push", path)
67
- end
68
- end
69
- end
70
-
71
- rescue LoadError
72
- end
73
-
74
12
  require 'rake/testtask'
75
13
  Rake::TestTask.new(:test) do |t|
76
14
  t.libs << "test"
@@ -1,17 +1,13 @@
1
1
  TAGSRC = \
2
- ../../ruby/include/ruby/*.h \
3
- ../../ruby/*.c \
4
- *.h \
5
- types/*.h \
6
- *.c \
7
- types/*.c
2
+ numo/types/*.h \
3
+ *.c
8
4
 
9
5
  tags : TAGS
10
6
  TAGS : $(TAGSRC)
11
7
  etags $(TAGSRC)
12
8
 
13
9
  doc :
14
- yard doc *.c types/*.c
10
+ yard doc *.c
15
11
 
16
12
  C_TMPL = <%=Dir.glob("#{__dir__}/gen/tmpl*/*.c").join(" ")%>
17
13
 
@@ -22,13 +18,13 @@ DEPENDS = $(C_TMPL) <%= __dir__ %>/gen/*.rb
22
18
  type_c = []
23
19
  type_rb = Dir.glob("#{__dir__}/gen/def/*.rb")
24
20
  type_rb.each do |s|
25
- type_c << c = "types/"+File.basename(s,".rb")+".c"
21
+ type_c << c = "t_"+File.basename(s,".rb")+".c"
26
22
  %>
27
23
  <%=c%>: <%=s%> $(DEPENDS)
28
- $(MAKEDIRS) $(@D) types
29
24
  ruby $(COGEN) -l -o $@ <%=s%>
30
25
  <% end %>
31
26
 
32
27
  src : <%= type_c.join(" ") %>
33
28
 
34
- CLEANOBJS = *.o */*.o *.bak types/*.c
29
+ CLEANOBJS = *.o t_*.c *.bak
30
+ DISTCLEANFILES = depend TAGS
@@ -7,7 +7,11 @@ if RUBY_VERSION < "2.1.0"
7
7
  exit(1)
8
8
  end
9
9
 
10
- rm_f 'numo/extconf.h'
10
+ def d(file)
11
+ File.join(__dir__,file)
12
+ end
13
+
14
+ rm_f d('numo/extconf.h')
11
15
 
12
16
  #$CFLAGS="-g3 -O0 -Wall"
13
17
  #$CFLAGS=" $(cflags) -O3 -m64 -msse2 -funroll-loops"
@@ -28,20 +32,20 @@ step
28
32
  index
29
33
  ndloop
30
34
  data
31
- types/bit
32
- types/int8
33
- types/int16
34
- types/int32
35
- types/int64
36
- types/uint8
37
- types/uint16
38
- types/uint32
39
- types/uint64
40
- types/sfloat
41
- types/dfloat
42
- types/scomplex
43
- types/dcomplex
44
- types/robject
35
+ t_bit
36
+ t_int8
37
+ t_int16
38
+ t_int32
39
+ t_int64
40
+ t_uint8
41
+ t_uint16
42
+ t_uint32
43
+ t_uint64
44
+ t_sfloat
45
+ t_dfloat
46
+ t_scomplex
47
+ t_dcomplex
48
+ t_robject
45
49
  math
46
50
  SFMT
47
51
  struct
@@ -89,14 +93,12 @@ have_var("rb_cComplex")
89
93
 
90
94
  $objs = srcs.collect{|i| i+".o"}
91
95
 
92
- create_header('numo/extconf.h')
96
+ create_header d('numo/extconf.h')
93
97
 
94
- depend_path = File.join(__dir__, "depend")
95
- File.open(depend_path, "w") do |depend|
96
- depend_erb_path = File.join(__dir__, "depend.erb")
97
- File.open(depend_erb_path, "r") do |depend_erb|
98
+ File.open(d('depend'), "w") do |depend|
99
+ File.open(d('depend.erb'), "r") do |depend_erb|
98
100
  erb = ERB.new(depend_erb.read)
99
- erb.filename = depend_erb_path
101
+ erb.filename = d('depend.erb')
100
102
  depend.print(erb.result)
101
103
  end
102
104
  end
@@ -50,7 +50,7 @@ code = DefLib.new do
50
50
  set file_name: $output||""
51
51
  set include_files: ["numo/types/#{type_name}.h"]
52
52
  set lib_name: "numo_"+type_name
53
-
53
+
54
54
  if (::RbConfig::CONFIG['target_cpu'] == 'x86_64') or (::RbConfig::CONFIG['target_cpu'] == 'x64')
55
55
  set is_simd: true
56
56
  else
@@ -27,7 +27,7 @@ module NArrayMethod
27
27
 
28
28
  def set2(meth, dtype, result_class)
29
29
  h = {dtype:dtype, result_class:result_class}
30
- def_method(meth, "set2", h)
30
+ def_method(meth, "set2", **h)
31
31
  end
32
32
 
33
33
  def cond_binary(meth,op=nil)
@@ -29,7 +29,9 @@ static void
29
29
  assert(na->base.type == NARRAY_DATA_T);
30
30
 
31
31
  if (na->ptr != NULL) {
32
- xfree(na->ptr);
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
  }
@@ -20,6 +20,7 @@ static VALUE
20
20
  }
21
21
  <% end %>
22
22
  NA_DATA_PTR(na) = ptr;
23
+ NA_DATA_OWNED(na) = TRUE;
23
24
  }
24
25
  break;
25
26
  case NARRAY_VIEW_T:
@@ -12,6 +12,7 @@ static VALUE
12
12
  if (na->size > 0 && ptr == NULL) {
13
13
  ptr = xmalloc(((na->size-1)/8/sizeof(BIT_DIGIT)+1)*sizeof(BIT_DIGIT));
14
14
  NA_DATA_PTR(na) = ptr;
15
+ NA_DATA_OWNED(na) = TRUE;
15
16
  }
16
17
  break;
17
18
  case NARRAY_VIEW_T:
@@ -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
- static VALUE na_aref(int argc, VALUE *argv, VALUE self)
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
- static VALUE na_aset(int argc, VALUE *argv, VALUE self)
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.
@@ -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;
@@ -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
- ptr = na_get_pointer_for_write(vna);
1319
-
1320
- memcpy(ptr, RSTRING_PTR(vstr), byte_size);
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
- ptr = na_get_pointer_for_write(self);
1367
- memcpy(ptr, RSTRING_PTR(vstr)+offset, byte_size);
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
  }
@@ -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"));
@@ -13,8 +13,8 @@ extern "C" {
13
13
  #endif
14
14
  #endif
15
15
 
16
- #define NARRAY_VERSION "0.9.1.5"
17
- #define NARRAY_VERSION_CODE 915
16
+ #define NARRAY_VERSION "0.9.1.6"
17
+ #define NARRAY_VERSION_CODE 916
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
- # define UINT322NUM(x) UINT2NUM(x)
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
- #endif
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)
@@ -4,8 +4,11 @@ typedef int16_t rtype;
4
4
  #define cRT cT
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2INT(x))
7
- #define m_data_to_num(x) INT2NUM((int)(x))
8
- #define m_extract(x) INT2NUM((int)*(dtype*)(x))
7
+ #if SIZEOF_INT > 2
8
+ #define m_data_to_num(x) INT2FIX(x)
9
+ #else
10
+ #define m_data_to_num(x) INT2NUM(x)
11
+ #endif
9
12
  #define m_sprintf(s,x) sprintf(s,"%d",(int)(x))
10
13
 
11
14
  #ifndef INT16_MIN
@@ -5,7 +5,6 @@ typedef int32_t rtype;
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2INT32(x))
7
7
  #define m_data_to_num(x) INT322NUM((int32_t)(x))
8
- #define m_extract(x) INT322NUM((int32_t)*(dtype*)(x))
9
8
  #define m_sprintf(s,x) sprintf(s,"%"PRId32,(int32_t)(x))
10
9
 
11
10
  #ifndef INT32_MIN
@@ -5,7 +5,6 @@ typedef int64_t rtype;
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2INT64(x))
7
7
  #define m_data_to_num(x) INT642NUM((int64_t)(x))
8
- #define m_extract(x) INT642NUM((int64_t)*(dtype*)(x))
9
8
  #define m_sprintf(s,x) sprintf(s,"%"PRId64,(int64_t)(x))
10
9
 
11
10
  #ifndef INT64_MIN
@@ -4,8 +4,7 @@ typedef int8_t rtype;
4
4
  #define cRT cT
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2INT(x))
7
- #define m_data_to_num(x) INT2NUM((int)(x))
8
- #define m_extract(x) INT2NUM((int)*(dtype*)(x))
7
+ #define m_data_to_num(x) INT2FIX(x)
9
8
  #define m_sprintf(s,x) sprintf(s,"%d",(int)(x))
10
9
 
11
10
  #ifndef INT8_MIN
@@ -4,8 +4,11 @@ typedef u_int16_t rtype;
4
4
  #define cRT cT
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2UINT(x))
7
- #define m_data_to_num(x) UINT2NUM((unsigned int)(x))
8
- #define m_extract(x) UINT2NUM((unsigned int)*(dtype*)(x))
7
+ #if SIZEOF_INT > 2
8
+ #define m_data_to_num(x) INT2FIX(x)
9
+ #else
10
+ #define m_data_to_num(x) UINT2NUM(x)
11
+ #endif
9
12
  #define m_sprintf(s,x) sprintf(s,"%u",(unsigned int)(x))
10
13
 
11
14
  #ifndef UINT16_MAX
@@ -5,7 +5,6 @@ typedef u_int32_t rtype;
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2UINT32(x))
7
7
  #define m_data_to_num(x) UINT322NUM((u_int32_t)(x))
8
- #define m_extract(x) UINT322NUM((u_int32_t)*(dtype*)(x))
9
8
  #define m_sprintf(s,x) sprintf(s,"%"PRIu32,(u_int32_t)(x))
10
9
 
11
10
  #ifndef UINT32_MAX
@@ -5,7 +5,6 @@ typedef u_int64_t rtype;
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2UINT64(x))
7
7
  #define m_data_to_num(x) UINT642NUM((u_int64_t)(x))
8
- #define m_extract(x) UINT642NUM((u_int64_t)*(dtype*)(x))
9
8
  #define m_sprintf(s,x) sprintf(s,"%"PRIu64,(u_int64_t)(x))
10
9
 
11
10
  #ifndef UINT64_MAX
@@ -4,8 +4,7 @@ typedef u_int8_t rtype;
4
4
  #define cRT cT
5
5
 
6
6
  #define m_num_to_data(x) ((dtype)NUM2UINT(x))
7
- #define m_data_to_num(x) UINT2NUM((unsigned int)(x))
8
- #define m_extract(x) UINT2NUM((unsigned int)*(dtype*)(x))
7
+ #define m_data_to_num(x) INT2FIX(x)
9
8
  #define m_sprintf(s,x) sprintf(s,"%u",(unsigned int)(x))
10
9
 
11
10
  #ifndef UINT8_MAX
@@ -1,6 +1,8 @@
1
1
  #define m_zero 0
2
2
  #define m_one 1
3
3
 
4
+ #define m_extract(x) m_data_to_num(*(dtype*)(x))
5
+
4
6
  #define m_from_double(x) (x)
5
7
  #define m_from_real(x) (x)
6
8
  #define m_from_sint(x) (x)
@@ -1,8 +1,2 @@
1
- begin
2
- major, minor, _ = RUBY_VERSION.split(/\./)
3
- require "#{major}.#{minor}/numo/narray.so"
4
- rescue LoadError
5
- require "numo/narray.so"
6
- end
7
-
1
+ require "numo/narray.so"
8
2
  require "numo/narray/extra"
@@ -39,6 +39,4 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "rake", "~> 10.0"
40
40
  end
41
41
  spec.add_development_dependency "test-unit", "~> 3.0"
42
- spec.add_development_dependency 'rake-compiler', "~> 1.0", ">= 1.0.1"
43
- spec.add_development_dependency "rake-compiler-dock", "~> 0.0"
44
42
  end
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.1.5
4
+ version: 0.9.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-08 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,40 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake-compiler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.0'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 1.0.1
65
- type: :development
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - "~>"
70
- - !ruby/object:Gem::Version
71
- version: '1.0'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 1.0.1
75
- - !ruby/object:Gem::Dependency
76
- name: rake-compiler-dock
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '0.0'
89
55
  description: Numo::NArray - New NArray class library in Ruby/Numo.
90
56
  email:
91
57
  - masa16.tanaka@gmail.com
@@ -265,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
231
  - !ruby/object:Gem::Version
266
232
  version: '0'
267
233
  requirements: []
268
- rubygems_version: 3.0.3
234
+ rubygems_version: 3.1.2
269
235
  signing_key:
270
236
  specification_version: 4
271
237
  summary: alpha release of Numo::NArray - New NArray class library in Ruby/Numo (NUmerical