Skip to content

Commit

Permalink
extend MatrixMap comparison, switch order of A_mul_B! for lincombs
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch committed Sep 26, 2019
1 parent f7abb5f commit b22a8b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/linearcombination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ else # 5-arg mul! is available for matrices
# map types that have an allocation-free 5-arg mul! implementation
const FreeMap = Union{MatrixMap,UniformScalingMap}

function A_mul_B!(y::AbstractVector, A::LinearCombination{T,As}, x::AbstractVector) where {T, As<:Tuple{Vararg{FreeMap}}}
# no size checking, will be done by individual maps
A_mul_B!(y, A.maps[1], x)
for n in 2:length(A.maps)
mul!(y, A.maps[n], x, true, true)
end
return y
end
function A_mul_B!(y::AbstractVector, A::LinearCombination, x::AbstractVector)
# no size checking, will be done by individual maps
A_mul_B!(y, A.maps[1], x)
Expand All @@ -85,14 +93,6 @@ function A_mul_B!(y::AbstractVector, A::LinearCombination, x::AbstractVector)
end
return y
end
function A_mul_B!(y::AbstractVector, A::LinearCombination{T,As}, x::AbstractVector) where {T, As<:Tuple{Vararg{FreeMap}}}
# no size checking, will be done by individual maps
A_mul_B!(y, A.maps[1], x)
for n in 2:length(A.maps)
mul!(y, A.maps[n], x, true, true)
end
return y
end

function LinearAlgebra.mul!(y::AbstractVector, A::LinearCombination{T,As}, x::AbstractVector, α::Number=true, β::Number=false) where {T, As<:Tuple{Vararg{FreeMap}}}
length(y) == size(A, 1) || throw(DimensionMismatch("mul!"))
Expand Down
4 changes: 3 additions & 1 deletion src/wrappedmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ LinearAlgebra.transpose(A::MatrixMap{T}) where {T} =
LinearAlgebra.adjoint(A::MatrixMap{T}) where {T} =
WrappedMap{T}(adjoint(A.lmap); issymmetric=A._issymmetric, ishermitian=A._ishermitian, isposdef=A._isposdef)

Base.:(==)(A::MatrixMap, B::MatrixMap) = (eltype(A) == eltype(B) && A.lmap == B.lmap)
Base.:(==)(A::MatrixMap, B::MatrixMap) =
(eltype(A)==eltype(B) && A.lmap==B.lmap && A._issymmetric==B._issymmetric &&
A._ishermitian==B._ishermitian && A._isposdef==B._isposdef)

if VERSION v"1.3.0-alpha.115"

Expand Down

0 comments on commit b22a8b8

Please sign in to comment.