This forum has been archived. All content is frozen. Please use KDE Discuss instead.

BiCGSTAB: 1, Newbie: 0

Tags: None
(comma "," separated)
hillaryryan
Registered Member
Posts
1
Karma
0

BiCGSTAB: 1, Newbie: 0

Sat Jun 07, 2014 12:18 am
Dear All,

I have been having problems getting BiCGSTAB to run in a simple test case for which I already know the answer. BiCGSTAB seems to give up on the problem after 0 iterations with info equal to NoConvergence. It seems odd to me that something can fail to converge after no iterations. Any help would be appreciated. I have attached the code and its output at the end of this message.

Many Thanks,
Hillary

Code:
Code: Select all
 
 int n = 3;
   VectorXd x(n), b(n);
   SparseMatrix<double> A(n,n);
   A.insert(0,0) = 0; A.insert(0,1) = 1; A.insert(0,2) = 2;
   A.insert(1,0) = 2; A.insert(1,1) = 4; A.insert(1,2) = 9;
   A.insert(2,0) = 10; A.insert(2,1) = 3; A.insert(2,2) = 2;
   
   b(0) = 0; b(1) = 1; b(2) = 2;

   cout<< "A: \n"  <<A << endl;
   cout<< "b: \n" << b << endl;

   BiCGSTAB<SparseMatrix<double>, DiagonalPreconditioner<double> > solver;
   solver.setMaxIterations(100);
   solver.compute(A);
   x = solver.solve(b);
   
   cout << "#iterations:     " << solver.iterations() << endl;
   cout << "estimated error: " << solver.error()      << endl;
   int solver_info = solver.info();
   if(solver_info == Success){
      printf("the solver succeeded\n");
   } else if(solver_info == NumericalIssue){
      printf("Numerical Issue\n");
   } else if(solver_info == NoConvergence){
      printf("NoConvergence\n");
   } else if(solver_info == InvalidInput){
      printf("InvalidInput\n");
   }


Output:
Code: Select all
A:
Nonzero entries:
(0,0) (2,1) (10,2) (_,_) (1,0) (4,1) (3,2) (_,_) (2,0) (9,1) (2,2) (_,_)

Outer pointers:
0 4 8  $
Inner non zeros:
3 3 3  $

0 1 2
2 4 9
10 3 2

b:
0
1
2
#iterations:     0
estimated error: -nan
NoConvergence


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]