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

Commit 3a9c2b9

Browse files
committed
some comments and coefficient type change
1 parent c439f97 commit 3a9c2b9

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/derivative_operators/derivative_operator.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function UpwindDifference{N}(derivative_order::Int,
117117
low_boundary_coefs = convert(SVector{boundary_point_count},_low_boundary_coefs)
118118
high_boundary_coefs = convert(SVector{boundary_point_count},reverse(SVector{boundary_stencil_length, T}[reverse(low_boundary_coefs[i]) for i in 1:boundary_point_count]))
119119

120-
coefficients = Vector{T}(undef,len)
120+
coefficients = nothing
121121

122122
DerivativeOperator{T,N,true,T,typeof(stencil_coefs),
123123
typeof(low_boundary_coefs),Vector{T},

src/derivative_operators/derivative_operator_functions.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
# Fallback mul! implementation for a single DerivativeOperator operating on an AbstractArray
13
function LinearAlgebra.mul!(x_temp::AbstractArray{T}, A::DerivativeOperator{T,N}, M::AbstractArray{T}) where {T<:Real,N}
24

35
# Check that x_temp has correct dimensions
@@ -25,6 +27,8 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T}, A::DerivativeOperator{T,N}
2527
end
2628
end
2729

30+
# A more efficient mul! implementation for a single, regular-grid, centered difference
31+
# DerivativeOperator operating on a 2D or 3D AbstractArray
2832
for MT in [2,3]
2933
@eval begin
3034
function LinearAlgebra.mul!(x_temp::AbstractArray{T,$MT}, A::DerivativeOperator{T,N,false,T2,S1}, M::AbstractArray{T,$MT}) where {T<:Real,N,T2,SL,S1<:SArray{Tuple{SL},T,1,SL}}
@@ -92,9 +96,17 @@ function *(A::DerivativeOperator{T,N},M::AbstractArray{T}) where {T<:Real,N}
9296
return x_temp
9397
end
9498

95-
# Will eventually implement proper dispatch
99+
# A more efficient mul! implementation for a composition of regular-grid, centered difference
100+
# DerivativeOperator operating on a 2D or 3D AbstractArray
96101
function LinearAlgebra.mul!(x_temp::AbstractArray{T,2}, A::AbstractDiffEqCompositeOperator, M::AbstractArray{T,2}) where {T}
97102

103+
#Check that composite operator satisfies: regular-grid, centered difference:
104+
#for L in A.ops
105+
# if L ... (does not satisfy conditions)
106+
# return (call fall back for multiplication of composite operators)
107+
# end
108+
#end
109+
98110
ndimsM = ndims(M)
99111
Wdims = ones(Int64,ndimsM)
100112
pad = zeros(Int64, ndimsM)
@@ -121,7 +133,7 @@ function LinearAlgebra.mul!(x_temp::AbstractArray{T,2}, A::AbstractDiffEqComposi
121133
for i in offset+1:Wdims[axis]-offset
122134
idx[axis]=i
123135

124-
W[idx...] += s[i-offset]
136+
W[idx...] += s[i-offset]
125137

126138
idx[axis] = mid_Wdims[axis]
127139
end

0 commit comments

Comments
 (0)