## RE: [Vxl-users] vnl_lsqr doesnt solve Ax=b

 RE: [Vxl-users] vnl_lsqr doesnt solve Ax=b From: Andrew Fitzgibbon - 2002-03-28 10:50:55 ```MATLAB will be fast for that matrix as it checks for symmetry (at the very least). Try A(i,i) = 1; A(i,i+1) = -2; A(i,i+2) = 1; > -----Original Message----- > From: vxl-users-admin@... > [mailto:vxl-users-admin@...] On Behalf Of > domi@... > Sent: 28 March 2002 10:44 > To: Vxl-users@... > Subject: Re: [Vxl-users] vnl_lsqr doesnt solve Ax=b > > > Well my feeling is that 2*n is enough. I get a good solution for > n=10,000 for 20,000 iterations. But it takes very long. Do you think I > could try using svd in my case to gain speed? > > > > > whereas for 30 equations it goes banana (wrong solution): > > > vnl_lsqr.cxx : The iteration limit ITNLIM was reached. > > > vnl_lsqr.cxx : iterations = 30 > > > > Could you try changing the # iterations to 120 in this case? > > > 60 already gave good results in my case. > > *I DONT KNOW IF THIS DOESNT DEPEND ON THE MATRIX* I used pretty naive > one: > > for (unsigned i=0; i A(i,i) = i+1.0; > b(i) = i+10.0; > } > > so the solution can be check by head. > > Domi > > > _______________________________________________ > Vxl-users mailing list > Vxl-users@... > https://lists.sourceforge.net/lists/listinfo/vxl-users > ```

 Re: [Vxl-users] vnl_lsqr doesnt solve Ax=b From: - 2002-03-27 15:51:34 ```> vnl_lsqr.cxx : The iteration limit ITNLIM was reached. From v3p/netlib/lsqr.c : /* ITNLIM input An upper limit on the number of iterations. */ /* Suggested value: */ /* ITNLIM = n/2 for well-conditioned systems */ /* with clustered singular values, */ /* ITNLIM = 4*n otherwise. */ ITNLIM is the 17th parameter to lsqr_() It can be set in vnl_lsqr by the method set_max_iterations(int). The default is "n", which should probably be changed to "4*n". Peter. ```
 Re: [Vxl-users] vnl_lsqr doesnt solve Ax=b From: - 2002-03-27 16:25:22 ```> whereas for 30 equations it goes banana (wrong solution): > > vnl_lsqr.cxx : x = 0 is the exact solution. No iterations were performed. > vnl_lsqr.cxx : The iteration limit ITNLIM was reached. > vnl_lsqr.cxx : residual norm estimate = 3.24731 > vnl_lsqr.cxx : result norm estimate = 14.2702 > vnl_lsqr.cxx : condition no. estimate = 106.047 > vnl_lsqr.cxx : iterations = 30 Whenever you see the message "The iteration limit ITNLIM was reached" you can expect that the result is incorrect or at least imprecise. Could you try changing the # iterations to 120 in this case? P.S. I've changed the default in vnl_lsqr.h to 4*n. Peter. ```
 Re: [Vxl-users] vnl_lsqr doesnt solve Ax=b From: - 2002-03-28 10:44:05 ```Well my feeling is that 2*n is enough. I get a good solution for n=10,000 for 20,000 iterations. But it takes very long. Do you think I could try using svd in my case to gain speed? > > whereas for 30 equations it goes banana (wrong solution): > > vnl_lsqr.cxx : The iteration limit ITNLIM was reached. > > vnl_lsqr.cxx : iterations = 30 > > Could you try changing the # iterations to 120 in this case? 60 already gave good results in my case. *I DONT KNOW IF THIS DOESNT DEPEND ON THE MATRIX* I used pretty naive one: for (unsigned i=0; i
 RE: [Vxl-users] vnl_lsqr doesnt solve Ax=b From: Andrew Fitzgibbon - 2002-03-28 10:50:55 ```MATLAB will be fast for that matrix as it checks for symmetry (at the very least). Try A(i,i) = 1; A(i,i+1) = -2; A(i,i+2) = 1; > -----Original Message----- > From: vxl-users-admin@... > [mailto:vxl-users-admin@...] On Behalf Of > domi@... > Sent: 28 March 2002 10:44 > To: Vxl-users@... > Subject: Re: [Vxl-users] vnl_lsqr doesnt solve Ax=b > > > Well my feeling is that 2*n is enough. I get a good solution for > n=10,000 for 20,000 iterations. But it takes very long. Do you think I > could try using svd in my case to gain speed? > > > > > whereas for 30 equations it goes banana (wrong solution): > > > vnl_lsqr.cxx : The iteration limit ITNLIM was reached. > > > vnl_lsqr.cxx : iterations = 30 > > > > Could you try changing the # iterations to 120 in this case? > > > 60 already gave good results in my case. > > *I DONT KNOW IF THIS DOESNT DEPEND ON THE MATRIX* I used pretty naive > one: > > for (unsigned i=0; i A(i,i) = i+1.0; > b(i) = i+10.0; > } > > so the solution can be check by head. > > Domi > > > _______________________________________________ > Vxl-users mailing list > Vxl-users@... > https://lists.sourceforge.net/lists/listinfo/vxl-users > ```
 RE: [Vxl-users] vnl_lsqr doesnt solve Ax=b From: Ian Scott - 2002-03-28 11:01:15 ```Dominique wrote: > Well my feeling is that 2*n is enough. I get a good solution for > n=10,000 for 20,000 iterations. Isn't the useful termination condition really Repeat ... Until ( answer isn't moving very much || error is small || error stops moving very much ) The iterations limit is an upper bound, to stop the algorithm running forever ( which would make it a non-algorithm.) I think Peter's mod to have an upper limit of 4*n is sensible. It is of-course trivial to change the value in your code using set_max_iterations() > But it takes very long. Just to check - Do you have all the optimisations turned on? Which platform/compiler are you using? Ian. ```
 [Vxl-users] vnl_lsqr - some benchmarks From: - 2002-03-28 15:46:46 ```Hi, You were right, Matlab gets dramatically slower with nonsymmetric non-only-diagonal matrix. for (signed i=0; i=0 ){ A(i,i+1) = 2.0; A(i,i-1) = -1.0; } b(i) = i+1.0; } Actually matlab gets far slower compared to vnl_lsqr but on the test system (above) I have: vnl_lsqr.cxx : The equations A*x = b are probably compatible. Norm(A*x - b) is as small as seems reasonable on this machine. vnl solves this (n=3000) very quickly while matlab chews it much longer. n=10,000 is solved by vnl in 1.5 min on my machine, matlab after a longer while crashes screaming for memory. --- I have all optimisations on. I am using solaris with gcc2.95. No things like netscape running in bg, or two calculations running at the same time. ---- I still will try svd today, just to compare. thank you for feedback dominique ```
 RE: [Vxl-users] vnl_lsqr doesnt solve Ax=b From: Andrew Fitzgibbon - 2002-03-27 16:04:47 ```Also, Domi, can you run the profiler to see where the 10 mins is spent? MATLAB has pretty highly optimized code paths -- we may be able to gain a factor of 2-5 just by micro-optimizing the sparse matrix stuff. A. ```