numo-narray 0.9.1.2 → 0.9.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -1
  3. data/ext/numo/narray/array.c +6 -6
  4. data/ext/numo/narray/data.c +8 -8
  5. data/ext/numo/narray/depend.erb +4 -4
  6. data/ext/numo/narray/extconf.rb +2 -2
  7. data/ext/numo/narray/gen/cogen.rb +13 -0
  8. data/ext/numo/narray/gen/def/dfloat.rb +1 -0
  9. data/ext/numo/narray/gen/def/sfloat.rb +1 -0
  10. data/ext/numo/narray/gen/narray_def.rb +14 -2
  11. data/ext/numo/narray/gen/spec.rb +26 -10
  12. data/ext/numo/narray/gen/tmpl/accum_binary.c +1 -1
  13. data/ext/numo/narray/gen/tmpl/accum_index.c +11 -1
  14. data/ext/numo/narray/gen/tmpl/alloc_func.c +3 -3
  15. data/ext/numo/narray/gen/tmpl/binary.c +149 -10
  16. data/ext/numo/narray/gen/tmpl/binary2.c +1 -1
  17. data/ext/numo/narray/gen/tmpl/bincount.c +1 -1
  18. data/ext/numo/narray/gen/tmpl/cast.c +1 -1
  19. data/ext/numo/narray/gen/tmpl/cond_binary.c +1 -1
  20. data/ext/numo/narray/gen/tmpl/each.c +1 -1
  21. data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
  22. data/ext/numo/narray/gen/tmpl/extract_data.c +3 -3
  23. data/ext/numo/narray/gen/tmpl/inspect.c +1 -1
  24. data/ext/numo/narray/gen/tmpl/lib.c +5 -0
  25. data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
  26. data/ext/numo/narray/gen/tmpl/median.c +3 -2
  27. data/ext/numo/narray/gen/tmpl/pow.c +1 -1
  28. data/ext/numo/narray/gen/tmpl/qsort.c +118 -56
  29. data/ext/numo/narray/gen/tmpl/store.c +4 -4
  30. data/ext/numo/narray/gen/tmpl/store_bit.c +4 -4
  31. data/ext/numo/narray/gen/tmpl/to_a.c +1 -1
  32. data/ext/numo/narray/gen/tmpl/unary_s.c +55 -9
  33. data/ext/numo/narray/gen/tmpl_bit/each.c +1 -1
  34. data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +1 -1
  35. data/ext/numo/narray/gen/tmpl_bit/inspect.c +1 -1
  36. data/ext/numo/narray/gen/tmpl_bit/mask.c +1 -1
  37. data/ext/numo/narray/gen/tmpl_bit/to_a.c +1 -1
  38. data/ext/numo/narray/index.c +64 -37
  39. data/ext/numo/narray/math.c +4 -4
  40. data/ext/numo/narray/narray.c +54 -29
  41. data/ext/numo/narray/ndloop.c +7 -7
  42. data/ext/numo/narray/numo/narray.h +9 -2
  43. data/ext/numo/narray/numo/template.h +18 -0
  44. data/ext/numo/narray/numo/types/bit.h +5 -0
  45. data/ext/numo/narray/numo/types/complex_macro.h +5 -0
  46. data/ext/numo/narray/numo/types/float_macro.h +5 -0
  47. data/ext/numo/narray/numo/types/int_macro.h +24 -0
  48. data/ext/numo/narray/numo/types/robj_macro.h +5 -0
  49. data/ext/numo/narray/numo/types/uint_macro.h +24 -0
  50. data/ext/numo/narray/numo/types/xint_macro.h +5 -25
  51. data/ext/numo/narray/rand.c +2 -29
  52. data/ext/numo/narray/step.c +1 -28
  53. data/ext/numo/narray/struct.c +26 -22
  54. data/lib/numo/narray/extra.rb +50 -1
  55. metadata +2 -2
@@ -1,4 +1,4 @@
1
- void
1
+ static void
2
2
  <%=c_iter%>(na_loop_t *const lp)
3
3
  {
4
4
  size_t i;
@@ -11,7 +11,7 @@ yield_each_with_index(dtype x, size_t *c, VALUE *a, int nd, int md)
11
11
  }
