[SciPy-User] scipy.sparse.linalg.cg statistics?
Fri Oct 1 07:56:31 CDT 2010
Fri, 01 Oct 2010 12:06:30 +0200, Nico Schlömer wrote:
>> Use the 'callback' argument.
> That works alright I guess.
> What I do right now is creating a *global array that's filled up as the
> callback function is called, after which I go ahead and plot it. Using a
> global variable here seems somewhat ugly to me -- might there be a more
> elegant solution at all?
Use variables from the outer scope:
def doit(M, b):
residuals = 
residuals.append(M*xk - b)
sol, info = scipy.sparse.linalg.cg(M, b, callback=callback)
More information about the SciPy-User