----- Messaggio inoltrato da mariagabriella.tana@... -----
Data: Fri, 24 Oct 2008 15:14:14 +0200
Da: mariagabriella.tana@...
Rispondi-A:mariagabriella.tana@...
Oggetto: Ufuncs problem
A: pygsl-discuss@...
Dear Pygsl users and developers,
I'm a new user of pygsl and I'm a beginner in Python programming.
I'm interested in the use of "root finding" algorithms to solve
equations containing "special functions" (sf.so) such as "digamma" and
"trigamma" functions.
Because of the equivalent of "gsl_sf_psi_int" is "psi(...)", in
pygsl.testing._ufuncs, I have written the following script like the
python equivalent of the C example found in the GSL Reference document:
#############################################################################
from pygsl.testing import _ufuncs
from pygsl import roots, errno
import pygsl._numobj as numx
def digamma(x,costante):
c=costante
tmp =_ufuncs.sf_psi(x)-c
return tmp
c=3
##def run_fsolver(val):
mysys = roots.gsl_function(digamma, (c))
solver = roots.brent(mysys)
#solver = roots.bisection(mysys)
#solver = roots.falsepos(mysys)
solver.set(0.0, 5.0)
iter = 0
## r_expected = numx.sqrt(5.0)
print "# Using solver ", solver.name()
print "# %5s [%9s %9s] %9s %10s %9s" % ("iter", "upper", "lower", "root",
"err", "err(est)")
for iter in range(100):
status = solver.iterate()
x_lo = solver.x_lower()
x_up = solver.x_upper()
status = roots.test_interval(x_lo, x_up, 0, 0.001)
r = solver.root()
if status == errno.GSL_SUCCESS:
print "# Convereged :"
print " %5d [%.7f %.7f] %.7f % .6f % .6f" %(iter, x_lo,
x_up, r, x_up - x_lo)
if status == errno.GSL_SUCCESS:
break
else:
raise ValueError, "Exeeded maximum number of iterations!"
#############################################################################
When the script is executed, a "Segmentation Fault" error occurs.
I would ask you if you help me to understand the problem.
Thnks in advance for your time and help.
Best wishes.
Gabriella
----- Fine del messaggio inoltrato -----
|