nmatrix 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/ext/nmatrix/data/complex.h +183 -159
  3. data/ext/nmatrix/data/data.cpp +113 -112
  4. data/ext/nmatrix/data/data.h +306 -292
  5. data/ext/nmatrix/data/ruby_object.h +193 -193
  6. data/ext/nmatrix/extconf.rb +11 -9
  7. data/ext/nmatrix/math.cpp +9 -11
  8. data/ext/nmatrix/math/math.h +3 -2
  9. data/ext/nmatrix/math/trsm.h +152 -152
  10. data/ext/nmatrix/nmatrix.h +30 -0
  11. data/ext/nmatrix/ruby_constants.cpp +67 -67
  12. data/ext/nmatrix/ruby_constants.h +35 -35
  13. data/ext/nmatrix/ruby_nmatrix.c +168 -183
  14. data/ext/nmatrix/storage/common.h +4 -3
  15. data/ext/nmatrix/storage/dense/dense.cpp +50 -50
  16. data/ext/nmatrix/storage/dense/dense.h +8 -7
  17. data/ext/nmatrix/storage/list/list.cpp +16 -16
  18. data/ext/nmatrix/storage/list/list.h +7 -6
  19. data/ext/nmatrix/storage/storage.cpp +32 -32
  20. data/ext/nmatrix/storage/storage.h +12 -11
  21. data/ext/nmatrix/storage/yale/class.h +2 -2
  22. data/ext/nmatrix/storage/yale/iterators/base.h +2 -1
  23. data/ext/nmatrix/storage/yale/iterators/iterator.h +2 -1
  24. data/ext/nmatrix/storage/yale/iterators/row.h +2 -1
  25. data/ext/nmatrix/storage/yale/iterators/row_stored.h +2 -1
  26. data/ext/nmatrix/storage/yale/iterators/row_stored_nd.h +1 -0
  27. data/ext/nmatrix/storage/yale/iterators/stored_diagonal.h +2 -1
  28. data/ext/nmatrix/storage/yale/yale.cpp +27 -27
  29. data/ext/nmatrix/storage/yale/yale.h +7 -6
  30. data/ext/nmatrix/ttable_helper.rb +10 -10
  31. data/ext/nmatrix/types.h +3 -2
  32. data/ext/nmatrix/util/io.cpp +7 -7
  33. data/ext/nmatrix/util/sl_list.cpp +26 -26
  34. data/ext/nmatrix/util/sl_list.h +19 -18
  35. data/lib/nmatrix/blas.rb +7 -7
  36. data/lib/nmatrix/io/mat5_reader.rb +30 -30
  37. data/lib/nmatrix/math.rb +73 -17
  38. data/lib/nmatrix/nmatrix.rb +10 -8
  39. data/lib/nmatrix/shortcuts.rb +3 -3
  40. data/lib/nmatrix/version.rb +3 -3
  41. data/spec/00_nmatrix_spec.rb +6 -0
  42. data/spec/math_spec.rb +77 -0
  43. data/spec/spec_helper.rb +9 -0
  44. metadata +2 -2
@@ -34,6 +34,7 @@
34
34
  * Standard Includes
35
35
  */
36
36
 
37
+ #include <ruby.h>
37
38
  #include <cstdlib>
38
39
 
39
40
  /*
@@ -53,10 +54,10 @@
53
54
  * Macros
54
55
  */
55
56
 
56
- #define NMATRIX_DTYPE_IS_COMPLEX(s) ((s->dtype == nm::COMPLEX64) or (s->dtype == nm::COMPLEX128))
57
- #define NMATRIX_DTYPE_IS_FLOAT(s) ((s->dtype == nm::FLOAT32) or (s->dtype == nm::FLOAT64))
58
- #define NMATRIX_DTYPE_IS_INTEGER(s) (s->dtype <= nm::INT64)
59
- #define NMATRIX_DTYPE_IS_RUBYOBJ(s) (s->dtype == nm::RUBYOBJ)
57
+ #define NMATRIX_DTYPE_IS_COMPLEX(s) ((s->dtype == nm::COMPLEX64) or (s->dtype == nm::COMPLEX128))
58
+ #define NMATRIX_DTYPE_IS_FLOAT(s) ((s->dtype == nm::FLOAT32) or (s->dtype == nm::FLOAT64))
59
+ #define NMATRIX_DTYPE_IS_INTEGER(s) (s->dtype <= nm::INT64)
60
+ #define NMATRIX_DTYPE_IS_RUBYOBJ(s) (s->dtype == nm::RUBYOBJ)
60
61
 
