-
Notifications
You must be signed in to change notification settings - Fork 1
/
Diff.py
41 lines (31 loc) · 765 Bytes
/
Diff.py
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
import numpy as np
def Dy(u):
rows, cols = u.shape
d = np.zeros_like(u)
d[1:, :] = u[1:, :] - u[0:-1, :]
d[0, :] = u[0, :] - u[-1, :]
return d
def Dyt(u):
rows, cols = u.shape
d = np.zeros_like(u)
d[0:-1, :] = u[0:-1, :] - u[1:, :]
d[-1, :] = u[-1, :] - u[0, :]
return d
def Dx(u):
rows, cols = u.shape
d = np.zeros_like(u)
d[:, 1:] = u[:, 1:]-u[:, 0:-1]
d[:, 0] = u[:, 0] - u[:, -1]
return d
def Dxt(u):
rows, cols = u.shape
d = np.zeros_like(u)
d[:, 0:-1] = u[:, 0:-1]-u[:, 1:]
d[:, -1] = u[:, -1] - u[:, 0]
return d
# function d = Dyt(u)
# [rows,cols] = size(u);
# d = zeros(rows,cols);
# d(1:rows-1,:) = u(1:rows-1,:)-u(2:rows,:);
# d(rows,:) = u(rows,:)-u(1,:);
# return