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

Commit 7b027a8

Browse files
explicitly zero caches
1 parent c1d0cc3 commit 7b027a8

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/composite_operators.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct DiffEqOperatorCombination{T,O<:Tuple{Vararg{AbstractDiffEqLinearOperator{
5353
T = eltype(ops[1])
5454
if cache == nothing
5555
cache = Vector{T}(undef, size(ops[1], 1))
56+
fill!(cache,0)
5657
end
5758
# TODO: safecheck dimensions
5859
new{T,typeof(ops),typeof(cache)}(ops, cache)
@@ -96,7 +97,9 @@ struct DiffEqOperatorComposition{T,O<:Tuple{Vararg{AbstractDiffEqLinearOperator{
9697
# Construct a list of caches to be used by mul! and ldiv!
9798
caches = []
9899
for op in ops[1:end-1]
99-
push!(caches, Vector{T}(undef, size(op, 1)))
100+
tmp = Vector{T}(undef, size(op, 1))
101+
fill!(tmp,0)
102+
push!(caches,tmp)
100103
end
101104
caches = tuple(caches...)
102105
end

src/derivative_operators/abstract_operator_functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ end
166166
################################################################################
167167

168168
function *(coeff_func::Function, A::DerivativeOperator{T,N,Wind}) where {T,N,Wind}
169-
coefficients = A.coefficients === nothing ? Vector{T}(undef, A.len) : A.coefficients
169+
coefficients = A.coefficients === nothing ? zeros(T,A.len) : A.coefficients
170170

171171
DerivativeOperator{T,N,Wind,typeof(A.dx),typeof(A.stencil_coefs),
172172
typeof(A.low_boundary_coefs),typeof(coefficients),

src/derivative_operators/derivative_operator.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function CenteredDifference{N}(derivative_order::Int,
103103
calculate_weights(derivative_order, high_boundary_x[end-i], high_boundary_x)) for i in boundary_point_count:-1:1]
104104
high_boundary_coefs = convert(SVector{boundary_point_count},_high_boundary_coefs)
105105

106-
coefficients = coeff_func isa Nothing ? nothing : Vector{T}(undef,len)
106+
coefficients = coeff_func isa Nothing ? nothing : zeros(T,len)
107107

108108
DerivativeOperator{T,N,false,typeof(dx),typeof(stencil_coefs),
109109
typeof(low_boundary_coefs),typeof(coefficients),
@@ -169,7 +169,7 @@ function UpwindDifference{N}(derivative_order::Int,
169169
_high_boundary_coefs = SVector{boundary_stencil_length, T}[convert(SVector{boundary_stencil_length, T}, ((-1/dx)^derivative_order) * calculate_weights(derivative_order, oneunit(T)*x0, high_boundary_x)) for x0 in R_boundary_deriv_spots]
170170
high_boundary_coefs = convert(SVector{boundary_point_count},_high_boundary_coefs)
171171

172-
coefficients = Vector{T}(undef,len)
172+
coefficients = zeros(T,len)
173173
if coeff_func != nothing
174174
compute_coeffs!(coeff_func, coefficients)
175175
end
@@ -215,7 +215,7 @@ function UpwindDifference{N}(derivative_order::Int,
215215
high_boundary_coefs = [_upwind_coefs ; _downwind_coefs]
216216

217217
# Compute coefficients
218-
coefficients = Vector{T}(undef,len)
218+
coefficients = zeros(T,len)
219219
if coeff_func != nothing
220220
compute_coeffs!(coeff_func, coefficients)
221221
end

test/upwind_operators_interface.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ end
586586
L = UpwindDifference(1,2, 0.1, N, 1.0)
587587
analyticL = 10.0*analyticOneTwoPos()
588588
x = rand(7)
589+
@show x
589590

590591
# Test that multiplication agrees with analytic multiplication
591592
@test L*x analyticL*x

0 commit comments

Comments
 (0)