Mercurial > octave
annotate scripts/sparse/ilu.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 628f26e122d9 |
children | 5d3faba0342e |
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:
30236
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:
27356
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/>. |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
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:
23396
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:
23396
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:
23396
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 ######################################################################## |
19056
4630a18757b3
Add missing bits from cset 38937efbee21.
Rik <rik@octave.org>
parents:
19055
diff
changeset
|
25 |
19053
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 {} {} ilu (@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 {} {} ilu (@var{A}, @var{opts}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
29 ## @deftypefnx {} {[@var{L}, @var{U}] =} ilu (@dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
30 ## @deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} ilu (@dots{}) |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
31 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
32 ## Compute the incomplete LU factorization of the sparse square matrix @var{A}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
33 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
34 ## @code{ilu} returns a unit lower triangular matrix @var{L}, an upper |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
35 ## triangular matrix @var{U}, and optionally a permutation matrix @var{P}, such |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
36 ## that @code{@var{L}*@var{U}} approximates @code{@var{P}*@var{A}}. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
37 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
38 ## The factors given by this routine may be useful as preconditioners for a |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
39 ## system of linear equations being solved by iterative methods such as BICG |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
40 ## (BiConjugate Gradients) or GMRES (Generalized Minimum Residual Method). |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
41 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
42 ## 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
|
43 ## @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
|
44 ## is the value of field. Names and specifiers are case sensitive. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
45 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
46 ## @table @code |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
47 ## @item type |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
48 ## Type of factorization. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
49 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
50 ## @table @asis |
25028
acb7094aebb3
Fix ilu when type is ilutp and two output arguments are required (#53440).
Marco Caliari <marco.caliari@univr.it>
parents:
24860
diff
changeset
|
51 ## @item @qcode{"nofill"} (default) |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
52 ## ILU factorization with no fill-in (ILU(0)). |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
53 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
54 ## Additional supported options: @code{milu}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
55 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
56 ## @item @qcode{"crout"} |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
57 ## Crout version of ILU factorization (@nospell{ILUC}). |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
58 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
59 ## Additional supported options: @code{milu}, @code{droptol}. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
60 ## |
25028
acb7094aebb3
Fix ilu when type is ilutp and two output arguments are required (#53440).
Marco Caliari <marco.caliari@univr.it>
parents:
24860
diff
changeset
|
61 ## @item @qcode{"ilutp"} |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
62 ## ILU factorization with threshold and pivoting. |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
63 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
64 ## Additional supported options: @code{milu}, @code{droptol}, @code{udiag}, |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
65 ## @code{thresh}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
66 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
67 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
68 ## @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
|
69 ## A non-negative scalar specifying the drop tolerance for factorization. The |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
70 ## default value is 0 which produces the complete LU factorization. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
71 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
72 ## Non-diagonal entries of @var{U} are set to 0 unless |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
73 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
74 ## @code{abs (@var{U}(i,j)) >= droptol * norm (@var{A}(:,j))}. |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
75 ## |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
76 ## Non-diagonal entries of @var{L} are set to 0 unless |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
77 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
78 ## @code{abs (@var{L}(i,j)) >= droptol * norm (@var{A}(:,j))/@var{U}(j,j)}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
79 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
80 ## @item milu |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
81 ## Modified incomplete LU factorization: |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
82 ## |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
83 ## @table @asis |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
84 ## @item @qcode{"row"} |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
85 ## Row-sum modified incomplete LU factorization. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
86 ## The factorization preserves row sums: |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
87 ## @code{@var{A} * e = @var{L} * @var{U} * e}, where e is a vector of ones. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
88 ## |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
89 ## @item @qcode{"col"} |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
90 ## Column-sum modified incomplete LU factorization. |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
91 ## The factorization preserves column sums: |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
92 ## @code{e' * @var{A} = e' * @var{L} * @var{U}}. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
93 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
94 ## @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
|
95 ## 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
|
96 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
97 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
98 ## @item udiag |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
99 ## If true, any zeros on the diagonal of the upper triangular factor are |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
100 ## replaced by the local drop tolerance |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
101 ## @code{droptol * norm (@var{A}(:,j))/@var{U}(j,j)}. The default is false. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
102 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
103 ## @item thresh |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
104 ## Pivot threshold for factorization. It can range between 0 (diagonal |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
105 ## pivoting) and 1 (default), where the maximum magnitude entry in the column |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
106 ## is chosen to be the pivot. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
107 ## @end table |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
108 ## |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
109 ## If @code{ilu} is called with just one output, the returned matrix is |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
110 ## @code{@var{L} + @var{U} - speye (size (@var{A}))}, where @var{L} is unit |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
111 ## lower triangular and @var{U} is upper triangular. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
112 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
113 ## With two outputs, @code{ilu} returns a unit lower triangular matrix @var{L} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
114 ## and an upper triangular matrix @var{U}. For @var{opts}.type == |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
115 ## @qcode{"ilutp"}, one of the factors is permuted based on the value of |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
116 ## @var{opts}.milu. When @var{opts}.milu == @qcode{"row"}, @var{U} is a |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
117 ## column permuted upper triangular factor. Otherwise, @var{L} is a |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
118 ## row-permuted unit lower triangular factor. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
119 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
120 ## If there are three named outputs and @var{opts}.milu != @qcode{"row"}, |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
121 ## @var{P} is returned such that @var{L} and @var{U} are incomplete factors |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
122 ## of @code{@var{P}*@var{A}}. When @var{opts}.milu == @qcode{"row"}, @var{P} |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
123 ## is returned such that @var{L} and @var{U} are incomplete factors of |
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
124 ## @code{@var{A}*@var{P}}. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
125 ## |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
126 ## EXAMPLES |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
127 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
128 ## @example |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
129 ## @group |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
130 ## A = gallery ("neumann", 1600) + speye (1600); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
131 ## opts.type = "nofill"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
132 ## nnz (A) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
133 ## ans = 7840 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
134 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
135 ## nnz (lu (A)) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
136 ## ans = 126478 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
137 ## |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
138 ## nnz (ilu (A, opts)) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
139 ## ans = 7840 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
140 ## @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
|
141 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
142 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
143 ## This shows that @var{A} has 7,840 nonzeros, the complete LU factorization |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
144 ## has 126,478 nonzeros, and the incomplete LU factorization, with 0 level of |
19295
76a6ba7d65d0
doc: Update documentation for ilu, ichol.
Nir Krakauer <nkrakauer@ccny.cuny.edu> and Rik <rik@octave.org>
parents:
19153
diff
changeset
|
145 ## fill-in, has 7,840 nonzeros, the same amount as @var{A}. Taken from: |
27356
4e632e942e84
doc: Improve documentation of sparse functions.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26597
diff
changeset
|
146 ## @url{https://www.mathworks.com/help/matlab/ref/ilu.html} |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
147 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
148 ## @example |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
149 ## @group |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
150 ## A = gallery ("wathen", 10, 10); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
151 ## b = sum (A, 2); |
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
152 ## tol = 1e-8; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
153 ## maxit = 50; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
154 ## opts.type = "crout"; |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
155 ## opts.droptol = 1e-4; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
156 ## [L, U] = ilu (A, opts); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
157 ## x = bicg (A, b, tol, maxit, L, U); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
158 ## norm (A * x - b, inf) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
159 ## @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
|
160 ## @end example |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
161 ## |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
162 ## This example uses ILU as preconditioner for a random FEM-Matrix, which has a |
21546
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
163 ## large condition number. Without @var{L} and @var{U} BICG would not |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
164 ## converge. |
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 ## @seealso{lu, ichol, bicg, gmres} |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
167 ## @end deftypefn |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
168 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
169 function [L, U, P] = ilu (A, opts = struct ()) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
170 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
171 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
|
172 print_usage (); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
173 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
174 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
175 if (! (issparse (A) && issquare (A))) |
24860
6266e321ef22
Merge code from SoCiS 2016 "Improve iterative methods" project (http://socis16octave-improveiterativemethods.blogspot.com)
Cristiano Dorigo <cristiano.dorigo@hotmail.it>
parents:
24534
diff
changeset
|
176 error ("ilu: 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
|
177 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
178 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
179 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
|
180 error ("ilu: OPTS must be a structure"); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
181 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
182 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
183 ## If A is empty then return empty L, U and P for Matlab compatibility |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
184 if (isempty (A)) |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
185 L = U = P = A; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
186 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
|
187 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
|
188 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
189 ## Parse input options |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
190 if (! isfield (opts, "type")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
191 opts.type = "nofill"; # set default |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
192 else |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
193 type = tolower (getfield (opts, "type")); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
194 if (! any (strcmp (type, {"nofill", "crout", "ilutp"}))) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
195 error ("ilu: invalid TYPE specified"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
196 endif |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
197 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
|
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 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
200 if (! isfield (opts, "droptol")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
201 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
|
202 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
203 if (! (isreal (opts.droptol) && isscalar (opts.droptol) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
204 && opts.droptol >= 0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
205 error ("ilu: DROPTOL must be a non-negative real scalar"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
206 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
207 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
208 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
209 if (! isfield (opts, "milu")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
210 opts.milu = "off"; # set default |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
211 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
212 milu = tolower (getfield (opts, "milu")); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
213 if (! any (strcmp (milu, {"off", "col", "row"}))) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
214 error ('ilu: MILU must be one of "off", "col", or "row"'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
215 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
216 opts.milu = milu; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
217 endif |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
218 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
219 if (! isfield (opts, "udiag")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
220 opts.udiag = 0; # set default |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
221 else |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
222 if (! isscalar (opts.udiag) || (opts.udiag != 0 && opts.udiag != 1)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
223 error ("ilu: UDIAG must be 0 or 1"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
224 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
225 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
226 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
227 if (! isfield (opts, "thresh")) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
228 opts.thresh = 1; # set default |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
229 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
230 if (! (isreal (opts.thresh) && isscalar (opts.thresh)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
231 || opts.thresh < 0 || opts.thresh > 1) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
232 error ("ilu: THRESH must be a scalar in the range [0, 1]"); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
233 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
234 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
235 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
236 n = length (A); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
237 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
238 ## Delegate to specialized ILU |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
239 switch (opts.type) |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
240 case "nofill" |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
241 [L, U] = __ilu0__ (A, opts.milu); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
242 if (nargout == 3) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
243 P = speye (length (A)); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
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 case "crout" |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
246 [L, U] = __iluc__ (A, opts.droptol, opts.milu); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
247 if (nargout == 3) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
248 P = speye (length (A)); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
249 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
250 case "ilutp" |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
251 if (nargout == 3) |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
252 [L, U, P] = __ilutp__ (A, opts.droptol, opts.thresh, |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
253 opts.milu, opts.udiag); |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
254 else |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
255 [L, U] = __ilutp__ (A, opts.droptol, opts.thresh, |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
256 opts.milu, opts.udiag); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
257 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
258 endswitch |
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 if (nargout == 1) |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
261 L = L + U - speye (n); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
262 endif |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
263 |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
264 endfunction |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
265 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
266 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
267 %!shared n, dtol, A |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
268 %! n = 1600; |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
269 %! dtol = 0.1; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
270 %! A = gallery ("neumann", n) + speye (n); |
25053 | 271 |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
272 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
273 %! opts.type = "nofill"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
274 %! assert (nnz (ilu (A, opts)), 7840); |
25053 | 275 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
276 ## This test has been verified in both Matlab and Octave. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
277 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
278 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
279 %! opts.milu = "row"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
280 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
281 %! [L, U] = ilu (A, opts); |
30236
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
282 %! e = ones (columns (A),1); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
283 %! assert (norm (A*e - L*U*e), 1e-14, 1e-14); |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
284 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
285 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
286 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
287 %! [L, U] = ilu (A, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
288 %! assert (norm (A - L * U, "fro") / norm (A, "fro"), 0.05, 1e-2); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
289 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
290 ## Check if the elements in U satisfy the non-dropping condition. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
291 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
292 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
293 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
294 %! [L, U] = ilu (A, opts); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
295 %! for j = 1:n |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
296 %! cmp_value = dtol * norm (A(:, j)); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
297 %! non_zeros = nonzeros (U(:, j)); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
298 %! assert (abs (non_zeros) >= cmp_value); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
299 %! endfor |
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
300 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
301 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
302 %! opts.droptol = dtol; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
303 %! [L, U] = ilu (A, opts); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
304 %! for j = 1:n |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
305 %! cmp_value = dtol * norm (A(:, j)); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
306 %! non_zeros = nonzeros (U(:, j)); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
307 %! assert (abs (non_zeros) >= cmp_value); |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
308 %! endfor |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
309 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
310 ## Check that the complete LU factorisation with crout and ilutp algorithms |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
311 ## produce the same result. |
19053
168c0aa9bb05
Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
312 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
313 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
314 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
315 %! [L1, U1] = ilu (A, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
316 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
317 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
318 %! [L2, U2] = ilu (A, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
319 %! assert (norm (L1 - L2, "fro") / norm (L1, "fro"), 0, eps); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
320 %! assert (norm (U1 - U2, "fro") / norm (U1, "fro"), 0, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
321 |
26597
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
322 ## Restore rand "state" value |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
323 %!shared old_rand_state, restore_state |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
324 %! ## Save and restore the state of the random number generator that is used by |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
325 %! ## the unit tests in this file. |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
326 %! old_rand_state = rand ("state"); |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
327 %! restore_state = onCleanup (@() rand ("state", old_rand_state)); |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
328 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
329 ## Tests for real matrices of different sizes for ilu0, iluc and ilutp. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
330 ## The difference A - L*U should be not greater than eps because with droptol |
25053 | 331 ## equal to 0, the LU complete factorization is performed. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
332 %!shared n_tiny, n_small, n_medium, n_large, A_tiny, A_small, A_medium, A_large |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
333 %! n_tiny = 5; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
334 %! n_small = 40; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
335 %! n_medium = 600; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
336 %! n_large = 10000; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
337 %! A_tiny = spconvert ([1 4 2 3 3 4 2 5; 1 1 2 3 4 4 5 5; 1 2 3 4 5 6 7 8]'); |
26597
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
338 %! ## initialize generator to make behavior reproducible |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
339 %! rand ("state", 42); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
340 %! A_small = sprand (n_small, n_small, 1/n_small) + speye (n_small); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
341 %! A_medium = sprand (n_medium, n_medium, 1/n_medium) + speye (n_medium); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
342 %! A_large = sprand (n_large, n_large, 1/n_large/10) + speye (n_large); |
25053 | 343 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
344 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
345 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
346 %! [L, U] = ilu (A_tiny); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
347 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), 0, n_tiny * eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
348 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
349 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
350 %! [L, U] = ilu (A_small); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
351 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
352 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
353 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
354 %! [L, U] = ilu (A_medium); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
355 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
356 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
357 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
358 %! [L, U] = ilu (A_large); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
359 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), 0, 1); |
25053 | 360 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
361 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
362 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
363 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
364 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
365 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
366 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
367 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
368 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
369 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
370 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
371 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
372 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
373 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
374 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
375 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
376 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
25053 | 377 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
378 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
379 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
380 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
381 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
382 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
383 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
384 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
385 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
386 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
387 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
388 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
389 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
390 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
391 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
392 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
393 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
394 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
395 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
396 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
397 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
398 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
399 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
400 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
401 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
402 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
403 ## Tests for complex matrices of different sizes for ilu0, iluc and ilutp. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
404 %!shared n_tiny, n_small, n_medium, n_large, A_tiny, A_small, A_medium, A_large |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
405 %! n_tiny = 5; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
406 %! n_small = 40; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
407 %! n_medium = 600; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
408 %! n_large = 10000; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
409 %! A_tiny = spconvert ([1 4 2 3 3 4 2 5; 1 1 2 3 4 4 5 5; 1 2 3 4 5 6 7 8]'); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
410 %! A_tiny(1,1) += 1i; |
26597
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
411 %! ## initialize generator to make behavior reproducible |
ee21e2bf3e50
ilu.m: Fix state of random number generator in BISTs.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
412 %! rand ("state", 42); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
413 %! A_small = sprand (n_small, n_small, 1/n_small) + ... |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
414 %! i * sprand (n_small, n_small, 1/n_small) + speye (n_small); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
415 %! A_medium = sprand (n_medium, n_medium, 1/n_medium) + ... |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
416 %! i * sprand (n_medium, n_medium, 1/n_medium) + speye (n_medium); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
417 %! A_large = sprand (n_large, n_large, 1/n_large/10) + ... |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
418 %! i * sprand (n_large, n_large, 1/n_large/10) + speye (n_large); |
25053 | 419 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
420 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
421 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
422 %! [L, U] = ilu (A_tiny); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
423 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), 0, n_tiny * eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
424 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
425 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
426 %! [L, U] = ilu (A_small); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
427 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
428 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
429 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
430 %! [L, U] = ilu (A_medium); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
431 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), 0, 1); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
432 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
433 %! opts.type = "nofill"; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
434 %! [L, U] = ilu (A_large); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
435 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), 0, 1); |
25053 | 436 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
437 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
438 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
439 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
440 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
441 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
442 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
443 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
444 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
445 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
446 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
447 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
448 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
449 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
450 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
451 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
452 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
25053 | 453 |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
454 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
455 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
456 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
457 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
458 %! [L, U] = ilu (A_tiny, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
459 %! assert (norm (A_tiny - L*U, "fro") / norm (A_tiny, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
460 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
461 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
462 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
463 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
464 %! [L, U] = ilu (A_small, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
465 %! assert (norm (A_small - L*U, "fro") / norm (A_small, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
466 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
467 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
468 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
469 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
470 %! [L, U] = ilu (A_medium, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
471 %! assert (norm (A_medium - L*U, "fro") / norm (A_medium, "fro"), eps, eps); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19295
diff
changeset
|
472 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
473 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
474 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
475 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
476 %! [L, U] = ilu (A_large, opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
477 %! assert (norm (A_large - L*U, "fro") / norm (A_large, "fro"), eps, eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
478 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
479 ## Specific tests for ilutp |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
480 %!shared A |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
481 %! A = sparse ([0 0 4 3 1; 5 1 2.3 2 4.5; 0 0 0 2 1;0 0 8 0 2.2; 0 0 9 9 1 ]); |
25053 | 482 |
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
|
483 %!test |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
484 %! opts.udiag = 1; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
485 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
486 %! opts.droptol = 0.2; |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
487 %! [L, U, P] = ilu (A, opts); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
488 %! assert (norm (U, "fro"), 17.4577, 1e-4); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
19053
diff
changeset
|
489 %! assert (norm (L, "fro"), 2.4192, 1e-4); |
25053 | 490 |
491 %!error <encountered a pivot equal to 0> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
492 %! opts.type = "ilutp"; |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
493 %! opts.udiag = 0; |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
494 %! opts.droptol = 0.2; |
25053 | 495 %! ilu (A, opts); |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
496 |
25053 | 497 ## Matlab R2017b doesn't error, but returns a singular L which isn't helpful. |
498 %!error <encountered a pivot equal to 0> | |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
499 %! A = sparse ([3 1 0 0 4; 3 1 0 0 -2;0 0 8 0 0; 0 4 0 4 -4.5; 0 -1 0 0 1]); |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
500 %! opts.type = "ilutp"; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
501 %! opts.droptol = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
502 %! opts.thresh = 0; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
503 %! opts.milu = "row"; |
25053 | 504 %! [L, U, P] = ilu (A, opts); |
505 | |
506 %!test <*53440> | |
507 %! A = sparse (magic (4)); | |
508 %! opts.type = "ilutp"; | |
509 %! [L, U] = ilu (A, opts); | |
28929
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
510 %! assert (L * U, A, eps); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
511 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
512 ## Tests for input validation |
25053 | 513 %!shared A_tiny, opts |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
514 %! A_tiny = spconvert ([1 4 2 3 3 4 2 5; 1 1 2 3 4 4 5 5; 1 2 3 4 5 6 7 8]'); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
515 |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
516 %!test |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
517 %! [L, U] = ilu (sparse ([])); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
518 %! assert (isempty (L)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
519 %! assert (isempty (U)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
520 %! opts.type = "crout"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
521 %! [L, U] = ilu (sparse ([]), opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
522 %! assert (isempty (L)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
523 %! assert (isempty (U)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
524 %! opts.type = "ilutp"; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
525 %! [L, U] = ilu (sparse ([]), opts); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
526 %! assert (isempty (L)); |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
527 %! assert (isempty (U)); |
25053 | 528 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
529 %!error <A must be a sparse square matrix> ilu (0) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
530 %!error <A must be a sparse square matrix> ilu ([]) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
531 %!error <zero on the diagonal> ilu (sparse (0)) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
532 |
25053 | 533 %!error <invalid TYPE specified> |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
534 %! opts.type = "foo"; |
25053 | 535 %! ilu (A_tiny, opts); |
536 %!error <invalid TYPE specified> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
537 %! opts.type = 1; |
25053 | 538 %! ilu (A_tiny, opts); |
539 %!error <invalid TYPE specified> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
540 %! opts.type = []; |
25053 | 541 %! ilu (A_tiny, opts); |
542 | |
543 %!error <DROPTOL must be a non-negative real scalar> | |
544 %! clear opts; | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
545 %! opts.droptol = -1; |
25053 | 546 %! ilu (A_tiny, opts); |
547 %!error <DROPTOL must be a non-negative real scalar> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
548 %! opts.droptol = 0.5i; |
25053 | 549 %! ilu (A_tiny, opts); |
550 %!error <DROPTOL must be a non-negative real scalar> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
551 %! opts.droptol = []; |
25053 | 552 %! ilu (A_tiny, opts); |
553 | |
554 %!error <MILU must be one of "off", "col", or "row"> | |
555 %! clear opts; | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
556 %! opts.milu = "foo"; |
25053 | 557 %! ilu (A_tiny, opts); |
558 %!error <MILU must be one of "off", "col", or "row"> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
559 %! opts.milu = 1; |
25053 | 560 %! ilu (A_tiny, opts); |
561 %!error <MILU must be one of "off", "col", or "row"> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
562 %! opts.milu = []; |
25053 | 563 %! ilu (A_tiny, opts); |
564 | |
565 %!error <UDIAG must be 0 or 1> | |
566 %! clear opts; | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
567 %! opts.udiag = -1; |
25053 | 568 %! ilu (A_tiny, opts); |
569 %!error <UDIAG must be 0 or 1> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
570 %! opts.udiag = 0.5i; |
25053 | 571 %! ilu (A_tiny, opts); |
572 %!error <UDIAG must be 0 or 1> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
573 %! opts.udiag = []; |
25053 | 574 %! ilu (A_tiny, opts); |
575 | |
576 %!error <THRESH must be a scalar in the range \[0, 1\]> | |
577 %! clear opts; | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
578 %! opts.thresh = -1; |
25053 | 579 %! ilu (A_tiny, opts); |
580 %!error <THRESH must be a scalar in the range \[0, 1\]> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
581 %! opts.thresh = 0.5i; |
25053 | 582 %! ilu (A_tiny, opts); |
583 %!error <THRESH must be a scalar in the range \[0, 1\]> | |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
584 %! opts.thresh = []; |
25053 | 585 %! ilu (A_tiny, opts); |