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

Commit 5c569d9

Browse files
committed
concretization tests and fixed BandedMatrix initialization and convolve_right_BC
1 parent 9cc8220 commit 5c569d9

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

src/DiffEqOperators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ include("derivative_operators/derivative_irreg_operator.jl")
3030
include("derivative_operators/derivative_operator.jl")
3131
include("derivative_operators/abstract_operator_functions.jl")
3232
include("derivative_operators/convolutions.jl")
33+
include("derivative_operators/concretization.jl")
3334

3435
### Composite Operators
3536
include("composite_operators.jl")

src/derivative_operators/concretization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function BandedMatrices.BandedMatrix(A::DerivativeOperator{T}) where T
4343
bl = A.boundary_length
4444
stl = A.stencil_length
4545
stl_2 = div(stl,2)
46-
L = BandedMatrix{T}(undef, (N, N+2), (max(stl-3,0),max(stl-1,0)))
46+
L = BandedMatrix{T}(Zeros(N, N+2), (max(stl-3,0),max(stl-1,0)))
4747
for i in 1:A.boundary_length
4848
L[i,1:stl] = A.low_boundary_coefs[i]
4949
end

src/derivative_operators/convolutions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function convolve_BC_right!(x_temp::AbstractVector{T}, x::AbstractVector{T}, A::
3737
coeffs = A.high_boundary_coefs
3838
Threads.@threads for i in 1 : A.boundary_length
3939
xtempi = coeffs[i][end]*x[end]
40-
@inbounds for idx in A.stencil_length:-1:1
40+
@inbounds for idx in A.stencil_length-1:-1:1
4141
xtempi += coeffs[i][end-idx] * x[end-idx]
4242
end
4343
x_temp[end-A.boundary_length+i] = xtempi

test/derivative_operators_interface.jl

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SparseArrays, DiffEqOperators, LinearAlgebra, Random, Test
1+
using SparseArrays, DiffEqOperators, LinearAlgebra, Random, Test, BandedMatrices
22

33
function second_derivative_stencil(N)
44
A = zeros(N,N+2)
@@ -30,15 +30,37 @@ end
3030
N = 10
3131
d_order = 2
3232
approx_order = 2
33-
x = collect(1:1.0:N).^2
3433
correct = second_derivative_stencil(N)
3534
A = DerivativeOperator{Float64}(d_order,approx_order,1.0,N)
3635

3736
@test convert_by_multiplication(Array,A,N) == correct
38-
@test_broken Array(A) == second_derivative_stencil(N)
39-
@test_broken sparse(A) == second_derivative_stencil(N)
37+
@test Array(A) == second_derivative_stencil(N)
38+
@test sparse(A) == second_derivative_stencil(N)
39+
@test BandedMatrix(A) == second_derivative_stencil(N)
4040
@test_broken opnorm(A, Inf) == opnorm(correct, Inf)
4141

42+
43+
# testing higher derivative and approximation concretization
44+
N = 20
45+
d_order = 4
46+
approx_order = 4
47+
A = DerivativeOperator{Float64}(d_order,approx_order,1.0,N)
48+
correct = convert_by_multiplication(Array,A,N)
49+
50+
@test Array(A) == correct
51+
@test sparse(A) == correct
52+
@test BandedMatrix(A) == correct
53+
54+
N = 40
55+
d_order = 8
56+
approx_order = 8
57+
A = DerivativeOperator{Float64}(d_order,approx_order,1.0,N)
58+
correct = convert_by_multiplication(Array,A,N)
59+
60+
@test Array(A) == correct
61+
@test sparse(A) == correct
62+
@test BandedMatrix(A) == correct
63+
4264
# testing correctness of multiplication
4365
N = 1000
4466
d_order = 4

0 commit comments

Comments
 (0)