nmatrix 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile +5 -0
  4. data/History.txt +97 -0
  5. data/Manifest.txt +34 -7
  6. data/README.rdoc +13 -13
  7. data/Rakefile +36 -26
  8. data/ext/nmatrix/data/data.cpp +15 -2
  9. data/ext/nmatrix/data/data.h +4 -0
  10. data/ext/nmatrix/data/ruby_object.h +5 -14
  11. data/ext/nmatrix/extconf.rb +3 -2
  12. data/ext/nmatrix/{util/math.cpp → math.cpp} +296 -6
  13. data/ext/nmatrix/math/asum.h +143 -0
  14. data/ext/nmatrix/math/geev.h +82 -0
  15. data/ext/nmatrix/math/gemm.h +267 -0
  16. data/ext/nmatrix/math/gemv.h +208 -0
  17. data/ext/nmatrix/math/ger.h +96 -0
  18. data/ext/nmatrix/math/gesdd.h +80 -0
  19. data/ext/nmatrix/math/gesvd.h +78 -0
  20. data/ext/nmatrix/math/getf2.h +86 -0
  21. data/ext/nmatrix/math/getrf.h +240 -0
  22. data/ext/nmatrix/math/getri.h +107 -0
  23. data/ext/nmatrix/math/getrs.h +125 -0
  24. data/ext/nmatrix/math/idamax.h +86 -0
  25. data/ext/nmatrix/{util → math}/lapack.h +60 -356
  26. data/ext/nmatrix/math/laswp.h +165 -0
  27. data/ext/nmatrix/math/long_dtype.h +52 -0
  28. data/ext/nmatrix/math/math.h +1154 -0
  29. data/ext/nmatrix/math/nrm2.h +181 -0
  30. data/ext/nmatrix/math/potrs.h +125 -0
  31. data/ext/nmatrix/math/rot.h +141 -0
  32. data/ext/nmatrix/math/rotg.h +115 -0
  33. data/ext/nmatrix/math/scal.h +73 -0
  34. data/ext/nmatrix/math/swap.h +73 -0
  35. data/ext/nmatrix/math/trsm.h +383 -0
  36. data/ext/nmatrix/nmatrix.cpp +176 -152
  37. data/ext/nmatrix/nmatrix.h +1 -2
  38. data/ext/nmatrix/ruby_constants.cpp +9 -4
  39. data/ext/nmatrix/ruby_constants.h +1 -0
  40. data/ext/nmatrix/storage/dense.cpp +57 -41
  41. data/ext/nmatrix/storage/list.cpp +52 -50
  42. data/ext/nmatrix/storage/storage.cpp +59 -43
  43. data/ext/nmatrix/storage/yale.cpp +352 -333
  44. data/ext/nmatrix/storage/yale.h +4 -0
  45. data/lib/nmatrix.rb +2 -2
  46. data/lib/nmatrix/blas.rb +4 -4
  47. data/lib/nmatrix/enumerate.rb +241 -0
  48. data/lib/nmatrix/lapack.rb +54 -1
  49. data/lib/nmatrix/math.rb +462 -0
  50. data/lib/nmatrix/nmatrix.rb +210 -486
  51. data/lib/nmatrix/nvector.rb +0 -62
  52. data/lib/nmatrix/rspec.rb +75 -0
  53. data/lib/nmatrix/shortcuts.rb +136 -108
  54. data/lib/nmatrix/version.rb +1 -1
  55. data/spec/blas_spec.rb +20 -12
  56. data/spec/elementwise_spec.rb +22 -13
  57. data/spec/io_spec.rb +1 -0
  58. data/spec/lapack_spec.rb +197 -0
  59. data/spec/nmatrix_spec.rb +39 -38
  60. data/spec/nvector_spec.rb +3 -9
  61. data/spec/rspec_monkeys.rb +29 -0
  62. data/spec/rspec_spec.rb +34 -0
  63. data/spec/shortcuts_spec.rb +14 -16
  64. data/spec/slice_spec.rb +242 -186
  65. data/spec/spec_helper.rb +19 -0
  66. metadata +33 -5
  67. data/ext/nmatrix/util/math.h +0 -2612
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 884e6aa70e17f383f0b979f94a911ad68960b48d
4
- data.tar.gz: 4f1194649cfc46eb2af3fb94808c09b05837fcc4
3
+ metadata.gz: 2c1dc8a7e82a68a64da1bbf5f52107e064eb1f62
4
+ data.tar.gz: dd24f0e30a500f7a397ffcddb21c8cbb4fbfd3d2
5
5
  SHA512:
