annotate scripts/sparse/ichol.m @ 27923:bd51beb6205e

update formatting of copyright notices * Use <https://octave.org/copyright/> instead of <https://octave.org/COPYRIGHT.html/>. * For consistency with other comments in the Octave sources, use C++-style comments for copyright blocks in C and C++ files. * Use delimiters above and below copyright blocks that are appropriate for the language used in the file. * Eliminate extra spacing inside copyright blocks. * lex.ll (looks_like_copyright): Also allow newlines and carriage returns before the word "Copyright". * scripts/mk-doc.pl (gethelp): Also skip empty comment lines. * bp-table.cc, type.m: Adjust tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Jan 2020 11:59:41 -0500
parents 1891570abac8
children 9f9ac219896d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ##
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 ## Copyright (C) 2013-2020 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
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 21580
diff changeset
161 ## Author: Eduardo Ramos Fernández <eduradical951@gmail.com>
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 21580
diff changeset
162 ## Author: Kai T. Ohlhus <k.ohlhus@gmail.com>
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 21580
diff changeset
163
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
164 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
165
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
166 if (nargin < 1 || nargin > 2 || nargout > 1)
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
167 print_usage ();
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
168 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
169
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
170 if (! (issparse (A) && issquare (A)))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
171 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
172 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
173
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
174 if (! isstruct (opts))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
175 error ("ichol: OPTS must be a structure.");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
176 endif
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
177
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
178 ## 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
179 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
180 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
181 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
182 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
183
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
184 ## Parse input options
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
185 if (! isfield (opts, "type"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
186 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
187 else
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
188 type = tolower (getfield (opts, "type"));
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
189 if (! strcmp (type, "nofill") && ! strcmp (type, "ict"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
190 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
191 endif
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
192 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
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
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
195 if (! isfield (opts, "droptol"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
196 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
197 else
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
198 if (! (isreal (opts.droptol) && isscalar (opts.droptol)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
199 && opts.droptol >= 0))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
200 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
201 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
202 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
203
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
204 michol = "";
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
205 if (! isfield (opts, "michol"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
206 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
207 else
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
208 michol = tolower (getfield (opts, "michol"));
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
209 if (! strcmp (michol, "off") && ! strcmp (michol, "on"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
210 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
211 endif
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
212 opts.michol = michol;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
213 endif
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
214
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
215 if (! isfield (opts, "diagcomp"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
216 opts.diagcomp = 0; # set default
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
217 else
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
218 if (! (isreal (opts.diagcomp) && isscalar (opts.diagcomp)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
219 && opts.diagcomp >= 0))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
220 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
221 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
222 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
223
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
224 if (! isfield (opts, "shape"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
225 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
226 else
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
227 shape = tolower (getfield (opts, "shape"));
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
228 if (! strcmp (shape, "lower") && ! strcmp (shape, "upper"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
229 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
230 endif
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
231 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
232 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
233
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
234 ## 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
235 A_in = [];
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
236 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
237 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
238 endif
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
239 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
240 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
241 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
242 else
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
243 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
244 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
245
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
246 ## 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
247 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
248 case "nofill"
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 20852
diff changeset
249 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
250 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
251 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
252 endswitch
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
253
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
254 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
255 L = L';
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
256 endif
19295
76a6ba7d65d0 doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents: 19153
diff changeset
257
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
258 endfunction
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
259
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
260
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
261 %!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
262 %! 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
263 %! -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
264 %! -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
265 %! -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
266 %! A1 = sparse (A1);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
267 %! A2 = gallery ("poisson", 30);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
268 %! 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
269 %! 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
270 %! 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
271 %! 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
272 %! [-1 0 1 ], nx, nx) / (hx ^ 2);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
273 %! 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
274 %! [-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
275 %! 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
276 %! 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
277 %! -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
278 %! -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
279 %! -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
280 %! A5 = sparse (A5);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
281 %! 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
282 %! -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
283 %! -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
284 %! -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
285 %! 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
286 %! 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
287 %! 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
288
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
289 ## 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
290
19053
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 %! 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
295 %! 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
296 %! 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
297 %! 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
298 %! 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
299 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
300 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
301 %! 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
302 %! 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
303 %! 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
304 %! 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
305 %! 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
306 %! 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
307 %! 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
308 %! 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
309 %! 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
310 %! 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
311 %!
df64071e538c Removed ichol0.cc, 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 %!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
313 %! 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
314 %! 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
315 %! 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
316 %! 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
317 %! 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
318 %! 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
319 %! 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
320 %! 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
321 %! 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
322 %! 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
323 %! 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
324 %! 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
325 %!
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
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: 19053
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: 19053
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: 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.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
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: 19053
diff changeset
332 %! L = ichol (A2, opts);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
333 %! 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
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: 19053
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: 19053
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: 19053
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: 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 %! 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
341 %! 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
342 %! 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
343 %!
df64071e538c Removed ichol0.cc, 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 %!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
345 %! 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
346 %! 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
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.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
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: 19053
diff changeset
350 %! 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
351 %! 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
352 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
353 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
354 %! 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
355 %! 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
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.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
358 %! 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
359 %! 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
360 %! 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
361
19295
76a6ba7d65d0 doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents: 19153
diff changeset
362 ## Negative pivot
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
363 %!error <negative pivot> ichol (A6)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
364 %!error ichol (A6)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
365 ## Complex entry in the diagonal
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
366 %!error <non-real pivot> ichol (A7)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
367
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
368 ## 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
369
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
370 #%!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
371 %! 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
372 %! 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
373 %! 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
374 %! 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
375 %! 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
376 %! 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
377 %! 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
378 %! 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
379 %! 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
380 %! 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
381 %! assert (norm (A1 - L * L', "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
382 %!
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
383 #%!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
384 %! 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
385 %! 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
386 %! 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
387 %! 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
388 %! 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
389 %! 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
390 %! 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
391 %! 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
392 %! 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
393 %! 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
394 %! 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
395 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.3266, 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
396 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
397 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
398 %! 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
399 %! 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
400 %! 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
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.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
403 %! 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
404 %! L = ichol (A2, opts);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
405 %! 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
406 %!
df64071e538c Removed ichol0.cc, 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 %!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
408 %! 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
409 %! 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
410 %! 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
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);
df64071e538c Removed ichol0.cc, 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
413 %! 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
414 %! 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
415 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
416 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
417 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
418 %! 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
419 %! 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
420 %! 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
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.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
423 %! 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
424 %! 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
425 %! 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: 19053
diff changeset
426 %!
df64071e538c Removed ichol0.cc, 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 %!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
428 %! 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
429 %! 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
430 %! 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
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.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
433 %! 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
434 %! 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
435 %! 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
436
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
437 ## Test input validation
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
438 %!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
439 %!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
440 %!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
441 %!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
442 %!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
443 %!test
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
444 %! opts.type = "foo";
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
445 %! 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
446 %! opts.type = 1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
447 %! 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
448 %! opts.type = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
449 %! 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
450 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
451 %! opts.droptol = -1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
452 %! 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
453 %! opts.droptol = 0.5i;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
454 %! 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
455 %! opts.droptol = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
456 %! 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
457 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
458 %! opts.michol = "foo";
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
459 %! 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
460 %! opts.michol = 1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
461 %! 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
462 %! opts.michol = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
463 %! 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
464 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
465 %! opts.diagcomp = -1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
466 %! 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
467 %! opts.diagcomp = 0.5i;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
468 %! 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
469 %! opts.diagcomp = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
470 %! 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
471 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
472 %! opts.shape = "foo";
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
473 %! 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
474 %! opts.shape = 1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
475 %! 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
476 %! opts.shape = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
477 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"');