CoCalc Public Files2016-12-05-095511.sagews
Author: Greg Cross
Views : 34
Compute Environment: Ubuntu 18.04 (Deprecated)
import numpy as np
from scipy import stats
import time

#stats.describe(primeModArray,axis = 1)
time0 = time.time()

width= 19
limit =9999999
prime = np.ones(limit/2, dtype=np.bool)
for i in xrange(3, int(limit**.5) + 1, 2):
if prime[i/2]:
prime[i*i/2: : i] = False
primeArray = prime.nonzero()[0]*2+1
primeArray = primeArray
primeArray[0] = 2
time1 = time.time()
length = int(primeArray.shape[0])
primeMods = primeArray[1:width+1]
primeModArray =np.empty([length,width],dtype=int)
for x in xrange(width):
for y in xrange(length):
primeModArray[y][x] = primeArray[y]
time2 = time.time()
output = np.mod(primeModArray,primeMods)
print output
print primeModArray.shape
print time1-time0
print time2-time1


/projects/sage/sage-7.5/local/lib/python2.7/site-packages/numpy/core/numeric.py:190: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future a = empty(shape, dtype, order) <string>:2: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future <string>:3: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
[[ 2 2 2 ..., 2 2 2] [ 0 3 3 ..., 3 3 3] [ 2 0 5 ..., 5 5 5] ..., [ 2 1 2 ..., 58 20 47] [ 1 3 4 ..., 60 22 49] [ 1 1 1 ..., 17 40 67]]