6
- metadata.gz: aa28bc42bbfd037d04e18797076547860cf15d4f4c48203a60ac410d4c9102652d12ed22f980d7edaf854ed876d517a72311a924c7c16ecb3796aec118726ea4
7
- data.tar.gz: 9d7132d3582dda04ea68afc8a93a3d2362f10d23519e00d65fe0af4a9b199ea74f990b43c2f5593131c02ed448534d86039cbc1da0c43d1cb1828dd0aa05181f
6
+ metadata.gz: 4368ba0104a54a72397beaa607cb58dc2c44763833ced2a532c6fe9626b3405d89c0d75b924950b19f02567530c1979dd9a1e463b1b0d812bc77e5b02812277e
7
+ data.tar.gz: c8a9094c70c19d7a45fc08f5237a123e6c694e32be358e9c39fa7d9e30c7f0c2e903674951f677d24d4fc725dee67d23b59669e1354b66cd96d8574de8312659
data/.gitignore CHANGED
@@ -28,3 +28,5 @@ ext/nmatrix/**/*.o
28
28
  ext/nmatrix/Makefile
29
29
  ext/nmatrix/**/Makefile
30
30
  ext/nmatrix/nmatrix_config.h
31
+ pkg/
32
+ .autotest
data/Gemfile CHANGED
@@ -3,3 +3,8 @@ source 'http://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'packable', ">= 1.3.5" # for Matlab IO
6
+
7
+ group :development do
8
+ gem 'pry'
9
+ #gem 'pry-debugger'
10
+ end
data/History.txt CHANGED
@@ -281,3 +281,100 @@
281
281
 
282
282
  * Repaired list matrix element-wise functions
283
283
 