61
62
 
62
63
  /*
@@ -69,7 +70,7 @@
69
70
  */
70
71
 
71
72
  namespace nm {
72
- const int NUM_STYPES = 3;
73
+ const int NUM_STYPES = 3;
73
74
  }
74
75
 
75
76
  extern "C" {
@@ -85,12 +86,12 @@ extern "C" {
85
86
  // Copying and Casting //
86
87
  /////////////////////////
87
88
 
88
- STORAGE* nm_dense_storage_from_list(const STORAGE* right, nm::dtype_t l_dtype, void*);
89
- STORAGE* nm_dense_storage_from_yale(const STORAGE* right, nm::dtype_t l_dtype, void*);
90
- STORAGE* nm_list_storage_from_dense(const STORAGE* right, nm::dtype_t l_dtype, void*);
91
- STORAGE* nm_list_storage_from_yale(const STORAGE* right, nm::dtype_t l_dtype, void*);
92
- STORAGE* nm_yale_storage_from_list(const STORAGE* right, nm::dtype_t l_dtype, void*);
93
- STORAGE* nm_yale_storage_from_dense(const STORAGE* right, nm::dtype_t l_dtype, void*);
89
+ STORAGE* nm_dense_storage_from_list(const STORAGE* right, nm::dtype_t l_dtype, void*);
90
+ STORAGE* nm_dense_storage_from_yale(const STORAGE* right, nm::dtype_t l_dtype, void*);
91
+ STORAGE* nm_list_storage_from_dense(const STORAGE* right, nm::dtype_t l_dtype, void*);
92
+ STORAGE* nm_list_storage_from_yale(const STORAGE* right, nm::dtype_t l_dtype, void*);
93
+ STORAGE* nm_yale_storage_from_list(const STORAGE* right, nm::dtype_t l_dtype, void*);
94
+ STORAGE* nm_yale_storage_from_dense(const STORAGE* right, nm::dtype_t l_dtype, void*);
94
95
 
95
96
  } // end of extern "C" block
96
97
 
@@ -754,8 +754,8 @@ public:
754
754
  nm_yale_storage_register(lhs);
755
755
  for (size_t m = 0; m < size(); ++m) {
756
756
  if (Yield) {
757
- la[m] = rb_yield(nm::yale_storage::nm_rb_dereference(a(m)));
758
- }
757
+ la[m] = rb_yield(nm::yale_storage::nm_rb_dereference(a(m)));
758
+ }
759
759
  else la[m] = static_cast<E>(a(m));
760
760
  }
761
761
  nm_yale_storage_unregister(lhs);
@@ -29,6 +29,7 @@
29
29
  #ifndef YALE_ITERATORS_BASE_H
30
30
  # define YALE_ITERATORS_BASE_H
31
31
 
32
+ #include <ruby.h>
32
33
  #include <type_traits>
33
34
  #include <typeinfo>
34
35
  #include <stdexcept>
@@ -139,4 +140,4 @@ public:
139
140
 
140
141
  } } // end of namespace nm::yale_storage
141
142
 
142
- #endif // YALE_ITERATORS_BASE_H
143
+ #endif // YALE_ITERATORS_BASE_H
@@ -29,6 +29,7 @@
29
29
  #ifndef YALE_ITERATORS_ITERATOR_H
30
30
  # define YALE_ITERATORS_ITERATOR_H
31
31
 
32
+ #include <ruby.h>
32
33
  #include <type_traits>
33
34
  #include <typeinfo>
34
35
 
@@ -127,4 +128,4 @@ public:
127
128
 
128
129
  } } // end of namespace nm::yale_storage
129
130
 
130
- #endif // YALE_ITERATORS_ITERATOR_H
131
+ #endif // YALE_ITERATORS_ITERATOR_H
@@ -31,6 +31,7 @@
31
31
  #ifndef YALE_ITERATORS_ROW_H
