def RenormalizeFunction(func, z_min, z_max):
    """
	It re-normalizes the Function in the new limits (z_min,z_max).
	We assume that region of the function definition will be cut not extended.
	"""
    spline = SplineCH()
    spline.compile(func)
    integrator = GaussLegendreIntegrator(500)
    integrator.setLimits(z_min, z_max)
    integral = integrator.integral(spline)
    n_points = func.getSize()
    step = (z_max - z_min) / (n_points - 1)
    new_func = Function()
    for i in range(n_points):
        x = z_min + step * i
        y = spline.getY(x) / integral
        new_func.add(x, y)
    new_func.setConstStep(1)
    return new_func
Пример #2
0
	f.add(x,y)

f.dump()

spline = SplineCH()
spline.compile(f)
	
spline.dump()

print "================"
n = 100
step = 0.8*(f.getMaxX() - f.getMinX())/(n-1)
y_dev_max = 0.
yp_dev_max = 0.
for j in range(n):
	x = f.getMinX() + j*step
	y = FF(x)
	yp = FFP(x)
	ys = math.fabs(spline.getY(x) - y)
	yps = math.fabs(spline.getYP(x) - yp)
	if(y_dev_max < ys): 
		#print "debug x=",x," dev y=",ys," y=",y
		y_dev_max = ys
	if(yp_dev_max < yps): 
		#print "debug x=",x," dev yp=",yps," yp=",yp
		yp_dev_max = yps
	
print " deviation y max =",y_dev_max
print " deviation yp max =",yp_dev_max