mdarray 0.5.3-java → 0.5.4-java

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.
Files changed (43) hide show
  1. data/README.md +325 -70
  2. data/doc/20130625 MDArray Internals.docx +0 -0
  3. data/lib/colt/colt.rb +2 -0
  4. data/lib/colt/matrix/colt_matrix.rb +365 -0
  5. data/lib/colt/matrix/matrix2D_floating_algebra.rb +325 -0
  6. data/lib/colt/matrix/matrix_hierarchy.rb +258 -0
  7. data/lib/mdarray.rb +54 -3
  8. data/lib/mdarray/access.rb +16 -0
  9. data/lib/mdarray/counter.rb +16 -0
  10. data/lib/mdarray/creation.rb +13 -1
  11. data/lib/mdarray/lazy_mdarray.rb +6 -2
  12. data/lib/mdarray/lazy_operators.rb +8 -0
  13. data/lib/mdarray/printing.rb +18 -3
  14. data/lib/mdarray/section.rb +101 -0
  15. data/lib/netcdf/attribute.rb +154 -0
  16. data/lib/netcdf/cdm_node.rb +71 -0
  17. data/lib/netcdf/dimension.rb +146 -0
  18. data/lib/netcdf/file.rb +253 -0
  19. data/lib/netcdf/file_writer.rb +474 -0
  20. data/lib/netcdf/group.rb +205 -0
  21. data/lib/netcdf/netcdf.rb +151 -0
  22. data/lib/netcdf/variable.rb +520 -0
  23. data/test/colt/test_complete.rb +1 -2
  24. data/test/colt/test_double_matrix2d.rb +186 -0
  25. data/test/colt/test_float_matrix2d.rb +171 -0
  26. data/test/colt/test_math.rb +21 -0
  27. data/test/colt/test_matrix.rb +172 -0
  28. data/test/complete.rb +9 -1
  29. data/test/env.rb +11 -1
  30. data/test/mdarray/test_complete.rb +2 -0
  31. data/test/mdarray/test_creation.rb +19 -28
  32. data/test/mdarray/test_non_numeric.rb +97 -0
  33. data/test/mdarray/test_sections.rb +94 -0
  34. data/test/mdarray/test_views.rb +23 -1
  35. data/test/netcdf/netcdfwriter.rb +197 -0
  36. data/test/netcdf/test_complete.rb +27 -0
  37. data/test/netcdf/test_netcdf.rb +331 -0
  38. data/test/netcdf/test_redefine.rb +120 -0
  39. data/vendor/incanter.jar +0 -0
  40. data/vendor/{netcdfAll-4.3.16.jar → netcdfAll-4.3.18.jar} +0 -0
  41. data/version.rb +1 -1
  42. metadata +44 -26
  43. data/vendor/parallelcolt-0.10.0.jar +0 -0
@@ -19,8 +19,7 @@
19
19
  # OR MODIFICATIONS.
20
20
  ##########################################################################################
21
21
 
22
- #=begin
23
22
  require_relative 'test_statistics'
24
23
  require_relative 'test_stat_list'
25
24
  require_relative 'test_math'
