Mercurial > hg > octave-nkf
annotate scripts/sparse/ichol.m @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | df437a52bcaf |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19602
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:
19602
diff
changeset
|
2 ## Copyright (C) 2013-2015 Kai T. Ohlhus <k.ohlhus@gmail.com> |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
3 ## |
19245
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. |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
5 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
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:
19246
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:
19246
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:
19246
diff
changeset
|
9 ## your option) any later version. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
10 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
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:
19246
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:
19246
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:
19246
diff
changeset
|
14 ## General Public License for more details. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
15 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
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:
19246
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:
19246
diff
changeset
|
18 ## <http://www.gnu.org/licenses/>. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
19 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
20 ## -*- texinfo -*- |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
21 ## @deftypefn {Function File} {@var{L} =} ichol (@var{A}) |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{L} =} ichol (@var{A}, @var{opts}) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
23 ## |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
24 ## Compute the incomplete Cholesky factorization of the sparse square matrix |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
25 ## @var{A}. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
26 ## |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
27 ## By default, @code{ichol} uses only the lower triangle of @var{A} and |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
28 ## produces a lower triangular factor @var{L} such that @tcode{L*L'} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
29 ## approximates @var{A}. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
30 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
31 ## The factor given by this routine may be useful as a preconditioner for a |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
32 ## system of linear equations being solved by iterative methods such as |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
33 ## PCG (Preconditioned Conjugate Gradient). |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
34 ## |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
35 ## The factorization may be modified by passing options in a structure |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
36 ## @var{opts}. The option name is a field of the structure and the setting |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
37 ## is the value of field. Names and specifiers are case sensitive. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
38 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
39 ## @table @asis |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
40 ## @item type |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
41 ## Type of factorization. |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
42 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
43 ## @table @asis |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
44 ## @item @qcode{"nofill"} (default) |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
45 ## Incomplete Cholesky factorization with no fill-in (@nospell{IC(0)}). |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
46 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
47 ## @item @qcode{"ict"} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
48 ## Incomplete Cholesky factorization with threshold dropping (@nospell{ICT}). |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
49 ## @end table |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
50 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
51 ## @item diagcomp |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
52 ## A non-negative scalar @var{alpha} for incomplete Cholesky factorization of |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
53 ## @code{@var{A} + @var{alpha} * diag (diag (@var{A}))} instead of @var{A}. |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
54 ## This can be useful when @var{A} is not positive definite. The default value |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
55 ## is 0. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
56 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
57 ## @item droptol |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
58 ## A non-negative scalar specifying the drop tolerance for factorization if |
19602
cbce5d1bcaf9
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
19487
diff
changeset
|
59 ## performing @nospell{ICT}@. The default value is 0 which produces the |
cbce5d1bcaf9
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
19487
diff
changeset
|
60 ## complete Cholesky factorization. |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
61 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
62 ## Non-diagonal entries of @var{L} are set to 0 unless |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
63 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
64 ## @code{abs (@var{L}(i,j)) >= droptol * norm (@var{A}(j:end, j), 1)}. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
65 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
66 ## @item michol |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
67 ## Modified incomplete Cholesky factorization: |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
68 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
69 ## @table @asis |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
70 ## @item @qcode{"off"} (default) |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
71 ## Row and column sums are not necessarily preserved. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
72 ## |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
73 ## @item @qcode{"on"} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
74 ## The diagonal of @var{L} is modified so that row (and column) sums are |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
75 ## preserved even when elements have been dropped during the factorization. |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
76 ## The relationship preserved is: @code{@var{A} * e = @var{L} * @var{L}' * e}, |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
77 ## where e is a vector of ones. |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
78 ## @end table |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
79 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
80 ## @item shape |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
81 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
82 ## @table @asis |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
83 ## @item @qcode{"lower"} (default) |
20374
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
84 ## Use only the lower triangle of @var{A} and return a lower triangular factor |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
85 ## @var{L} such that @tcode{L*L'} approximates @var{A}. |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
86 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
87 ## @item @qcode{"upper"} |
20374
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
88 ## Use only the upper triangle of @var{A} and return an upper triangular factor |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
89 ## @var{U} such that @code{U'*U} approximates @var{A}. |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
90 ## @end table |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
91 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
92 ## |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
93 ## EXAMPLES |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
94 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
95 ## The following problem demonstrates how to factorize a sample symmetric |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
96 ## positive definite matrix with the full Cholesky decomposition and with the |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
97 ## incomplete one. |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
98 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
99 ## @example |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
100 ## @group |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
101 ## A = [ 0.37, -0.05, -0.05, -0.07; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
102 ## -0.05, 0.116, 0.0, -0.05; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
103 ## -0.05, 0.0, 0.116, -0.05; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
104 ## -0.07, -0.05, -0.05, 0.202]; |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
105 ## A = sparse (A); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
106 ## nnz (tril (A)) |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
107 ## ans = 9 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
108 ## L = chol (A, "lower"); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
109 ## nnz (L) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
110 ## ans = 10 |
19246
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:
19245
diff
changeset
|
111 ## norm (A - L * L', "fro") / norm (A, "fro") |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
112 ## ans = 1.1993e-16 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
113 ## opts.type = "nofill"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
114 ## L = ichol (A, opts); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
115 ## nnz (L) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
116 ## ans = 9 |
19246
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:
19245
diff
changeset
|
117 ## norm (A - L * L', "fro") / norm (A, "fro") |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
118 ## ans = 0.019736 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
119 ## @end group |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
120 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
121 ## |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
122 ## Another example for decomposition is a finite difference matrix used to |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
123 ## solve a boundary value problem on the unit square. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
124 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
125 ## @example |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
126 ## @group |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
127 ## nx = 400; ny = 200; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
128 ## hx = 1 / (nx + 1); hy = 1 / (ny + 1); |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
129 ## Dxx = spdiags ([ones(nx, 1), -2*ones(nx, 1), ones(nx, 1)], |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
130 ## [-1 0 1 ], nx, nx) / (hx ^ 2); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
131 ## Dyy = spdiags ([ones(ny, 1), -2*ones(ny, 1), ones(ny, 1)], |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
132 ## [-1 0 1 ], ny, ny) / (hy ^ 2); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
133 ## A = -kron (Dxx, speye (ny)) - kron (speye (nx), Dyy); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
134 ## nnz (tril (A)) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
135 ## ans = 239400 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
136 ## opts.type = "nofill"; |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
137 ## L = ichol (A, opts); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
138 ## nnz (tril (A)) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
139 ## ans = 239400 |
19246
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:
19245
diff
changeset
|
140 ## norm (A - L * L', "fro") / norm (A, "fro") |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
141 ## ans = 0.062327 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
142 ## @end group |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
143 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
144 ## |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
145 ## References for implemented algorithms: |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
146 ## |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
147 ## [1] @nospell{Y. Saad}. "Preconditioning Techniques." @cite{Iterative |
19345
431dc1da050c
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
19247
diff
changeset
|
148 ## Methods for Sparse Linear Systems}, @nospell{PWS} Publishing Company, 1996. |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
149 ## |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
150 ## [2] @nospell{M. Jones, P. Plassmann}: @cite{An Improved Incomplete |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
151 ## Cholesky Factorization}, 1992. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
152 ## @seealso{chol, ilu, pcg} |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
153 ## @end deftypefn |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
154 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
155 function L = ichol (A, opts = struct ()) |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
156 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
157 if (nargin < 1 || nargin > 2 || nargout > 1) |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
158 print_usage (); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
159 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
160 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
161 if (! (issparse (A) && issquare (A))) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
162 error ("ichol: A must be a sparse square matrix"); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
163 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
164 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
165 if (! isstruct (opts)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
166 error ("ichol: OPTS must be a structure."); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
167 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
168 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
169 ## If A is empty then return empty L for Matlab compatibility |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
170 if (isempty (A)) |
19246
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:
19245
diff
changeset
|
171 L = A; |
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:
19245
diff
changeset
|
172 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:
19245
diff
changeset
|
173 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:
19245
diff
changeset
|
174 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
175 ## Parse input options |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
176 if (! isfield (opts, "type")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
177 opts.type = "nofill"; # set default |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
178 else |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
179 type = tolower (getfield (opts, "type")); |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
180 if (! strcmp (type, "nofill") && ! strcmp (type, "ict")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
181 error ('ichol: TYPE must be "nofill" or "ict"'); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
182 endif |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
183 opts.type = type; |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
184 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
185 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
186 if (! isfield (opts, "droptol")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
187 opts.droptol = 0; # set default |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
188 else |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
189 if (! (isreal (opts.droptol) && isscalar (opts.droptol) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
190 && opts.droptol >= 0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
191 error ("ichol: DROPTOL must be a non-negative real scalar"); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
192 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
193 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
194 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
195 michol = ""; |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
196 if (! isfield (opts, "michol")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
197 opts.michol = "off"; # set default |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
198 else |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
199 michol = tolower (getfield (opts, "michol")); |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
200 if (! strcmp (michol, "off") && ! strcmp (michol, "on")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
201 error ('ichol: MICHOL must be "on" or "off"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
202 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
203 opts.michol = michol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
204 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
205 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
206 if (! isfield (opts, "diagcomp")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
207 opts.diagcomp = 0; # set default |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
208 else |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
209 if (! (isreal (opts.diagcomp) && isscalar (opts.diagcomp) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
210 && opts.diagcomp >= 0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
211 error ("ichol: DIAGCOMP must be a non-negative real scalar"); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
212 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
213 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
214 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
215 if (! isfield (opts, "shape")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
216 opts.shape = "lower"; # set default |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
217 else |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
218 shape = tolower (getfield (opts, "shape")); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
219 if (! strcmp (shape, "lower") && ! strcmp (shape, "upper")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
220 error ('ichol: SHAPE must be "lower" or "upper"'); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
221 endif |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
222 opts.shape = shape; |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
223 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
224 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
225 ## Prepare input for specialized ICHOL |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
226 A_in = []; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
227 if (opts.diagcomp > 0) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
228 A += opts.diagcomp * diag (diag (A)); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
229 endif |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
230 if (strcmp (opts.shape, "upper")) |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
231 A_in = triu (A); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
232 A_in = A_in'; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
233 else |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
234 A_in = tril (A); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
235 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
236 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
237 ## Delegate to specialized ICHOL |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
238 switch (opts.type) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
239 case "nofill" |
19246
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:
19245
diff
changeset
|
240 L = __ichol0__ (A_in, opts.michol); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
241 case "ict" |
19246
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:
19245
diff
changeset
|
242 L = __icholt__ (A_in, opts.droptol, opts.michol); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
243 endswitch |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
244 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
245 if (strcmp (opts.shape, "upper")) |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
246 L = L'; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
247 endif |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
248 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
249 endfunction |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
250 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
251 |
19246
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:
19245
diff
changeset
|
252 %!shared A1, A2, A3, A4, A5, A6, A7 |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
253 %! A1 = [ 0.37, -0.05, -0.05, -0.07; |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
254 %! -0.05, 0.116, 0.0, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
255 %! -0.05, 0.0, 0.116, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
256 %! -0.07, -0.05, -0.05, 0.202]; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
257 %! A1 = sparse (A1); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
258 %! A2 = gallery ("poisson", 30); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
259 %! A3 = gallery ("tridiag", 50); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
260 %! nx = 400; ny = 200; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
261 %! hx = 1 / (nx + 1); hy = 1 / (ny + 1); |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
262 %! Dxx = spdiags ([ones(nx, 1), -2*ones(nx, 1), ones(nx, 1)], |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
263 %! [-1 0 1 ], nx, nx) / (hx ^ 2); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
264 %! Dyy = spdiags ([ones(ny, 1), -2*ones(ny, 1), ones(ny, 1)], |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
265 %! [-1 0 1 ], ny, ny) / (hy ^ 2); |
19246
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:
19245
diff
changeset
|
266 %! A4 = -kron (Dxx, speye (ny)) - kron (speye (nx), Dyy); |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
267 %! A5 = [ 0.37, -0.05, -0.05, -0.07; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
268 %! -0.05, 0.116, 0.0, -0.05 + 0.05i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
269 %! -0.05, 0.0, 0.116, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
270 %! -0.07, -0.05 - 0.05i, -0.05, 0.202]; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
271 %! A5 = sparse (A5); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
272 %! A6 = [ 0.37, -0.05 - i, -0.05, -0.07; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
273 %! -0.05 + i, 0.116, 0.0, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
274 %! -0.05, 0.0, 0.116, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
275 %! -0.07, -0.05, -0.05, 0.202]; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
276 %! A6 = sparse (A6); |
19246
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:
19245
diff
changeset
|
277 %! A7 = A5; |
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:
19245
diff
changeset
|
278 %! A7(1) = 2i; |
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:
19245
diff
changeset
|
279 |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
280 ## ICHOL0 tests |
19246
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:
19245
diff
changeset
|
281 |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
282 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
283 %! opts.type = "nofill"; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
284 %! opts.michol = "off"; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
285 %! assert (nnz (tril (A1)), nnz (ichol (A1, opts))); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
286 %! assert (nnz (tril (A2)), nnz (ichol (A2, opts))); |
19246
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:
19245
diff
changeset
|
287 %! assert (nnz (tril (A3)), nnz (ichol (A3, opts))); |
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:
19245
diff
changeset
|
288 %! assert (nnz (tril (A4)), nnz (ichol (A4, opts))); |
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:
19245
diff
changeset
|
289 %! assert (nnz (tril (A5)), nnz (ichol (A5, opts))); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
290 %! |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
291 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
292 %! opts.type = "nofill"; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
293 %! opts.michol = "off"; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
294 %! L = ichol (A1, opts); |
19246
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:
19245
diff
changeset
|
295 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0197, 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:
19245
diff
changeset
|
296 %! opts.shape = "upper"; |
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:
19245
diff
changeset
|
297 %! U = ichol (A1, opts); |
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:
19245
diff
changeset
|
298 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.0197, 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:
19245
diff
changeset
|
299 %! opts.shape = "lower"; |
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:
19245
diff
changeset
|
300 %! L = ichol (A1, opts); |
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:
19245
diff
changeset
|
301 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0197, 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:
19245
diff
changeset
|
302 %! |
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:
19245
diff
changeset
|
303 %!test |
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:
19245
diff
changeset
|
304 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
305 %! opts.shape = "lower"; |
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:
19245
diff
changeset
|
306 %! opts.type = "nofill"; |
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:
19245
diff
changeset
|
307 %! L = ichol (A1, opts); |
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:
19245
diff
changeset
|
308 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0279, 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:
19245
diff
changeset
|
309 %! opts.shape = "upper"; |
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:
19245
diff
changeset
|
310 %! U = ichol (A1, opts); |
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:
19245
diff
changeset
|
311 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.0279, 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:
19245
diff
changeset
|
312 %! opts.shape = "lower"; |
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:
19245
diff
changeset
|
313 %! opts.diagcomp = 3e-3; |
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:
19245
diff
changeset
|
314 %! L = ichol (A1, opts); |
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:
19245
diff
changeset
|
315 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0272, 1e-4); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
316 %! |
19246
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:
19245
diff
changeset
|
317 %!test |
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:
19245
diff
changeset
|
318 %! opts.type = "nofill"; |
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:
19245
diff
changeset
|
319 %! opts.michol = "off"; |
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:
19245
diff
changeset
|
320 %! L = ichol (A2, opts); |
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:
19245
diff
changeset
|
321 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.0893, 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:
19245
diff
changeset
|
322 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
323 %! L = ichol (A2, opts); |
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:
19245
diff
changeset
|
324 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.2377, 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:
19245
diff
changeset
|
325 %! |
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:
19245
diff
changeset
|
326 %!test |
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:
19245
diff
changeset
|
327 %! opts.type = "nofill"; |
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:
19245
diff
changeset
|
328 %! opts.michol = "off"; |
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:
19245
diff
changeset
|
329 %! L = ichol (A3, opts); |
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:
19245
diff
changeset
|
330 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps); |
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:
19245
diff
changeset
|
331 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
332 %! L = ichol (A3, opts); |
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:
19245
diff
changeset
|
333 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps); |
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:
19245
diff
changeset
|
334 %! |
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:
19245
diff
changeset
|
335 %!test |
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:
19245
diff
changeset
|
336 %! opts.type = "nofill"; |
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:
19245
diff
changeset
|
337 %! opts.michol = "off"; |
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:
19245
diff
changeset
|
338 %! L = ichol (A4, opts); |
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:
19245
diff
changeset
|
339 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.0623, 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:
19245
diff
changeset
|
340 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
341 %! L = ichol (A4, opts); |
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:
19245
diff
changeset
|
342 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.1664, 1e-4); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
343 %! |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
344 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
345 %! opts.type = "nofill"; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
346 %! opts.michol = "off"; |
19246
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:
19245
diff
changeset
|
347 %! L = ichol (A5, opts); |
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:
19245
diff
changeset
|
348 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.0195, 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:
19245
diff
changeset
|
349 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
350 %! L = ichol (A5, opts); |
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:
19245
diff
changeset
|
351 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.0276, 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:
19245
diff
changeset
|
352 |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
353 ## Negative pivot |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
354 %!error <negative pivot> ichol (A6) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
355 %!error ichol (A6) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
356 ## Complex entry in the diagonal |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
357 %!error <non-real pivot> ichol (A7) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
358 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
359 ## ICHOLT tests |
19487
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19345
diff
changeset
|
360 |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
361 #%!test |
19246
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:
19245
diff
changeset
|
362 %! opts.type = "ict"; |
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:
19245
diff
changeset
|
363 %! opts.droptol = 1e-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:
19245
diff
changeset
|
364 %! opts.michol = "off"; |
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:
19245
diff
changeset
|
365 %! L = ichol (A1, opts); |
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:
19245
diff
changeset
|
366 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.2065, 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:
19245
diff
changeset
|
367 %! opts.shape = "upper"; |
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:
19245
diff
changeset
|
368 %! U = ichol (A1, opts); |
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:
19245
diff
changeset
|
369 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.2065, 1e-4); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
370 %! opts.shape = "lower"; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
371 %! L = ichol (A1, opts); |
19246
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:
19245
diff
changeset
|
372 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.2065, 1e-4); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
373 %! |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
374 #%!test |
19246
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:
19245
diff
changeset
|
375 %! opts.type = "ict"; |
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:
19245
diff
changeset
|
376 %! opts.droptol = 1e-1; |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
377 %! opts.michol = "on"; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
378 %! L = ichol (A1, opts); |
19246
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:
19245
diff
changeset
|
379 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.3266, 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:
19245
diff
changeset
|
380 %! opts.shape = "upper"; |
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:
19245
diff
changeset
|
381 %! U = ichol (A1, opts); |
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:
19245
diff
changeset
|
382 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.3266, 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:
19245
diff
changeset
|
383 %! opts.shape = "lower"; |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
384 %! opts.diagcomp = 3e-3; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
385 %! L = ichol (A1, opts); |
19246
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:
19245
diff
changeset
|
386 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.3266, 1e-4); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
387 %! |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
388 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
389 %! opts.type = "ict"; |
19246
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:
19245
diff
changeset
|
390 %! opts.droptol = 1e-1; |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
391 %! opts.michol = "off"; |
19246
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:
19245
diff
changeset
|
392 %! L = ichol (A2, opts); |
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:
19245
diff
changeset
|
393 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.0893, 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:
19245
diff
changeset
|
394 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
395 %! L = ichol (A2, opts); |
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:
19245
diff
changeset
|
396 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.2377, 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:
19245
diff
changeset
|
397 %! |
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:
19245
diff
changeset
|
398 %!test |
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:
19245
diff
changeset
|
399 %! opts.type = "ict"; |
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:
19245
diff
changeset
|
400 %! opts.droptol = 1e-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:
19245
diff
changeset
|
401 %! opts.michol = "off"; |
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:
19245
diff
changeset
|
402 %! L = ichol (A3, opts); |
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:
19245
diff
changeset
|
403 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps); |
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:
19245
diff
changeset
|
404 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
405 %! L = ichol (A3, opts); |
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:
19245
diff
changeset
|
406 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps); |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
407 %! |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
408 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
409 %! opts.type = "ict"; |
19246
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:
19245
diff
changeset
|
410 %! opts.droptol = 1e-1; |
19245
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
411 %! opts.michol = "off"; |
19246
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:
19245
diff
changeset
|
412 %! L = ichol (A4, opts); |
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:
19245
diff
changeset
|
413 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.1224, 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:
19245
diff
changeset
|
414 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
415 %! L = ichol (A4, opts); |
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:
19245
diff
changeset
|
416 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.2118, 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:
19245
diff
changeset
|
417 %! |
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:
19245
diff
changeset
|
418 %!test |
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:
19245
diff
changeset
|
419 %! opts.type = "ict"; |
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:
19245
diff
changeset
|
420 %! opts.droptol = 1e-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:
19245
diff
changeset
|
421 %! opts.michol = "off"; |
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:
19245
diff
changeset
|
422 %! L = ichol (A5, opts); |
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:
19245
diff
changeset
|
423 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.2044, 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:
19245
diff
changeset
|
424 %! opts.michol = "on"; |
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:
19245
diff
changeset
|
425 %! L = ichol (A5, opts); |
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:
19245
diff
changeset
|
426 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.3231, 1e-4); |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
427 |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
428 ## Test input validation |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
429 %!error <A must be a sparse square matrix> ichol ([]) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
430 %!error <A must be a sparse square matrix> ichol (0) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
431 %!error <pivot equal to 0> ichol (sparse (0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
432 %!error <pivot equal to 0> ichol (sparse (-0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
433 %!error <negative pivot> ichol (sparse (-1)) |
19246
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:
19245
diff
changeset
|
434 %!test |
19247
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
435 %! opts.type = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
436 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
437 %! opts.type = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
438 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
439 %! opts.type = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
440 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
441 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
442 %! opts.droptol = -1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
443 %! fail ("ichol (A1, opts)", "DROPTOL must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
444 %! opts.droptol = 0.5i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
445 %! fail ("ichol (A1, opts)", "DROPTOL must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
446 %! opts.droptol = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
447 %! fail ("ichol (A1, opts)", "DROPTOL must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
448 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
449 %! opts.michol = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
450 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
451 %! opts.michol = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
452 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
453 %! opts.michol = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
454 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
455 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
456 %! opts.diagcomp = -1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
457 %! fail ("ichol (A1, opts)", "DIAGCOMP must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
458 %! opts.diagcomp = 0.5i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
459 %! fail ("ichol (A1, opts)", "DIAGCOMP must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
460 %! opts.diagcomp = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
461 %! fail ("ichol (A1, opts)", "DIAGCOMP must be a non-negative real scalar"); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
462 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
463 %! opts.shape = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
464 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
465 %! opts.shape = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
466 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
467 %! opts.shape = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
468 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19246
diff
changeset
|
469 |