Functions | |
def | init |
Variables | |
int | X = 100 |
int | Y = 100 |
float | dx = 0.1 |
float | dy = 0.1 |
float | dt = 0.0001 |
tuple | P1 = zeros((X, Y), "float64") |
tuple | P2 = zeros((X, Y), "float64") |
tuple | Ux1 = zeros((X, Y), "float64") |
tuple | Ux2 = zeros((X, Y), "float64") |
tuple | Uy1 = zeros((X, Y), "float64") |
tuple | Uy2 = zeros((X, Y), "float64") |
float | Ro = 1.21 |
int | C = 343 |
K = Ro*C*C | |
tuple | ang = arange(-pi, pi, 2 * pi / 100) |
tuple | sig = cos(ang) |
int | idx = 0 |
tuple | res = zeros(1000, "float64") |
tuple | start = time.clock() |
init() start = time.clock() for t in range(1000): if idx < len(sig): P1[X / 2, Y / 2] += sig[idx] idx += 1 | |
string | code |
int | loop = 1000 |
type_converters = scipy.weave.converters.blitz) | |
if idx < len(sig): P1[X / 2, Y / 2] += sig[idx] idx += 1 | |
tuple | end = time.clock() |
def weavecompare.init | ( | ) |
tuple weavecompare.ang = arange(-pi, pi, 2 * pi / 100) |
int weavecompare.C = 343 |
string weavecompare::code |
Initial value:
" \ \ blitz::Range I(0, P1.shape()[0] - 2), J(0, P1.shape()[1] - 2); \ for (int t = 0; t < loop; t++)\ {\ if(idx < sig.shape()[0])\ {\ P1(P1.shape()[0] / 2, P1.shape()[1] / 2) = sig(idx);\ idx++;\ }\ \ Ux2(I + 1, J) = Ux1(I + 1, J) - dt / Ro / dx * (P1(I + 1, J) - P1(I, J)); \ Uy2(I, J + 1) = Uy1(I, J + 1) - dt / Ro / dy * (P1(I, J + 1) - P1(I, J)); \ P2(I, J) = P1(I, J) - K * dt / dx * (Ux2(I + 1, J) - Ux2(I, J)) - K * dt / dy * (Uy2(I, J + 1) - Uy2(I, J)); \ \ blitz::cycleArrays(P1, P2); \ blitz::cycleArrays(Ux1, Ux2); \ blitz::cycleArrays(Uy1, Uy2); \ }\ "
float weavecompare.dt = 0.0001 |
float weavecompare.dx = 0.1 |
float weavecompare.dy = 0.1 |
tuple weavecompare::end = time.clock() |
int weavecompare.idx = 0 |
weavecompare.K = Ro*C*C |
int weavecompare::loop = 1000 |
tuple weavecompare.P1 = zeros((X, Y), "float64") |
tuple weavecompare.P2 = zeros((X, Y), "float64") |
tuple weavecompare.res = zeros(1000, "float64") |
float weavecompare.Ro = 1.21 |
tuple weavecompare.sig = cos(ang) |
tuple weavecompare::start = time.clock() |
init() start = time.clock() for t in range(1000): if idx < len(sig): P1[X / 2, Y / 2] += sig[idx] idx += 1
res[t] = P1[X / 2, Y / 2]
for x in range(X - 1): for y in range(Y - 1): Ux2[x + 1, y] = Ux1[x + 1, y] - dt / Ro / dx * (P1[x + 1, y] - P1[x, y]) Uy2[x, y + 1] = Uy1[x, y + 1] - dt / Ro / dy * (P1[x, y + 1] - P1[x, y])
for x in range(X - 1): for y in range(Y - 1): P2[x, y] = P1[x, y] - K * dt / dx * (Ux2[x + 1, y] - Ux2[x, y]) - K * dt / dy * (Uy2[x, y + 1] - Uy2[x, y])
tmp = P2 P2 = P1 P1 = tmp
tmp = Ux2 Ux2 = Ux1 Ux1 = tmp
tmp = Uy2 Uy2 = Uy1 Uy1 = tmp
end = time.clock()
print " The python loop is " + str(1000*(end - start)) + "[msec]"
weavecompare.type_converters = scipy.weave.converters.blitz) |
if idx < len(sig): P1[X / 2, Y / 2] += sig[idx] idx += 1
tuple weavecompare.Ux1 = zeros((X, Y), "float64") |
tuple weavecompare.Ux2 = zeros((X, Y), "float64") |
tuple weavecompare.Uy1 = zeros((X, Y), "float64") |
tuple weavecompare.Uy2 = zeros((X, Y), "float64") |
int weavecompare.X = 100 |
int weavecompare.Y = 100 |