26
- #=end
25
+ require_relative 'test_matrix'
@@ -0,0 +1,186 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ##########################################################################################
4
+ # Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
5
+ # and distribute this software and its documentation, without fee and without a signed
6
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
7
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
8
+ # distributions.
9
+ #
10
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
11
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
12
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
13
+ # POSSIBILITY OF SUCH DAMAGE.
14
+ #
15
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
17
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
18
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
19
+ # OR MODIFICATIONS.
20
+ ##########################################################################################
21
+
22
+ require 'rubygems'
23
+ require "test/unit"
24
+ require 'shoulda'
25
+
26
+ require 'mdarray'
27
+
28
+ class MDArrayTest < Test::Unit::TestCase
29
+
30
+ context "Colt Matrix" do
31
+
32
+ setup do
33
+
34
+
35
+ end
36
+
37
+ #-------------------------------------------------------------------------------------
38
+ #
39
+ #-------------------------------------------------------------------------------------
40
+
41
+ should "test matrix functions" do
42
+
43
+ b = MDMatrix.double([3], [1.5, 1, 1.3])
44
+
45
+ pos = MDArray.double([3, 3], [2, -1, 0, -1, 2, -1, 0, -1, 2])
46
+ matrix = MDMatrix.from_mdarray(pos)
47
+ result = matrix.chol
48
+ p "Cholesky decomposition"
49
+ result.print
50
+ printf("\n\n")
51
+
52
+ eig = matrix.eig
53
+ p "eigen decomposition"
54
+ p "eigenvalue matrix"
55
+ eig[0].print
56
+ printf("\n\n")
57
+ p "imaginary parts of the eigenvalues"
58
+ eig[1].print
59
+ printf("\n\n")
60
+ p "real parts of the eigenvalues"
61
+ eig[2].print
62
+ printf("\n\n")
63
+ p "eigenvector matrix"
64
+ eig[3].print
65
+ printf("\n\n")
66
+
67
+ lu = matrix.lu
68
+ p "lu decomposition"
69
+ p "is non singular: #{lu[0]}"
70
+ p "determinant: #{lu[1]}"
71
+ p "pivot vector: #{lu[2]}"
72
+ p "lower triangular matrix"
73
+ lu[3].print
74
+ printf("\n\n")
75
+ p "upper triangular matrix"
76
+ lu[4].print
77
+ printf("\n\n")
78
+
79
+ # Returns the condition of matrix A, which is the ratio of largest to
80
+ # smallest singular value.
81
+ p "condition of matrix"
82
+ p matrix.cond
83
+
84
+ # Solves the upper triangular system U*x=b;
85
+ p "solving the equation by backward_solve"
86
+ solve = lu[4].backward_solve(b)
87
+ solve.print
88
+ printf("\n\n")
89
+
90
+ # Solves the lower triangular system U*x=b;
91
+ p "solving the equation by forward_solve"
92
+ solve = lu[3].forward_solve(b)
93
+ solve.print
94
+ printf("\n\n")
95
+
96
+ qr = matrix.qr
97
+ p "QR decomposition"
98
+ p "Matrix has full rank: #{qr[0]}"
99
+ p "Orthogonal factor Q:"
100
+ qr[1].print
101
+ printf("\n\n")
102
+ p "Upper triangular factor, R"
103
+ qr[2].print
104
+ printf("\n\n")
105
+
106
+ svd = matrix.svd
107
+ p "Singular value decomposition"
108
+ p "operation success? #{svd[0]}" # 0 success; < 0 ith value is illegal; > 0 not converge
109
+ p "cond: #{svd[1]}"
110
+ p "norm2: #{svd[2]}"
111
+ p "rank: #{svd[3]}"
112
+ p "singular values"
113
+ p svd[4]
114
+ p "Diagonal matrix of singular values"
115
+ # svd[5].print
116
+ printf("\n\n")
117
+ p "left singular vectors U"
118
+ svd[6].print
119
+ printf("\n\n")
120
+ p "right singular vectors V"
121
+ svd[7].print
122
+ printf("\n\n")
123
+
124
+ m = MDArray.typed_arange("double", 0, 16)
125
+ m.reshape!([4, 4])
126
+ matrix1 = MDMatrix.from_mdarray(m)
127
+ # mat2 = matrix.chol
128
+ matrix1.print
129
+ printf("\n\n")
130
+
131
+ m = MDArray.typed_arange("double", 16, 32)
132
+ m.reshape!([4, 4])
133
+ matrix2 = MDMatrix.from_mdarray(m)
134
+ matrix2.print
135
+ printf("\n\n")
136
+
137
+ result = matrix1 * matrix2
138
+ p "matrix multiplication"
139
+ result.print
140
+ printf("\n\n")
141
+
142
+ result = matrix1.kron(matrix2)
143
+ p "Kronecker multiplication"
144
+ result.print
145
+ printf("\n\n")
146
+
147
+ print "determinant is: #{result.det}"
148
+ printf("\n\n")
149
+
150
+ p "norm1"
151
+ p result.norm1
152
+
153
+ p "norm2"
154
+ p result.norm2
155
+
156
+ p "Returns the Frobenius norm of matrix A, which is Sqrt(Sum(A[i,j]^2))"
157
+ p result.normF
158
+
159
+ p "Returns the infinity norm of matrix A, which is the maximum absolute row sum."
160
+ p result.norm_infinity
161
+
162
+ power3 = result ** 3
163
+ power3.print
164
+ printf("\n\n")
165
+
166
+ p result.trace
167
+
168
+ trap_lower = result.trapezoidal_lower
169
+ trap_lower.print
170
+ printf("\n\n")
171
+
172
+ p result.vector_norm2
173
+
174
+ result.normalize!
175
+ result.print
176
+ printf("\n\n")
177
+
178
+ p "summing all values of result: #{result.sum}"
179
+
180
+ result.mdarray.print
181
+
182
+ end
183
+ #=end
184
+ end
185
+
186
+ end
@@ -0,0 +1,171 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ##########################################################################################
4
+ # Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
5
+ # and distribute this software and its documentation, without fee and without a signed
6
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
7
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
8
+ # distributions.
9
+ #
10
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
11
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
12
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
13
+ # POSSIBILITY OF SUCH DAMAGE.
14
+ #
15
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
17
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
18
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
19
+ # OR MODIFICATIONS.
20
+ ##########################################################################################
21
+
22
+ require 'rubygems'
23
+ require "test/unit"
24
+ require 'shoulda'
25
+
26
+ require 'mdarray'
27
+
28
+ class MDArrayTest < Test::Unit::TestCase
29
+
30
+ context "Colt Matrix" do
31
+
32
+ setup do
33
+
34
+
35
+ end
36
+
37
+ #-------------------------------------------------------------------------------------
38
+ #
39
+ #-------------------------------------------------------------------------------------
40
+
41
+ should "test matrix functions" do
42
+
43
+ b = MDMatrix.float([3], [1.5, 1, 1.3])
44
+
45
+ pos = MDArray.float([3, 3], [2, -1, 0, -1, 2, -1, 0, -1, 2])
46
+ matrix = MDMatrix.from_mdarray(pos)
47
+ result = matrix.chol
48
+ p "Cholesky decomposition"
49
+ result.print
50
+ printf("\n\n")
51
+
52
+ eig = matrix.eig
53
+ p "eigen decomposition"
54
+ p "eigenvalue matrix"
55
+ eig[0].print
56
+ printf("\n\n")
57
+ p "imaginary parts of the eigenvalues"
58
+ eig[1].print
59
+ printf("\n\n")
60
+ p "real parts of the eigenvalues"
61
+ eig[2].print
62
+ printf("\n\n")
63
+ p "eigenvector matrix"
64
+ eig[3].print
65
+ printf("\n\n")
66
+
67
+ lu = matrix.lu
68
+ p "lu decomposition"
69
+ p "is non singular: #{lu[0]}"
70
+ p "determinant: #{lu[1]}"
71
+ p "pivot vector: #{lu[2]}"
72
+ p "lower triangular matrix"
73
+ lu[3].print
74
+ printf("\n\n")
75
+ p "upper triangular matrix"
76
+ lu[4].print
77
+ printf("\n\n")
78
+
79
+ # Returns the condition of matrix A, which is the ratio of largest to
80
+ # smallest singular value.
81
+ p "condition of matrix"
82
+ p matrix.cond
83
+
84
+ # Solves the upper triangular system U*x=b;
85
+ p "solving the equation by backward_solve"
86
+ solve = lu[4].backward_solve(b)
87
+ solve.print
88
+ printf("\n\n")
89
+
90
+ # Solves the lower triangular system U*x=b;
91
+ p "solving the equation by forward_solve"
92
+ solve = lu[3].forward_solve(b)
93
+ solve.print
94
+ printf("\n\n")
95
+
96
+ qr = matrix.qr
97
+ p "QR decomposition"
98
+ p "Matrix has full rank: #{qr[0]}"
99
+ p "Householder vectors"
100
+ qr[1].print
101
+ printf("\n\n")
102
+ p "Orthogonal factor Q:"
103
+ qr[2].print
104
+ printf("\n\n")
105
+ p "Upper triangular factor, R"
106
+ qr[3].print
107
+ printf("\n\n")
108
+
109
+ m = MDArray.typed_arange("float", 0, 16)
110
+ m.reshape!([4, 4])
111
+ matrix1 = MDMatrix.from_mdarray(m)
112
+ # mat2 = matrix.chol
113
+ matrix1.print
114
+ printf("\n\n")
115
+
116
+ m = MDArray.typed_arange("float", 16, 32)
117
+ m.reshape!([4, 4])
118
+ matrix2 = MDMatrix.from_mdarray(m)
119
+ matrix2.print
120
+ printf("\n\n")
121
+
122
+ result = matrix1 * matrix2
123
+ p "matrix multiplication"
124
+ result.print
125
+ printf("\n\n")
126
+
127
+ result = matrix1.kron(matrix2)
128
+ p "Kronecker multiplication"
129
+ result.print
130
+ printf("\n\n")
131
+
132
+ print "determinant is: #{result.det}"
133
+ printf("\n\n")
134
+
135
+ p "norm1"
136
+ p result.norm1
137
+
138
+ p "norm2"
139
+ p result.norm2
140
+
141
+ p "Returns the Frobenius norm of matrix A, which is Sqrt(Sum(A[i,j]^2))"
142
+ p result.normF
143
+
144
+ p "Returns the infinity norm of matrix A, which is the maximum absolute row sum."
145
+ p result.norm_infinity
146
+
147
+ power3 = result ** 3
148
+ power3.print
149
+ printf("\n\n")
150
+
151
+ p result.trace
152
+
153
+ trap_lower = result.trapezoidal_lower
154
+ trap_lower.print
155
+ printf("\n\n")
156
+
157
+ p result.vector_norm2
158
+
159
+ result.normalize!
160
+ result.print
161
+ printf("\n\n")
162
+
163
+ p "summing all values of result: #{result.sum}"
164
+
165
+ result.mdarray.print
166
+
167
+ end
168
+ #=end
169
+ end
170
+
171
+ end
@@ -1,3 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ##########################################################################################
4
+ # Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
5
+ # and distribute this software and its documentation, without fee and without a signed
6
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
7
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
8
+ # distributions.
9
+ #
10
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
11
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
12
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
13
+ # POSSIBILITY OF SUCH DAMAGE.
14
+ #
15
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
17
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
18
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
19
+ # OR MODIFICATIONS.
20
+ ##########################################################################################
21
+
1
22
  require 'rubygems'
