def test_fmod(self): """tests if the fmod function works""" a = simplearray.array(test_sample).fill_arange()/10 b = cumath.fmod(a,2) for i in range(test_sample): self.assert_(math.fmod(a[i],2) == b[i])
def test_fmod(self): """tests if the fmod function works""" for s in sizes: a = gpuarray.arange(s, dtype=np.float32) / 10 a2 = gpuarray.arange(s, dtype=np.float32) / 45.2 + 0.1 b = cumath.fmod(a, a2) a = a.get() a2 = a2.get() b = b.get() for i in range(s): assert math.fmod(a[i], a2[i]) == b[i]
def test_fmod(self): """tests if the fmod function works""" for s in sizes: a = gpuarray.arange(s, dtype=np.float32)/10 a2 = gpuarray.arange(s, dtype=np.float32)/45.2 + 0.1 b = cumath.fmod(a, a2) a = a.get() a2 = a2.get() b = b.get() for i in range(s): assert math.fmod(a[i], a2[i]) == b[i]
limit = 100 # limit = int(input('Limit: ')) start_time = time() with open('primes1.txt') as f: primes = np.fromiter(map(int, f.read().strip().split(',')), dtype=np.uint32) p_gpu = gpuarray.to_gpu(primes) antiprimes = [] most = 0 for x in gpuarray.arange(2, limit + 1, dtype=np.uint32): print(x) fac = [[], []] x_temp = x.copy() for prime in p_gpu: more = cumath.fmod(x_temp, prime).get() == np.uintc(0) if more: power = 0 while more: power += 1 x_temp = x_temp / prime more = cumath.fmod(x_temp, prime).get() == np.uintc(0) if more: fac[0].append(prime) fac[1].append(power) if x_temp.get() <= np.uintc(1): break if not fac: continue num_primes = len(fac[0]) eq_gpu = gpuarray.to_gpu(np.empty(num_primes, dtype=np.int32))