nmatrix-fftw 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/ext/nmatrix/data/complex.h +388 -0
  3. data/ext/nmatrix/data/data.h +652 -0
  4. data/ext/nmatrix/data/meta.h +64 -0
  5. data/ext/nmatrix/data/ruby_object.h +389 -0
  6. data/ext/nmatrix/math/asum.h +120 -0
  7. data/ext/nmatrix/math/cblas_enums.h +36 -0
  8. data/ext/nmatrix/math/cblas_templates_core.h +507 -0
  9. data/ext/nmatrix/math/gemm.h +241 -0
  10. data/ext/nmatrix/math/gemv.h +178 -0
  11. data/ext/nmatrix/math/getrf.h +255 -0
  12. data/ext/nmatrix/math/getrs.h +121 -0
  13. data/ext/nmatrix/math/imax.h +79 -0
  14. data/ext/nmatrix/math/laswp.h +165 -0
  15. data/ext/nmatrix/math/long_dtype.h +49 -0
  16. data/ext/nmatrix/math/math.h +745 -0
  17. data/ext/nmatrix/math/nrm2.h +160 -0
  18. data/ext/nmatrix/math/rot.h +117 -0
  19. data/ext/nmatrix/math/rotg.h +106 -0
  20. data/ext/nmatrix/math/scal.h +71 -0
  21. data/ext/nmatrix/math/trsm.h +332 -0
  22. data/ext/nmatrix/math/util.h +148 -0
  23. data/ext/nmatrix/nm_memory.h +60 -0
  24. data/ext/nmatrix/nmatrix.h +438 -0
  25. data/ext/nmatrix/ruby_constants.h +106 -0
  26. data/ext/nmatrix/storage/common.h +177 -0
  27. data/ext/nmatrix/storage/dense/dense.h +129 -0
  28. data/ext/nmatrix/storage/list/list.h +138 -0
  29. data/ext/nmatrix/storage/storage.h +99 -0
  30. data/ext/nmatrix/storage/yale/class.h +1139 -0
  31. data/ext/nmatrix/storage/yale/iterators/base.h +143 -0
  32. data/ext/nmatrix/storage/yale/iterators/iterator.h +131 -0
  33. data/ext/nmatrix/storage/yale/iterators/row.h +450 -0
  34. data/ext/nmatrix/storage/yale/iterators/row_stored.h +140 -0
  35. data/ext/nmatrix/storage/yale/iterators/row_stored_nd.h +169 -0
  36. data/ext/nmatrix/storage/yale/iterators/stored_diagonal.h +124 -0
  37. data/ext/nmatrix/storage/yale/math/transpose.h +110 -0
  38. data/ext/nmatrix/storage/yale/yale.h +203 -0
  39. data/ext/nmatrix/types.h +55 -0
  40. data/ext/nmatrix/util/io.h +115 -0
  41. data/ext/nmatrix/util/sl_list.h +144 -0
  42. data/ext/nmatrix/util/util.h +78 -0
  43. data/ext/nmatrix_fftw/extconf.rb +122 -0
  44. data/ext/nmatrix_fftw/nmatrix_fftw.cpp +274 -0
  45. data/lib/nmatrix/fftw.rb +343 -0
  46. data/spec/00_nmatrix_spec.rb +736 -0
  47. data/spec/01_enum_spec.rb +190 -0
  48. data/spec/02_slice_spec.rb +389 -0
  49. data/spec/03_nmatrix_monkeys_spec.rb +78 -0
  50. data/spec/2x2_dense_double.mat +0 -0
  51. data/spec/4x4_sparse.mat +0 -0
  52. data/spec/4x5_dense.mat +0 -0
  53. data/spec/blas_spec.rb +193 -0
  54. data/spec/elementwise_spec.rb +303 -0
  55. data/spec/homogeneous_spec.rb +99 -0
  56. data/spec/io/fortran_format_spec.rb +88 -0
  57. data/spec/io/harwell_boeing_spec.rb +98 -0
  58. data/spec/io/test.rua +9 -0
  59. data/spec/io_spec.rb +149 -0
  60. data/spec/lapack_core_spec.rb +482 -0
  61. data/spec/leakcheck.rb +16 -0
  62. data/spec/math_spec.rb +807 -0
  63. data/spec/nmatrix_yale_resize_test_associations.yaml +2802 -0
  64. data/spec/nmatrix_yale_spec.rb +286 -0
  65. data/spec/plugins/fftw/fftw_spec.rb +348 -0
  66. data/spec/rspec_monkeys.rb +56 -0
  67. data/spec/rspec_spec.rb +34 -0
  68. data/spec/shortcuts_spec.rb +310 -0
  69. data/spec/slice_set_spec.rb +157 -0
  70. data/spec/spec_helper.rb +149 -0
  71. data/spec/stat_spec.rb +203 -0
  72. data/spec/test.pcd +20 -0
  73. data/spec/utm5940.mtx +83844 -0
  74. metadata +151 -0
