def test_trapz2d_complex128(self): x = np.asarray(np.random.rand(5, 5)+1j*np.random.rand(5, 5), np.complex128) x_gpu = gpuarray.to_gpu(x) z = integrate.trapz2d(x_gpu) assert np.allclose(np.trapz(np.trapz(x)), z)
def test_trapz2d_float64(self): x = np.asarray(np.random.rand(5, 5), np.float64) x_gpu = gpuarray.to_gpu(x) z = integrate.trapz2d(x_gpu) assert np.allclose(np.trapz(np.trapz(x)), z)
printf("x: %d y: %d\\n", n, m); } } } ''') #loop_pixels = mod.get_function('loop_pixels') #loop_pixels( np.int32(n), np.int32(m), block = (256,4,1)) for x in xrange(n): for y in xrange(m): print(x, y) #set a tempKSI so numexpr can work tempKSI=KSIdotR[x,y] temp = ne.evaluate('holo * exp(1j * k * tempKSI / KSInorm)') #Sum up temp, and multiply by the length and width to get the volume. #reconstruction[x,y]=temp.sum()*distX*distY temp_gpu = gpuarray.to_gpu(temp) print(temp_gpu.gpudata) reconstruction[x,y] = integrate.trapz2d(temp_gpu, 6e-6, 6e-6) name='{}reconstruction'.format(zz) np.save(name,reconstruction)
def test_trapz2d_complex128(self): x = np.asarray( np.random.rand(5, 5) + 1j * np.random.rand(5, 5), np.complex128) x_gpu = gpuarray.to_gpu(x) z = integrate.trapz2d(x_gpu) assert np.allclose(np.trapz(np.trapz(x)), z)
import numpy as np import pycuda.autoinit import pycuda.gpuarray as gpuarray import scikits.cuda.integrate as integrate integrate.init() a = np.asarray(np.random.rand(10), np.float32) #x = np.asarray(np.random.rand(10, 10), np.float32) x = np.ones( (2000, 2000) ) * 10 x_gpu = gpuarray.to_gpu(x) a_gpu = gpuarray.to_gpu(a) b = integrate.trapz(a_gpu) z = integrate.trapz2d(x_gpu) print(z) np.allclose(np.trapz(np.trapz(x)), z)