284
+ === 0.0.7 / 2013-08-22
285
+
286
+ * 6 major enhancements:
287
+
288
+ * Eliminated NVector in favor of NMatrix objects with
289
+ #effective_dim smaller than #dim; added NVector-like
290
+ functionality to NMatrix, sometimes with #respond_to? dependent
291
+ upon matrix dimensions; allowed for NVector.new to continue
292
+ to function as before, but now returns an NMatrix instead
293
+
294
+ * Began major re-factoring of headers for math.cpp
295
+
296
+ * Added two singular value decomposition functions for dense
297
+ NMatrix objects, #gesvd and #gesdd, for floating point and
298
+ complex dtypes
299
+
300
+ * Added additional slicing shorthand, which uses hashes (e.g.,
301
+ n[0=>3,2] for n[0..3,2]), which may eventually allow users to use
302
+ n[0:3,2] notation instead (needs Ruby core patch)
303
+
304
+ * #[] and #[]= calls no longer need index on those matrix shape
305
+ elements which are equal to 1 (e.g., vectors)
306
+
307
+ * Yale slicing-by-reference has been added
308
+
309
+ * 18 minor enhancements:
310
+
311
+ * Added user-friendly NMatrix::LAPACK::laswp method
312
+
313
+ * Added NMatrix#permute_columns! and NMatrix#permute_columns
314
+
315
+ * Added NMatrix#abs to compute element-wise absolute values, and
316
+ #abs_dtype to determine the dtype returned by a call to #abs on a
317
+ given matrix (needed for RSpec)
318
+
319
+ * Added NMatrix#size to compute the total number of cells in an
320
+ NMatrix object (solely accounting for the shape, not sparsity)
321
+
322
+ * Added RSpec monkey patches for #be_within to work with NMatrix
323
+ objects; usable by requiring "nmatrix/rspec"
324
+
325
+ * Added experimental NMatrix::LAPACK::lapack_gesvd function (which
326
+ does NOT depend upon CLAPACK) (by @ryanmt and @mohawkjohn)
327
+
328
+ * Added experimental non-LAPACK-dependent function
329
+ NMatrix::LAPACK::lapack_gesdd
330
+
331
+ * Added NMatrix#supershape method for getting the shape of a
332
+ slice's parent or other ancestor, which may be useful for calling
333
+ ATLAS and LAPACK functions on slices
334
+
335
+ * Aliased NMatrix[] to function like N[] shortcut for matrix
336
+ creation (by @agarie)
337
+
338
+ * Added #layer for matrices with dimension greater than two
339
+ (corresponds to #row and #column)
340
+
341
+ * Added #rank and #each_rank generics for #row/#column/#layer and
342
+ #each_row/#each_column/#each_layer respectively (#each_rank
343
+ replaces #each_along_dim)
344
+
345
+ * Replaced #reduce_along_dim with #inject_rank
346
+
347
+ * NMatrix#to_a now works for up to two dimensional matrices; and
348
+ returns a flattened array for single-row matrices
349
+
350
+ * NMatrix#to_flat_a now returns a flattened array of all entries
351
+
352
+ * Re-organized NMatrix Ruby sources into multiple files: math.rb
353
+ for instance methods which are mathematical in nature or are
354
+ essentially ATLAS/LAPACK/BLAS calls, enumerate.rb for methods
355
+ involving enumeration; and existing shortcuts.rb for convenience
356
+ functions and shortcut constructors, and nmatrix.rb for core
357
+ functionality (#inspect, #to_h, #to_a, #to_s, #pretty_print,
358
+ and so on)
359
+
360
+ * Improved #pretty_print, which now also prints layers (the third
361
+ dimension in a 3D matrix)
362
+
363
+ * Re-factored some of dense slicing to remove some redundant code
364
+
365
+ * Added shortcut functions #list?, #dense?, #yale? for quickly
366
+ testing matrix storage type
367
+
368
+ * 5 bug fixes:
369
+
370
+ * Fixed compilation problem involving <typeinfo> and <vector> STL
371
+ headers
372
+
373
+ * Fixed NMatrix#inverse problem with non-square matrices
374
+
375
+ * Fixed invalid read problem detected by Valgrind for
376
+ Yale element-wise subtraction in spec
377
+
378
+ * Fixed conversion from Ruby object to Complex and Rational
379
+
380
+ * Fixed memory leak in slicing
data/Manifest.txt CHANGED
@@ -7,27 +7,32 @@ Rakefile
7
7
  Gemfile
8
8
  Guardfile
9
9
  nmatrix.gemspec
10
+ spec/blas_spec.rb
11
+ spec/elementwise_spec.rb
10
12
  spec/io_spec.rb
13
+ spec/lapack_spec.rb
11
14
  spec/math_spec.rb
12
- spec/nmatrix_spec.rb
13
15
  spec/nmatrix_list_spec.rb
16
+ spec/nmatrix_spec.rb
14
17
  spec/nmatrix_yale_spec.rb
15
18
  spec/nvector_spec.rb
16
- spec/slice_spec.rb
19
+ spec/rspec_spec.rb
17
20
  spec/shortcuts_spec.rb
18
- spec/elementwise_spec.rb
19
- spec/blas_spec.rb
20
- spec/lapack_spec.rb
21
+ spec/slice_spec.rb
21
22
  spec/spec_helper.rb
