Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit f02c2f5

Browse files
committed
irregular-irregular composition multiplication works now
1 parent 45660b6 commit f02c2f5

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

src/derivative_operators/derivative_operator_functions.jl

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,49 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,2}, A::AbstractDiffEqComposi
297297
end
298298
# Call everything A.ops using fallback
299299
else
300+
#operating_dims
301+
operating_dims = zeros(Int64,2)
302+
for L in A.ops
303+
if diff_axis(L) == 1
304+
operating_dims[1] = 1
305+
else
306+
operating_dims[2] = 1
307+
end
308+
end
309+
310+
x_temp_1, x_temp_2 = size(x_temp)
311+
312+
# Handle first case additively
300313
N = diff_axis(A.ops[1])
301314
if N == 1
302-
mul!(x_temp,A.ops[1],M)
315+
if operating_dims[2] == 1
316+
mul!(x_temp,A.ops[1],view(M,1:x_temp_1+2,1:x_temp_2))
317+
else
318+
mul!(x_temp,A.ops[1],M)
319+
end
303320
else
304-
mul!(x_temp,A.ops[1],M)
321+
if operating_dims[1] == 1
322+
mul!(x_temp,A.ops[1],view(M,1:x_temp_1,1:x_temp_2+2))
323+
else
324+
mul!(x_temp,A.ops[1],M)
325+
end
305326
end
327+
306328
for L in A.ops[2:end]
307-
mul_add!(x_temp,L,M)
329+
N = diff_axis(L)
330+
if N == 1
331+
if operating_dims[2] == 1
332+
mul_add!(x_temp,L,view(M,1:x_temp_1+2,1:x_temp_2))
333+
else
334+
mul_add!(x_temp,L,M)
335+
end
336+
else
337+
if operating_dims[1] == 1
338+
mul_add!(x_temp,L,view(M,1:x_temp_1,1:x_temp_2+2))
339+
else
340+
mul_add!(x_temp,L,M)
341+
end
342+
end
308343
end
309344
end
310345
end

test/2D_3D_fast_multiplication.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ end
494494
# Test composition of all operators
495495
A = Lx2+Lx3+Lx4+Ly2+Ly3+Ly4
496496
M_temp = zeros(N,N)
497-
@test_broken mul!(M_temp, A, M)
498-
@test_broken M_temp = ((Lx2*M)[1:N,2:N+1]+(Lx3*M)[1:N,2:N+1]+(Lx4*M)[1:N,2:N+1]+(Ly2*M)[2:N+1,1:N]+(Ly3*M)[2:N+1,1:N]+(Ly4*M)[2:N+1,1:N])
497+
mul!(M_temp, A, M)
498+
@test M_temp ((Lx2*M)[1:N,2:N+1]+(Lx3*M)[1:N,2:N+1]+(Lx4*M)[1:N,2:N+1]+(Ly2*M)[2:N+1,1:N]+(Ly3*M)[2:N+1,1:N]+(Ly4*M)[2:N+1,1:N])
499499

500500
end

0 commit comments

Comments
 (0)