Mercurial > octave-antonio
annotate scripts/sparse/ilu.m @ 20164:df437a52bcaf stable
doc: Update more docstrings to have one sentence summary as first line.
Reviewed miscellaneous, sparse, strings in scripts directory.
* scripts/miscellaneous/bzip2.m, scripts/miscellaneous/citation.m,
scripts/miscellaneous/compare_versions.m, scripts/miscellaneous/computer.m,
scripts/miscellaneous/debug.m, scripts/miscellaneous/dir.m,
scripts/miscellaneous/edit.m, scripts/miscellaneous/error_ids.m,
scripts/miscellaneous/fileattrib.m, scripts/miscellaneous/fullfile.m,
scripts/miscellaneous/genvarname.m, scripts/miscellaneous/gzip.m,
scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/news.m,
scripts/miscellaneous/open.m, scripts/miscellaneous/parseparams.m,
scripts/miscellaneous/recycle.m, scripts/miscellaneous/run.m,
scripts/miscellaneous/swapbytes.m, scripts/miscellaneous/tar.m,
scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m,
scripts/miscellaneous/what.m, scripts/sparse/bicg.m, scripts/sparse/bicgstab.m,
scripts/sparse/cgs.m, scripts/sparse/colperm.m, scripts/sparse/eigs.m,
scripts/sparse/etreeplot.m, scripts/sparse/gmres.m, scripts/sparse/gplot.m,
scripts/sparse/ichol.m, scripts/sparse/ilu.m, scripts/sparse/pcg.m,
scripts/sparse/pcr.m, scripts/sparse/qmr.m, scripts/sparse/spaugment.m,
scripts/sparse/spconvert.m, scripts/sparse/spdiags.m, scripts/sparse/spfun.m,
scripts/sparse/spones.m, scripts/sparse/sprandsym.m, scripts/sparse/spstats.m,
scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/sparse/treelayout.m,
scripts/sparse/treeplot.m, scripts/strings/base2dec.m,
scripts/strings/bin2dec.m, scripts/strings/blanks.m, scripts/strings/cstrcat.m,
scripts/strings/deblank.m, scripts/strings/dec2base.m,
scripts/strings/dec2bin.m, scripts/strings/dec2hex.m,
scripts/strings/findstr.m, scripts/strings/hex2dec.m, scripts/strings/index.m,
scripts/strings/isletter.m, scripts/strings/isstrprop.m,
scripts/strings/mat2str.m, scripts/strings/ostrsplit.m,
scripts/strings/regexptranslate.m, scripts/strings/rindex.m,
scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strchr.m,
scripts/strings/strjoin.m, scripts/strings/strjust.m,
scripts/strings/strmatch.m, scripts/strings/strsplit.m,
scripts/strings/strtok.m, scripts/strings/strtrim.m,
scripts/strings/strtrunc.m, scripts/strings/substr.m,
scripts/strings/untabify.m, scripts/time/datenum.m:
Update more docstrings to have one sentence summary as first line.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 May 2015 14:22:02 -0700 |
parents | 9fc020886ae9 |
children |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19597
diff
changeset
|
1 ## Copyright (C) 2014-2015 Eduardo Ramos Fernández <eduradical951@gmail.com> |
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19597
diff
changeset
|
2 ## Copyright (C) 2013-2015 Kai T. Ohlhus <k.ohlhus@gmail.com> |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
3 ## |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
4 ## This file is part of Octave. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
5 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
6 ## Octave is free software; you can redistribute it and/or modify it |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
7 ## under the terms of the GNU General Public License as published by |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
9 ## your option) any later version. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
10 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
11 ## Octave is distributed in the hope that it will be useful, but |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
14 ## General Public License for more details. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
15 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
16 ## You should have received a copy of the GNU General Public License |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
17 ## along with Octave; see the file COPYING. If not, see |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
18 ## <http://www.gnu.org/licenses/>. |
19056
4630a18757b3
Add missing bits from cset 38937efbee21.
Rik <rik@octave.org>
parents:
19055
diff
changeset
|
19 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
20 ## -*- texinfo -*- |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
21 ## @deftypefn {Function File} {} ilu (@var{A}) |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
22 ## @deftypefnx {Function File} {} ilu (@var{A}, @var{opts}) |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
23 ## @deftypefnx {Function File} {[@var{L}, @var{U}] =} ilu (@dots{}) |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
24 ## @deftypefnx {Function File} {[@var{L}, @var{U}, @var{P}] =} ilu (@dots{}) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
25 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
26 ## Compute the incomplete LU factorization of the sparse square matrix @var{A}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
27 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
28 ## @code{ilu} returns a unit lower triangular matrix @var{L}, an upper |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
29 ## triangular matrix @var{U}, and optionally a permutation matrix @var{P}, such |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
30 ## that @code{@var{L}*@var{U}} approximates @code{@var{P}*@var{A}}. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
31 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
32 ## The factors given by this routine may be useful as preconditioners for a |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
33 ## system of linear equations being solved by iterative methods such as BICG |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
34 ## (BiConjugate Gradients) or GMRES (Generalized Minimum Residual Method). |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
35 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
36 ## The factorization may be modified by passing options in a structure |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
37 ## @var{opts}. The option name is a field of the structure and the setting |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
38 ## is the value of field. Names and specifiers are case sensitive. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
39 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
40 ## @table @code |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
41 ## @item type |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
42 ## Type of factorization. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
43 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
44 ## @table @asis |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
45 ## @item @qcode{"nofill"} |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
46 ## ILU factorization with no fill-in (ILU(0)). |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
47 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
48 ## Additional supported options: @code{milu}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
49 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
50 ## @item @qcode{"crout"} |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
51 ## Crout version of ILU factorization (@nospell{ILUC}). |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
52 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
53 ## Additional supported options: @code{milu}, @code{droptol}. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
54 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
55 ## @item @qcode{"ilutp"} (default) |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
56 ## ILU factorization with threshold and pivoting. |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
57 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
58 ## Additional supported options: @code{milu}, @code{droptol}, @code{udiag}, |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
59 ## @code{thresh}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
60 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
61 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
62 ## @item droptol |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
63 ## A non-negative scalar specifying the drop tolerance for factorization. The |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
64 ## default value is 0 which produces the complete LU factorization. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
65 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
66 ## Non-diagonal entries of @var{U} are set to 0 unless |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
67 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
68 ## @code{abs (@var{U}(i,j)) >= droptol * norm (@var{A}(:,j))}. |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
69 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
70 ## Non-diagonal entries of @var{L} are set to 0 unless |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
71 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
72 ## @code{abs (@var{L}(i,j)) >= droptol * norm (@var{A}(:,j))/@var{U}(j,j)}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
73 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
74 ## @item milu |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
75 ## Modified incomplete LU factorization: |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
76 ## |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
77 ## @table @asis |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
78 ## @item @qcode{"row"} |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
79 ## Row-sum modified incomplete LU factorization. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
80 ## The factorization preserves row sums: |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
81 ## @code{@var{A} * e = @var{L} * @var{U} * e}, where e is a vector of ones. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
82 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
83 ## @item @qcode{"col"} |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
84 ## Column-sum modified incomplete LU factorization. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
85 ## The factorization preserves column sums: |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
86 ## @code{e' * @var{A} = e' * @var{L} * @var{U}}. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
87 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
88 ## @item @qcode{"off"} (default) |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
89 ## Row and column sums are not necessarily preserved. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
90 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
91 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
92 ## @item udiag |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
93 ## If true, any zeros on the diagonal of the upper triangular factor are |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
94 ## replaced by the local drop tolerance |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
95 ## @code{droptol * norm (@var{A}(:,j))/@var{U}(j,j)}. The default is false. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
96 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
97 ## @item thresh |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
98 ## Pivot threshold for factorization. It can range between 0 (diagonal |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
99 ## pivoting) and 1 (default), where the maximum magnitude entry in the column |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
100 ## is chosen to be the pivot. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
101 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
102 ## |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
103 ## If @code{ilu} is called with just one output, the returned matrix is |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
104 ## @code{@var{L} + @var{U} - speye (size (@var{A}))}, where @var{L} is unit |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
105 ## lower triangular and @var{U} is upper triangular. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
106 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
107 ## With two outputs, @code{ilu} returns a unit lower triangular matrix @var{L} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
108 ## and an upper triangular matrix @var{U}. For @var{opts}.type == |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
109 ## @qcode{"ilutp"}, one of the factors is permuted based on the value of |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
110 ## @var{opts}.milu. When @var{opts}.milu == @qcode{"row"}, @var{U} is a |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
111 ## column permuted upper triangular factor. Otherwise, @var{L} is a |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
112 ## row-permuted unit lower triangular factor. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
113 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
114 ## If there are three named outputs and @var{opts}.milu != @qcode{"row"}, |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
115 ## @var{P} is returned such that @var{L} and @var{U} are incomplete factors |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
116 ## of @code{@var{P}*@var{A}}. When @var{opts}.milu == @qcode{"row"}, @var{P} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
117 ## is returned such that @var{L} and @var{U} are incomplete factors of |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
118 ## @code{@var{A}*@var{P}}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
119 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
120 ## EXAMPLES |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
121 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
122 ## @example |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
123 ## @group |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
124 ## A = gallery ("neumann", 1600) + speye (1600); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
125 ## opts.type = "nofill"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
126 ## nnz (A) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
127 ## ans = 7840 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
128 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
129 ## nnz (lu (A)) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
130 ## ans = 126478 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
131 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
132 ## nnz (ilu (A, opts)) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
133 ## ans = 7840 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
134 ## @end group |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
135 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
136 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
137 ## This shows that @var{A} has 7,840 nonzeros, the complete LU factorization |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
138 ## has 126,478 nonzeros, and the incomplete LU factorization, with 0 level of |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
139 ## fill-in, has 7,840 nonzeros, the same amount as @var{A}. Taken from: |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
140 ## http://www.mathworks.com/help/matlab/ref/ilu.html |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
141 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
142 ## @example |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
143 ## @group |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
144 ## A = gallery ("wathen", 10, 10); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
145 ## b = sum (A, 2); |
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
146 ## tol = 1e-8; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
147 ## maxit = 50; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
148 ## opts.type = "crout"; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
149 ## opts.droptol = 1e-4; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
150 ## [L, U] = ilu (A, opts); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
151 ## x = bicg (A, b, tol, maxit, L, U); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
152 ## norm (A * x - b, inf) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
153 ## @end group |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
154 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
155 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
156 ## This example uses ILU as preconditioner for a random FEM-Matrix, which has a |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
157 ## large condition number. Without @var{L} and @var{U} BICG would not converge. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
158 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
159 ## @seealso{lu, ichol, bicg, gmres} |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
160 ## @end deftypefn |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
161 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
162 function [L, U, P] = ilu (A, opts = struct ()) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
163 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
164 if (nargin < 1 || nargin > 2 || (nargout > 3)) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
165 print_usage (); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
166 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
167 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
168 if (! (issparse (A) && issquare (A))) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
169 error ("ichol: A must be a sparse square matrix"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
170 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
171 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
172 if (! isstruct (opts)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
173 error ("ichol: OPTS must be a structure."); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
174 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
175 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
176 ## If A is empty then return empty L, U and P for Matlab compatibility |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
177 if (isempty (A)) |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
178 L = U = P = A; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
179 return; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
180 endif |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
181 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
182 ## Parse input options |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
183 if (! isfield (opts, "type")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
184 opts.type = "nofill"; # set default |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
185 else |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
186 type = tolower (getfield (opts, "type")); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
187 if (! any (strcmp (type, {"nofill", "crout", "ilutp"}))) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
188 error ("ilu: invalid TYPE specified"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
189 endif |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
190 opts.type = type; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
191 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
192 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
193 if (! isfield (opts, "droptol")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
194 opts.droptol = 0; # set default |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
195 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
196 if (! (isreal (opts.droptol) && isscalar (opts.droptol) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
197 && opts.droptol >= 0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
198 error ("ilu: DROPTOL must be a non-negative real scalar"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
199 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
200 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
201 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
202 if (! isfield (opts, "milu")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
203 opts.milu = "off"; # set default |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
204 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
205 milu = tolower (getfield (opts, "milu")); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
206 if (! any (strcmp (milu, {"off", "col", "row"}))) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
207 error ('ilu: MILU must be one of "off", "col", or "row"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
208 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
209 opts.milu = milu; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
210 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
211 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
212 if (! isfield (opts, "udiag")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
213 opts.udiag = 0; # set default |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
214 else |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
215 if (! isscalar (opts.udiag) || (opts.udiag != 0 && opts.udiag != 1)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
216 error ("ilu: UDIAG must be 0 or 1"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
217 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
218 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
219 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
220 if (! isfield (opts, "thresh")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
221 opts.thresh = 1; # set default |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
222 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
223 if (! (isreal (opts.thresh) && isscalar (opts.thresh)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
224 || opts.thresh < 0 || opts.thresh > 1) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
225 error ("ilu: THRESH must be a scalar in the range [0, 1]"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
226 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
227 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
228 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
229 n = length (A); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
230 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
231 ## Delegate to specialized ILU |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
232 switch (opts.type) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
233 case "nofill" |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
234 [L, U] = __ilu0__ (A, opts.milu); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
235 if (nargout == 3) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
236 P = speye (length (A)); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
237 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
238 case "crout" |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
239 [L, U] = __iluc__ (A, opts.droptol, opts.milu); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
240 if (nargout == 3) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
241 P = speye (length (A)); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
242 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
243 case "ilutp" |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
244 if (nargout == 2) |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
245 [L, U] = __ilutp__ (A, opts.droptol, opts.thresh, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
246 opts.milu, opts.udiag); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
247 elseif (nargout == 3) |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
248 [L, U, P] = __ilutp__ (A, opts.droptol, opts.thresh, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
249 opts.milu, opts.udiag); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
250 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
251 endswitch |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
252 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
253 if (nargout == 1) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
254 L = L + U - speye (n); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
255 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
256 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
257 endfunction |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
258 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
259 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
260 %!shared n, dtol, A |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
261 %! n = 1600; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
262 %! dtol = 0.1; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
263 %! A = gallery ("neumann", n) + speye (n); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
264 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
265 %! opts.type = "nofill"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
266 %! assert (nnz (ilu (A, opts)), 7840); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
267 ## This test has been verified in both Matlab and Octave. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
268 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
269 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
270 %! opts.milu = "row"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
271 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
272 %! [L, U] = ilu (A, opts); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
273 %! e = ones (size (A, 2),1); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
274 %! assert (norm (A*e - L*U*e), 1e-14, 1e-14); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
275 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
276 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
277 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
278 %! [L, U] = ilu (A, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
279 %! assert (norm (A - L * U, "fro") / norm (A, "fro"), 0.05, 1e-2); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
280 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
281 ## Check if the elements in U satisfy the non-dropping condition. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
282 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
283 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
284 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
285 %! [L, U] = ilu (A, opts); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
286 %! for j = 1:n |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
287 %! cmp_value = dtol * norm (A(:, j)); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
288 %! non_zeros = nonzeros (U(:, j)); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
289 %! assert (abs (non_zeros) >= cmp_value); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
290 %! endfor |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
291 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
292 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
293 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
294 %! [L, U] = ilu (A, opts); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
295 %! for j = 1:n |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
296 %! cmp_value = dtol * norm (A(:, j)); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
297 %! non_zeros = nonzeros (U(:, j)); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
298 %! assert (abs (non_zeros) >= cmp_value); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
299 %! endfor |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
300 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
301 ## Check that the complete LU factorisation with crout and ilutp algorithms |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
302 ## produce the same result. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
303 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
304 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
305 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
306 %! [L1, U1] = ilu (A, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
307 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
308 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
309 %! [L2, U2] = ilu (A, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
310 %! assert (norm (L1 - L2, "fro") / norm (L1, "fro"), 0, eps); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
311 %! assert (norm (U1 - U2, "fro") / norm (U1, "fro"), 0, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
312 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
313 ## Tests for real matrices of different sizes for ilu0, iluc and ilutp. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
314 ## The difference A - L*U should be not greater than eps because with droptol |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
315 ## equaling 0, the LU complete factorization is performed. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
316 %!shared n_tiny, n_small, n_medium, n_large, A_tiny, A_small, A_medium, A_large |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
317 %! n_tiny = 5; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
318 %! n_small = 40; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
319 %! n_medium = 600; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
320 %! n_large = 10000; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
321 %! A_tiny = spconvert ([1 4 2 3 3 4 2 5; 1 1 2 3 4 4 5 5; 1 2 3 4 5 6 7 8]'); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
322 %! A_small = sprand (n_small, n_small, 1/n_small) + speye (n_small); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
323 %! A_medium = sprand (n_medium, n_medium, 1/n_medium) + speye (n_medium); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
324 %! A_large = sprand (n_large, n_large, 1/n_large/10) + speye (n_large); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
325 %! |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
326 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
327 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
328 %! [L, U] = ilu (A_tiny); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
329 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), 0, n_tiny * eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
330 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
331 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
332 %! [L, U] = ilu (A_small); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
333 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
334 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
335 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
336 %! [L, U] = ilu (A_medium); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
337 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
338 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
339 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
340 %! [L, U] = ilu (A_large); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
341 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), 0, 1); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
342 %! |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
343 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
344 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
345 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
346 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
347 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
348 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
349 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
350 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
351 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
352 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
353 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
354 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
355 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
356 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
357 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
358 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
359 %! |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
360 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
361 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
362 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
363 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
364 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
365 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
366 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
367 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
368 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
369 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
370 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
371 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
372 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
373 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
374 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
375 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
376 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
377 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
378 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
379 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
380 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
381 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
382 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
383 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
384 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
385 ## Tests for complex matrices of different sizes for ilu0, iluc and ilutp. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
386 %!shared n_tiny, n_small, n_medium, n_large, A_tiny, A_small, A_medium, A_large |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
387 %! n_tiny = 5; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
388 %! n_small = 40; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
389 %! n_medium = 600; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
390 %! n_large = 10000; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
391 %! A_tiny = spconvert ([1 4 2 3 3 4 2 5; 1 1 2 3 4 4 5 5; 1 2 3 4 5 6 7 8]'); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
392 %! A_tiny(1,1) += 1i; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
393 %! A_small = sprand (n_small, n_small, 1/n_small) + ... |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
394 %! i * sprand (n_small, n_small, 1/n_small) + speye (n_small); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
395 %! A_medium = sprand (n_medium, n_medium, 1/n_medium) + ... |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
396 %! i * sprand (n_medium, n_medium, 1/n_medium) + speye (n_medium); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
397 %! A_large = sprand (n_large, n_large, 1/n_large/10) + ... |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
398 %! i * sprand (n_large, n_large, 1/n_large/10) + speye (n_large); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
399 %! |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
400 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
401 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
402 %! [L, U] = ilu (A_tiny); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
403 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), 0, n_tiny * eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
404 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
405 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
406 %! [L, U] = ilu (A_small); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
407 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
408 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
409 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
410 %! [L, U] = ilu (A_medium); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
411 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
412 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
413 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
414 %! [L, U] = ilu (A_large); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
415 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), 0, 1); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
416 %! |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
417 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
418 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
419 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
420 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
421 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
422 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
423 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
424 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
425 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
426 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
427 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
428 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
429 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
430 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
431 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
432 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
433 %! |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
434 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
435 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
436 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
437 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
438 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
439 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
440 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
441 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
442 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
443 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
444 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
445 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
446 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
447 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
448 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
449 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
450 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
451 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
452 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
453 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
454 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
455 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
456 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
457 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
458 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
459 ## Specific tests for ilutp |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
460 |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
461 %!shared a1, a2 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
462 %! a1 = sparse ([0 0 4 3 1; 5 1 2.3 2 4.5; 0 0 0 2 1;0 0 8 0 2.2; 0 0 9 9 1 ]); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
463 %! a2 = sparse ([3 1 0 0 4; 3 1 0 0 -2;0 0 8 0 0; 0 4 0 4 -4.5; 0 -1 0 0 1]); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
464 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
465 %! opts.udiag = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
466 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
467 %! opts.droptol = 0.2; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
468 %! [L, U, P] = ilu (a1, opts); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
469 %! assert (norm (U, "fro"), 17.4577, 1e-4); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
470 %! assert (norm (L, "fro"), 2.4192, 1e-4); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
471 %! opts.udiag = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
472 %! #fail ("ilu (a1, opts)"); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
473 %! |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
474 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
475 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
476 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
477 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
478 %! opts.milu = "row"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
479 %! #fail ("ilu (a2, opts)"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
480 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
481 ## Tests for input validation |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
482 %!shared A_tiny |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
483 %! A_tiny = spconvert ([1 4 2 3 3 4 2 5; 1 1 2 3 4 4 5 5; 1 2 3 4 5 6 7 8]'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
484 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
485 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
486 %! [L, U] = ilu (sparse ([])); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
487 %! assert (isempty (L)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
488 %! assert (isempty (U)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
489 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
490 %! [L, U] = ilu (sparse ([]), opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
491 %! assert (isempty (L)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
492 %! assert (isempty (U)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
493 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
494 %! [L, U] = ilu (sparse ([]), opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
495 %! assert (isempty (L)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
496 %! assert (isempty (U)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
497 %!error <A must be a sparse square matrix> ilu (0) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
498 %!error <A must be a sparse square matrix> ilu ([]) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
499 %!error <zero on the diagonal> ilu (sparse (0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
500 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
501 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
502 %! opts.type = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
503 %! fail ("ilu (A_tiny, opts)", "invalid TYPE specified"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
504 %! opts.type = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
505 %! fail ("ilu (A_tiny, opts)", "invalid TYPE specified"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
506 %! opts.type = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
507 %! fail ("ilu (A_tiny, opts)", "invalid TYPE specified"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
508 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
509 %! opts.droptol = -1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
510 %! fail ("ilu (A_tiny, opts)", "DROPTOL must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
511 %! opts.droptol = 0.5i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
512 %! fail ("ilu (A_tiny, opts)", "DROPTOL must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
513 %! opts.droptol = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
514 %! fail ("ilu (A_tiny, opts)", "DROPTOL must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
515 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
516 %! opts.milu = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
517 %! fail ("ilu (A_tiny, opts)", 'MILU must be one of "off"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
518 %! opts.milu = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
519 %! fail ("ilu (A_tiny, opts)", 'MILU must be one of "off"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
520 %! opts.milu = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
521 %! fail ("ilu (A_tiny, opts)", 'MILU must be one of "off"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
522 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
523 %! opts.udiag = -1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
524 %! fail ("ilu (A_tiny, opts)", "UDIAG must be 0 or 1"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
525 %! opts.udiag = 0.5i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
526 %! fail ("ilu (A_tiny, opts)", "UDIAG must be 0 or 1"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
527 %! opts.udiag = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
528 %! fail ("ilu (A_tiny, opts)", "UDIAG must be 0 or 1"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
529 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
530 %! opts.thresh = -1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
531 %! fail ("ilu (A_tiny, opts)", "THRESH must be a scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
532 %! opts.thresh = 0.5i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
533 %! fail ("ilu (A_tiny, opts)", "THRESH must be a scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
534 %! opts.thresh = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
535 %! fail ("ilu (A_tiny, opts)", "THRESH must be a scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
536 |