22
23
  lib/nmatrix.rb
24
+ lib/nmatrix/rspec.rb
23
25
  lib/nmatrix/io/market.rb
24
26
  lib/nmatrix/io/mat5_reader.rb
25
27
  lib/nmatrix/io/mat_reader.rb
26
28
  lib/nmatrix/blas.rb
29
+ lib/nmatrix/enumerate.rb
27
30
  lib/nmatrix/lapack.rb
31
+ lib/nmatrix/math.rb
28
32
  lib/nmatrix/monkeys.rb
29
33
  lib/nmatrix/nmatrix.rb
30
34
  lib/nmatrix/nvector.rb
35
+ lib/nmatrix/rspec.rb
31
36
  lib/nmatrix/shortcuts.rb
32
37
  lib/nmatrix/version.rb
33
38
  lib/nmatrix/yale_functions.rb
@@ -46,12 +51,34 @@ ext/nmatrix/storage/storage.cpp
46
51
  ext/nmatrix/storage/storage.h
47
52
  ext/nmatrix/storage/yale.cpp
48
53
  ext/nmatrix/storage/yale.h
49
- ext/nmatrix/util/math.cpp
50
- ext/nmatrix/util/math.h
51
54
  ext/nmatrix/util/sl_list.cpp
52
55
  ext/nmatrix/util/sl_list.h
53
56
  ext/nmatrix/util/util.h
54
57
  ext/nmatrix/util/lapack.h
58
+ ext/nmatrix/math.cpp
59
+ ext/nmatrix/math/asum.h
60
+ ext/nmatrix/math/geev.h
61
+ ext/nmatrix/math/gemm.h
62
+ ext/nmatrix/math/gemv.h
63
+ ext/nmatrix/math/ger.h
64
+ ext/nmatrix/math/gesdd.h
65
+ ext/nmatrix/math/gesvd.h
66
+ ext/nmatrix/math/getf2.h
67
+ ext/nmatrix/math/getrf.h
68
+ ext/nmatrix/math/getri.h
69
+ ext/nmatrix/math/getrs.h
70
+ ext/nmatrix/math/idamax.h
71
+ ext/nmatrix/math/lapack.h
72
+ ext/nmatrix/math/laswp.h
73
+ ext/nmatrix/math/long_dtype.h
74
+ ext/nmatrix/math/math.h
75
+ ext/nmatrix/math/nrm2.h
76
+ ext/nmatrix/math/potrs.h
77
+ ext/nmatrix/math/rot.h
78
+ ext/nmatrix/math/rotg.h
79
+ ext/nmatrix/math/scal.h
80
+ ext/nmatrix/math/swap.h
81
+ ext/nmatrix/math/trsm.h
55
82
  ext/nmatrix/nmatrix.cpp
56
83
  ext/nmatrix/nmatrix.h
57
84
  ext/nmatrix/ruby_constants.cpp
data/README.rdoc CHANGED
@@ -79,17 +79,17 @@ Read the instructions in +CONTRIBUTING.md+ if you want to help NMatrix.
79
79
 
80
80
  == Features
81
81
 
82
- The following features exist in the current version of NMatrix (0.0.6):
82
+ The following features exist in the current version of NMatrix (0.0.7):
83
83
 
84
84
  * Matrix and vector storage containers: dense, yale, list (more to come)
85
85
  * Data types: byte (uint8), int8, int16, int32, int64, float32, float64, complex64, complex128, rational64, rational128,
86
86
  Ruby object
87
- * Conversion between storage and data types (except from-complex, and from-float-to-rational)
87
+ * Interconversion between storage and data types
88
88
  * Element-wise and right-hand-scalar operations and comparisons for all matrix types
89
89
  * Matrix-matrix multiplication for dense (with and without ATLAS) and yale
90
90
  * Matrix-vector multiplication for dense (with and without ATLAS)
