from jhplot import *
import time
HParam.setFastMath() # apply fast calculations for functions
# comment out this code for full precision (java Math)
print "Fast calculations are set to ", HParam.isFastMath(), " working .."
a=F1D("acos(x)+asin(x)+atan(2*x)+cos(x)")
s=0;
start = time.time()
for i in range (10000000):
s=s+a.eval(0.99-0.00000001*i)
end = time.time()
print "fast calculation result=",s, " time used (sec)",end - start
HParam.setFastMath(False)
print "Fast calculations are set to ", HParam.isFastMath(), " working .."
s=0;
start = time.time()
for i in range (10000000):
s=s+a.eval(0.99-0.00000001*i)
end = time.time()
print "fast calculation result=",s, " time used (sec)",end - start
Ads help maintain this website.