multiarray 0.10.3 → 0.10.4
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.
- data/Rakefile +1 -1
- data/lib/multiarray/complex.rb +6 -6
- data/test/tc_multiarray.rb +10 -10
- data/test/tc_sequence.rb +5 -5
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/multiarray/complex.rb
CHANGED
@@ -695,10 +695,10 @@ module Hornetseye
|
|
695
695
|
define_unary_op :imag, :scalar
|
696
696
|
|
697
697
|
def real_with_decompose
|
698
|
-
if typecode
|
699
|
-
decompose 0
|
700
|
-
elsif typecode == OBJECT
|
698
|
+
if typecode == OBJECT or is_a?( Variable )
|
701
699
|
real_without_decompose
|
700
|
+
elsif typecode < COMPLEX_
|
701
|
+
decompose 0
|
702
702
|
else
|
703
703
|
self
|
704
704
|
end
|
@@ -719,10 +719,10 @@ module Hornetseye
|
|
719
719
|
end
|
720
720
|
|
721
721
|
def imag_with_decompose
|
722
|
-
if typecode
|
723
|
-
decompose 1
|
724
|
-
elsif typecode == OBJECT
|
722
|
+
if typecode == OBJECT or is_a?( Variable )
|
725
723
|
imag_without_decompose
|
724
|
+
elsif typecode < COMPLEX_
|
725
|
+
decompose 1
|
726
726
|
else
|
727
727
|
Hornetseye::lazy( *shape ) { typecode.new( 0 ) }
|
728
728
|
end
|
data/test/tc_multiarray.rb
CHANGED
@@ -338,21 +338,21 @@ class TC_MultiArray < Test::Unit::TestCase
|
|
338
338
|
assert_equal M[ [ 1, 4 ], [ 5, 6 ] ], M[ [ C( 1, 2, 3 ), 4 ], [ 5, 6 ] ].r
|
339
339
|
assert_equal M[ [ 2, 4 ], [ 5, 6 ] ], M[ [ C( 1, 2, 3 ), 4 ], [ 5, 6 ] ].g
|
340
340
|
assert_equal M[ [ 3, 4 ], [ 5, 6 ] ], M[ [ C( 1, 2, 3 ), 4 ], [ 5, 6 ] ].b
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
341
|
+
assert_equal M[ [ 1, 4 ], [ 5, 6 ] ],
|
342
|
+
M[ [ C( 1, 2, 3 ), 4 ], [ 5, 6 ] ].collect { |x| x.r }
|
343
|
+
assert_equal M[ [ 2, 4 ], [ 5, 6 ] ],
|
344
|
+
M[ [ C( 1, 2, 3 ), 4 ], [ 5, 6 ] ].collect { |x| x.g }
|
345
|
+
assert_equal M[ [ 3, 4 ], [ 5, 6 ] ],
|
346
|
+
M[ [ C( 1, 2, 3 ), 4 ], [ 5, 6 ] ].collect { |x| x.b }
|
347
347
|
end
|
348
348
|
|
349
349
|
def test_real_imag
|
350
350
|
assert_equal M[ [ 1, 3 ], [ 4, 5 ] ], M[ [ X( 1, 2 ), 3 ], [ 4, 5 ] ].real
|
351
351
|
assert_equal M[ [ 2, 0 ], [ 0, 0 ] ], M[ [ X( 1, 2 ), 3 ], [ 4, 5 ] ].imag
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
352
|
+
assert_equal M[ [ 1, 3 ], [ 4, 5 ] ],
|
353
|
+
M[ [ X( 1, 2 ), 3 ], [ 4, 5 ] ].collect { |x| x.real }
|
354
|
+
assert_equal M[ [ 2, 0 ], [ 0, 0 ] ],
|
355
|
+
M[ [ X( 1, 2 ), 3 ], [ 4, 5 ] ].collect { |x| x.imag }
|
356
356
|
end
|
357
357
|
|
358
358
|
def test_inject
|
data/test/tc_sequence.rb
CHANGED
@@ -220,9 +220,9 @@ class TC_Sequence < Test::Unit::TestCase
|
|
220
220
|
assert_equal [ 1, 4, 5 ], t[ C( 1, 2, 3 ), 4, 5 ].r.to_a
|
221
221
|
assert_equal [ 2, 4, 5 ], t[ C( 1, 2, 3 ), 4, 5 ].g.to_a
|
222
222
|
assert_equal [ 3, 4, 5 ], t[ C( 1, 2, 3 ), 4, 5 ].b.to_a
|
223
|
-
|
224
|
-
|
225
|
-
|
223
|
+
assert_equal [ 1, 4, 5 ], t[ C( 1, 2, 3 ), 4, 5 ].collect { |x| x.r }.to_a
|
224
|
+
assert_equal [ 2, 4, 5 ], t[ C( 1, 2, 3 ), 4, 5 ].collect { |x| x.g }.to_a
|
225
|
+
assert_equal [ 3, 4, 5 ], t[ C( 1, 2, 3 ), 4, 5 ].collect { |x| x.b }.to_a
|
226
226
|
s = t[ 0, 0, 0 ]
|
227
227
|
assert_equal 1, s.r = 1
|
228
228
|
assert_equal S[ 1, 2, 3 ], s.g = S[ 1, 2, 3 ]
|
@@ -242,8 +242,8 @@ class TC_Sequence < Test::Unit::TestCase
|
|
242
242
|
[ S( O, 2 ), S( X, 2 ) ].each do |t|
|
243
243
|
assert_equal [ 1, 3 ], t[ X( 1, 2 ), 3 ].real.to_a
|
244
244
|
assert_equal [ 2, 0 ], t[ X( 1, 2 ), 3 ].imag.to_a
|
245
|
-
|
246
|
-
|
245
|
+
assert_equal [ 1, 3 ], t[ X( 1, 2 ), 3 ].collect { |x| x.real }.to_a
|
246
|
+
assert_equal [ 2, 0 ], t[ X( 1, 2 ), 3 ].collect { |x| x.imag }.to_a
|
247
247
|
s = t[ 0, 0 ]
|
248
248
|
assert_equal 1, s.real = 1
|
249
249
|
assert_equal S[ 2, 3 ], s.imag = S[ 2, 3 ]
|