32
32
  # define YALE_ITERATORS_ROW_H
33
33
 
34
+ #include <ruby.h>
34
35
  #include <stdexcept>
35
36
 
36
37
  namespace nm { namespace yale_storage {
@@ -446,4 +447,4 @@ public:
446
447
 
447
448
  } } // end of nm::yale_storage namespace
448
449
 
449
- #endif // YALE_ITERATORS_ROW_H
450
+ #endif // YALE_ITERATORS_ROW_H
@@ -34,6 +34,7 @@
34
34
  #ifndef YALE_ITERATORS_ROW_STORED_H
35
35
  # define YALE_ITERATORS_ROW_STORED_H
36
36
 
37
+ #include <ruby.h>
37
38
  #include <stdexcept>
38
39
 
39
40
  namespace nm { namespace yale_storage {
@@ -136,4 +137,4 @@ public:
136
137
 
137
138
  }} // end of namespace nm::yale_storage
138
139
 
139
- #endif // YALE_ITERATORS_ROW_STORED_H
140
+ #endif // YALE_ITERATORS_ROW_STORED_H
@@ -29,6 +29,7 @@
29
29
  #ifndef YALE_ITERATORS_ROW_STORED_ND_H
30
30
  # define YALE_ITERATORS_ROW_STORED_ND_H
31
31
 
32
+ #include <ruby.h>
32
33
  #include <type_traits>
33
34
  #include <typeinfo>
34
35
  #include <stdexcept>
@@ -29,6 +29,7 @@
29
29
  #ifndef YALE_ITERATORS_STORED_DIAGONAL_H
30
30
  # define YALE_ITERATORS_STORED_DIAGONAL_H
31
31
 
32
+ #include <ruby.h>
32
33
  #include <type_traits>
33
34
  #include <typeinfo>
34
35
 
@@ -120,4 +121,4 @@ public:
120
121
 
121
122
  } } // end of namespace nm::yale_storage
122
123
 
123
- #endif // YALE_ITERATORS_STORED_DIAGONAL_H
124
+ #endif // YALE_ITERATORS_STORED_DIAGONAL_H
@@ -85,7 +85,7 @@
85
85
  */
86
86
 
