-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlap2DPeriodicFT.m
42 lines (35 loc) · 1.04 KB
/
lap2DPeriodicFT.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [LT] = lap2DPeriodicFT(N, h);
%
% [LT] = lap2DPeriodicFT(N, h);
%
% Computes the Fourier Transform of the 5-point 2D periodic Laplacian
% on a square.
%
% Returns:
% LT = 2D FT of the Laplacian as a vector
%
% Input:
% N = number of mesh points in each direction
% h = mesh width
%
%
%
% License: This code is free to use for any purposes, provided
% any publications resulting from the use of this code
% reference the original code/author.
%
% Author: Samuel Isaacson ([email protected])
% Date: 11/2007
%
% Please notify the author of any bugs, and contribute any
% modifications or bug fixes back to the original author.
%
% Disclaimer:
% This code is provided as is. The author takes no responsibility
% for its results or effects.
M = N * N;
% 2D Fourier Space Indexes:
l = repmat( (0:(N-1))', N, 1 );
m = reshape( repmat( (0:(N-1)), N, 1 ), M, 1);
% Fourier Transformed 2D Laplace Operator on Square:
LT = -(4 / (h*h)) * ( sin( (pi/N) * l ).^2 + sin( (pi/N) * m ).^2 );