On Nov 26, 6:50 am, William Stein <[email protected]> wrote:
> Here it is:
I played around with williams code and rewrote the two for loops in
cython. I ended up with another 2.1 x speed improvement, maybe it's
possible to do even more? ;)
cell1:
var("x,y")
f = symbolic_expression(y^2*abs(3*exp(2*pi*i*(x+i*y))*3*exp(4*2*pi*i*(x
+i*y)) + 8*exp(2*pi*i*(x+i*y))*10*exp(4*2*pi*i*(x+i*y)))).function
(x,y)
# Optimized "compiled" version of f to double precision:
f = fast_callable(f,CDF,[x,y])
cell2:
%cython
cdef int maxY, M
cdef float d, supNorm, m, K_max
# NOTE: M, d and maxY are different!
cpdef calc(f):
maxY = 30
M = 50
d = 0.01
supNorm = 0
for N from 0 <= N < M:
K_max = M*(int(maxY-1/2)+1)
for K from 0 <= K < K_max:
a = -0.5 + N*d
b = 0.5 + K*d
m = f(a,b)
if m > supNorm:
supNorm = m
print N
print supNorm
cell3:
%time
calc(f)
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org