Skip to content

Commit 386849a

Browse files
committed
Simplify construction of 3D Poisson matrix
1 parent ae5a3b3 commit 386849a

File tree

3 files changed

+14
-39
lines changed

3 files changed

+14
-39
lines changed

test/cg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using LinearMaps
44

55
srand(1234321)
66

7-
include("getDivGrad.jl")
7+
include("poisson_matrix.jl")
88

99
facts("cg") do
1010

@@ -39,7 +39,7 @@ context("Small full system") do
3939
end
4040

4141
context("Sparse Laplacian") do
42-
A = getDivGrad(32,32,32)
42+
A = poisson_matrix(Float64, 32, 3)
4343
L = tril(A)
4444
D = diag(A)
4545
U = triu(A)

test/getDivGrad.jl

Lines changed: 0 additions & 37 deletions
This file was deleted.

test/poisson_matrix.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function poisson_matrix{T}(::Type{T}, n, dims)
2+
D = second_order_central_diff(T, n);
3+
A = copy(D);
4+
5+
for idx = 2 : dims
6+
A = kron(A, speye(n)) + kron(speye(size(A, 1)), D);
7+
end
8+
9+
A
10+
end
11+
12+
second_order_central_diff{T}(::Type{T}, dim) = convert(SparseMatrixCSC{T, Int}, SymTridiagonal(fill(2 * one(T), dim), fill(-one(T), dim - 1)))

0 commit comments

Comments
 (0)