20 May
2008
20 May
'08
8:52 p.m.
On Mon, May 19, 2008 at 4:41 PM, Neilen Marais <nmarais@sun.ac.za> wrote:
if callback is not None and iter_ > olditer: callback(x)
I'm a bit uneducated about the meaning of all the iterative variables, but is there a way I can obtain the residual from x here? Otherwise, would it not make sense to allow more complicated callback functions?
Neilen, since you know A and b when you call the iterative solve you can compute residuals like so: A = ..... #some matrix b = ..... # some rhs residuals = [] def callback(x): residuals.append(norm(b - A*x)) x,info = cg(A, b, callback=callback) # residuals now contains ||b-A*x|| at each iteration -- Nathan Bell wnbell@gmail.com http://graphics.cs.uiuc.edu/~wnbell/