biconjugate gradient problem


forall
09-08-2006, 03:06 PM
hi,

the NR code 'linbcg' (biconjugate gradient method) crashes when i try to solve the linear system with the following nonsymmetric LHS matrix afull, RHS vector b and initial guess x (trivially substituted into the driver xlinbcg):

NP=5
afull(1,: )=(/ 1._dp, 0._dp, 0._dp, 0._dp, 0._dp/)
afull(2,: )=(/-2._dp, 9._dp, 0._dp,-3._dp,-4._dp/)
afull(3,: )=(/-5._dp, 0._dp,20._dp,-6._dp,-9._dp/)
afull(4,: )=(/ 0._dp, 0._dp, 0._dp, 1._dp, 0._dp/)
afull(5,: )=(/ 0._dp,-4._dp,-9._dp,-7._dp,20._dp/)
b=0._dp; b(1)=1._dp; b(4)=5._dp
x=0._dp

the system is neither large nor difficult (2 of the 5 unknowns are uncoupled), but the linbcg code crashes with division-by-zero when variable 'akden' becomes 0.0 on the second iteration. this occurs regardless of the initial estimate, but does not occur for other RHS vectors b. An LU decomposition code solves the system with no problems.

any ideas? thanks in advance.

widmermt
01-07-2007, 11:26 AM
forall,

I don't know if you're still having problems after all these months later, but I've posted a correction to the algorithm which might help you:

http://www.numerical-recipes.com/forum/showthread.php?p=2001#post2001

Regards,

Mark Widmer