87
87
  extern "C" {
88
- static YALE_STORAGE* alloc(nm::dtype_t dtype, size_t* shape, size_t dim);
88
+ static YALE_STORAGE* alloc(nm::dtype_t dtype, size_t* shape, size_t dim);
89
89
 
90
90
  static size_t yale_count_slice_copy_ndnz(const YALE_STORAGE* s, size_t*, size_t*);
91
91
 
@@ -117,10 +117,10 @@ template <typename LD, typename RD>
117
117
  static VALUE map_merged_stored(VALUE left, VALUE right, VALUE init);
118
118
 
119
119
  template <typename DType>
120
- static bool ndrow_is_empty(const YALE_STORAGE* s, IType ija, const IType ija_next);
120
+ static bool ndrow_is_empty(const YALE_STORAGE* s, IType ija, const IType ija_next);
121
121
 
122
122
  template <typename LDType, typename RDType>
123
- static bool ndrow_eqeq_ndrow(const YALE_STORAGE* l, const YALE_STORAGE* r, IType l_ija, const IType l_ija_next, IType r_ija, const IType r_ija_next);
123
+ static bool ndrow_eqeq_ndrow(const YALE_STORAGE* l, const YALE_STORAGE* r, IType l_ija, const IType l_ija_next, IType r_ija, const IType r_ija_next);
124
124
 
125
125
  template <typename LDType, typename RDType>
126
126
  static bool eqeq(const YALE_STORAGE* left, const YALE_STORAGE* right);
@@ -128,9 +128,9 @@ static bool eqeq(const YALE_STORAGE* left, const YALE_STORAGE* right);
128
128
  template <typename LDType, typename RDType>
129
129
  static bool eqeq_different_defaults(const YALE_STORAGE* s, const LDType& s_init, const YALE_STORAGE* t, const RDType& t_init);
130
130
 
131
- static void increment_ia_after(YALE_STORAGE* s, IType ija_size, IType i, long n);
131
+ static void increment_ia_after(YALE_STORAGE* s, IType ija_size, IType i, long n);
132
132
 
133
- static IType insert_search(YALE_STORAGE* s, IType left, IType right, IType key, bool& found);
133
+ static IType insert_search(YALE_STORAGE* s, IType left, IType right, IType key, bool& found);
134
134
 
135
135
  template <typename DType>
136
136
  static char vector_insert(YALE_STORAGE* s, size_t pos, size_t* j, void* val_, size_t n, bool struct_only);
@@ -436,13 +436,13 @@ int binary_search(YALE_STORAGE* s, IType left, IType right, IType key) {
436
436
  IType mid_j = ija[mid];
437
437
 
438
438
  if (mid_j == key)
439
- return mid;
439
+ return mid;
440
440
 
441
441
  else if (mid_j > key)
442
- return binary_search(s, left, mid - 1, key);
442
+ return binary_search(s, left, mid - 1, key);
443
443
 
444
444
  else
445
- return binary_search(s, mid + 1, right, key);
445
+ return binary_search(s, mid + 1, right, key);
446
446
  }
447
447
 
448
448
 
@@ -503,7 +503,7 @@ static char vector_insert_resize(YALE_STORAGE* s, size_t current_size, size_t po
503
503
  }
504
504
 
505
505
  if (new_capacity < current_size + n)
506
- new_capacity = current_size + n;
506
+ new_capacity = current_size + n;
507
507
 
508
508
  nm_yale_storage_register(s);
509
509
 
@@ -564,8 +564,8 @@ static char vector_insert_resize(YALE_STORAGE* s, size_t current_size, size_t po
564
564
  * diag). Does not free anything; you are responsible!
565
565
  *
566
566
  * TODO: Improve this so it can handle non-contiguous element insertions
567
- * efficiently. For now, we can just sort the elements in the row in
568
- * question.)
567
+ * efficiently. For now, we can just sort the elements in the row in
568
+ * question.)
569
569
  */
570
570
  template <typename DType>
