Mercurial > octave
annotate scripts/sparse/ichol.m @ 31254:5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
* interp1.m, logspace.m, triplequad.m, textread.m, __w2mpth__.m, ode15i.m,
__print_parse_opts__.m, ichol.m, discrete_rnd.m, isstring.m:
Use sequence "%!#" to disable BIST tests.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 04 Oct 2022 07:34:47 -0700 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 2013-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
7 ## |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
14 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
15 ## 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
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
19 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
20 ## 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
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
25 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
27 ## @deftypefn {} {@var{L} =} ichol (@var{A}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
28 ## @deftypefnx {} {@var{L} =} ichol (@var{A}, @var{opts}) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
29 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
30 ## Compute the incomplete Cholesky factorization of the sparse square matrix |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
31 ## @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
|
32 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
33 ## 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:
19153
diff
changeset
|
34 ## 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:
19153
diff
changeset
|
35 ## approximates @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
|
36 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
37 ## 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
|
38 ## system of linear equations being solved by iterative methods such as |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
39 ## PCG (Preconditioned Conjugate Gradient). |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
40 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
41 ## 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
|
42 ## @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
|
43 ## is the value of field. Names and specifiers are case sensitive. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
44 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
45 ## @table @asis |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
46 ## @item type |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
47 ## Type of factorization. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
48 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
49 ## @table @asis |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
50 ## @item @qcode{"nofill"} (default) |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
51 ## 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:
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 ## @item @qcode{"ict"} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
54 ## 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:
19153
diff
changeset
|
55 ## @end table |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
56 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
57 ## @item diagcomp |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
58 ## 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:
19153
diff
changeset
|
59 ## @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:
19153
diff
changeset
|
60 ## 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:
19153
diff
changeset
|
61 ## is 0. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
62 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
63 ## @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
|
64 ## A non-negative scalar specifying the drop tolerance for factorization if |
19405
cbce5d1bcaf9
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
19295
diff
changeset
|
65 ## performing @nospell{ICT}@. The default value is 0 which produces the |
cbce5d1bcaf9
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
19295
diff
changeset
|
66 ## complete Cholesky factorization. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
67 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
68 ## 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:
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 ## @code{abs (@var{L}(i,j)) >= droptol * norm (@var{A}(j:end, j), 1)}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
71 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
72 ## @item michol |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
73 ## Modified incomplete Cholesky factorization: |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
74 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
75 ## @table @asis |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
76 ## @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
|
77 ## 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
|
78 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
79 ## @item @qcode{"on"} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
80 ## 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:
19153
diff
changeset
|
81 ## 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:
19153
diff
changeset
|
82 ## 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:
19153
diff
changeset
|
83 ## 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:
19153
diff
changeset
|
84 ## @end table |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
85 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
86 ## @item shape |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
87 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
88 ## @table @asis |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
89 ## @item @qcode{"lower"} (default) |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
90 ## 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:
19833
diff
changeset
|
91 ## @var{L} such that @tcode{L*L'} approximates @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
|
92 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
93 ## @item @qcode{"upper"} |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
94 ## 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:
19833
diff
changeset
|
95 ## @var{U} such that @code{U'*U} approximates @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
|
96 ## @end table |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
97 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
98 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
99 ## EXAMPLES |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
100 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
101 ## 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
|
102 ## 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
|
103 ## incomplete one. |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
104 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
105 ## @example |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
106 ## @group |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
107 ## 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
|
108 ## -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
|
109 ## -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
|
110 ## -0.07, -0.05, -0.05, 0.202]; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
111 ## A = sparse (A); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
112 ## nnz (tril (A)) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
113 ## ans = 9 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
114 ## L = chol (A, "lower"); |
19053
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 = 10 |
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
|
117 ## norm (A - L * L', "fro") / norm (A, "fro") |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
118 ## ans = 1.1993e-16 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
119 ## opts.type = "nofill"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
120 ## L = ichol (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
|
121 ## nnz (L) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
122 ## ans = 9 |
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
|
123 ## norm (A - L * L', "fro") / norm (A, "fro") |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
124 ## ans = 0.019736 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
125 ## @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
|
126 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
127 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
128 ## 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:
19054
diff
changeset
|
129 ## solve a boundary value problem on the unit square. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
130 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
131 ## @example |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
132 ## @group |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
133 ## 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
|
134 ## hx = 1 / (nx + 1); hy = 1 / (ny + 1); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
135 ## 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:
19054
diff
changeset
|
136 ## [-1 0 1 ], nx, nx) / (hx ^ 2); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
137 ## 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:
19054
diff
changeset
|
138 ## [-1 0 1 ], ny, ny) / (hy ^ 2); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
139 ## 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
|
140 ## 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
|
141 ## ans = 239400 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
142 ## opts.type = "nofill"; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
143 ## 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
|
144 ## 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
|
145 ## ans = 239400 |
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
|
146 ## norm (A - L * L', "fro") / norm (A, "fro") |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
147 ## ans = 0.062327 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
148 ## @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
|
149 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
150 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
151 ## References for implemented algorithms: |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
152 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
153 ## [1] @nospell{Y. Saad}. "Preconditioning Techniques." @cite{Iterative |
19153
431dc1da050c
doc: Periodic spellcheck of documentation.
Rik <rik@octave.org>
parents:
19055
diff
changeset
|
154 ## Methods for Sparse Linear Systems}, @nospell{PWS} Publishing Company, 1996. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
155 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
156 ## [2] @nospell{M. Jones, P. Plassmann}: @cite{An Improved Incomplete |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
157 ## Cholesky Factorization}, 1992. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
158 ## @seealso{chol, ilu, pcg} |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
159 ## @end deftypefn |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
160 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
161 function L = ichol (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
|
162 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
163 if (nargin < 1) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
164 print_usage (); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
165 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
166 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
167 if (! (issparse (A) && issquare (A))) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
168 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
|
169 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
170 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
171 if (! isstruct (opts)) |
28905
89a425f2c202
maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
172 error ("ichol: OPTS must be a structure"); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
173 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
174 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
175 ## If A is empty then return empty L for Matlab compatibility |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
176 if (isempty (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
|
177 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:
19053
diff
changeset
|
178 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
|
179 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
|
180 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
181 ## Parse input options |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
182 if (! isfield (opts, "type")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
183 opts.type = "nofill"; # 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
|
184 else |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
185 type = tolower (getfield (opts, "type")); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
186 if (! strcmp (type, "nofill") && ! strcmp (type, "ict")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
187 error ('ichol: TYPE must be "nofill" or "ict"'); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
188 endif |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
189 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
|
190 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
191 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
192 if (! isfield (opts, "droptol")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
193 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
|
194 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
195 if (! (isreal (opts.droptol) && isscalar (opts.droptol) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
196 && opts.droptol >= 0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
197 error ("ichol: 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
|
198 endif |
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 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
201 michol = ""; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
202 if (! isfield (opts, "michol")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
203 opts.michol = "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 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
205 michol = tolower (getfield (opts, "michol")); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
206 if (! strcmp (michol, "off") && ! strcmp (michol, "on")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
207 error ('ichol: MICHOL must be "on" or "off"'); |
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.michol = michol; |
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, "diagcomp")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
213 opts.diagcomp = 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 (! (isreal (opts.diagcomp) && isscalar (opts.diagcomp) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
216 && opts.diagcomp >= 0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
217 error ("ichol: DIAGCOMP 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
|
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 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
220 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
221 if (! isfield (opts, "shape")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
222 opts.shape = "lower"; # 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
|
223 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
224 shape = tolower (getfield (opts, "shape")); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
225 if (! strcmp (shape, "lower") && ! strcmp (shape, "upper")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
226 error ('ichol: SHAPE must be "lower" or "upper"'); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
227 endif |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
228 opts.shape = shape; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
229 endif |
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 ## Prepare input for specialized ICHOL |
19053
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 = []; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
233 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
|
234 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
|
235 endif |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
236 if (strcmp (opts.shape, "upper")) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
237 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
|
238 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
|
239 else |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
240 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
|
241 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
242 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
243 ## Delegate to specialized ICHOL |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
244 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
|
245 case "nofill" |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
246 L = __ichol0__ (A_in, opts.michol); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
247 case "ict" |
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
|
248 L = __icholt__ (A_in, opts.droptol, opts.michol); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
249 endswitch |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
250 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
251 if (strcmp (opts.shape, "upper")) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
252 L = L'; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
253 endif |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
254 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
255 endfunction |
19053
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 |
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
|
258 %!shared A1, A2, A3, A4, A5, A6, A7 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
259 %! A1 = [ 0.37, -0.05, -0.05, -0.07; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
260 %! -0.05, 0.116, 0.0, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
261 %! -0.05, 0.0, 0.116, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
262 %! -0.07, -0.05, -0.05, 0.202]; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
263 %! A1 = sparse (A1); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
264 %! A2 = gallery ("poisson", 30); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
265 %! A3 = gallery ("tridiag", 50); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
266 %! 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
|
267 %! hx = 1 / (nx + 1); hy = 1 / (ny + 1); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
268 %! 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:
19054
diff
changeset
|
269 %! [-1 0 1 ], nx, nx) / (hx ^ 2); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
270 %! 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:
19054
diff
changeset
|
271 %! [-1 0 1 ], ny, ny) / (hy ^ 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
|
272 %! A4 = -kron (Dxx, speye (ny)) - kron (speye (nx), Dyy); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
273 %! A5 = [ 0.37, -0.05, -0.05, -0.07; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
274 %! -0.05, 0.116, 0.0, -0.05 + 0.05i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
275 %! -0.05, 0.0, 0.116, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
276 %! -0.07, -0.05 - 0.05i, -0.05, 0.202]; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
277 %! A5 = sparse (A5); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
278 %! A6 = [ 0.37, -0.05 - i, -0.05, -0.07; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
279 %! -0.05 + i, 0.116, 0.0, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
280 %! -0.05, 0.0, 0.116, -0.05; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
281 %! -0.07, -0.05, -0.05, 0.202]; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
282 %! A6 = sparse (A6); |
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
|
283 %! 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:
19053
diff
changeset
|
284 %! 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:
19053
diff
changeset
|
285 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
286 ## ICHOL0 tests |
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 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
288 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
289 %! 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
|
290 %! 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
|
291 %! 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
|
292 %! assert (nnz (tril (A2)), nnz (ichol (A2, 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
|
293 %! 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:
19053
diff
changeset
|
294 %! 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:
19053
diff
changeset
|
295 %! assert (nnz (tril (A5)), nnz (ichol (A5, opts))); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
296 %! |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
297 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
298 %! 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
|
299 %! 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
|
300 %! L = ichol (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
|
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:
19053
diff
changeset
|
302 %! 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:
19053
diff
changeset
|
303 %! 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:
19053
diff
changeset
|
304 %! 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:
19053
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:
19053
diff
changeset
|
306 %! 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:
19053
diff
changeset
|
307 %! 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:
19053
diff
changeset
|
308 %! |
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
|
309 %!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:
19053
diff
changeset
|
310 %! 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:
19053
diff
changeset
|
311 %! 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:
19053
diff
changeset
|
312 %! 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:
19053
diff
changeset
|
313 %! 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:
19053
diff
changeset
|
314 %! 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:
19053
diff
changeset
|
315 %! 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:
19053
diff
changeset
|
316 %! 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:
19053
diff
changeset
|
317 %! 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:
19053
diff
changeset
|
318 %! 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:
19053
diff
changeset
|
319 %! 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:
19053
diff
changeset
|
320 %! 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:
19053
diff
changeset
|
321 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0272, 1e-4); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
322 %! |
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
|
323 %!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:
19053
diff
changeset
|
324 %! 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:
19053
diff
changeset
|
325 %! 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:
19053
diff
changeset
|
326 %! L = ichol (A2, opts); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
327 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.0893, 1e-4); |
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 %! 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:
19053
diff
changeset
|
329 %! L = ichol (A2, opts); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
330 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.2377, 1e-4); |
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
|
331 %! |
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 %!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:
19053
diff
changeset
|
333 %! 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:
19053
diff
changeset
|
334 %! 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:
19053
diff
changeset
|
335 %! 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:
19053
diff
changeset
|
336 %! 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:
19053
diff
changeset
|
337 %! 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:
19053
diff
changeset
|
338 %! 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:
19053
diff
changeset
|
339 %! 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:
19053
diff
changeset
|
340 %! |
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
|
341 %!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:
19053
diff
changeset
|
342 %! 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:
19053
diff
changeset
|
343 %! 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:
19053
diff
changeset
|
344 %! 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:
19053
diff
changeset
|
345 %! 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:
19053
diff
changeset
|
346 %! 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:
19053
diff
changeset
|
347 %! 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:
19053
diff
changeset
|
348 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.1664, 1e-4); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
349 %! |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
350 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
351 %! 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
|
352 %! opts.michol = "off"; |
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
|
353 %! 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:
19053
diff
changeset
|
354 %! 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:
19053
diff
changeset
|
355 %! 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:
19053
diff
changeset
|
356 %! 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:
19053
diff
changeset
|
357 %! 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:
19053
diff
changeset
|
358 |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
359 ## Negative pivot |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
360 %!error <negative pivot> ichol (A6) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
361 %!error ichol (A6) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
362 ## Complex entry in the diagonal |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
363 %!error <non-real pivot> ichol (A7) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
364 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
365 ## ICHOLT tests |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
366 |
31254
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
367 %!#test |
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
|
368 %! 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:
19053
diff
changeset
|
369 %! 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:
19053
diff
changeset
|
370 %! 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:
19053
diff
changeset
|
371 %! 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:
19053
diff
changeset
|
372 %! 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:
19053
diff
changeset
|
373 %! 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:
19053
diff
changeset
|
374 %! 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:
19053
diff
changeset
|
375 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.2065, 1e-4); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
376 %! 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
|
377 %! L = ichol (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
|
378 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.2065, 1e-4); |
31254
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
379 |
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
380 %!#test |
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
|
381 %! 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:
19053
diff
changeset
|
382 %! opts.droptol = 1e-1; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
383 %! 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
|
384 %! L = ichol (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
|
385 %! 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:
19053
diff
changeset
|
386 %! 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:
19053
diff
changeset
|
387 %! 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:
19053
diff
changeset
|
388 %! 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:
19053
diff
changeset
|
389 %! opts.shape = "lower"; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
390 %! 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
|
391 %! L = ichol (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
|
392 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.3266, 1e-4); |
31254
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
393 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
394 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
395 %! opts.type = "ict"; |
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
|
396 %! opts.droptol = 1e-1; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
397 %! opts.michol = "off"; |
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
|
398 %! L = ichol (A2, opts); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
399 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.0893, 1e-4); |
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
|
400 %! 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:
19053
diff
changeset
|
401 %! L = ichol (A2, opts); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21568
diff
changeset
|
402 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.2377, 1e-4); |
31254
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
403 |
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
|
404 %!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:
19053
diff
changeset
|
405 %! 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:
19053
diff
changeset
|
406 %! 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:
19053
diff
changeset
|
407 %! 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:
19053
diff
changeset
|
408 %! 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:
19053
diff
changeset
|
409 %! 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:
19053
diff
changeset
|
410 %! 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:
19053
diff
changeset
|
411 %! 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:
19053
diff
changeset
|
412 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps); |
31254
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
413 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
414 %!test |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
415 %! opts.type = "ict"; |
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 %! opts.droptol = 1e-1; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
417 %! opts.michol = "off"; |
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
|
418 %! 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:
19053
diff
changeset
|
419 %! 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:
19053
diff
changeset
|
420 %! 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:
19053
diff
changeset
|
421 %! 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:
19053
diff
changeset
|
422 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.2118, 1e-4); |
31254
5d6b058a22dc
maint: use sequence "%!#" to disable BIST tests.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
423 |
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
|
424 %!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:
19053
diff
changeset
|
425 %! 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:
19053
diff
changeset
|
426 %! 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:
19053
diff
changeset
|
427 %! 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:
19053
diff
changeset
|
428 %! 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:
19053
diff
changeset
|
429 %! 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:
19053
diff
changeset
|
430 %! 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:
19053
diff
changeset
|
431 %! 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:
19053
diff
changeset
|
432 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.3231, 1e-4); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
433 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
434 ## Test input validation |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
435 %!error <A must be a sparse square matrix> ichol ([]) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
436 %!error <A must be a sparse square matrix> ichol (0) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
437 %!error <pivot equal to 0> ichol (sparse (0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
438 %!error <pivot equal to 0> ichol (sparse (-0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
439 %!error <negative pivot> ichol (sparse (-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
|
440 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
441 %! opts.type = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
442 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
443 %! opts.type = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
444 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
445 %! opts.type = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
446 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
447 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
448 %! opts.droptol = -1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
449 %! 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:
19054
diff
changeset
|
450 %! opts.droptol = 0.5i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
451 %! 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:
19054
diff
changeset
|
452 %! opts.droptol = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
453 %! 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:
19054
diff
changeset
|
454 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
455 %! opts.michol = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
456 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
457 %! opts.michol = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
458 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
459 %! opts.michol = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
460 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
461 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
462 %! opts.diagcomp = -1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
463 %! 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:
19054
diff
changeset
|
464 %! opts.diagcomp = 0.5i; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
465 %! 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:
19054
diff
changeset
|
466 %! opts.diagcomp = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
467 %! 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:
19054
diff
changeset
|
468 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
469 %! opts.shape = "foo"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
470 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
471 %! opts.shape = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
472 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
473 %! opts.shape = []; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
474 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"'); |