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: Tue, 14 Mar 2017 22:00:26 -0400 (EDT)
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 #10, patch #9282 (project octave):

Re: Comment #5

1. Solved by Comment #7.

2. I learned from Cristiano, and added try...catch to detect singular
preconditioner matrix. Matlab checks it, too. For example (it is similar to a
test from pcg of Cristiano),


N = 3;
A = rand(3);
A = A*A';
M = [1 0 0; 0 1 0; 0 0 0]; % the last rows is zero
[x,flag] = minres (A, ones(3,1), [], [], M);


Then flag = 2, which means that Matlab detected singular preconditioner
matrix.

However, Matlab does not check whether A is symmetric or whether A is
hermitian. Because pcg of Cristiano checks whether A is hermitian, my minres
checks it.

3. I fixed it.

4. Matlab accepts complex matrix and works on it. Test code:


% Use many random hermitian A and complex b to test

N = 20; %Number of tests
n = 100; %Size of matrices
tol = 1e-10;
maxit = 2 * n;

flag_set = zeros(N, 1);
relres_set = zeros(N, 1);
iter_set = zeros(N, 1);

A_set = rand(N * n, n) + 1i * rand(N * n, n);
b_set = rand(N * n, 1) + 1i * rand(N * n, 1);

for j = 1: N
    A = A_set(((j - 1) * n + 1): j * n, :);
    A = (A + A') / 2; %Make A hermitian
    b = b_set(((j - 1) * n + 1): j * n, :);
    
    [x, flag, relres, iter, resvec] = minres (A, b, tol, maxit);
    
    flag_set(j) = flag;
    relres_set(j) = relres;
    iter_set(j) = iter;
end

allconverge = all(flag_set == zeros(N, 1));
max_converge_iter = max(iter_set);
min_converge_iter = min(iter_set);
max_relres = max(relres_set);


If allconverge = 1, then Matlab minres works for all the A and b above.




(file #40006)
    _______________________________________________________

Additional Item Attachment:

File name: minres.m                       Size:20 KB


    _______________________________________________________

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]