571
571
  static char vector_insert(YALE_STORAGE* s, size_t pos, size_t* j, void* val_, size_t n, bool struct_only) {
@@ -585,7 +585,7 @@ static char vector_insert(YALE_STORAGE* s, size_t pos, size_t* j, void* val_, si
585
585
  vector_insert_resize<DType>(s, size, pos, j, n, struct_only);
586
586
 
587
587
  // Need to get the new locations for ija and a.
588
- ija = s->ija;
588
+ ija = s->ija;
589
589
  a = reinterpret_cast<DType*>(s->a);
590
590
  } else {
591
591
  /*
@@ -594,7 +594,7 @@ static char vector_insert(YALE_STORAGE* s, size_t pos, size_t* j, void* val_, si
594
594
  * the end, one element at a time.
595
595
  *
596
596
  * TODO: This can be made slightly more efficient, but only after the tests
597
- * are written.
597
+ * are written.
598
598
  */
599
599
 
600
600
  if (struct_only) {
@@ -655,10 +655,10 @@ static IType insert_search(YALE_STORAGE* s, IType left, IType right, IType key,
655
655
  return mid;
656
656
 
657
657
  } else if (mid_j > key) {
658
- return insert_search(s, left, mid-1, key, found);
658
+ return insert_search(s, left, mid-1, key, found);
659
659
 
660
660
  } else {
661
- return insert_search(s, mid+1, right, key, found);
661
+ return insert_search(s, mid+1, right, key, found);
662
662
  }
663
663
  }
664
664
 
@@ -1119,10 +1119,10 @@ static bool is_pos_default_value(YALE_STORAGE* s, size_t apos) {
1119
1119
  extern "C" {
1120
1120
 
1121
1121
  void nm_init_yale_functions() {
1122
- /*
1123
- * This module stores methods that are useful for debugging Yale matrices,
1124
- * i.e. the ones with +:yale+ stype.
1125
- */
1122
+ /*
1123
+ * This module stores methods that are useful for debugging Yale matrices,
1124
+ * i.e. the ones with +:yale+ stype.
1125
+ */
1126
1126
  cNMatrix_YaleFunctions = rb_define_module_under(cNMatrix, "YaleFunctions");
1127
1127
 
1128
1128
  // Expert recommendation. Eventually this should go in a separate gem, or at least a separate module.
@@ -1336,7 +1336,7 @@ static void* default_value_ptr(const YALE_STORAGE* s) {
1336
1336
  */
1337
1337
  static VALUE obj_at(YALE_STORAGE* s, size_t k) {
1338
1338
  if (s->dtype == nm::RUBYOBJ) return reinterpret_cast<VALUE*>(((YALE_STORAGE*)(s->src))->a)[k];
1339
- else return rubyobj_from_cval(reinterpret_cast<void*>(reinterpret_cast<char*>(((YALE_STORAGE*)(s->src))->a) + k * DTYPE_SIZES[s->dtype]), s->dtype).rval;
1339
+ else return nm::rubyobj_from_cval(reinterpret_cast<void*>(reinterpret_cast<char*>(((YALE_STORAGE*)(s->src))->a) + k * DTYPE_SIZES[s->dtype]), s->dtype).rval;
1340
1340
  }
1341
1341
 
1342
1342
 
@@ -1345,7 +1345,7 @@ static VALUE obj_at(YALE_STORAGE* s, size_t k) {
1345
1345
  */
1346
1346
  static VALUE default_value(const YALE_STORAGE* s) {
1347
1347
  if (s->dtype == nm::RUBYOBJ) return *reinterpret_cast<VALUE*>(default_value_ptr(s));
1348
- else return rubyobj_from_cval(default_value_ptr(s), s->dtype).rval;
1348
+ else return nm::rubyobj_from_cval(default_value_ptr(s), s->dtype).rval;
1349
1349
  }
1350
1350
 
1351
1351
 
@@ -1664,7 +1664,7 @@ static VALUE nm_a(int argc, VALUE* argv, VALUE self) {
1664
1664
  }
1665
1665
  } else {
1666
1666
  for (size_t i = 0; i < size; ++i) {
1667
- vals[i] = rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*i, s->dtype).rval;
1667
+ vals[i] = nm::rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*i, s->dtype).rval;
1668
1668
  }
1669
1669
  }
1670
1670
  VALUE ary = rb_ary_new4(size, vals);
@@ -1681,7 +1681,7 @@ static VALUE nm_a(int argc, VALUE* argv, VALUE self) {
1681
1681
  NM_CONSERVATIVE(nm_unregister_value(&idx));
1682
1682
  NM_CONSERVATIVE(nm_unregister_value(&self));
1683
1683
  if (index >= size) rb_raise(rb_eRangeError, "out of range");
1684
- return rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype] * index, s->dtype).rval;
1684
+ return nm::rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype] * index, s->dtype).rval;
1685
1685
  }
1686
1686
  }
1687
1687
 
@@ -1712,7 +1712,7 @@ static VALUE nm_d(int argc, VALUE* argv, VALUE self) {
1712
1712
  }
1713
1713
  } else {
1714
1714
  for (size_t i = 0; i < s->shape[0]; ++i) {
1715
- vals[i] = rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*i, s->dtype).rval;
1715
+ vals[i] = nm::rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*i, s->dtype).rval;
1716
1716
  }
1717
1717
  }
1718
1718
  nm_unregister_values(vals, s->shape[0]);
@@ -1725,7 +1725,7 @@ static VALUE nm_d(int argc, VALUE* argv, VALUE self) {
1725
1725
  NM_CONSERVATIVE(nm_unregister_value(&idx));
1726
1726
  NM_CONSERVATIVE(nm_unregister_value(&self));
1727
1727
  if (index >= s->shape[0]) rb_raise(rb_eRangeError, "out of range");
1728
- return rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype] * index, s->dtype).rval;
1728
+ return nm::rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype] * index, s->dtype).rval;
1729
1729
  }
1730
1730
  }
1731
1731
 
@@ -1752,7 +1752,7 @@ static VALUE nm_lu(VALUE self) {
1752
1752
  }
