octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #9282] add minres for sparse linear system


From: Xie Rui
Subject: [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems
Date: Thu, 9 Mar 2017 06:14:11 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

Follow-up Comment #2, patch #9282 (project octave):

Thank you very much for your advices!
I ran the example with a slightly different code in matlab. That is, use the
complete form of the outputs.

n = 100; on = ones(n,1); 
A = spdiags([-2*on 4*on -2*on],-1:1,n,n);
b = sum(A,2); 
tol = 1e-10; 
maxit = 50; 
M1 = spdiags(4*on,0,n,n);

[x,flag,relres,iter,resvec,resveccg] = minres(A,b,tol, maxit,M1)

The result of relres (relative residual) and iter (iteration) is

relres =

   4.6537e-14
iter =

    50

not 49. It is strange.

For my m-file, I try to set maxit as 100. That is

n = 100; on = ones(n,1); 
A = spdiags([-2*on 4*on -2*on],-1:1,n,n);
b = sum(A,2); 
tol = 1e-10; 
maxit = 100;
M1 = spdiags(4*on,0,n,n);

[x,flag,relres,iter,resvec] = minres(A,b,tol,maxit,M1)

Then the result is

>> x'
ans =

 Columns 1 through 13:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000   1.00000   1.00000   1.00000   1.00000

 Columns 14 through 26:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000   1.00000   1.00000   1.00000   1.00000

 Columns 27 through 39:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000   1.00000   1.00000   1.00000   1.00000

 Columns 40 through 52:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000   1.00000   1.00000   1.00000   1.00000

 Columns 53 through 65:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000   1.00000   1.00000   1.00000   1.00000

 Columns 66 through 78:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000   1.00000   1.00000   1.00000   1.00000

 Columns 79 through 91:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000   1.00000   1.00000   1.00000   1.00000

 Columns 92 through 100:

   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000   1.00000  
1.00000   1.00000

and

flag = 0
relres =   4.4991e-014
iter =  50

Note that it converged at iteration 50 to a solution with relative residul
4.5e-014.
There is a bug about using maxit in my code. I am fixing it, and I will do
others that you mentioned.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?9282>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]