12
12
 
13
13
 
14
- void
14
+ static void
15
15
  <%=c_iter%>(na_loop_t *const lp)
16
16
  {
17
17
  size_t i;
@@ -11,7 +11,7 @@ static VALUE
11
11
  @overload inspect
12
12
  @return [String]
13
13
  */
14
- VALUE
14
+ static VALUE
15
15
  <%=c_func(0)%>(VALUE ary)
16
16
  {
17
17
  return na_ndloop_inspect(ary, <%=c_iter%>, Qnil);
@@ -103,7 +103,7 @@ static VALUE
103
103
  g.idx0 = NULL;
104
104
  na_ndloop3(&ndf, &g, 2, mask, val);
105
105
 
106
- view = na_s_allocate_view(CLASS_OF(val));
106
+ view = na_s_allocate_view(rb_obj_class(val));
107
107
  GetNArrayView(view, nv);
108
108
  na_setup_shape((narray_t*)nv, 1, &n_1);
109
109
 
@@ -1,4 +1,4 @@
1
- void
1
+ static void
2
2
  <%=c_iter%>(na_loop_t *const lp)
3
3
  {
4
4
  size_t i;
@@ -82,7 +82,7 @@ static ID id_shift_left;
82
82
  static ID id_mask;
83
83
 
84
84
 
85
- void
85
+ static void
86
86
  na_index_set_step(na_index_arg_t *q, int i, size_t n, size_t beg, ssize_t step)
87
87
  {
88
88
  q->n = n;
@@ -93,7 +93,7 @@ na_index_set_step(na_index_arg_t *q, int i, size_t n, size_t beg, ssize_t step)
93
93
  q->orig_dim = i;
94
94
  }
95
95
 
96
- void
96
+ static void
97
97
  na_index_set_scalar(na_index_arg_t *q, int i, ssize_t size, ssize_t x)
98
98
  {
99
99
  if (x < -size || x >= size)
@@ -567,7 +567,7 @@ VALUE na_aref_md_protected(VALUE data_value)
567
567
  } else {
568
568
  ndim_new = na_ndim_new_narray(ndim, q);
569
569
  }
570
- view = na_s_allocate_view(CLASS_OF(self));
570
+ view = na_s_allocate_view(rb_obj_class(self));
571
571
 
572
572
  na_copy_flags(self, view);
573
573
  GetNArrayView(view,na2);
@@ -610,7 +610,7 @@ na_aref_md_ensure(VALUE data_value)
610
610
  return Qnil;
611
611
  }
612
612
 
613
- VALUE
613
+ static VALUE
614
614
  na_aref_md(int argc, VALUE *argv, VALUE self, int keep_dim, int result_nd)
615
615
  {
616
616
  VALUE args; // should be GC protected
@@ -632,7 +632,7 @@ na_aref_md(int argc, VALUE *argv, VALUE self, int keep_dim, int result_nd)
632
632
  if (rb_obj_is_kind_of(idx, numo_cNArray)) {
633
633
  GetNArray(idx,nidx);
634
634
  if (NA_NDIM(nidx)>1) {
635
- store = nary_new(CLASS_OF(self),NA_NDIM(nidx),NA_SHAPE(nidx));
635
+ store = nary_new(rb_obj_class(self),NA_NDIM(nidx),NA_SHAPE(nidx));
636
636
  idx = na_flatten(idx);
637
637
  RARRAY_ASET(args,0,idx);
638
638
  }
@@ -666,7 +666,7 @@ na_aref_main(int nidx, VALUE *idx, VALUE self, int keep_dim, int nd)
666
666
  return rb_funcall(self,id_dup,0);
667
667
  }
668
668
  if (nidx==1) {
669
- if (CLASS_OF(*idx)==numo_cBit) {
669
+ if (rb_obj_class(*idx)==numo_cBit) {
670
670
  return rb_funcall(*idx,id_mask,1,self);
671
671
  }
672
672
  }
@@ -674,17 +674,6 @@ na_aref_main(int nidx, VALUE *idx, VALUE self, int keep_dim, int nd)
674
674
  }
675
675
 
676
676
 
677
- /* method: slice(idx1,idx2,...,idxN) */
678
- static VALUE na_slice(int argc, VALUE *argv, VALUE self)
679
- {
680
- int nd;
681
- size_t pos;
682
-
683
- nd = na_get_result_dimension(self, argc, argv, 0, &pos);
684
- return na_aref_main(argc, argv, self, 1, nd);
685
- }
686
-
687
-
688
677
  static int
689
678
  check_index_count(int argc, int na_ndim, int count_new, int count_rest)
690
679
  {
@@ -692,16 +681,18 @@ check_index_count(int argc, int na_ndim, int count_new, int count_rest)
692
681
 
693
682
  switch(count_rest) {
694
683
  case 0:
695
- if (count_new == 0 && argc == 1) return 1;
684
+ if (argc == 1 && count_new == 0) return 1;
696
685
  if (argc == result_nd) return result_nd;
697
686
  rb_raise(rb_eIndexError,"# of index(=%i) should be "
698
- "equal to ndim(=%i)",argc,na_ndim);
687
+ "equal to ndim(=%i) or 1", argc,na_ndim);
699
688
  break;
700
689
  case 1:
701
690
  if (argc-1 <= result_nd) return result_nd;
702
691
  rb_raise(rb_eIndexError,"# of index(=%i) > ndim(=%i) with :rest",
703
692
  argc,na_ndim);
704
693
  break;
694
+ default:
695
+ rb_raise(rb_eIndexError,"multiple rest-dimension is not allowd");
705
696
  }
706
697
  return -1;
707
698
  }
@@ -712,7 +703,6 @@ na_get_result_dimension(VALUE self, int argc, VALUE *argv, ssize_t stride, size_
712
703
  int i, j;
713
704
  int count_new=0;
714
705
  int count_rest=0;
715
- int count_else=0;
716
706
  ssize_t x, s, m, pos, *idx;
717
707
  narray_t *na;
718
708
  narray_view_t *nv;
@@ -721,8 +711,7 @@ na_get_result_dimension(VALUE self, int argc, VALUE *argv, ssize_t stride, size_
721
711
 
722
712
  GetNArray(self,na);
723
713
  if (na->size == 0) {
724
- rb_raise(rb_eRuntimeError, "cannot get index of empty array");
725
- return -1;
714
+ rb_raise(nary_eShapeError, "cannot get element of empty array");
726
715
  }
727
716
  idx = ALLOCA_N(ssize_t, argc);
728
717
  for (i=j=0; i<argc; i++) {
@@ -745,16 +734,10 @@ na_get_result_dimension(VALUE self, int argc, VALUE *argv, ssize_t stride, size_
745
734
  argv[i] = sym_new;
746
735
  count_new++;
747
736
  }
748
- // not break
749
- default:
750
- count_else++;
751
737
  }
752
738
  }
753
739
 
754
- if (count_rest > 1) {
755
- rb_raise(rb_eIndexError,"multiple rest-dimension is not allowd");
756
- }
757
- if (count_else != 0) {
740
+ if (j != argc) {
758
741
  return check_index_count(argc, na->ndim, count_new, count_rest);
759
742
  }
760
743
 
@@ -773,8 +756,9 @@ na_get_result_dimension(VALUE self, int argc, VALUE *argv, ssize_t stride, size_
773
756
  }
774
757
  }
775
758
  *pos_idx = pos;
759
+ return 0;
776
760
  }
777
- else if (argc==1 && j==1) {
761
+ if (j == 1) {
778
762
  x = na_range_check(idx[0], na->size, 0);
779
763
  for (i=na->ndim-1; i>=0; i--) {
780
764
  s = na->shape[i];
@@ -788,19 +772,19 @@ na_get_result_dimension(VALUE self, int argc, VALUE *argv, ssize_t stride, size_
788
772
  }
789
773
  }
790
774
  *pos_idx = pos;
791
- } else {
792
- return check_index_count(argc, na->ndim, count_new, count_rest);
775
+ return 0;
793
776
  }
794
777
  break;
795
778
  default:
796
779
  if (!stride) {
797
780
  stride = nary_element_stride(self);
798
781
  }
799
- if (argc==1 && j==1) {
782
+ if (j == 1) {
800
783
  x = na_range_check(idx[0], na->size, 0);
801
784
  *pos_idx = stride * x;
785
+ return 0;
802
786
  }
803
- else if (j == na->ndim) {
787
+ if (j == na->ndim) {
804
788
  pos = 0;
805
789
  for (i=j-1; i>=0; i--) {
806
790
  x = na_range_check(idx[i], na->shape[i], i);
@@ -808,11 +792,54 @@ na_get_result_dimension(VALUE self, int argc, VALUE *argv, ssize_t stride, size_
808
792
  stride *= na->shape[i];
809
793
  }
810
794
  *pos_idx = pos;
811
- } else {
812
- return check_index_count(argc, na->ndim, count_new, count_rest);
795
+ return 0;
796
+ }
797
+ }
798
+ rb_raise(rb_eIndexError,"# of index(=%i) should be "
799
+ "equal to ndim(=%i) or 1", argc,na->ndim);
800
+ return -1;
801
+ }
802
+
803
+
804
+ static int
805
+ na_get_result_dimension_for_slice(VALUE self, int argc, VALUE *argv)
806
+ {
807
+ int i;
808
+ int count_new=0;
809
+ int count_rest=0;
810
+ narray_t *na;
811
+ VALUE a;
812
+
813
+ GetNArray(self,na);
814
+ if (na->size == 0) {
815
+ rb_raise(nary_eShapeError, "cannot get element of empty array");
816
+ }
817
+ for (i=0; i<argc; i++) {
818
+ a = argv[i];
819
+ switch(TYPE(a)) {
820
+ case T_FALSE:
821
+ case T_SYMBOL:
822
+ if (a==sym_rest || a==sym_tilde || a==Qfalse) {
823
+ argv[i] = Qfalse;
824
+ count_rest++;
825
+ } else if (a==sym_new || a==sym_minus) {
826
+ argv[i] = sym_new;
827
+ count_new++;
828
+ }
813
829
  }
814
830
  }
815
- return 0;
831
+
832
+ return check_index_count(argc, na->ndim, count_new, count_rest);
833
+ }
834
+
835
+
836
+ /* method: slice(idx1,idx2,...,idxN) */
837
+ static VALUE na_slice(int argc, VALUE *argv, VALUE self)
838
+ {
839
+ int nd;
840
+
841
+ nd = na_get_result_dimension_for_slice(self, argc, argv);
842
+ return na_aref_main(argc, argv, self, 1, nd);
816
843
  }
817
844
 
818
845
 
@@ -14,7 +14,7 @@ static ID id_UPCAST;
14
14
  static ID id_DISPATCH;
15
15
  static ID id_extract;
16
16
 
17
- VALUE
17
+ static VALUE
18
18
  nary_type_s_upcast(VALUE type1, VALUE type2)
19
19
  {
20
20
  VALUE upcast_hash;
@@ -35,7 +35,7 @@ nary_type_s_upcast(VALUE type1, VALUE type2)
35
35
  }
36
36
 
37
37
 
38
- VALUE nary_math_cast2(VALUE type1, VALUE type2)
38
+ static VALUE nary_math_cast2(VALUE type1, VALUE type2)
39
39
  {
40
40
  if ( RTEST(rb_class_inherited_p( type1, cNArray )) ){
41
41
  return nary_type_s_upcast( type1, type2 );
@@ -57,7 +57,7 @@ VALUE nary_math_cast2(VALUE type1, VALUE type2)
57
57
 
58
58
  VALUE na_ary_composition_dtype(VALUE);
59
59
 
60
- VALUE nary_mathcast(int argc, VALUE *argv)
60
+ static VALUE nary_mathcast(int argc, VALUE *argv)
61
61
  {
62
62
  VALUE type, type2;
63
63
  int i;
@@ -82,7 +82,7 @@ VALUE nary_mathcast(int argc, VALUE *argv)
82
82
  @param [NArray,Numeric] x input array.
83
83
  @return [NArray] result.
84
84
  */
85
- VALUE nary_math_method_missing(int argc, VALUE *argv, VALUE mod)
85
+ static VALUE nary_math_method_missing(int argc, VALUE *argv, VALUE mod)
86
86
  {
87
87
  VALUE type, ans, typemod, hash;
88
88
  if (argc>1) {
@@ -132,7 +132,7 @@ nary_debug_info(VALUE self)
132
132
  narray_t *na;
133
133
  GetNArray(self,na);
134
134
 
135
- printf("%s:\n",rb_class2name(CLASS_OF(self)));
135
+ printf("%s:\n",rb_class2name(rb_obj_class(self)));
136
136
  printf(" id = 0x%"PRI_VALUE_PREFIX"x\n", self);
137
137
  printf(" type = %d\n", na->type);
138
138
  printf(" flag = [%d,%d]\n", na->flag[0], na->flag[1]);
@@ -728,6 +728,38 @@ na_empty_p(VALUE self)
728
728
  }
729
729
 
730
730
 
731
+ /*
732
+ Release memory for array data. Ignored for NArray-view.
733
+ This method is useful to free memory of referenced (i.e., GC does not work)
734
+ but unused NArray object.
735
+ @overload free
736
+ */
737
+ static VALUE
738
+ na_free(VALUE self)
739
+ {
740
+ narray_t *na;
741
+ char *ptr;
742
+
743
+ GetNArray(self,na);
744
+
745
+ switch(NA_TYPE(na)) {
746
+ case NARRAY_DATA_T:
747
+ ptr = NA_DATA_PTR(na);
748
+ if (ptr != NULL) {
749
+ NA_DATA_PTR(na) = NULL;
750
+ xfree(ptr);
751
+ }
752
+ break;
753
+ case NARRAY_VIEW_T:
754
+ break;
755
+ case NARRAY_FILEMAP_T:
756
+ default:
757
+ rb_bug("invalid narray type : %d",NA_TYPE(na));
758
+ }
759
+ return self;
760
+ }
761
+
762
+
731
763
  /* method: shape() -- returns shape, array of the size of dimensions */
732
764
  static VALUE
733
765
  na_shape(VALUE self)
@@ -912,7 +944,7 @@ na_make_view(VALUE self)
912
944
  GetNArray(self,na);
913
945
  nd = na->ndim;
914
946
 
915
- view = na_s_allocate_view(CLASS_OF(self));
947
+ view = na_s_allocate_view(rb_obj_class(self));
916
948
 
917
949
  na_copy_flags(self, view);
918
950
  GetNArrayView(view, na2);
@@ -965,7 +997,7 @@ na_make_view(VALUE self)
965
997
  * @param [Integer] dim dimension at which new axis is inserted.
966
998
  * @return [Numo::NArray] result narray view.
967
999
  */
968
- VALUE
1000
+ static VALUE
969
1001
  na_expand_dims(VALUE self, VALUE vdim)
970
1002
  {
971
1003
  int i, j, nd, dim;
@@ -1024,7 +1056,7 @@ na_expand_dims(VALUE self, VALUE vdim)
1024
1056
  *
1025
1057
  * Return reversed view along specified dimeinsion
1026
1058
  */
1027
- VALUE
1059
+ static VALUE
1028
1060
  nary_reverse(int argc, VALUE *argv, VALUE self)
1029
1061
  {
1030
1062
  int i, nd;
@@ -1043,7 +1075,7 @@ nary_reverse(int argc, VALUE *argv, VALUE self)
1043
1075
  GetNArray(self,na);
1044
1076
  nd = na->ndim;
1045
1077
 
1046
- view = na_s_allocate_view(CLASS_OF(self));
1078
+ view = na_s_allocate_view(rb_obj_class(self));
1047
1079
 
1048
1080
  na_copy_flags(self, view);
1049
1081
  GetNArrayView(view, na2);
@@ -1143,7 +1175,7 @@ nary_coerce(VALUE x, VALUE y)
1143
1175
  {
1144
1176
  VALUE type;
1145
1177
 
1146
- type = numo_na_upcast(CLASS_OF(x), CLASS_OF(y));
1178
+ type = numo_na_upcast(rb_obj_class(x), rb_obj_class(y));
1147
1179
  y = rb_funcall(type,id_cast,1,y);
1148
1180
  return rb_assoc_new(y , x);
1149
1181
  }
@@ -1160,7 +1192,7 @@ nary_byte_size(VALUE self)
1160
1192
  narray_t *na;
1161
1193
 
1162
1194
  GetNArray(self,na);
1163
- velmsz = rb_const_get(CLASS_OF(self), id_element_byte_size);
1195
+ velmsz = rb_const_get(rb_obj_class(self), id_element_byte_size);
1164
1196
  if (FIXNUM_P(velmsz)) {
1165
1197
  return SIZET2NUM(NUM2SIZET(velmsz) * na->size);
1166
1198
  }
@@ -1283,7 +1315,7 @@ nary_store_binary(int argc, VALUE *argv, VALUE self)
1283
1315
 
1284
1316
  GetNArray(self,na);
1285
1317
  size = NA_SIZE(na);
1286
- velmsz = rb_const_get(CLASS_OF(self), id_element_byte_size);
1318
+ velmsz = rb_const_get(rb_obj_class(self), id_element_byte_size);
1287
1319
  if (FIXNUM_P(velmsz)) {
1288
1320
  byte_size = size * NUM2SIZET(velmsz);
1289
1321
  } else {
@@ -1341,7 +1373,7 @@ nary_marshal_dump(VALUE self)
1341
1373
  rb_ary_push(a, INT2FIX(1)); // version
1342
1374
  rb_ary_push(a, na_shape(self));
1343
1375
  rb_ary_push(a, INT2FIX(NA_FLAG0(self)));
1344
- if (CLASS_OF(self) == numo_cRObject) {
1376
+ if (rb_obj_class(self) == numo_cRObject) {
1345
1377
  narray_t *na;
1346
1378
  VALUE *ptr;
1347
1379
  size_t offset=0;
@@ -1362,7 +1394,7 @@ nary_marshal_dump(VALUE self)
1362
1394
  return a;
1363
1395
  }
1364
1396
 
1365
- VALUE na_inplace( VALUE self );
1397
+ static VALUE na_inplace( VALUE self );
1366
1398
  /*
1367
1399
  Load marshal data.
1368
1400
  @overload marshal_load(data)
@@ -1387,7 +1419,7 @@ nary_marshal_load(VALUE self, VALUE a)
1387
1419
  na_initialize(self,RARRAY_AREF(a,1));
1388
1420
  NA_FL0_SET(self,FIX2INT(RARRAY_AREF(a,2)));
1389
1421
  v = RARRAY_AREF(a,3);
1390
- if (CLASS_OF(self) == numo_cRObject) {
1422
+ if (rb_obj_class(self) == numo_cRObject) {
1391
1423
  narray_t *na;
1392
1424
  char *ptr;
1393
1425
  if (TYPE(v) != T_ARRAY) {
@@ -1609,7 +1641,7 @@ nary_reduce_dimension(int argc, VALUE *argv, int naryc, VALUE *naryv,
1609
1641
  /*
1610
1642
  Return true if column major.
1611
1643
  */
1612
- VALUE na_column_major_p( VALUE self )
1644
+ static VALUE na_column_major_p( VALUE self )
1613
1645
  {
1614
1646
  if (TEST_COLUMN_MAJOR(self))
1615
1647
  return Qtrue;
@@ -1620,7 +1652,7 @@ VALUE na_column_major_p( VALUE self )
1620
1652
  /*
1621
1653
  Return true if row major.
1622
1654
  */
1623
- VALUE na_row_major_p( VALUE self )
1655
+ static VALUE na_row_major_p( VALUE self )
1624
1656
  {
1625
1657
  if (TEST_ROW_MAJOR(self))
1626
1658
  return Qtrue;
@@ -1632,7 +1664,7 @@ VALUE na_row_major_p( VALUE self )
1632
1664
  /*
1633
1665
  Return true if byte swapped.
1634
1666
  */
1635
- VALUE na_byte_swapped_p( VALUE self )
1667
+ static VALUE na_byte_swapped_p( VALUE self )
1636
1668
  {
1637
1669
  if (TEST_BYTE_SWAPPED(self))
1638
1670
  return Qtrue;
@@ -1642,7 +1674,7 @@ VALUE na_byte_swapped_p( VALUE self )
1642
1674
  /*
1643
1675
  Return true if not byte swapped.
1644
1676
  */
1645
- VALUE na_host_order_p( VALUE self )
1677
+ static VALUE na_host_order_p( VALUE self )
1646
1678
  {
1647
1679
  if (TEST_BYTE_SWAPPED(self))
1648
1680
  return Qfalse;
@@ -1654,7 +1686,7 @@ VALUE na_host_order_p( VALUE self )
1654
1686
  Returns view of narray with inplace flagged.
1655
1687
  @return [Numo::NArray] view of narray with inplace flag.
1656
1688
  */
1657
- VALUE na_inplace( VALUE self )
1689
+ static VALUE na_inplace( VALUE self )
1658
1690
  {
1659
1691
  VALUE view = self;
1660
1692
  view = na_make_view(self);
@@ -1666,24 +1698,16 @@ VALUE na_inplace( VALUE self )
1666
1698
  Set inplace flag to self.
1667
1699
  @return [Numo::NArray] self
1668
1700
  */
1669
- VALUE na_inplace_bang( VALUE self )
1701
+ static VALUE na_inplace_bang( VALUE self )
1670
1702
  {
1671
1703
  SET_INPLACE(self);
1672
1704
  return self;
1673
1705
  }
1674
1706
 
1675
- VALUE na_inplace_store( VALUE self, VALUE val )
1676
- {
1677
- if (self==val)
1678
- return self;
1679
- else
1680
- return na_store( self, val );
1681
- }
1682
-
1683
1707
  /*
1684
1708
  Return true if inplace flagged.
1685
1709
  */
1686
- VALUE na_inplace_p( VALUE self )
1710
+ static VALUE na_inplace_p( VALUE self )
1687
1711
  {
1688
1712
  if (TEST_INPLACE(self))
1689
1713
  return Qtrue;
@@ -1695,7 +1719,7 @@ VALUE na_inplace_p( VALUE self )
1695
1719
  Unset inplace flag to self.
1696
1720
  @return [Numo::NArray] self
1697
1721
  */
1698
- VALUE na_out_of_place_bang( VALUE self )
1722
+ static VALUE na_out_of_place_bang( VALUE self )
1699
1723
  {
1700
1724
  UNSET_INPLACE(self);
1701
1725
  return self;
@@ -1791,7 +1815,7 @@ static VALUE na_inspect_cols_set(VALUE mod, VALUE num)
1791
1815
  @param [Object] other
1792
1816
  @return [Boolean] true if self and other is equal.
1793
1817
  */
1794
- VALUE
1818
+ static VALUE
1795
1819
  na_equal(VALUE self, volatile VALUE other)
1796
1820
  {
1797
1821
  volatile VALUE vbool;
@@ -1801,7 +1825,7 @@ na_equal(VALUE self, volatile VALUE other)
1801
1825
  GetNArray(self,na1);
1802
1826
 
1803
1827
  if (!rb_obj_is_kind_of(other,cNArray)) {
1804
- other = rb_funcall(CLASS_OF(self), id_cast, 1, other);
1828
+ other = rb_funcall(rb_obj_class(self), id_cast, 1, other);
1805
1829
  }
1806
1830
 
1807
1831
  GetNArray(other,na2);
@@ -1875,6 +1899,7 @@ Init_narray()
1875
1899
  rb_define_method(cNArray, "ndim", na_ndim,0);
1876
1900
  rb_define_alias (cNArray, "rank","ndim");
1877
1901
  rb_define_method(cNArray, "empty?", na_empty_p, 0);
1902
+ rb_define_method(cNArray, "free", na_free, 0);
1878
1903
 
1879
1904
  rb_define_method(cNArray, "debug_info", nary_debug_info, 0);
1880
1905