91
- * Dense and list matrix slicing by copy and reference
92
- * Yale matrix slicing by copy
91
+ * Lots of enumerators (each, each_with_indices, each_row, each_column, each_rank, map, etc.)
92
+ * Matrix slicing by copy and reference (for dense, yale, and list)
93
93
  * Native reading and writing of dense and yale matrices
94
94
  * Optional compression for dense matrices with symmetry or triangularity: symmetric, skew, hermitian, upper, lower
95
95
  * Matlab .MAT v5 file input
@@ -106,6 +106,9 @@ The following features exist in the current version of NMatrix (0.0.6):
106
106
  * xGETRF
107
107
  * xLASWP, xSCAL
108
108
  * xLAUUM (no LAPACK needed, but BLAS dtypes only)
109
+ * LAPACK (non-ATLAS) access:
110
+ * xGESVD, xGESDD (singular value decomposition)
111
+ * xGEEV (eigenvalue decomposition of a asymmetric square matrices)
109
112
  * LU decomposition
110
113
  * Matrix inversions (requires LAPACK; BLAS dtypes only)
111
114
  * Determinant calculation for BLAS dtypes
@@ -114,20 +117,17 @@ The following features exist in the current version of NMatrix (0.0.6):
114
117
 
115
118
  === Planned Features (Short-to-Medium Term)
116
119
 
117
- These are features planned for NMatrix 0.1.0, our first beta:
120
+ We are nearly the release of NMatrix 0.1.0, our first beta.
118
121
 
119
- * Yale matrix slicing
120
- * calculation of determinant (LAPACK-free), trace, and eigenvalues (characteristic polynomial)
121
- * exponentials and square roots
122
- * matrix inversions (LAPACK-free)
123
- * matrix decomposition/factorization
124
- * calculation of additional norms
122
+ These are features planned for NMatrix 0.2.0:
123
+
124
+ * slice assignments (`x[1..3,0..4] = some_other_matrix`)
125
+ * LAPACK-free calculation of determinant, trace, and eigenvalues (characteristic polynomial)
126
+ * LAPACK-free matrix inversions
125
127
  * tensor products
126
128
  * principal component analysis (PCA)
127
129
  * improved file I/O
128
130
  * compression of yale symmetries in I/O
129
- * operation scheduling
130
- * parallelization of some types of operations
131
131
  * optimization of non-BLAS data types on BLAS-like operations (e.g., matrix multiplication for rational numbers)
132
132
 
133
133
  === Warning
data/Rakefile CHANGED
@@ -33,7 +33,8 @@ require 'rspec/core/rake_task'
33
33
  require 'rspec/core'
34
34
  require 'rspec/core/rake_task'
35
35
  RSpec::Core::RakeTask.new(:spec) do |spec|
36
- spec.pattern = FileList['spec/**/*_spec.rb']
36
+ # Load nmatrix_spec first.
37
+ spec.pattern = FileList['spec/nmatrix_spec.rb', 'spec/**/*_spec.rb'].uniq
37
38
  end
38
39
 
39
40
  BASEDIR = Pathname( __FILE__ ).dirname.relative_path_from( Pathname.pwd )
@@ -69,23 +70,31 @@ task :pry do |task|
69
70
  run *cmd
70
71
  end
71
72
 