2
23
  require "test/unit"
3
24
  require 'shoulda'
@@ -0,0 +1,172 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ##########################################################################################
4
+ # Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
5
+ # and distribute this software and its documentation, without fee and without a signed
6
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
7
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
8
+ # distributions.
9
+ #
10
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
11
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
12
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
13
+ # POSSIBILITY OF SUCH DAMAGE.
14
+ #
15
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
17
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
18
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
19
+ # OR MODIFICATIONS.
20
+ ##########################################################################################
21
+
22
+ require 'rubygems'
23
+ require "test/unit"
24
+ require 'shoulda'
25
+
26
+ require 'mdarray'
27
+
28
+ class MDArrayTest < Test::Unit::TestCase
29
+
30
+ context "Colt Matrix" do
31
+
32
+ setup do
33
+
34
+ end
35
+
36
+ #-------------------------------------------------------------------------------------
37
+ #
38
+ #-------------------------------------------------------------------------------------
39
+
40
+ should "create 1D matrices" do
41
+
42
+ d1 = MDArray.double([5, 3, 6, 7])
43
+ assert_raise (RuntimeError) { matrix = MDMatrix.from_mdarray(d1) }
44
+
45
+ d2 = MDArray.typed_arange("double", 0, 15)
46
+ double_matrix = MDMatrix.from_mdarray(d2)
47
+ double_matrix.print
48
+ printf("\n\n")
49
+
50
+ f1 = MDArray.typed_arange("float", 0, 15)
51
+ float_matrix = MDMatrix.from_mdarray(f1)
52
+ float_matrix.print
53
+ printf("\n\n")
54
+
55
+ l1 = MDArray.typed_arange("long", 0, 15)
56
+ long_matrix = MDMatrix.from_mdarray(l1)
57
+ long_matrix.print
58
+ printf("\n\n")
59
+
60
+ i1 = MDArray.typed_arange("int", 0, 15)
61
+ int_matrix = MDMatrix.from_mdarray(i1)
62
+ int_matrix.print
63
+ printf("\n\n")
64
+
65
+ end
66
+
67
+ #-------------------------------------------------------------------------------------
68
+ #
69
+ #-------------------------------------------------------------------------------------
70
+
71
+ should "create 3D matrices" do
72
+
73
+ d1 = MDArray.double([5, 3, 6, 7])
74
+ assert_raise (RuntimeError) { matrix = MDMatrix.from_mdarray(d1) }
75
+
76
+ d2 = MDArray.typed_arange("double", 0, 60)
77
+ d2.reshape!([5, 3, 4])
78
+ double_matrix = MDMatrix.from_mdarray(d2)
79
+ double_matrix.print
80
+ printf("\n\n")
81
+
82
+ f1 = MDArray.typed_arange("float", 0, 60)
83
+ f1.reshape!([5, 3, 4])
84
+ float_matrix = MDMatrix.from_mdarray(f1)
85
+ float_matrix.print
86
+ printf("\n\n")
87
+
88
+ l1 = MDArray.typed_arange("long", 0, 60)
89
+ l1.reshape!([5, 3, 4])
90
+ long_matrix = MDMatrix.from_mdarray(l1)
91
+ long_matrix.print
92
+ printf("\n\n")
93
+
94
+ i1 = MDArray.typed_arange("int", 0, 60)
95
+ i1.reshape!([5, 3, 4])
96
+ int_matrix = MDMatrix.from_mdarray(i1)
97
+ int_matrix.print
98
+ printf("\n\n")
99
+
100
+ end
101
+
102
+ #-------------------------------------------------------------------------------------
103
+ #
104
+ #-------------------------------------------------------------------------------------
105
+ #=begin
106
+ should "create 2D matrices" do
107
+
108
+ d1 = MDArray.double([5, 3, 6, 7])
109
+ assert_raise (RuntimeError) { matrix = MDMatrix.from_mdarray(d1) }
110
+
111
+ d2 = MDArray.typed_arange("double", 0, 15)
112
+ d2.reshape!([5, 3])
113
+ double_matrix = MDMatrix.from_mdarray(d2)
114
+ double_matrix.print
115
+ printf("\n\n")
116
+
117
+ f1 = MDArray.typed_arange("float", 0, 15)
118
+ f1.reshape!([5, 3])
119
+ float_matrix = MDMatrix.from_mdarray(f1)
120
+ float_matrix.print
121
+ printf("\n\n")
122
+
123
+ l1 = MDArray.typed_arange("long", 0, 15)
124
+ l1.reshape!([5, 3])
125
+ long_matrix = MDMatrix.from_mdarray(l1)
126
+ long_matrix.print
127
+ printf("\n\n")
128
+
129
+ i1 = MDArray.typed_arange("int", 0, 15)
130
+ i1.reshape!([5, 3])
131
+ int_matrix = MDMatrix.from_mdarray(i1)
132
+ int_matrix.print
133
+ printf("\n\n")
134
+
135
+ end
136
+
137
+ #-------------------------------------------------------------------------------------
138
+ #
139
+ #-------------------------------------------------------------------------------------
140
+
141
+ should "create matrices from sliced MDArray" do
142
+
143
+ d1 = MDArray.typed_arange("double", 0, 90)
144
+ d1.reshape!([5, 3, 6])
145
+
146
+ d1.print
147
+ d2 = d1.slice(0, 0)
148
+ d2.print
149
+ matrix = MDMatrix.from_mdarray(d2)
150
+ matrix.print
151
+ p " "
152
+
153
+ d2 = d1.slice(0, 1)
154
+ d2.print
155
+ matrix = MDMatrix.from_mdarray(d2)
156
+ matrix.print
157
+ p " "
158
+
159
+ d2 = d1.slice(1, 1)
160
+ d2.print
161
+ matrix = MDMatrix.from_mdarray(d2)
162
+ matrix.print
163
+ p " "
164
+
165
+ end
166
+
167
+ end
168
+
169
+ end
170
+
171
+ require_relative 'test_double_matrix2d'
172
+ # require_relative 'test_float_matrix2d'