We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a359c7c commit a462e5aCopy full SHA for a462e5a
src/adjtrans.jl
@@ -513,8 +513,9 @@ function _dot_nonrecursive(u, v)
513
end
514
515
516
-rmul!(X::AdjOrTrans, s::Number) = (lmul!(wrapperop(X)(s), parent(X)); X)
517
-lmul!(s::Number, X::AdjOrTrans) = (rmul!(parent(X), wrapperop(X)(s)); X)
+# we use (n A^T) = (A n)^T, which holds if the product of n and the elements of A is commutative
+rmul!(X::AdjOrTrans{<:Union{Real,Complex}}, s::Union{Real,Complex}) = (lmul!(wrapperop(X)(s), parent(X)); X)
518
+lmul!(s::Union{Real,Complex}, X::AdjOrTrans{<:Union{Real,Complex}}) = (rmul!(parent(X), wrapperop(X)(s)); X)
519
520
# Adjoint/Transpose-vector * vector
521
*(u::AdjointAbsVec{<:Number}, v::AbstractVector{<:Number}) = dot(u.parent, v)
test/adjtrans.jl
@@ -12,6 +12,7 @@ isdefined(Main, :LinearAlgebraTestHelpers) || Base.include(Main, TESTHELPERS)
12
13
using Main.LinearAlgebraTestHelpers.OffsetArrays
14
using Main.LinearAlgebraTestHelpers.ImmutableArrays
15
+using Main.LinearAlgebraTestHelpers.Quaternions
16
17
@testset "Adjoint and Transpose inner constructor basics" begin
18
intvec, intmat = [1, 2], [1 2; 3 4]
@@ -811,7 +812,8 @@ end
811
812
813
@testset "lmul!/rmul! by numbers" begin
814
@testset "$(eltype(A))" for A in (rand(4, 4), rand(ComplexF64,4,4),
- fill([1 2; 3 4], 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
@@ -824,6 +826,13 @@ end
824
826
825
827
@test rmul!(op(A), -2im) == op(B) * -2im
828
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
834
+ @test rmul!(op(A), q) == op(B) * q
835
+ end
836
837
838
0 commit comments