72
- #namespace :console do
73
- # CONSOLE_CMD = ['irb', "-r './lib/nmatrix.rb'"]
74
- # desc "Run console under GDB."
75
- # task :gdb => [ :compile ] do |task|
76
- # cmd = [ 'gdb' ] + GDB_OPTIONS
77
- # cmd += [ '--args' ]
78
- # cmd += CONSOLE_CMD
79
- # run( *cmd )
80
- # end
81
- #
82
- # desc "Run console under Valgrind."
83
- # task :valgrind => [ :compile ] do |task|
84
- # cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
85
- # cmd += CONSOLE_CMD
86
- # run( *cmd )
87
- # end
88
- #end
73
+ namespace :pry do
74
+ task :valgrind => [ :compile ] do |task|
75
+ cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
76
+ cmd += ['ruby', '-Ilib:ext', "-r './lib/nmatrix.rb'", "-r 'pry'", "-e 'binding.pry'"]
77
+ run *cmd
78
+ end
79
+ end
80
+
81
+ namespace :console do
82
+ CONSOLE_CMD = ['irb', "-r './lib/nmatrix.rb'"]
83
+ desc "Run console under GDB."
84
+ task :gdb => [ :compile ] do |task|
85
+ cmd = [ 'gdb' ] + GDB_OPTIONS
86
+ cmd += [ '--args' ]
87
+ cmd += CONSOLE_CMD
88
+ run( *cmd )
89
+ end
90
+
91
+ desc "Run console under Valgrind."
92
+ task :valgrind => [ :compile ] do |task|
93
+ cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
94
+ cmd += CONSOLE_CMD
95
+ run( *cmd )
96
+ end
97
+ end
89
98
 
90
99
  task :default => :spec
91
100
 
@@ -98,7 +107,7 @@ namespace :spec do
98
107
  # spurious (and eminently ignorable) warnings from the ruby
99
108
  # interpreter
100
109
 
101
- RSPEC_CMD = [ 'ruby', '-S', 'rspec', '-Ilib:ext', SPECDIR ]
110
+ RSPEC_CMD = [ 'ruby', '-S', 'rspec', '-Ilib:ext', "#{SPECDIR}/nmatrix_spec.rb #{SPECDIR}" ]
102
111
 
103
112
  #desc "Run the spec for generator.rb"
104
113
  #task :generator do |task|
@@ -107,7 +116,7 @@ namespace :spec do
107
116
 
108
117
  desc "Run specs under GDB."
109
118
  task :gdb => [ :compile ] do |task|
110
- cmd = [ 'gdb' ] + GDB_OPTIONS
119
+ cmd = [ 'gdb' ] + GDB_OPTIONS
111
120
  cmd += [ '--args' ]
112
121
  cmd += RSPEC_CMD
113
122
  run( *cmd )
@@ -116,22 +125,23 @@ namespace :spec do
116
125
  desc "Run specs under cgdb."
117
126
  task :cgdb => [ :compile ] do |task|
118
127
  cmd = [ 'cgdb' ] + GDB_OPTIONS
119
- cmd += [ '--args' ]
120
- cmd += RSPEC_CMD
121
- run( *cmd )
128
+ cmd += [ '--args' ]
129
+ cmd += RSPEC_CMD
130
+ run( *cmd )
122
131
  end
123
132
 
124
133
  desc "Run specs under Valgrind."
125
134
  task :valgrind => [ :compile ] do |task|
126
- cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
127
- cmd += RSPEC_CMD
128
- run( *cmd )
135
+ cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
136
+ cmd += RSPEC_CMD
137
+ run( *cmd )
129
138
  end
130
139
  end
131
140
 
132
141
 
133
142
  LEAKCHECK_CMD = [ 'ruby', '-Ilib:ext', "#{SPECDIR}/leakcheck.rb" ]
134
143
 
144
+
135
145
  desc "Run leakcheck script."
136
146
  task :leakcheck => [ :compile ] do |task|
137
147
  cmd = [ 'valgrind' ] + VALGRIND_OPTIONS
@@ -83,6 +83,8 @@ namespace nm {
83
83
  break;
84
84
  case T_FLOAT:
85
85
  case T_RATIONAL:
86
+ case T_FIXNUM:
87
+ case T_BIGNUM:
86
88
  r = NUM2DBL(other.rval);
87
89
  i = 0.0;
88
90
  break;
@@ -91,14 +93,16 @@ namespace nm {
91
93
  }
92
94
  }
93
95
 
96
+
94
97
  template <typename Type>