1753
1753
  } else {
1754
1754
  for (size_t i = 0; i < size - s->shape[0] - 1; ++i) {
1755
- vals[i] = rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*(s->shape[0] + 1 + i), s->dtype).rval;
1755
+ vals[i] = nm::rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*(s->shape[0] + 1 + i), s->dtype).rval;
1756
1756
  }
1757
1757
  }
1758
1758
 
@@ -1927,7 +1927,7 @@ static VALUE nm_nd_row(int argc, VALUE* argv, VALUE self) {
1927
1927
  ret = rb_hash_new();
1928
1928
 
1929
1929
  for (size_t idx = pos; idx < nextpos; ++idx) {
1930
- rb_hash_aset(ret, INT2FIX(s->ija[idx]), rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*idx, s->dtype).rval);
1930
+ rb_hash_aset(ret, INT2FIX(s->ija[idx]), nm::rubyobj_from_cval((char*)(s->a) + DTYPE_SIZES[s->dtype]*idx, s->dtype).rval);
1931
1931
  }
1932
1932
  }
1933
1933
  NM_CONSERVATIVE(nm_unregister_value(&as));
@@ -42,6 +42,7 @@
42
42
  * Standard Includes
43
43
  */
44
44
 
45
+ #include <ruby.h>
45
46
  #include <limits> // for std::numeric_limits<T>::max()
46
47
  #include <stdexcept>
47
48
 
