Hi, I'm trying to monitor the residual while doing an iterative solve. In iterative.py I see: x, iter_, resid, info, ndx1, ndx2, sclr1, sclr2, ijob = \ revcom(b, x, work, iter_, resid, info, ndx1, ndx2, ijob) 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? Thanks Neilen
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/
participants (2)
-
Nathan Bell
-
Neilen Marais