95
98
  Rational<Type>::Rational(const RubyObject& other) {
96
99
  switch (TYPE(other.rval)) {
97
100
  case T_RATIONAL:
98
- n = NUM2LONG(rb_funcall(this->rval, rb_intern("numerator"), 0));
99
- d = NUM2LONG(rb_funcall(this->rval, rb_intern("denominator"), 0));
101
+ n = NUM2LONG(rb_funcall(other.rval, rb_intern("numerator"), 0));
102
+ d = NUM2LONG(rb_funcall(other.rval, rb_intern("denominator"), 0));
100
103
  break;
101
104
  case T_FIXNUM:
105
+ case T_BIGNUM:
102
106
  n = NUM2LONG(other.rval);
103
107
  d = 1;
104
108
  break;
@@ -340,5 +344,14 @@ void* rubyobj_to_cval(VALUE val, nm::dtype_t dtype) {
340
344
  return ret_val;
341
345
  }
342
346
 
347
+ void nm_init_data() {
348
+ nm::RubyObject obj(INT2FIX(1));
349
+ nm::Rational32 x(obj);
350
+ nm::Rational64 y(obj);
351
+ nm::Rational128 z(obj);
352
+ nm::Complex64 a(obj);
353
+ nm::Complex128 b(obj);
354
+ }
355
+
343
356
 
344
357
  } // end of extern "C" block
@@ -46,6 +46,8 @@
46
46
  #include "ruby_object.h"
47
47
 
48
48
  namespace nm {
49
+
50
+
49
51
  /*
50
52
  * Constants
51
53
  */
@@ -776,6 +778,8 @@ void rubyval_to_cval(VALUE val, nm::dtype_t dtype, void* loc);
776
778
  nm::RubyObject rubyobj_from_cval(void* val, nm::dtype_t dtype);
777
779
  nm::RubyObject rubyobj_from_cval_by_itype(void* val, nm::itype_t itype);
778
780
 
781
+ void nm_init_data();
782
+
779
783
  } // end of extern "C" block
780
784
 
781
785
  #endif // DATA_H
@@ -123,21 +123,12 @@ class RubyObject {
123
123
  inline operator double() const { RETURN_OBJ2NUM(NUM2DBL) }
124
124
  inline operator float() const { RETURN_OBJ2NUM(NUM2DBL) }
125
125
 
126
- //template <typename IntType>
127
- //inline operator Rational<typename std::enable_if<std::is_integral<IntType>::value, IntType>::type>() const { return this->to<Rational<IntType> >(); }
128
-
129
- //template <typename IntType>
130
- //inline operator Rational<typename std::enable_if<std::is_integral<IntType>::value, IntType>::type>&() const { static Rational<IntType> x = this->to<Rational<IntType> >(); return x; }
131
- //inline operator Rational32() const { return this->to<Rational32>(); }
132
- //inline operator Rational64() const { return this->to<Rational64>(); }
133
- //inline operator Rational128() const { return this->to<Rational128>(); }
134
-
135
- //template <typename FloatType>
136
- //inline operator Complex<typename std::enable_if<std::is_floating_point<FloatType>::value, FloatType>::type>() const { return this->to<Complex<FloatType> >(); }
137
-
138
- //template <typename FloatType>
139
- //inline operator Complex<typename std::enable_if<std::is_floating_point<FloatType>::value, FloatType>::type>&() const { static Complex<FloatType> x = this->to<Complex<FloatType> >(); return x; }
126
+ inline operator Rational32() const { return this->to<Rational32>(); }
127
+ inline operator Rational64() const { return this->to<Rational64>(); }
128
+ inline operator Rational128() const { return this->to<Rational128>(); }
140
129
 
130
+ inline operator Complex64() const { return this->to<Complex64>(); }
131
+ inline operator Complex128() const { return this->to<Complex128>(); }
141
132
  /*
142
133
  * Copy constructors.
143
134
  */