nmatrix 0.1.0.rc4 → 0.1.0.rc5

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.
@@ -362,7 +362,7 @@ public:
362
362
  */
363
363
  void insert(SLICE* slice, VALUE right) {
364
364
 
365
- NM_CONSERVATIVE(nm_register_value(right));
365
+ NM_CONSERVATIVE(nm_register_value(&right));
366
366
 
367
367
  std::pair<NMATRIX*,bool> nm_and_free =
368
368
  interpret_arg_as_dense_nmatrix(right, dtype());
@@ -410,7 +410,7 @@ public:
410
410
  }
411
411
  } else NM_FREE(v);
412
412
 
413
- NM_CONSERVATIVE(nm_unregister_value(right));
413
+ NM_CONSERVATIVE(nm_unregister_value(&right));
414
414
  }
415
415
 
416
416
 
@@ -843,11 +843,11 @@ public:
843
843
  */
844
844
  template <typename E>
845
845
  VALUE map_merged_stored(VALUE klass, nm::YaleStorage<E>& t, VALUE r_init) const {
846
- nm_register_value(r_init);
846
+ nm_register_value(&r_init);
847
847
  VALUE s_init = const_default_value(),
848
848
  t_init = t.const_default_value();
849
- nm_register_value(s_init);
850
- nm_register_value(t_init);
849
+ nm_register_value(&s_init);
850
+ nm_register_value(&t_init);
851
851
 
852
852
  // Make a reasonable approximation of the resulting capacity
853
853
  size_t s_ndnz = count_copy_ndnz(),
@@ -861,9 +861,9 @@ public:
861
861
  YALE_STORAGE* rs= YaleStorage<nm::RubyObject>::create(xshape, reserve);
862
862
 
863
863
  if (r_init == Qnil) {
864
- nm_unregister_value(r_init);
864
+ nm_unregister_value(&r_init);
865
865
  r_init = rb_yield_values(2, s_init, t_init);
866
- nm_register_value(r_init);
866
+ nm_register_value(&r_init);
867
867
  }
868
868
 
869
869
  nm::RubyObject r_init_obj(r_init);
@@ -874,13 +874,13 @@ public:
874
874
  nm_register_nmatrix(m);
875
875
  VALUE result = Data_Wrap_Struct(klass, nm_mark, nm_delete, m);
876
876
  nm_unregister_nmatrix(m);
877
- nm_register_value(result);
878
- nm_unregister_value(r_init);
877
+ nm_register_value(&result);
878
+ nm_unregister_value(&r_init);
879
879
 
880
880
  RETURN_SIZED_ENUMERATOR_PRE
881
- nm_unregister_value(result);
882
- nm_unregister_value(t_init);
883
- nm_unregister_value(s_init);
881
+ nm_unregister_value(&result);
882
+ nm_unregister_value(&t_init);
883
+ nm_unregister_value(&s_init);
884
884
  // No obvious, efficient way to pass a length function as the fourth argument here:
885
885
  RETURN_SIZED_ENUMERATOR(result, 0, 0, 0);
886
886
 
@@ -924,9 +924,9 @@ public:
924
924
  //RB_P(rb_funcall(result, rb_intern("yale_ija"), 0));
925
925
  }
926
926
  }
927
- nm_unregister_value(result);
928
- nm_unregister_value(t_init);
929
- nm_unregister_value(s_init);
927
+ nm_unregister_value(&result);
928
+ nm_unregister_value(&t_init);
929
+ nm_unregister_value(&s_init);
930
930
 
931
931
  return result;
932
932
  }
@@ -891,13 +891,13 @@ public:
891
891
  // Helper function used only for the RETURN_SIZED_ENUMERATOR macro. Returns the length of
892
892
  // the matrix's storage.
893
893
  static VALUE nm_yale_stored_enumerator_length(VALUE nmatrix) {
894
- NM_CONSERVATIVE(nm_register_value(nmatrix));
894
+ NM_CONSERVATIVE(nm_register_value(&nmatrix));
895
895
  YALE_STORAGE* s = NM_STORAGE_YALE(nmatrix);
896
896
  YALE_STORAGE* src = s->src == s ? s : reinterpret_cast<YALE_STORAGE*>(s->src);
897
897
  size_t ia_size = src->shape[0];
898
898
  // FIXME: This needs to be corrected for slicing.
899
899
  size_t len = std::min( s->shape[0] + s->offset[0], s->shape[1] + s->offset[1] ) + nm_yale_storage_get_size(src) - ia_size;
900
- NM_CONSERVATIVE(nm_unregister_value(nmatrix));
900
+ NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
901
901
  return INT2FIX(len);
902
902
  }
