hzhan0607 / cusp-library

Automatically exported from code.google.com/p/cusp-library
Apache License 2.0
0 stars 0 forks source link

bicgstab can't solve Ix = b #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Cusp's bicgstab can't solve the system Ix = b.  Instead of converging in one 
step, it yields NaN's.

For example, take "examples/Solvers/bicgstab.cu"

    http://code.google.com/p/cusp-library/source/browse/examples/Solvers/bicgstab.cu

Change line 32,

-    cusp::krylov::bicgstab(A, x, b, monitor, M);
+    cusp::krylov::bicgstab(M, x, b, monitor, M);

The solver fails to converge.

Original issue reported on code.google.com by heypa...@gmail.com on 16 Aug 2010 at 12:33

GoogleCodeExporter commented 8 years ago
The attached patch checks for a possible exit condition in the middle of the 
bicgstab iteration.
It seems to solve this problem, but I'm not sure if it creates any others. It 
also causes the verbose monitor to show two outputs per iteration. I'm not sure 
how to fix that, or if it should be fixed.

Original comment by filipe.c...@gmail.com on 14 Nov 2010 at 7:48

Attachments:

GoogleCodeExporter commented 8 years ago
I think a second call to .finished() is probably the best solution here.  The 
Iterative Template Library [1] does exactly that (see attached).

Re: multiple outputs

I think that's just something clients will have to keep in mind.  The 
verbose_monitor is probably OK as-is, but we'll need to change the 
convergence_monitor.

Feel free to apply the patch Filipe

[1] http://osl.iu.edu/research/itl/

Original comment by wnbell on 14 Nov 2010 at 7:15

Attachments:

GoogleCodeExporter commented 8 years ago
This issue was closed by revision a64c5b762b.

Original comment by filipe.c...@gmail.com on 15 Nov 2010 at 3:19

GoogleCodeExporter commented 8 years ago
The NaN's in the result stem from r_r_star_old being zero in this line,

     ValueType beta = (r_r_star_new / r_r_star_old) * (alpha / omega);

The workaround I have been using is to replace the while condition,

-    while (!monitor.finished(r))
+    while (!monitor.finished(r) && r_r_star_old)

I have been using this for 2 months now without problem, but I don't
understand bicgstab enough to vouch for it.

Original comment by heypa...@gmail.com on 19 Nov 2010 at 4:01