@@ -0,0 +1,106 @@
1
+ /////////////////////////////////////////////////////////////////////
2
+ // = NMatrix
3
+ //
4
+ // A linear algebra library for scientific computation in Ruby.
5
+ // NMatrix is part of SciRuby.
6
+ //
7
+ // NMatrix was originally inspired by and derived from NArray, by
8
+ // Masahiro Tanaka: http://narray.rubyforge.org
9
+ //
10
+ // == Copyright Information
11
+ //
12
+ // SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
13
+ // NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
14
+ //
15
+ // Please see LICENSE.txt for additional copyright notices.
16
+ //
17
+ // == Contributing
18
+ //
19
+ // By contributing source code to SciRuby, you agree to be bound by
20
+ // our Contributor Agreement:
21
+ //
22
+ // * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
23
+ //
24
+ // == data.h
25
+ //
26
+ // Header file for dealing with data types.
27
+
28
+ #ifndef RUBY_CONSTANTS_H
29
+ #define RUBY_CONSTANTS_H
30
+
31
+ /*
32
+ * Standard Includes
33
+ */
34
+
35
+ #include <ruby.h>
36
+
37
+ /*
38
+ * Data
39
+ */
40
+
41
+ extern ID nm_rb_dtype,
42
+ nm_rb_stype,
43
+
44
+ nm_rb_capacity,
45
+ nm_rb_default,
46
+
47
+ nm_rb_real,
48
+ nm_rb_imag,
49
+
50
+ nm_rb_numer,
51
+ nm_rb_denom,
52
+
53
+ nm_rb_complex_conjugate,
54
+ nm_rb_transpose,
55
+ nm_rb_no_transpose,
56
+ nm_rb_left,
57
+ nm_rb_right,
58
+ nm_rb_upper,
59
+ nm_rb_lower,
60
+ nm_rb_unit,
61
+ nm_rb_nonunit,
62
+
63
+ nm_rb_dense,
64
+ nm_rb_list,
65
+ nm_rb_yale,
66
+
67
+ nm_rb_row,
68
+ nm_rb_column,
69
+
70
+ nm_rb_add,
71
+ nm_rb_sub,
72
+ nm_rb_mul,
73
+ nm_rb_div,
74
+
75
+ nm_rb_negate,
76
+
77
+ nm_rb_percent,
78
+ nm_rb_gt,
79
+ nm_rb_lt,
80
+ nm_rb_eql,
81
+ nm_rb_neql,
82
+ nm_rb_gte,
83
+ nm_rb_lte,
84
+
85
+ nm_rb_hash;
86
+
87
+ extern VALUE cNMatrix,
88
+ cNMatrix_IO,
89
+ cNMatrix_IO_Matlab,
90
+ cNMatrix_YaleFunctions,
91
+
92
+ cNMatrix_GC_holder,
93
+
94
+ nm_eDataTypeError,
95
+ nm_eConvergenceError,
96
+ nm_eStorageTypeError,
97
+ nm_eShapeError,
98
+ nm_eNotInvertibleError;
99
+
100
+ /*
101
+ * Functions
102
+ */
103
+
104
+ void nm_init_ruby_constants(void);
105
+
106
+ #endif // RUBY_CONSTANTS_H
@@ -0,0 +1,177 @@
1
+ /////////////////////////////////////////////////////////////////////
2
+ // = NMatrix
3
+ //
4
+ // A linear algebra library for scientific computation in Ruby.
5
+ // NMatrix is part of SciRuby.
6
+ //
7
+ // NMatrix was originally inspired by and derived from NArray, by
8
+ // Masahiro Tanaka: http://narray.rubyforge.org
9
+ //
10
+ // == Copyright Information
11
+ //
12
+ // SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
13
+ // NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
14
+ //
15
+ // Please see LICENSE.txt for additional copyright notices.
16
+ //
17
+ // == Contributing
18
+ //
19
+ // By contributing source code to SciRuby, you agree to be bound by
20
+ // our Contributor Agreement:
21
+ //
22
+ // * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
23
+ //
24
+ // == common.h
25
+ //
26
+ // Header file for code common to all storage types.
27
+
28
+ #ifndef STORAGE_COMMON_H
29
+ #define STORAGE_COMMON_H
30
+
31
+ /*
32
+ * Standard Includes
33
+ */
34
+
35
+ #include <ruby.h>
36
+ #include <cmath> // pow().
37
+
38
+ /*
39
+ * Project Includes
40
+ */
41
+ #include "data/data.h"
42
+ #include "nmatrix.h"
43
+
44
+ /*
45
+ * Macros
46
+ */
47
+
48
+ extern "C" {
49
+
50
+ /*
51
+ * Types
52
+ */
53
+
54
+ // For binary operations involving matrices that need to be casted.
55
+ struct STORAGE_PAIR {
56
+ STORAGE* left;
57
+ STORAGE* right;
58
+ };
59
+
60
+ struct SLICE {
61
+ size_t* coords; // Coordinate of first element
62
+ size_t* lengths; // Lengths of slice
63
+ bool single; // true if all lengths equal to 1 (represents single matrix element)
64
+ };
65
+
66
+ /*
67
+ * Data
68
+ */
69
+
70
+ /*
71
+ * Functions
72
+ */
73
+
74
+ size_t nm_storage_count_max_elements(const STORAGE* storage);
75
+ VALUE nm_enumerator_length(VALUE nmatrix);
76
+
77
+ } // end of extern "C" block
78
+
79
+ namespace nm {
80
+
81
+ /*
82
+ * Templated helper function for element-wise operations, used by dense, yale, and list.
83
+ */
84
+ template <ewop_t op, typename LDType, typename RDType>
85
+ inline VALUE ew_op_switch(LDType left, RDType right) {
86
+ switch (op) {
87
+ case EW_ADD:
88
+ return RubyObject(left + right).rval;
89
+
90
+ case EW_SUB:
91
+ return RubyObject(left - right).rval;
92
+
93
+ case EW_MUL:
94
+ return RubyObject(left * right).rval;
95
+
96
+ case EW_DIV:
97
+ return RubyObject(left / right).rval;
98
+
99
+ case EW_POW:
100
+ return RubyObject(pow(left, right)).rval;
101
+
102
+ case EW_MOD:
103
+ rb_raise(rb_eNotImpError, "Element-wise modulo is currently not supported.");
104
+ break;
105
+
106
+ default:
107
+ rb_raise(rb_eStandardError, "This should not happen.");
108
+ }
109
+ return Qnil;
110
+ }
111
+
112
+ #define EWOP_INT_INT_DIV(ltype, rtype) template <> \
113
+ inline VALUE ew_op_switch<EW_DIV>( ltype left, rtype right) { \
114
+ if (right == 0) rb_raise(rb_eZeroDivError, "cannot divide type by 0, would throw SIGFPE"); \
115
+ if ((left > 0 && right > 0) || (left < 0 && right < 0)) \
116
+ return left / right; \
117
+ else \
118
+ return ( ltype )(std::floor((double)(left) / (double)(right))); \
119
+ }
120
+
121
+ #define EWOP_UINT_UINT_DIV(ltype, rtype) template <> \
122
+ inline VALUE ew_op_switch<EW_DIV>( ltype left, rtype right) { \
123
+ if (right == 0) rb_raise(rb_eZeroDivError, "cannot divide type by 0, would throw SIGFPE"); \
124
+ return left / right; \
125
+ }
126
+
127
+ #define EWOP_INT_UINT_DIV(ltype, rtype) template <> \
128
+ inline VALUE ew_op_switch<EW_DIV>( ltype left, rtype right) { \
129
+ if (right == 0) rb_raise(rb_eZeroDivError, "cannot divide type by 0, would throw SIGFPE"); \
130
+ if (left > 0 ) return left / right; \
131
+ else return ( ltype )(std::floor((double)(left) / (double)(right))); \
132
+ }
133
+
134
+ #define EWOP_UINT_INT_DIV(ltype, rtype) template <> \
135
+ inline VALUE ew_op_switch<EW_DIV>( ltype left, rtype right) { \
136
+ if (right == 0) rb_raise(rb_eZeroDivError, "cannot divide type by 0, would throw SIGFPE"); \
137
+ if (right > 0) return left / right; \
138
+ else return ( ltype )(std::floor((double)(left) / (double)(right))); \
139
+ }
140
+
141
+ #define EWOP_FLOAT_INT_DIV(ltype, rtype) template <> \
142
+ inline VALUE ew_op_switch<EW_DIV>( ltype left, rtype right) { \
143
+ return left / (ltype)(right); \
144
+ }
145
+
146
+ // Ensure that divisions are done in the Ruby way, and that (int)x/0 always raises a Ruby error instead
147
+ // of throwing a SIGFPE.
148
+ EWOP_INT_INT_DIV(int64_t, int64_t)
149
+ EWOP_INT_INT_DIV(int32_t, int32_t)
150
+ EWOP_INT_INT_DIV(int32_t, int64_t)
151
+ EWOP_INT_INT_DIV(int16_t, int16_t)
152
+ EWOP_INT_INT_DIV(int16_t, int32_t)
153
+ EWOP_INT_INT_DIV(int16_t, int64_t)
154
+ EWOP_INT_INT_DIV(int8_t, int8_t)
155
+ EWOP_INT_UINT_DIV(int8_t, u_int8_t)
156
+ EWOP_INT_INT_DIV(int8_t, int16_t)
157
+ EWOP_INT_INT_DIV(int8_t, int32_t)
158
+ EWOP_INT_INT_DIV(int8_t, int64_t)
159
+ EWOP_UINT_UINT_DIV(uint8_t, uint8_t)
160
+ EWOP_UINT_INT_DIV(uint8_t, int8_t)
161
+ EWOP_UINT_INT_DIV(uint8_t, int16_t)
162
+ EWOP_UINT_INT_DIV(uint8_t, int32_t)
163
+ EWOP_UINT_INT_DIV(uint8_t, int64_t)
164
+ EWOP_FLOAT_INT_DIV(float, int8_t)
165
+ EWOP_FLOAT_INT_DIV(float, u_int8_t)
166
+ EWOP_FLOAT_INT_DIV(float, int16_t)
167
+ EWOP_FLOAT_INT_DIV(float, int32_t)
168
+ EWOP_FLOAT_INT_DIV(float, int64_t)
169
+ EWOP_FLOAT_INT_DIV(double, int8_t)
170
+ EWOP_FLOAT_INT_DIV(double, u_int8_t)
171
+ EWOP_FLOAT_INT_DIV(double, int16_t)
172
+ EWOP_FLOAT_INT_DIV(double, int32_t)
173
+ EWOP_FLOAT_INT_DIV(double, int64_t)
174
+
175
+ }
176
+
177
+ #endif // STORAGE_COMMON_H
@@ -0,0 +1,129 @@
1
+ /////////////////////////////////////////////////////////////////////
2
+ // = NMatrix
3
+ //
4
+ // A linear algebra library for scientific computation in Ruby.
5
+ // NMatrix is part of SciRuby.
6
+ //
7
+ // NMatrix was originally inspired by and derived from NArray, by
8
+ // Masahiro Tanaka: http://narray.rubyforge.org
9
+ //
10
+ // == Copyright Information
11
+ //
12
+ // SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
13
+ // NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
14
+ //
15
+ // Please see LICENSE.txt for additional copyright notices.
16
+ //
17
+ // == Contributing
18
+ //
19
+ // By contributing source code to SciRuby, you agree to be bound by
20
+ // our Contributor Agreement:
21
+ //
22
+ // * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
23
+ //
24
+ // == dense.h
25
+ //
26
+ // Dense n-dimensional matrix storage.
27
+
28
+ #ifndef DENSE_H
29
+ #define DENSE_H
30
+
31
+ /*
32
+ * Standard Includes
33
+ */
34
+
35
+ #include <ruby.h>
36
+ #include <cstdlib>
37
+
38
+ /*
39
+ * Project Includes
40
+ */
41
+
42
+ #include "types.h"
43
+ //#include "util/math.h"
44
+
45
+ #include "data/data.h"
46
+
47
+ #include "../common.h"
48
+
49
+ #include "nmatrix.h"
50
+
51
+ /*
52
+ * Macros
53
+ */
54
+
55
+ /*
56
+ * Types
57
+ */
58
+
59
+ /*
60
+ * Data
61
+ */
62
+
63
+ extern "C" {
64
+
65
+ /*
66
+ * Functions
67
+ */
68
+
69
+ ///////////////
70
+ // Lifecycle //
71
+ ///////////////
72
+
73
+ DENSE_STORAGE* nm_dense_storage_create(nm::dtype_t dtype, size_t* shape, size_t dim, void* elements, size_t elements_length);
74
+ void nm_dense_storage_delete(STORAGE* s);
75
+ void nm_dense_storage_delete_ref(STORAGE* s);
76
+ void nm_dense_storage_mark(STORAGE*);
77
+ void nm_dense_storage_register(const STORAGE* s);
78
+ void nm_dense_storage_unregister(const STORAGE* s);
79
+
80
+
81
+ ///////////////
82
+ // Accessors //
83
+ ///////////////
84
+
85
+
86
+ VALUE nm_dense_map_pair(VALUE self, VALUE right);
87
+ VALUE nm_dense_map(VALUE self);
88
+ VALUE nm_dense_each(VALUE nmatrix);
89
+ VALUE nm_dense_each_with_indices(VALUE nmatrix);
90
+ void* nm_dense_storage_get(const STORAGE* s, SLICE* slice);
91
+ void* nm_dense_storage_ref(const STORAGE* s, SLICE* slice);
92
+ void nm_dense_storage_set(VALUE left, SLICE* slice, VALUE right);
93
+
94
+ ///////////
95
+ // Tests //
96
+ ///////////
97
+
98
+ bool nm_dense_storage_eqeq(const STORAGE* left, const STORAGE* right);
99
+ bool nm_dense_storage_is_symmetric(const DENSE_STORAGE* mat, int lda);
100
+ bool nm_dense_storage_is_hermitian(const DENSE_STORAGE* mat, int lda);
101
+
102
+ //////////
103
+ // Math //
104
+ //////////
105
+
106
+ STORAGE* nm_dense_storage_matrix_multiply(const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector);
107
+
108
+ /////////////
109
+ // Utility //
110
+ /////////////
111
+
112
+ size_t nm_dense_storage_pos(const DENSE_STORAGE* s, const size_t* coords);
113
+ void nm_dense_storage_coords(const DENSE_STORAGE* s, const size_t slice_pos, size_t* coords_out);
114
+
115
+ /////////////////////////
116
+ // Copying and Casting //
117
+ /////////////////////////
118
+
119
+ DENSE_STORAGE* nm_dense_storage_copy(const DENSE_STORAGE* rhs);
120
+ STORAGE* nm_dense_storage_copy_transposed(const STORAGE* rhs_base);
121
+ STORAGE* nm_dense_storage_cast_copy(const STORAGE* rhs, nm::dtype_t new_dtype, void*);
122
+
123
+ } // end of extern "C" block
124
+
125
+ namespace nm {
126
+ std::pair<NMATRIX*,bool> interpret_arg_as_dense_nmatrix(VALUE right, nm::dtype_t dtype);
127
+ } // end of namespace nm
128
+
129
+ #endif // DENSE_H
@@ -0,0 +1,138 @@
1
+ /////////////////////////////////////////////////////////////////////
2
+ // = NMatrix
3
+ //
4
+ // A linear algebra library for scientific computation in Ruby.
5
+ // NMatrix is part of SciRuby.
6
+ //
7
+ // NMatrix was originally inspired by and derived from NArray, by
8
+ // Masahiro Tanaka: http://narray.rubyforge.org
9
+ //
10
+ // == Copyright Information
11
+ //
12
+ // SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
13
+ // NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
14
+ //
15
+ // Please see LICENSE.txt for additional copyright notices.
16
+ //
17
+ // == Contributing
18
+ //
19
+ // By contributing source code to SciRuby, you agree to be bound by
20
+ // our Contributor Agreement:
21
+ //
22
+ // * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
23
+ //
24
+ // == list.h
25
+ //
26
+ // List-of-lists n-dimensional matrix storage. Uses singly-linked
27
+ // lists.
28
+
29
+ #ifndef LIST_H
30
+ #define LIST_H
31
+
32
+ /*
33
+ * Standard Includes
34
+ */
35
+
36
+ #include <ruby.h>
37
+ #include <cstdlib>
38
+ #include <list>
39
+ /*
40
+ * Project Includes
41
+ */
42
+
43
+ #include "types.h"
44
+ #include "data/data.h"
45
+ #include "../common.h"
46
+ #include "util/sl_list.h"
47
+ #include "nmatrix.h"
48
+
49
+ /*
50
+ * Macros
51
+ */
52
+
53
+ /*
54
+ * Types
55
+ */
56
+
57
+
58
+
59
+ /*
60
+ * Data
61
+ */
62
+
63
+ extern "C" {
64
+
65
+ /*
66
+ * Functions
67
+ */
68
+
69
+ ////////////////
70
+ // Lifecycle //
71
+ ///////////////
72
+
73
+ LIST_STORAGE* nm_list_storage_create(nm::dtype_t dtype, size_t* shape, size_t dim, void* init_val);
74
+ void nm_list_storage_delete(STORAGE* s);
75
+ void nm_list_storage_delete_ref(STORAGE* s);
76
+ void nm_list_storage_mark(STORAGE*);
77
+ void nm_list_storage_register(const STORAGE* s);
78
+ void nm_list_storage_unregister(const STORAGE* s);
79
+ void nm_list_storage_register_list(const LIST* l, size_t recursions);
80
+ void nm_list_storage_unregister_list(const LIST* l, size_t recursions);
81
+ void nm_list_storage_register_node(const NODE* n);
82
+ void nm_list_storage_unregister_node(const NODE* n);
83
+ void nm_list_storage_completely_unregister_node(const NODE* curr);
84
+ ///////////////
85
+ // Accessors //
86
+ ///////////////
87
+
88
+ VALUE nm_list_each_with_indices(VALUE nmatrix, bool stored);
89
+ void* nm_list_storage_ref(const STORAGE* s, SLICE* slice);
90
+ void* nm_list_storage_get(const STORAGE* s, SLICE* slice);
91
+ NODE* nm_list_storage_insert(STORAGE* s, SLICE* slice, void* val);
92
+ void nm_list_storage_set(VALUE left, SLICE* slice, VALUE right);
93
+ void nm_list_storage_remove(STORAGE* s, SLICE* slice);
94
+
95
+ ///////////
96
+ // Tests //
97
+ ///////////
98
+
99
+ bool nm_list_storage_eqeq(const STORAGE* left, const STORAGE* right);
100
+
101
+ //////////
102
+ // Math //
103
+ //////////
104
+
105
+ STORAGE* nm_list_storage_matrix_multiply(const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector);
106
+
107
+
108
+ /////////////
109
+ // Utility //
110
+ /////////////
111
+
112
+ size_t nm_list_storage_count_elements_r(const LIST* l, size_t recursions);
113
+ size_t nm_list_storage_count_nd_elements(const LIST_STORAGE* s);
114
+
115
+ /*
116
+ * Count non-zero elements. See also count_list_storage_nd_elements.
117
+ */
118
+ inline size_t nm_list_storage_count_elements(const LIST_STORAGE* s) {
119
+ return nm_list_storage_count_elements_r(s->rows, s->dim - 1);
120
+ }
121
+
122
+ /////////////////////////
123
+ // Copying and Casting //
124
+ /////////////////////////
125
+
126
+ LIST_STORAGE* nm_list_storage_copy(const LIST_STORAGE* rhs);
127
+ STORAGE* nm_list_storage_copy_transposed(const STORAGE* rhs_base);
128
+ STORAGE* nm_list_storage_cast_copy(const STORAGE* rhs, nm::dtype_t new_dtype, void*);
129
+ VALUE nm_list_storage_to_hash(const LIST_STORAGE* s, const nm::dtype_t dtype);
130
+
131
+ // Exposed functions
132
+ VALUE nm_to_hash(VALUE self);
133
+ VALUE nm_list_map_merged_stored(VALUE left, VALUE right, VALUE init);
134
+ VALUE nm_list_map_stored(VALUE left, VALUE init);
135
+ VALUE nm_list_default_value(VALUE self);
136
+ } // end of extern "C" block
137
+
138
+ #endif // LIST_H