@@ -12,6 +12,7 @@ isdefined(Main, :LinearAlgebraTestHelpers) || Base.include(Main, TESTHELPERS)
1212
1313using Main. LinearAlgebraTestHelpers. OffsetArrays
1414using Main. LinearAlgebraTestHelpers. ImmutableArrays
15+ using Main. LinearAlgebraTestHelpers. Quaternions
1516
1617@testset " Adjoint and Transpose inner constructor basics" begin
1718 intvec, intmat = [1 , 2 ], [1 2 ; 3 4 ]
809810 end
810811end
811812
813+ @testset " lmul!/rmul! by numbers" begin
814+ @testset " $(eltype (A)) " for A in (rand (4 , 4 ), rand (ComplexF64,4 ,4 ),
815+ fill ([1 2 ; 3 4 ], 4 , 4 ),
816+ fill (Quaternion (1 ,2 ,3 ,4 ), 4 , 4 ))
817+ B = copy (A)
818+ @testset for op in (transpose, adjoint)
819+ A .= B
820+ @test lmul! (2 , op (A)) == 2 * op (B)
821+ A .= B
822+ @test rmul! (op (A), 2 ) == op (B) * 2
823+ if eltype (A) <: Complex
824+ A .= B
825+ @test lmul! (- 2im , op (A)) == - 2im * op (B)
826+ A .= B
827+ @test rmul! (op (A), - 2im ) == op (B) * - 2im
828+ end
829+ if eltype (A) <: Quaternion
830+ A .= B
831+ q = Quaternion (0 ,1 ,4 ,7 )
832+ @test lmul! (q, op (A)) == q * op (B)
833+ A .= B
834+ @test rmul! (op (A), q) == op (B) * q
835+ end
836+ end
837+ end
838+ end
839+
812840@testset " fillband!" begin
813841 for A in (rand (4 , 4 ), rand (ComplexF64,4 ,4 ))
814842 B = similar (A)
0 commit comments