[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-patch-tracker] [patch #9282] add minres for sparse linear system
From: |
Nicholas Jankowski |
Subject: |
[Octave-patch-tracker] [patch #9282] add minres for sparse linear systems |
Date: |
Wed, 8 Mar 2017 11:28:42 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 |
Follow-up Comment #1, patch #9282 (project octave):
Nice work. some comments:
are there any tests you could add to the end of the m-file, perhaps to verify
expected input/output handling, errors, maybe verifying results as expected
from the matlab examples?
I did run the example given on the referenced matlab help page
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 = minres(A,b,tol,maxit,M1);
minres converged at iteration 49 to a solution with relative
residual 4.7e-014
the output x is more or less equal to ones(100,1), with error on the order of
1e-14.
running the same on your minres produces:
>> x'
ans =
Columns 1 through 8:
0.97030 0.94062 0.91098 0.88142 0.85195 0.82260 0.79338
0.76433
Columns 9 through 16:
0.73547 0.70681 0.67839 0.65023 0.62234 0.59476 0.56750
0.54059
Columns 17 through 24:
0.51406 0.48792 0.46220 0.43692 0.41211 0.38779 0.36398
0.34071
Columns 25 through 32:
0.31800 0.29586 0.27434 0.25344 0.23320 0.21363 0.19476
0.17661
Columns 33 through 40:
0.15921 0.14257 0.12673 0.11171 0.09752 0.08419 0.07175
0.06022
Columns 41 through 48:
0.04962 0.03998 0.03131 0.02365 0.01701 0.01142 0.00690
0.00347
Columns 49 through 56:
0.00116 0.00000 0.00000 0.00116 0.00347 0.00690 0.01142
0.01701
Columns 57 through 64:
0.02365 0.03131 0.03998 0.04962 0.06022 0.07175 0.08419
0.09752
Columns 65 through 72:
0.11171 0.12673 0.14257 0.15921 0.17661 0.19476 0.21363
0.23320
Columns 73 through 80:
0.25344 0.27434 0.29586 0.31800 0.34071 0.36398 0.38779
0.41211
Columns 81 through 88:
0.43692 0.46220 0.48792 0.51406 0.54059 0.56750 0.59476
0.62234
Columns 89 through 96:
0.65023 0.67839 0.70681 0.73547 0.76433 0.79338 0.82260
0.85195
Columns 97 through 100:
0.88142 0.91098 0.94062 0.97030
Since it's an example we can use to test algorithm compatibility, I would
suggest adding the following test block to the end of the file in addition to
any others to catch input/output, format, etc.
## test for algorithm accuracy and compatibility from matlab doc example
%!test
%! 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 = minres (A, b, tol, maxit, M1);
%! assert (size (x), [100, 1]);
%! assert (x,ones(100,1),1e-13);
Some of your errors related to providing incorrect inputs (nargin<2 test for
example) should call print_usage()
Regarding usage, I don't know how mandatory this is, but usually there's a
separate line for each valid calling method. so a line for minres(A,b), then
minres(A,b,tol), etc.
Last, a complete patch should also update the scripts/sparse/module.mk file,
the documentation file (I guess under doc/interpreter/sparse.txi), and add the
new function to /NEWS
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/patch/?9282>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Xie Rui, 2017/03/08
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems,
Nicholas Jankowski <=
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Xie Rui, 2017/03/09
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Xie Rui, 2017/03/11
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Xie Rui, 2017/03/11
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Marco Caliari, 2017/03/11
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Nicholas Jankowski, 2017/03/12
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Xie Rui, 2017/03/13
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Nicholas Jankowski, 2017/03/13
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Xie Rui, 2017/03/13
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Xie Rui, 2017/03/14
- [Octave-patch-tracker] [patch #9282] add minres for sparse linear systems, Marco Caliari, 2017/03/15