diff --git a/src/sparse/interfaces.jl b/src/sparse/interfaces.jl index 5cf3b1b767..352feb307a 100644 --- a/src/sparse/interfaces.jl +++ b/src/sparse/interfaces.jl @@ -11,7 +11,7 @@ Base.:(\)(adjA::Adjoint{T, LowerTriangular{T, S}},B::CuMatrix{T}) where {T<:Blas LinearAlgebra.mul!(C::CuVector{T},A::CuSparseMatrix,B::CuVector) where {T} = mv!('N',one(T),A,B,zero(T),C,'O') LinearAlgebra.mul!(C::CuVector{T},transA::Transpose{<:Any,<:CuSparseMatrix},B::CuVector) where {T} = mv!('T',one(T),parent(transA),B,zero(T),C,'O') -LinearAlgebra.mul!(C::CuVector{T},adjA::Adjoint{<:Any,<:CuSparseMatrix},B::CuVector) where {T} = mv!('C',one(T),parent(transA),B,zero(T),C,'O') +LinearAlgebra.mul!(C::CuVector{T},adjA::Adjoint{<:Any,<:CuSparseMatrix},B::CuVector) where {T} = mv!('C',one(T),parent(adjA),B,zero(T),C,'O') LinearAlgebra.mul!(C::CuVector{T},A::HermOrSym{T,<:CuSparseMatrix{T}},B::CuVector{T}) where T = mv!('N',one(T),A,B,zero(T),C,'O') LinearAlgebra.mul!(C::CuVector{T},transA::Transpose{<:Any, <:HermOrSym{T,<:CuSparseMatrix{T}}},B::CuVector{T}) where {T} = mv!('T',one(T),parent(transA),B,zero(T),C,'O') LinearAlgebra.mul!(C::CuVector{T},adjA::Adjoint{<:Any, <:HermOrSym{T,<:CuSparseMatrix{T}}},B::CuVector{T}) where {T} = mv!('C',one(T),parent(adjA),B,zero(T),C,'O') diff --git a/test/sparse.jl b/test/sparse.jl index d4b946d813..f813da97dd 100644 --- a/test/sparse.jl +++ b/test/sparse.jl @@ -2006,4 +2006,50 @@ end end end +@testset "mul!" begin + for elty in [Float32,Float64,ComplexF32,ComplexF64] + A = sparse(rand(elty,m,m)) + x = rand(elty,m) + y = rand(elty,m) + @testset "csr" begin + d_x = CuArray(x) + d_y = CuArray(y) + d_A = CuSparseMatrixCSR(A) + d_Aᵀ = transpose(d_A) + d_Aᴴ = adjoint(d_A) + CUSPARSE.mul!(d_y, d_A, d_x) + h_y = collect(d_y) + z = A * x + @test z ≈ h_y + CUSPARSE.mul!(d_y, d_Aᵀ, d_x) + h_y = collect(d_y) + z = transpose(A) * x + @test z ≈ h_y + CUSPARSE.mul!(d_y, d_Aᴴ, d_x) + h_y = collect(d_y) + z = adjoint(A) * x + @test z ≈ h_y + end + @testset "csc" begin + d_x = CuArray(x) + d_y = CuArray(y) + d_A = CuSparseMatrixCSC(A) + d_Aᵀ = transpose(d_A) + d_Aᴴ = adjoint(d_A) + CUSPARSE.mul!(d_y, d_A, d_x) + h_y = collect(d_y) + z = A * x + @test z ≈ h_y + CUSPARSE.mul!(d_y, d_Aᵀ, d_x) + h_y = collect(d_y) + z = transpose(A) * x + @test z ≈ h_y + CUSPARSE.mul!(d_y, d_Aᴴ, d_x) + h_y = collect(d_y) + z = adjoint(A) * x + @test z ≈ h_y + end + end +end + end