This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import * | |
N = 10 | |
a = zeros((3, N, N, N))+1 | |
b = zeros((3, N, N, N))+2 | |
c = zeros((3, N, N, N)) | |
a1 = zeros((N, N, N, 3))+1 | |
b1 = zeros((N, N, N, 3))+2 | |
c1 = zeros((N, N, N, 3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import * | |
a = zeros((2,3,4,5)) | |
b = rollaxis(a, 3) | |
a[:] = 1 | |
print b.shape, b[0,0,0,0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# memview_bench_v6.pyx | |
import numpy as np | |
cimport numpy as np | |
from libc.math cimport sqrt | |
cimport cython | |
@cython.boundscheck(False) | |
@cython.wraparound(False) | |
def pairwise(np.ndarray[double, ndim=2, mode='c'] X not None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import * | |
N = 8 | |
x = sin(4*pi*arange(N)/N)+sin(6*pi*arange(N)/N) | |
x_hat_c = fft.fft(x) # Use regular fft | |
x_hat_r = fft.rfft(x) # Use rfft. Should be same | |
M = 3*N//2 | |
x_hat_c_pad = zeros(M, complex) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Burger's equation | |
from numpy import * | |
from scipy.special import erf | |
import matplotlib.pyplot as plt | |
N = 512 | |
x = 2*pi*arange(N)/N | |
k = fft.rfftfreq(N, 1./N) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import * | |
from mpi4py import MPI | |
from mpi4py_fft.mpifft import PFFT, Function | |
N = array([25, 28, 23], dtype=int) | |
for slab in range(3): | |
fft = PFFT(MPI.COMM_WORLD, N, axes=(0,1,2), collapse=False, slab=slab) | |
u = Function(fft, False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from mpi4py import MPI | |
from mpi4py_fft import PFFT, DistributedArray, newDarray, Function | |
rank = 1 | |
N = (32, 32, 32) | |
FFT = PFFT(MPI.COMM_WORLD, N) | |
M = (3,)*rank + N | |
# Create 3 versions of array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpi4py import MPI | |
import numpy as np | |
from shenfun import * | |
nu = 0.000625 | |
eta = 0.01 | |
end_time = 0.1 | |
dt = 0.01 # no adaptive time stepping | |
comm = MPI.COMM_WORLD | |
N = (2**5, 2**5, 2**5) # 32^3 |