903
903
 
@@ -905,32 +905,32 @@ static VALUE nm_yale_stored_enumerator_length(VALUE nmatrix) {
905
905
  // Helper function used only for the RETURN_SIZED_ENUMERATOR macro. Returns the length of
906
906
  // the matrix's storage.
907
907
  static VALUE nm_yale_stored_nondiagonal_enumerator_length(VALUE nmatrix) {
908
- NM_CONSERVATIVE(nm_register_value(nmatrix));
908
+ NM_CONSERVATIVE(nm_register_value(&nmatrix));
909
909
  YALE_STORAGE* s = NM_STORAGE_YALE(nmatrix);
910
910
  if (s->src != s) s = reinterpret_cast<YALE_STORAGE*>(s->src); // need to get the original storage shape
911
911
 
912
912
  size_t ia_size = s->shape[0];
913
913
  size_t len = nm_yale_storage_get_size(NM_STORAGE_YALE(nmatrix)) - ia_size;
914
- NM_CONSERVATIVE(nm_unregister_value(nmatrix));
914
+ NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
915
915
  return INT2FIX(len);
916
916
  }
917
917
 
918
918
  // Helper function for diagonal length.
919
919
  static VALUE nm_yale_stored_diagonal_enumerator_length(VALUE nmatrix) {
920
- NM_CONSERVATIVE(nm_register_value(nmatrix));
920
+ NM_CONSERVATIVE(nm_register_value(&nmatrix));
921
921
  YALE_STORAGE* s = NM_STORAGE_YALE(nmatrix);
922
922
  size_t len = std::min( s->shape[0] + s->offset[0], s->shape[1] + s->offset[1] );
923
- NM_CONSERVATIVE(nm_unregister_value(nmatrix));
923
+ NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
924
924
  return INT2FIX(len);
925
925
  }
926
926
 
927
927
 
928
928
  // Helper function for full enumerator length.
929
929
  static VALUE nm_yale_enumerator_length(VALUE nmatrix) {
930
- NM_CONSERVATIVE(nm_register_value(nmatrix));
930
+ NM_CONSERVATIVE(nm_register_value(&nmatrix));
931
931
  YALE_STORAGE* s = NM_STORAGE_YALE(nmatrix);
932
932
  size_t len = s->shape[0] * s->shape[1];
933
- NM_CONSERVATIVE(nm_unregister_value(nmatrix));
933
+ NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
934
934
  return INT2FIX(len);
935
935
  }
936
936
 
@@ -940,12 +940,12 @@ static VALUE nm_yale_enumerator_length(VALUE nmatrix) {
940
940
  */
941
941
  template <typename D>
942
942
  static VALUE map_stored(VALUE self) {
943
- NM_CONSERVATIVE(nm_register_value(self));
943
+ NM_CONSERVATIVE(nm_register_value(&self));
944
944
  YALE_STORAGE* s = NM_STORAGE_YALE(self);
945
945
  YaleStorage<D> y(s);
946
946
 
947
947
  RETURN_SIZED_ENUMERATOR_PRE
948
- NM_CONSERVATIVE(nm_unregister_value(self));
948
+ NM_CONSERVATIVE(nm_unregister_value(&self));
949
949
  RETURN_SIZED_ENUMERATOR(self, 0, 0, nm_yale_stored_enumerator_length);
950
950
 
951
951
  YALE_STORAGE* r = y.template alloc_copy<nm::RubyObject, true>();
@@ -953,7 +953,7 @@ static VALUE map_stored(VALUE self) {
953
953
  NMATRIX* m = nm_create(nm::YALE_STORE, reinterpret_cast<STORAGE*>(r));
954
954
  VALUE to_return = Data_Wrap_Struct(CLASS_OF(self), nm_mark, nm_delete, m);
955
955
  nm_yale_storage_unregister(r);
956
- NM_CONSERVATIVE(nm_unregister_value(self));
956
+ NM_CONSERVATIVE(nm_unregister_value(&self));
957
957
  return to_return;
958
958
  }
959
959
 
@@ -975,13 +975,13 @@ static VALUE map_merged_stored(VALUE left, VALUE right, VALUE init) {
975
975
  */
976
976
  template <typename DType>
977
977
  static VALUE each_stored_with_indices(VALUE nm) {
978
- NM_CONSERVATIVE(nm_register_value(nm));
978
+ NM_CONSERVATIVE(nm_register_value(&nm));
979
979
  YALE_STORAGE* s = NM_STORAGE_YALE(nm);
980
980
  YaleStorage<DType> y(s);
981
981
 
982
982
  // If we don't have a block, return an enumerator.
983
983
  RETURN_SIZED_ENUMERATOR_PRE
984
- NM_CONSERVATIVE(nm_unregister_value(nm));
984
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
985
985
  RETURN_SIZED_ENUMERATOR(nm, 0, 0, nm_yale_stored_enumerator_length);
986
986
 
987
987
  for (typename YaleStorage<DType>::const_stored_diagonal_iterator d = y.csdbegin(); d != y.csdend(); ++d) {
@@ -994,7 +994,7 @@ static VALUE each_stored_with_indices(VALUE nm) {
994
994
  }
995
995
  }
996
996
 
997
- NM_CONSERVATIVE(nm_unregister_value(nm));
997
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
998
998
 
999
999
  return nm;
1000
1000
  }
@@ -1005,21 +1005,21 @@ static VALUE each_stored_with_indices(VALUE nm) {
1005
1005
  */
1006
1006
  template <typename DType>
1007
1007
  static VALUE stored_diagonal_each_with_indices(VALUE nm) {
1008
- NM_CONSERVATIVE(nm_register_value(nm));
1008
+ NM_CONSERVATIVE(nm_register_value(&nm));
1009
1009
 
1010
1010
  YALE_STORAGE* s = NM_STORAGE_YALE(nm);
1011
1011
  YaleStorage<DType> y(s);
1012
1012
 
1013
1013
  // If we don't have a block, return an enumerator.
1014
1014
  RETURN_SIZED_ENUMERATOR_PRE
1015
- NM_CONSERVATIVE(nm_unregister_value(nm));
1015
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1016
1016
  RETURN_SIZED_ENUMERATOR(nm, 0, 0, nm_yale_stored_diagonal_length); // FIXME: need diagonal length
1017
1017
 
1018
1018
  for (typename YaleStorage<DType>::const_stored_diagonal_iterator d = y.csdbegin(); d != y.csdend(); ++d) {
1019
1019
  rb_yield_values(3, ~d, d.rb_i(), d.rb_j());
1020
1020
  }
1021
1021
 
1022
- NM_CONSERVATIVE(nm_unregister_value(nm));
1022
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1023
1023
 
1024
1024
  return nm;
1025
1025
  }
@@ -1030,14 +1030,14 @@ static VALUE stored_diagonal_each_with_indices(VALUE nm) {
1030
1030
  */
1031
1031
  template <typename DType>
1032
1032
  static VALUE stored_nondiagonal_each_with_indices(VALUE nm) {
1033
- NM_CONSERVATIVE(nm_register_value(nm));
1033
+ NM_CONSERVATIVE(nm_register_value(&nm));
1034
1034
 
1035
1035
  YALE_STORAGE* s = NM_STORAGE_YALE(nm);
1036
1036
  YaleStorage<DType> y(s);
1037
1037
 
1038
1038
  // If we don't have a block, return an enumerator.
1039
1039
  RETURN_SIZED_ENUMERATOR_PRE
1040
- NM_CONSERVATIVE(nm_unregister_value(nm));
1040
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1041
1041
  RETURN_SIZED_ENUMERATOR(nm, 0, 0, 0); // FIXME: need diagonal length
1042
1042
 
1043
1043
  for (typename YaleStorage<DType>::const_row_iterator it = y.cribegin(); it != y.criend(); ++it) {
@@ -1046,7 +1046,7 @@ static VALUE stored_nondiagonal_each_with_indices(VALUE nm) {
1046
1046
  }
1047
1047
  }
1048
1048
 
1049
- NM_CONSERVATIVE(nm_unregister_value(nm));
1049
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1050
1050
 
1051
1051
  return nm;
1052
1052
  }
@@ -1057,14 +1057,14 @@ static VALUE stored_nondiagonal_each_with_indices(VALUE nm) {
1057
1057
  */
1058
1058
  template <typename DType>
1059
1059
  static VALUE each_ordered_stored_with_indices(VALUE nm) {
1060
- NM_CONSERVATIVE(nm_register_value(nm));
1060
+ NM_CONSERVATIVE(nm_register_value(&nm));
1061
1061
 
1062
1062
  YALE_STORAGE* s = NM_STORAGE_YALE(nm);
1063
1063
  YaleStorage<DType> y(s);
1064
1064
 
1065
1065
  // If we don't have a block, return an enumerator.
1066
1066
  RETURN_SIZED_ENUMERATOR_PRE
1067
- NM_CONSERVATIVE(nm_unregister_value(nm));
1067
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1068
1068
  RETURN_SIZED_ENUMERATOR(nm, 0, 0, nm_yale_stored_enumerator_length);
1069
1069
 
1070
1070
  for (typename YaleStorage<DType>::const_row_iterator it = y.cribegin(); it != y.criend(); ++it) {
@@ -1073,7 +1073,7 @@ static VALUE each_ordered_stored_with_indices(VALUE nm) {
1073
1073
  }
1074
1074
  }
1075
1075
 
1076
- NM_CONSERVATIVE(nm_unregister_value(nm));
1076
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1077
1077
 
1078
1078
  return nm;
1079
1079
  }
@@ -1081,21 +1081,21 @@ static VALUE each_ordered_stored_with_indices(VALUE nm) {
1081
1081
 
1082
1082
  template <typename DType>
1083
1083
  static VALUE each_with_indices(VALUE nm) {
1084
- NM_CONSERVATIVE(nm_register_value(nm));
1084
+ NM_CONSERVATIVE(nm_register_value(&nm));
1085
1085
 
1086
1086
  YALE_STORAGE* s = NM_STORAGE_YALE(nm);
1087
1087
  YaleStorage<DType> y(s);
1088
1088
 
1089
1089
  // If we don't have a block, return an enumerator.
1090
1090
  RETURN_SIZED_ENUMERATOR_PRE
1091
- NM_CONSERVATIVE(nm_unregister_value(nm));
1091
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1092
1092
  RETURN_SIZED_ENUMERATOR(nm, 0, 0, nm_yale_enumerator_length);
1093
1093
 
1094
1094
  for (typename YaleStorage<DType>::const_iterator iter = y.cbegin(); iter != y.cend(); ++iter) {
1095
1095
  rb_yield_values(3, ~iter, iter.rb_i(), iter.rb_j());
1096
1096
  }
1097
1097
 
1098
- NM_CONSERVATIVE(nm_unregister_value(nm));
1098
+ NM_CONSERVATIVE(nm_unregister_value(&nm));
1099
1099
 
1100
1100
  return nm;
1101
1101
  }
@@ -1556,12 +1556,12 @@ static bool is_pos_default_value(YALE_STORAGE* s, size_t apos) {
1556
1556
  */
1557
1557
  static VALUE nm_row_keys_intersection(VALUE m1, VALUE ii1, VALUE m2, VALUE ii2) {
1558
1558
 
1559
- NM_CONSERVATIVE(nm_register_value(m1));
1560
- NM_CONSERVATIVE(nm_register_value(m2));
1559
+ NM_CONSERVATIVE(nm_register_value(&m1));
1560
+ NM_CONSERVATIVE(nm_register_value(&m2));
1561
1561
 
1562
1562
  if (NM_SRC(m1) != NM_STORAGE(m1) || NM_SRC(m2) != NM_STORAGE(m2)) {
1563
- NM_CONSERVATIVE(nm_unregister_value(m2));
1564
- NM_CONSERVATIVE(nm_unregister_value(m1));
1563
+ NM_CONSERVATIVE(nm_unregister_value(&m2));
1564
+ NM_CONSERVATIVE(nm_unregister_value(&m1));
1565
1565
  rb_raise(rb_eNotImpError, "must be called on a real matrix and not a slice");
1566
1566
  }
1567
1567
 
@@ -1586,7 +1586,7 @@ static VALUE nm_row_keys_intersection(VALUE m1, VALUE ii1, VALUE m2, VALUE ii2)
1586
1586
 
1587
1587
  // Reserve max(diff1,diff2) space -- that's the max intersection possible.
1588
1588
  VALUE ret = rb_ary_new2(std::max(diff1,diff2)+1);
1589
- nm_register_value(ret);
1589
+ nm_register_value(&ret);
1590
1590
 
1591
1591
  // Handle once the special case where both have the diagonal in exactly
1592
1592
  // the same place.
@@ -1628,9 +1628,9 @@ static VALUE nm_row_keys_intersection(VALUE m1, VALUE ii1, VALUE m2, VALUE ii2)
1628
1628
  if (t->ija[idx2] == i1) rb_ary_push(ret, INT2FIX(i1));
1629
1629
  }
1630
1630
 
1631
- nm_unregister_value(ret);
1632
- NM_CONSERVATIVE(nm_unregister_value(m1));
1633
- NM_CONSERVATIVE(nm_unregister_value(m2));
1631
+ nm_unregister_value(&ret);
1632
+ NM_CONSERVATIVE(nm_unregister_value(&m1));
1633
+ NM_CONSERVATIVE(nm_unregister_value(&m2));
1634
1634
 
1635
1635
  return ret;
1636
1636
  }
@@ -1644,11 +1644,11 @@ static VALUE nm_row_keys_intersection(VALUE m1, VALUE ii1, VALUE m2, VALUE ii2)
1644
1644
  * Get the A array of a Yale matrix (which stores the diagonal and the LU portions of the matrix).
1645
1645
  */
1646
1646
  static VALUE nm_a(int argc, VALUE* argv, VALUE self) {
1647
- NM_CONSERVATIVE(nm_register_value(self));
1647
+ NM_CONSERVATIVE(nm_register_value(&self));
1648
1648
 
1649
1649
  VALUE idx;
1650
1650
  rb_scan_args(argc, argv, "01", &idx);
1651
- NM_CONSERVATIVE(nm_register_value(idx));
1651
+ NM_CONSERVATIVE(nm_register_value(&idx));
1652
1652
 
1653
1653
  YALE_STORAGE* s = reinterpret_cast<YALE_STORAGE*>(NM_SRC(self));
1654
1654
  size_t size = nm_yale_storage_get_size(s);
@@ -1674,13 +1674,13 @@ static VALUE nm_a(int argc, VALUE* argv, VALUE self) {
1674
1674
  rb_ary_push(ary, Qnil);
1675
1675
 
1676
1676
  nm_unregister_values(vals, size);
1677
- NM_CONSERVATIVE(nm_unregister_value(idx));
1678
- NM_CONSERVATIVE(nm_unregister_value(self));
1677
+ NM_CONSERVATIVE(nm_unregister_value(&idx));
1678
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1679
1679
  return ary;
1680
1680
  } else {
1681
1681
  size_t index = FIX2INT(idx);
1682
- NM_CONSERVATIVE(nm_unregister_value(idx));
1683
- NM_CONSERVATIVE(nm_unregister_value(self));
1682
+ NM_CONSERVATIVE(nm_unregister_value(&idx));
1683
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1684
1684
  if (index >= size) rb_raise(rb_eRangeError, "out of range");
1685
1685
  return rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype] * index, s->dtype).rval;
1686
1686
  }
@@ -1695,10 +1695,10 @@ static VALUE nm_a(int argc, VALUE* argv, VALUE self) {
1695
1695
  * Get the diagonal ("D") portion of the A array of a Yale matrix.
1696
1696
  */
1697
1697
  static VALUE nm_d(int argc, VALUE* argv, VALUE self) {
1698
- NM_CONSERVATIVE(nm_register_value(self));
1698
+ NM_CONSERVATIVE(nm_register_value(&self));
1699
1699
  VALUE idx;
1700
1700
  rb_scan_args(argc, argv, "01", &idx);
1701
- NM_CONSERVATIVE(nm_register_value(idx));
1701
+ NM_CONSERVATIVE(nm_register_value(&idx));
1702
1702
 
1703
1703
  YALE_STORAGE* s = reinterpret_cast<YALE_STORAGE*>(NM_SRC(self));
1704
1704
 
@@ -1717,14 +1717,14 @@ static VALUE nm_d(int argc, VALUE* argv, VALUE self) {
1717
1717
  }
1718
1718
  }
1719
1719
  nm_unregister_values(vals, s->shape[0]);
1720
- NM_CONSERVATIVE(nm_unregister_value(idx));
1721
- NM_CONSERVATIVE(nm_unregister_value(self));
1720
+ NM_CONSERVATIVE(nm_unregister_value(&idx));
1721
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1722
1722
 
1723
1723
  return rb_ary_new4(s->shape[0], vals);
1724
1724
  } else {
1725
1725
  size_t index = FIX2INT(idx);
1726
- NM_CONSERVATIVE(nm_unregister_value(idx));
1727
- NM_CONSERVATIVE(nm_unregister_value(self));
1726
+ NM_CONSERVATIVE(nm_unregister_value(&idx));
1727
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1728
1728
  if (index >= s->shape[0]) rb_raise(rb_eRangeError, "out of range");
1729
1729
  return rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype] * index, s->dtype).rval;
1730
1730
  }
@@ -1737,7 +1737,7 @@ static VALUE nm_d(int argc, VALUE* argv, VALUE self) {
1737
1737
  * Get the non-diagonal ("LU") portion of the A array of a Yale matrix.
1738
1738
  */
1739
1739
  static VALUE nm_lu(VALUE self) {
1740
- NM_CONSERVATIVE(nm_register_value(self));
1740
+ NM_CONSERVATIVE(nm_register_value(&self));
1741
1741
 
1742
1742
  YALE_STORAGE* s = reinterpret_cast<YALE_STORAGE*>(NM_SRC(self));
1743
1743
 
@@ -1763,7 +1763,7 @@ static VALUE nm_lu(VALUE self) {
1763
1763
  rb_ary_push(ary, Qnil);
1764
1764
 
1765
1765
  nm_unregister_values(vals, size - s->shape[0] - 1);
1766
- NM_CONSERVATIVE(nm_unregister_value(self));
1766
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1767
1767
 
1768
1768
  return ary;
1769
1769
  }
@@ -1776,7 +1776,7 @@ static VALUE nm_lu(VALUE self) {
1776
1776
  * JA and LU portions of the IJA and A arrays, respectively.
1777
1777
  */
1778
1778
  static VALUE nm_ia(VALUE self) {
1779
- NM_CONSERVATIVE(nm_register_value(self));
1779
+ NM_CONSERVATIVE(nm_register_value(&self));
1780
1780
 
1781
1781
  YALE_STORAGE* s = reinterpret_cast<YALE_STORAGE*>(NM_SRC(self));
1782
1782
 
@@ -1786,7 +1786,7 @@ static VALUE nm_ia(VALUE self) {
1786
1786
  vals[i] = INT2FIX(s->ija[i]);
1787
1787
  }
1788
1788
 
1789
- NM_CONSERVATIVE(nm_unregister_value(self));
1789
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1790
1790
 
1791
1791
  return rb_ary_new4(s->shape[0]+1, vals);
1792
1792
  }
@@ -1800,7 +1800,7 @@ static VALUE nm_ia(VALUE self) {
1800
1800
  */
1801
1801
  static VALUE nm_ja(VALUE self) {
1802
1802
 
1803
- NM_CONSERVATIVE(nm_register_value(self));
1803
+ NM_CONSERVATIVE(nm_register_value(&self));
1804
1804
 
1805
1805
  YALE_STORAGE* s = reinterpret_cast<YALE_STORAGE*>(NM_SRC(self));
1806
1806
 
@@ -1820,7 +1820,7 @@ static VALUE nm_ja(VALUE self) {
1820
1820
  rb_ary_push(ary, Qnil);
1821
1821
 
1822
1822
  nm_unregister_values(vals, size - s->shape[0] - 1);
1823
- NM_CONSERVATIVE(nm_unregister_value(self));
1823
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1824
1824
 
1825
1825
  return ary;
1826
1826
  }
@@ -1833,11 +1833,11 @@ static VALUE nm_ja(VALUE self) {
1833
1833
  * Get the IJA array of a Yale matrix (or a component of the IJA array).
1834
1834
  */
1835
1835
  static VALUE nm_ija(int argc, VALUE* argv, VALUE self) {
1836
- NM_CONSERVATIVE(nm_register_value(self));
1836
+ NM_CONSERVATIVE(nm_register_value(&self));
1837
1837
 
1838
1838
  VALUE idx;
1839
1839
  rb_scan_args(argc, argv, "01", &idx);
1840
- NM_CONSERVATIVE(nm_register_value(idx));
1840
+ NM_CONSERVATIVE(nm_register_value(&idx));
1841
1841
 
1842
1842
  YALE_STORAGE* s = reinterpret_cast<YALE_STORAGE*>(NM_SRC(self));
1843
1843
  size_t size = nm_yale_storage_get_size(s);
@@ -1858,16 +1858,16 @@ static VALUE nm_ija(int argc, VALUE* argv, VALUE self) {
1858
1858
  rb_ary_push(ary, Qnil);
1859
1859
 
1860
1860
  nm_unregister_values(vals, size);
1861
- NM_CONSERVATIVE(nm_unregister_value(idx));
1862
- NM_CONSERVATIVE(nm_unregister_value(self));
1861
+ NM_CONSERVATIVE(nm_unregister_value(&idx));
1862
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1863
1863
 
1864
1864
  return ary;
1865
1865
 
1866
1866
  } else {
1867
1867
  size_t index = FIX2INT(idx);
1868
1868
  if (index >= size) rb_raise(rb_eRangeError, "out of range");
1869
- NM_CONSERVATIVE(nm_unregister_value(self));
1870
- NM_CONSERVATIVE(nm_unregister_value(idx));
1869
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1870
+ NM_CONSERVATIVE(nm_unregister_value(&idx));
1871
1871
  return INT2FIX(s->ija[index]);
1872
1872
  }
1873
1873
  }
@@ -1886,17 +1886,17 @@ static VALUE nm_ija(int argc, VALUE* argv, VALUE self) {
1886
1886
  */
1887
1887
  static VALUE nm_nd_row(int argc, VALUE* argv, VALUE self) {
1888
1888
 
1889
- NM_CONSERVATIVE(nm_register_value(self));
1889
+ NM_CONSERVATIVE(nm_register_value(&self));
1890
1890
 
1891
1891
  if (NM_SRC(self) != NM_STORAGE(self)) {
1892
- NM_CONSERVATIVE(nm_unregister_value(self));
1892
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1893
1893
  rb_raise(rb_eNotImpError, "must be called on a real matrix and not a slice");
1894
1894
  }
1895
1895
 
1896
1896
  VALUE i_, as;
1897
1897
  rb_scan_args(argc, argv, "11", &i_, &as);
1898
- NM_CONSERVATIVE(nm_register_value(as));
1899
- NM_CONSERVATIVE(nm_register_value(i_));
1898
+ NM_CONSERVATIVE(nm_register_value(&as));
1899
+ NM_CONSERVATIVE(nm_register_value(&i_));
1900
1900
 
1901
1901
  bool keys = false;
1902
1902
  if (as != Qnil && rb_to_id(as) != nm_rb_hash) keys = true;
@@ -1907,9 +1907,9 @@ static VALUE nm_nd_row(int argc, VALUE* argv, VALUE self) {
1907
1907
  //nm::dtype_t dtype = NM_DTYPE(self);
1908
1908
 
1909
1909
  if (i >= s->shape[0]) {
1910
- NM_CONSERVATIVE(nm_unregister_value(self));
1911
- NM_CONSERVATIVE(nm_unregister_value(as));
1912
- NM_CONSERVATIVE(nm_unregister_value(i_));
1910
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1911
+ NM_CONSERVATIVE(nm_unregister_value(&as));
1912
+ NM_CONSERVATIVE(nm_unregister_value(&i_));
1913
1913
  rb_raise(rb_eRangeError, "out of range (%lu >= %lu)", i, s->shape[0]);
1914
1914
  }
1915
1915
 
@@ -1932,9 +1932,9 @@ static VALUE nm_nd_row(int argc, VALUE* argv, VALUE self) {
1932
1932
  rb_hash_aset(ret, INT2FIX(s->ija[idx]), rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*idx, s->dtype).rval);
1933
1933
  }
1934
1934
  }
1935
- NM_CONSERVATIVE(nm_unregister_value(as));
1936
- NM_CONSERVATIVE(nm_unregister_value(i_));
1937
- NM_CONSERVATIVE(nm_unregister_value(self));
1935
+ NM_CONSERVATIVE(nm_unregister_value(&as));
1936
+ NM_CONSERVATIVE(nm_unregister_value(&i_));
1937
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1938
1938
  return ret;
1939
1939
  }
1940
1940
 
@@ -1969,30 +1969,30 @@ static VALUE nm_nd_row(int argc, VALUE* argv, VALUE self) {
1969
1969
  */
1970
1970
  VALUE nm_vector_set(int argc, VALUE* argv, VALUE self) { //, VALUE i_, VALUE jv, VALUE vv, VALUE pos_) {
1971
1971
 
1972
- NM_CONSERVATIVE(nm_register_value(self));
1972
+ NM_CONSERVATIVE(nm_register_value(&self));
1973
1973
 
1974
1974
  if (NM_SRC(self) != NM_STORAGE(self)) {
1975
- NM_CONSERVATIVE(nm_unregister_value(self));
1975
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1976
1976
  rb_raise(rb_eNotImpError, "must be called on a real matrix and not a slice");
1977
1977
  }
1978
1978
 
1979
1979
  // i, jv, vv are mandatory; pos is optional; thus "31"
1980
1980
  VALUE i_, jv, vv, pos_;
1981
1981
  rb_scan_args(argc, argv, "31", &i_, &jv, &vv, &pos_);
1982
- NM_CONSERVATIVE(nm_register_value(i_));
1983
- NM_CONSERVATIVE(nm_register_value(jv));
1984
- NM_CONSERVATIVE(nm_register_value(vv));
1985
- NM_CONSERVATIVE(nm_register_value(pos_));
1982
+ NM_CONSERVATIVE(nm_register_value(&i_));
1983
+ NM_CONSERVATIVE(nm_register_value(&jv));
1984
+ NM_CONSERVATIVE(nm_register_value(&vv));
1985
+ NM_CONSERVATIVE(nm_register_value(&pos_));
1986
1986
 
1987
1987
  size_t len = RARRAY_LEN(jv); // need length in order to read the arrays in
1988
1988
  size_t vvlen = RARRAY_LEN(vv);
1989
1989
 
1990
1990
  if (len != vvlen) {
1991
- NM_CONSERVATIVE(nm_unregister_value(pos_));
1992
- NM_CONSERVATIVE(nm_unregister_value(vv));
1993
- NM_CONSERVATIVE(nm_unregister_value(jv));
1994
- NM_CONSERVATIVE(nm_unregister_value(i_));
1995
- NM_CONSERVATIVE(nm_unregister_value(self));
1991
+ NM_CONSERVATIVE(nm_unregister_value(&pos_));
1992
+ NM_CONSERVATIVE(nm_unregister_value(&vv));
1993
+ NM_CONSERVATIVE(nm_unregister_value(&jv));
1994
+ NM_CONSERVATIVE(nm_unregister_value(&i_));
1995
+ NM_CONSERVATIVE(nm_unregister_value(&self));
1996
1996
  rb_raise(rb_eArgError, "lengths must match between j array (%lu) and value array (%lu)", len, vvlen);
1997
1997
  }
1998
1998
 
@@ -2023,11 +2023,11 @@ VALUE nm_vector_set(int argc, VALUE* argv, VALUE self) { //, VALUE i_, VALUE jv,
2023
2023
  nm_unregister_values(reinterpret_cast<VALUE*>(vals), len);
2024
2024
  }
2025
2025
 
2026
- NM_CONSERVATIVE(nm_unregister_value(pos_));
2027
- NM_CONSERVATIVE(nm_unregister_value(vv));
2028
- NM_CONSERVATIVE(nm_unregister_value(jv));
2029
- NM_CONSERVATIVE(nm_unregister_value(i_));
2030
- NM_CONSERVATIVE(nm_unregister_value(self));
2026
+ NM_CONSERVATIVE(nm_unregister_value(&pos_));
2027
+ NM_CONSERVATIVE(nm_unregister_value(&vv));
2028
+ NM_CONSERVATIVE(nm_unregister_value(&jv));
2029
+ NM_CONSERVATIVE(nm_unregister_value(&i_));
2030
+ NM_CONSERVATIVE(nm_unregister_value(&self));
2031
2031
 
2032
2032
  // Return the updated position
2033
2033
  pos += len;