@@ -84,15 +85,15 @@ extern "C" {
84
85
 
85
86
  YALE_STORAGE* nm_yale_storage_create(nm::dtype_t dtype, size_t* shape, size_t dim, size_t init_capacity);
86
87
  YALE_STORAGE* nm_yale_storage_create_from_old_yale(nm::dtype_t dtype, size_t* shape, char* ia, char* ja, char* a, nm::dtype_t from_dtype);
87
- YALE_STORAGE* nm_yale_storage_create_merged(const YALE_STORAGE* merge_template, const YALE_STORAGE* other);
88
+ YALE_STORAGE* nm_yale_storage_create_merged(const YALE_STORAGE* merge_template, const YALE_STORAGE* other);
88
89
  void nm_yale_storage_delete(STORAGE* s);
89
90
  void nm_yale_storage_delete_ref(STORAGE* s);
90
- void nm_yale_storage_init(YALE_STORAGE* s, void* default_val);
91
- void nm_yale_storage_mark(STORAGE*);
91
+ void nm_yale_storage_init(YALE_STORAGE* s, void* default_val);
92
+ void nm_yale_storage_mark(STORAGE*);
92
93
  void nm_yale_storage_register(const STORAGE* s);
93
94
  void nm_yale_storage_unregister(const STORAGE* s);
94
- void nm_yale_storage_register_a(void* a, size_t size);
95
- void nm_yale_storage_unregister_a(void* a, size_t size);
95
+ void nm_yale_storage_register_a(void* a, size_t size);
96
+ void nm_yale_storage_unregister_a(void* a, size_t size);
96
97
 
97
98
  ///////////////
98
99
  // Accessors //
@@ -104,7 +105,7 @@ extern "C" {
104
105
  VALUE nm_yale_stored_nondiagonal_each_with_indices(VALUE nmatrix);
105
106
  VALUE nm_yale_each_ordered_stored_with_indices(VALUE nmatrix);
106
107
  void* nm_yale_storage_get(const STORAGE* s, SLICE* slice);
107
- void* nm_yale_storage_ref(const STORAGE* s, SLICE* slice);
108
+ void* nm_yale_storage_ref(const STORAGE* s, SLICE* slice);
108
109
  void nm_yale_storage_set(VALUE left, SLICE* slice, VALUE right);
109
110
 
110
111
  //char nm_yale_storage_vector_insert(YALE_STORAGE* s, size_t pos, size_t* js, void* vals, size_t n, bool struct_only, nm::dtype_t dtype, nm::itype_t itype);
@@ -42,16 +42,16 @@ EWOPS = [
42
42
  ]
43
43
 
44
44
  LR_ALLOWED = {
45
- :uint8_t => DTYPES,
46
- :int8_t => DTYPES,
47
- :int16_t => DTYPES,
48
- :int32_t => DTYPES,
49
- :int64_t => DTYPES,
50
- :float32_t => DTYPES,
51
- :float64_t => DTYPES,
52
- :'nm::Complex64' => DTYPES,
53
- :'nm::Complex128' => DTYPES,
54
- :'nm::RubyObject' => DTYPES
45
+ :uint8_t => DTYPES,
46
+ :int8_t => DTYPES,
47
+ :int16_t => DTYPES,
48
+ :int32_t => DTYPES,
49
+ :int64_t => DTYPES,
50
+ :float32_t => DTYPES,
51
+ :float64_t => DTYPES,
52
+ :'nm::Complex64' => DTYPES,
53
+ :'nm::Complex128' => DTYPES,
54
+ :'nm::RubyObject' => DTYPES
55
55
  }
56
56
 
57
57
  lines =
@@ -32,6 +32,7 @@
32
32
  * Standard Includes
33
33
  */
34
34
 
35
+ #include <ruby.h>
35
36
  #include <cstdint>
36
37
 
37
38
  /*
@@ -46,8 +47,8 @@
46
47
  * Types
47
48
  */
48
49
 
49
- typedef float float32_t;
50
- typedef double float64_t;
50
+ typedef float float32_t;
51
+ typedef double float64_t;
51
52
 
52
53
  typedef size_t IType;
53
54
 
@@ -104,9 +104,9 @@ extern "C" {
104
104
  nm::dtype_t nm_dtype_from_rbstring(VALUE str) {
105
105
 
106
106
  for (size_t index = 0; index < NM_NUM_DTYPES; ++index) {
107
- if (!std::strncmp(RSTRING_PTR(str), DTYPE_NAMES[index], RSTRING_LEN(str))) {
108
- return static_cast<nm::dtype_t>(index);
109
- }
107
+ if (!std::strncmp(RSTRING_PTR(str), DTYPE_NAMES[index], RSTRING_LEN(str))) {
108
+ return static_cast<nm::dtype_t>(index);
109
+ }
110
110
  }
111
111
 
112
112
  rb_raise(rb_eArgError, "invalid data type string (%s) specified", RSTRING_PTR(str));
@@ -121,7 +121,7 @@ nm::dtype_t nm_dtype_from_rbsymbol(VALUE sym) {
121
121
 
122
122
  for (size_t index = 0; index < NM_NUM_DTYPES; ++index) {
123
123
  if (sym_id == rb_intern(DTYPE_NAMES[index])) {
124
- return static_cast<nm::dtype_t>(index);
124
+ return static_cast<nm::dtype_t>(index);
125
125
  }
126
126
  }
127
127
 
@@ -138,7 +138,7 @@ nm::stype_t nm_stype_from_rbstring(VALUE str) {
138
138
 
139
139
  for (size_t index = 0; index < NM_NUM_STYPES; ++index) {
140
140
  if (!std::strncmp(RSTRING_PTR(str), STYPE_NAMES[index], 3)) {
141
- return static_cast<nm::stype_t>(index);
141
+ return static_cast<nm::stype_t>(index);
142
142
  }
143
143
  }
144
144
 
@@ -153,7 +153,7 @@ nm::stype_t nm_stype_from_rbsymbol(VALUE sym) {
153
153
 
154
154
  for (size_t index = 0; index < NM_NUM_STYPES; ++index) {
155
155
  if (SYM2ID(sym) == rb_intern(STYPE_NAMES[index])) {
156
- return static_cast<nm::stype_t>(index);
156
+ return static_cast<nm::stype_t>(index);
157
157
  }
158
158
  }
159
159
 
@@ -169,7 +169,7 @@ nm::stype_t nm_stype_from_rbsymbol(VALUE sym) {
169
169
  static nm::io::matlab_dtype_t matlab_dtype_from_rbsymbol(VALUE sym) {
170
170
  for (size_t index = 0; index < nm::io::NUM_MATLAB_DTYPES; ++index) {
171
171
  if (SYM2ID(sym) == rb_intern(nm::io::MATLAB_DTYPE_NAMES[index])) {
172
- return static_cast<nm::io::matlab_dtype_t>(index);
172
+ return static_cast<nm::io::matlab_dtype_t>(index);
173
173
  }
174
174
  }
175
175