Skip to content

dispatch mul! to relax constraint #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/joAbstractLinearOperator/base_functions.jl
Original file line number Diff line number Diff line change
@@ -541,8 +541,9 @@ hvcat(rows::Tuple{Vararg{Int}}, ops::joAbstractLinearOperator...) = joBlock(coll
## overloaded LinearAlgebra functions

# mul!(...,jo,...)
mul!(y::LocalVector{RDT},A::joAbstractLinearOperator{DDT,RDT},x::LocalVector{DDT}) where {DDT,RDT} = y[:] = A * x
mul!(y::LocalMatrix{RDT},A::joAbstractLinearOperator{DDT,RDT},x::LocalMatrix{DDT}) where {DDT,RDT} = y[:,:] = A * x
# relax JOLI type constraint for IterativeSolvers
mul!(y::Union{LocalVector{RDT},LocalVector{DDT}},A::joAbstractLinearOperator{DDT,RDT},x::LocalVector{DDT}) where {DDT,RDT} = y[:] = jo_convert(eltype(y), A * x)
mul!(y::Union{LocalMatrix{RDT},LocalMatrix{DDT}},A::joAbstractLinearOperator{DDT,RDT},x::LocalMatrix{DDT}) where {DDT,RDT} = y[:,:] = jo_convert(eltype(y), A * x)

# ldiv!(...,jo,...)
ldiv!(y::LocalVector{DDT},A::joAbstractLinearOperator{DDT,RDT},x::LocalVector{RDT}) where {DDT,RDT} = y[:] = A \ x
8 changes: 8 additions & 0 deletions test/test_type.jl
Original file line number Diff line number Diff line change
@@ -54,4 +54,12 @@ x4 = transpose(A2) * y
@test isadjoint(A1)[1]
@test isadjoint(A2)[1]

# test for mul!, x will drop the imaginary part because x is real
mul!(y, A1, x)
mul!(x, A1, x)
@test x == jo_convert(Float32, y)
mul!(x, A1', y)
mul!(y, A1', y)
@test x == y

end