Skip to content

select intermediate destination of CompositionMap based on input #80

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

Merged
merged 4 commits into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions src/composition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,18 @@ function A_mul_B!(y::AbstractVector, A::CompositeMap, x::AbstractVector)
if N==1
A_mul_B!(y, A.maps[1], x)
else
T = eltype(y)
dest = Array{T}(undef, size(A.maps[1], 1))
dest = similar(y, size(A.maps[1], 1))
A_mul_B!(dest, A.maps[1], x)
source = dest
if N>2
dest = Array{T}(undef, size(A.maps[2], 1))
dest = similar(y, size(A.maps[2], 1))
end
for n in 2:N-1
try
resize!(dest, size(A.maps[n], 1))
catch err
if err == ErrorException("cannot resize array with shared data")
dest = Array{T}(undef, size(A.maps[n], 1))
dest = similar(y, size(A.maps[n], 1))
else
rethrow(err)
end
Expand Down
5 changes: 2 additions & 3 deletions src/kronecker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ Base.:(==)(A::KroneckerMap, B::KroneckerMap) = (eltype(A) == eltype(B) && A.maps
na, ma = size(At)
mb, nb = size(B)
v = zeros(T, ma)
Ty = eltype(y)
temp1 = Array{Ty}(undef, na)
temp2 = Array{Ty}(undef, nb)
temp1 = similar(y, na)
temp2 = similar(y, nb)
@views @inbounds for i in 1:ma
v[i] = one(T)
A_mul_B!(temp1, At, v)
Expand Down