@@ -581,7 +581,9 @@ let x = spv_x1, x2 = x2 = spv_x2
581
581
582
582
# multiplies
583
583
xm = SparseVector (8 , [2 , 6 ], [5.0 , - 19.25 ])
584
- @test exact_equal (x .* x, abs2 (x))
584
+ let y= x # workaround for broadcast not preserving sparsity in general
585
+ @test exact_equal (x .* y, abs2 (x))
586
+ end
585
587
@test exact_equal (x .* x2, xm)
586
588
@test exact_equal (x2 .* x, xm)
587
589
@@ -724,19 +726,19 @@ let x = sprand(16, 0.5), x2 = sprand(16, 0.4)
724
726
end
725
727
726
728
# scale
727
- let sx = SparseVector (x. n, x. nzind, x. nzval * 2.5 )
728
- @test exact_equal (x * 2.5 , sx)
729
- @test exact_equal (x * (2.5 + 0.0 * im), complex (sx))
730
- @test exact_equal (2.5 * x, sx)
731
- @test exact_equal ((2.5 + 0.0 * im) * x, complex (sx))
732
- @test exact_equal (x * 2.5 , sx)
733
- @test exact_equal (2.5 * x, sx)
734
- @test exact_equal (x .* 2.5 , sx)
735
- @test exact_equal (2.5 .* x, sx)
736
- @test exact_equal (x / 2.5 , SparseVector (x. n, x. nzind, x. nzval / 2.5 ))
729
+ let α = 2.5 , sx = SparseVector (x. n, x. nzind, x. nzval * α )
730
+ @test exact_equal (x * α , sx)
731
+ @test exact_equal (x * (α + 0.0 * im), complex (sx))
732
+ @test exact_equal (α * x, sx)
733
+ @test exact_equal ((α + 0.0 * im) * x, complex (sx))
734
+ @test exact_equal (x * α , sx)
735
+ @test exact_equal (α * x, sx)
736
+ @test exact_equal (x .* α , sx)
737
+ @test exact_equal (α .* x, sx)
738
+ @test exact_equal (x / α , SparseVector (x. n, x. nzind, x. nzval / α ))
737
739
738
740
xc = copy (x)
739
- @test is (scale! (xc, 2.5 ), xc)
741
+ @test is (scale! (xc, α ), xc)
740
742
@test exact_equal (xc, sx)
741
743
end
742
744
0 commit comments