changeset 6:cb8e50ca9e15

Add attempt att apply methods for Laplace
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 17 Dec 2018 14:18:22 +0100
parents 2737156fb884
children 99591b5c34a6
files diffOp.jl
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/diffOp.jl	Mon Dec 17 14:17:25 2018 +0100
+++ b/diffOp.jl	Mon Dec 17 14:18:22 2018 +0100
@@ -1,6 +1,6 @@
 abstract type DiffOp end
 
-function apply(D::DiffOp, v::AbstractVector) where N
+function apply(D::DiffOp, v::AbstractVector)
     error("not implemented")
 end
 
@@ -28,6 +28,20 @@
     op
 end
 
-function apply(L::Laplace, v::AbstractVector)::AbstractVector
+# u = L*v
+function apply(L::Laplace, u::AbstractVector, v::AbstractVector)::AbstractVector
+    N = closureSize(L.op)
+    M = length(v)
+
+    for i ∈ 1:N
+        u[i] = apply(L.op.closureStencils[i], v, i)
+    end
 
+    for i ∈ N+1:M-N
+        u[i] = apply(L.op.innerStencil, i);
+    end
+
+    for i ∈ M:-1:M-N+1
+        u[i] = apply(flip(L.op.closureStencils[M-i+1]), v, i)
+    end
 end