annotate scripts/sparse/ichol.m @ 19055:38937efbee21

Incorporate new functions ichol and ilu into Octave. * NEWS: Announce new functions. * aspell-octave.en.pws: Add new functions names to custom Octave dictionary. * sparse.txi: Add functions to Octave manual. * __unimplemented__.m: Remove functions from unimplemented list. * lu.cc (Flu), luinc.cc (Fluinc), chol.cc (Fchol): Add seealso links in docstrings. * __ichol__.cc: Wrap long lines to less than 80 chars. Remove trailing whitespace. Don't repeat input validation done in ichol.m for internal functions. Avoid resizing retval vector. * __ilu__.cc: Wrap long lines to less than 80 chars. Remove trailing whitespace. Don't repeat input validation done in ichol.m for internal functions. Avoid resizing retval vector. * ichol.m: Rewrite docstring. Use Octave coding conventions (double quotes hash for comments, ! instead of ~). Replace %!error tests not being run with fail(). * ilu.m: Rewrite docstring. Use Octave coding conventions (double quotes hash for comments, ! instead of ~). Replace %!error tests not being run with fail().
author Rik <rik@octave.org>
date Tue, 26 Aug 2014 15:27:21 -0700
parents df64071e538c
children 431dc1da050c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
1 ## Copyright (C) 2014 Eduardo Ramos Fernández <eduradical951@gmail.com>
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
2 ## Copyright (C) 2013 Kai T. Ohlhus <k.ohlhus@gmail.com>
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
3 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
4 ## This file is part of Octave.
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
5 ##
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
7 ## under the terms of the GNU General Public License as published by
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
9 ## your option) any later version.
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
10 ##
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
14 ## General Public License for more details.
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
15 ##
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
16 ## You should have received a copy of the GNU General Public License
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
18 ## <http://www.gnu.org/licenses/>.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
19
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
20 ## -*- texinfo -*-
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
21 ## @deftypefn {Function File} {@var{L} =} ichol (@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
22 ## @deftypefnx {Function File} {@var{L} =} ichol (@var{A}, @var{opts})
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
23 ##
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
24 ## Compute the incomplete Cholesky factorization of the sparse square matrix
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
25 ## @var{A} with zero-fill.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
26 ##
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
27 ## By default, ichol references the lower triangle of @var{A} and produces
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
28 ## lower triangular factors.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
29 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
30 ## The factor given by this routine may be useful as a preconditioner for a
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
31 ## system of linear equations being solved by iterative methods such as
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
32 ## PCG (Preconditioned Conjugate Gradient).
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
33 ##
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
34 ## The factorization may be modified by passing options in a structure
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
35 ## @var{opts}. The option name is a field in the structure and the setting
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
36 ## is the value of field. Names and specifiers are case sensitive.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
37 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
38 ## @table @asis
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
39 ## @item type
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
40 ## Type of factorization.
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
41 ## String indicating which flavor of incomplete Cholesky to perform. Valid
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
42 ## values of this field are @qcode{"nofill"} and @qcode{"ict"}. The
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
43 ## @qcode{"nofill"} variant performs incomplete Cholesky with zero-fill
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
44 ## [IC(0)]. The @qcode{"ict"} variant performs incomplete Cholesky with
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
45 ## threshold dropping [ICT]. The default value is @qcode{"nofill"}.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
46 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
47 ## @item droptol
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
48 ## Drop tolerance when type is @qcode{"ict"}.
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
49 ## Non-negative scalar used as a drop tolerance when performing ICT@. Elements
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
50 ## which are smaller in magnitude than a local drop tolerance are dropped from
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
51 ## the resulting factor except for the diagonal element which is never dropped.
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
52 ## The local drop tolerance at step j of the factorization is
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
53 ## @code{norm (@var{A}(j:end, j), 1) * droptol}. @code{droptol} is ignored if
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
54 ## @code{type} is @qcode{"nofill"}. The default value is 0.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
55 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
56 ## @item michol
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
57 ## Indicate whether modified incomplete Cholesky [MIC] is performed.
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
58 ## The field may be @qcode{"on"} or @qcode{"off"}. When performing MIC, the
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
59 ## diagonal is compensated for dropped elements to enforce the relationship
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
60 ## @code{@var{A} * @var{e} = @var{L} * @var{L}' * @var{e}} where
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
61 ## @code{@var{e} = ones (columns (@var{A}), 1)}. The default value is
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
62 ## @qcode{"off"}.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
63 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
64 ## @item diagcomp
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
65 ## Perform compensated incomplete Cholesky with the specified coefficient.
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
66 ## The coefficient is a real non-negative scalar used as a global diagonal
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
67 ## shift @code{@var{alpha}} in forming the incomplete Cholesky factor. That
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
68 ## is, instead of performing incomplete Cholesky on @code{@var{A}}, the
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
69 ## factorization of @code{@var{A} + @var{alpha} * diag (diag (@var{A}))} is
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
70 ## formed. The default value is 0.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
71 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
72 ## @item shape
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
73 ## Determine which triangle is referenced and returned.
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
74 ## Valid values are @qcode{"upper"} and @qcode{"lower"}. If @qcode{"upper"}
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
75 ## is specified, only the upper triangle of @code{@var{A}} is referenced and
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
76 ## @code{@var{R}} is constructed such that @code{@var{A}} is approximated by
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
77 ## @code{@var{R}' * @var{R}}. If @qcode{"lower"} is specified, only the
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
78 ## lower triangle of @code{@var{A}} is referenced and @code{@var{L}} is
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
79 ## constructed such that @code{@var{A}} is approximated by @code{@var{L} *
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
80 ## @var{L}'}. The default value is @qcode{"lower"}.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
81 ## @end table
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
82 ##
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
83 ## Examples
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
84 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
85 ## The following problem demonstrates how to factorize a sample symmetric
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
86 ## positive definite matrix with the full Cholesky decomposition and with the
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
87 ## incomplete one.
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
88 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
89 ## @example
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
90 ## @group
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
91 ## A = [ 0.37, -0.05, -0.05, -0.07;
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
92 ## -0.05, 0.116, 0.0, -0.05;
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
93 ## -0.05, 0.0, 0.116, -0.05;
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
94 ## -0.07, -0.05, -0.05, 0.202];
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
95 ## A = sparse (A);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
96 ## nnz (tril (A))
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
97 ## ans = 9
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
98 ## L = chol (A, "lower");
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
99 ## nnz (L)
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
100 ## ans = 10
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
101 ## norm (A - L * L', "fro") / norm (A, "fro")
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
102 ## ans = 1.1993e-16
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
103 ## opts.type = "nofill";
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
104 ## L = ichol (A, opts);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
105 ## nnz (L)
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
106 ## ans = 9
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
107 ## norm (A - L * L', "fro") / norm (A, "fro")
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
108 ## ans = 0.019736
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
109 ## @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
110 ## @end example
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
111 ##
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
112 ## Another example for decomposition is a finite difference matrix used to
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
113 ## solve a boundary value problem on the unit square.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
114 ##
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
115 ## @example
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
116 ## @group
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
117 ## nx = 400; ny = 200;
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
118 ## hx = 1 / (nx + 1); hy = 1 / (ny + 1);
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
119 ## Dxx = spdiags ([ones(nx, 1), -2*ones(nx, 1), ones(nx, 1)],
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
120 ## [-1 0 1 ], nx, nx) / (hx ^ 2);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
121 ## Dyy = spdiags ([ones(ny, 1), -2*ones(ny, 1), ones(ny, 1)],
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
122 ## [-1 0 1 ], ny, ny) / (hy ^ 2);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
123 ## A = -kron (Dxx, speye (ny)) - kron (speye (nx), Dyy);
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
124 ## nnz (tril (A))
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
125 ## ans = 239400
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
126 ## opts.type = "nofill";
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
127 ## L = ichol (A, opts);
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
128 ## nnz (tril (A))
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
129 ## ans = 239400
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
130 ## norm (A - L * L', "fro") / norm (A, "fro")
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
131 ## ans = 0.062327
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
132 ## @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
133 ## @end example
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 ## References for implemented algorithms:
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
136 ##
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
137 ## [1] @nospell{Y. Saad}. "Preconditioning Techniques." @cite{Iterative
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
138 ## Methods for Sparse Linear Systems}, PWS Publishing Company, 1996.
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
139 ##
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
140 ## [2] @nospell{M. Jones, P. Plassmann}: @cite{An Improved Incomplete
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
141 ## Cholesky Factorization}, 1992.
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
142 ## @seealso{chol, ilu, pcg}
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
143 ## @end deftypefn
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
144
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
145 function L = ichol (A, opts = struct ())
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
146
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
147 if (nargin < 1 || nargin > 2 || nargout > 1)
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
148 print_usage ();
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
149 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
150
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
151 if (! (issparse (A) && issquare (A)))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
152 error ("ichol: A must be a sparse square matrix");
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
153 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
154
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
155 if (! isstruct (opts))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
156 error ("ichol: OPTS must be a structure.");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
157 endif
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
158
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
159 ## If A is empty then return empty L for Matlab compatibility
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
160 if (isempty (A))
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
161 L = A;
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
162 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
163 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
164
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
165 ## Parse input options
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
166 if (! isfield (opts, "type"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
167 opts.type = "nofill"; # set default
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
168 else
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
169 type = tolower (getfield (opts, "type"));
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
170 if (! strcmp (type, "nofill") && ! strcmp (type, "ict"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
171 error ('ichol: TYPE must be "nofill" or "ict"');
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
172 endif
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
173 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
174 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
175
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
176 if (! isfield (opts, "droptol"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
177 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
178 else
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
179 if (! (isreal (opts.droptol) && isscalar (opts.droptol)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
180 && opts.droptol >= 0))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
181 error ("ichol: DROPTOL must be a non-negative real scalar");
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
182 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
183 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
184
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
185 michol = "";
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
186 if (! isfield (opts, "michol"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
187 opts.michol = "off"; # set default
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
188 else
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
189 michol = tolower (getfield (opts, "michol"));
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
190 if (! strcmp (michol, "off") && ! strcmp (michol, "on"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
191 error ('ichol: MICHOL must be "on" or "off"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
192 endif
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
193 opts.michol = michol;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
194 endif
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
195
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
196 if (! isfield (opts, "diagcomp"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
197 opts.diagcomp = 0; # set default
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
198 else
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
199 if (! (isreal (opts.diagcomp) && isscalar (opts.diagcomp)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
200 && opts.diagcomp >= 0))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
201 error ("ichol: DIAGCOMP must be a non-negative real scalar");
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
202 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
203 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
204
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
205 if (! isfield (opts, "shape"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
206 opts.shape = "lower"; # set default
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
207 else
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
208 shape = tolower (getfield (opts, "shape"));
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
209 if (! strcmp (shape, "lower") && ! strcmp (shape, "upper"))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
210 error ('ichol: SHAPE must be "lower" or "upper"');
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
211 endif
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
212 opts.shape = shape;
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
213 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
214
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
215 ## Prepare input for specialized ICHOL
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
216 A_in = [];
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
217 if (opts.diagcomp > 0)
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
218 A += opts.diagcomp * diag (diag (A));
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
219 endif
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
220 if (strcmp (opts.shape, "upper"))
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
221 A_in = triu (A);
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
222 A_in = A_in';
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
223 else
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
224 A_in = tril (A);
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
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 ## Delegate to specialized ICHOL
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
228 switch (opts.type)
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
229 case "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
230 L = __ichol0__ (A_in, opts.michol);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
231 case "ict"
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
232 L = __icholt__ (A_in, opts.droptol, opts.michol);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
233 endswitch
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
234
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
235 if (strcmp (opts.shape, "upper"))
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
236 L = L';
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
237 endif
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
238
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
239 endfunction
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
240
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
241
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
242 %!shared A1, A2, A3, A4, A5, A6, A7
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
243 %! A1 = [ 0.37, -0.05, -0.05, -0.07;
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
244 %! -0.05, 0.116, 0.0, -0.05;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
245 %! -0.05, 0.0, 0.116, -0.05;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
246 %! -0.07, -0.05, -0.05, 0.202];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
247 %! A1 = sparse (A1);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
248 %! A2 = gallery ("poisson", 30);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
249 %! A3 = gallery ("tridiag", 50);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
250 %! nx = 400; ny = 200;
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
251 %! hx = 1 / (nx + 1); hy = 1 / (ny + 1);
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
252 %! Dxx = spdiags ([ones(nx, 1), -2*ones(nx, 1), ones(nx, 1)],
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
253 %! [-1 0 1 ], nx, nx) / (hx ^ 2);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
254 %! Dyy = spdiags ([ones(ny, 1), -2*ones(ny, 1), ones(ny, 1)],
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
255 %! [-1 0 1 ], ny, ny) / (hy ^ 2);
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
256 %! A4 = -kron (Dxx, speye (ny)) - kron (speye (nx), Dyy);
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
257 %! A5 = [ 0.37, -0.05, -0.05, -0.07;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
258 %! -0.05, 0.116, 0.0, -0.05 + 0.05i;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
259 %! -0.05, 0.0, 0.116, -0.05;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
260 %! -0.07, -0.05 - 0.05i, -0.05, 0.202];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
261 %! A5 = sparse (A5);
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
262 %! A6 = [ 0.37, -0.05 - i, -0.05, -0.07;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
263 %! -0.05 + i, 0.116, 0.0, -0.05;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
264 %! -0.05, 0.0, 0.116, -0.05;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
265 %! -0.07, -0.05, -0.05, 0.202];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
266 %! A6 = sparse (A6);
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
267 %! A7 = A5;
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
268 %! A7(1) = 2i;
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
269
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
270 ## ICHOL0 tests
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
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
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
273 %! opts.type = "nofill";
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
274 %! opts.michol = "off";
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
275 %! assert (nnz (tril (A1)), nnz (ichol (A1, opts)));
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
276 %! assert (nnz (tril (A2)), nnz (ichol (A2, opts)));
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
277 %! assert (nnz (tril (A3)), nnz (ichol (A3, opts)));
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
278 %! assert (nnz (tril (A4)), nnz (ichol (A4, opts)));
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
279 %! assert (nnz (tril (A5)), nnz (ichol (A5, opts)));
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
280 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
281 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
282 %! opts.type = "nofill";
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
283 %! opts.michol = "off";
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
284 %! L = ichol (A1, opts);
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
285 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0197, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
286 %! opts.shape = "upper";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
287 %! U = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
288 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.0197, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
289 %! opts.shape = "lower";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
290 %! L = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
291 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0197, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
292 %!
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
293 %!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
294 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
295 %! opts.shape = "lower";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
296 %! opts.type = "nofill";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
297 %! L = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
298 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0279, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
299 %! opts.shape = "upper";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
300 %! U = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
301 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.0279, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
302 %! opts.shape = "lower";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
303 %! opts.diagcomp = 3e-3;
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
304 %! L = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
305 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.0272, 1e-4);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
306 %!
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
307 %!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
308 %! opts.type = "nofill";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
309 %! opts.michol = "off";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
310 %! L = ichol (A2, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
311 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.0893, 1e-4)
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
312 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
313 %! L = ichol (A2, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
314 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.2377, 1e-4)
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
315 %!
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
316 %!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
317 %! opts.type = "nofill";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
318 %! opts.michol = "off";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
319 %! L = ichol (A3, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
320 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
321 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
322 %! L = ichol (A3, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
323 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
324 %!
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
325 %!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
326 %! opts.type = "nofill";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
327 %! opts.michol = "off";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
328 %! L = ichol (A4, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
329 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.0623, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
330 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
331 %! L = ichol (A4, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
332 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.1664, 1e-4);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
333 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
334 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
335 %! opts.type = "nofill";
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
336 %! opts.michol = "off";
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
337 %! L = ichol (A5, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
338 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.0195, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
339 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
340 %! L = ichol (A5, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
341 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.0276, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
342
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
343 ## Negative pivot
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
344 %!error <negative pivot> ichol (A6)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
345 %!error ichol (A6)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
346 ## Complex entry in the diagonal
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
347 %!error <non-real pivot> ichol (A7)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
348
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
349 ## ICHOLT tests
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
350
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
351 %%!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
352 %! opts.type = "ict";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
353 %! opts.droptol = 1e-1;
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
354 %! opts.michol = "off";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
355 %! L = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
356 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.2065, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
357 %! opts.shape = "upper";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
358 %! U = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
359 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.2065, 1e-4);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
360 %! opts.shape = "lower";
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
361 %! L = ichol (A1, opts);
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
362 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.2065, 1e-4);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
363 %!
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
364 %%!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
365 %! opts.type = "ict";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
366 %! opts.droptol = 1e-1;
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
367 %! opts.michol = "on";
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
368 %! L = ichol (A1, opts);
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
369 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.3266, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
370 %! opts.shape = "upper";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
371 %! U = ichol (A1, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
372 %! assert (norm (A1 - U' * U, "fro") / norm (A1, "fro"), 0.3266, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
373 %! opts.shape = "lower";
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
374 %! opts.diagcomp = 3e-3;
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
375 %! L = ichol (A1, opts);
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
376 %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.3266, 1e-4);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
377 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
378 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
379 %! opts.type = "ict";
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
380 %! opts.droptol = 1e-1;
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
381 %! opts.michol = "off";
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
382 %! L = ichol (A2, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
383 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.0893, 1e-4)
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
384 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
385 %! L = ichol (A2, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
386 %! assert (norm (A2 - L*L', "fro") / norm (A2, "fro"), 0.2377, 1e-4)
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
387 %!
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
388 %!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
389 %! opts.type = "ict";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
390 %! opts.droptol = 1e-1;
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
391 %! opts.michol = "off";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
392 %! L = ichol (A3, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
393 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
394 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
395 %! L = ichol (A3, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
396 %! assert (norm (A3 - L*L', "fro") / norm (A3, "fro"), eps, eps);
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
397 %!
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
398 %!test
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
399 %! opts.type = "ict";
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
400 %! opts.droptol = 1e-1;
19053
168c0aa9bb05 Added all the files related with ilu.m and ichol.m functions.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff changeset
401 %! opts.michol = "off";
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
402 %! L = ichol (A4, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
403 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.1224, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
404 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
405 %! L = ichol (A4, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
406 %! assert (norm (A4 - L*L', "fro") / norm (A4, "fro"), 0.2118, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
407 %!
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.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 %!test
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
409 %! opts.type = "ict";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
410 %! opts.droptol = 1e-1;
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
411 %! opts.michol = "off";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
412 %! L = ichol (A5, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
413 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.2044, 1e-4);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
414 %! opts.michol = "on";
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
415 %! L = ichol (A5, opts);
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
416 %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.3231, 1e-4);
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
417
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
418 %% Input validation tests
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
419
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
420 %!error <A must be a sparse square matrix> ichol ([])
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
421 %!error <A must be a sparse square matrix> ichol (0)
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
422 %!error <pivot equal to 0> ichol (sparse (0))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
423 %!error <pivot equal to 0> ichol (sparse (-0))
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
424 %!error <negative pivot> ichol (sparse (-1))
19054
df64071e538c Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents: 19053
diff changeset
425 %!test
19055
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
426 %! opts.type = "foo";
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
427 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
428 %! opts.type = 1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
429 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
430 %! opts.type = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
431 %! fail ("ichol (A1, opts)", 'TYPE must be "nofill"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
432 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
433 %! opts.droptol = -1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
434 %! fail ("ichol (A1, opts)", "DROPTOL must be a non-negative real scalar");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
435 %! opts.droptol = 0.5i;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
436 %! fail ("ichol (A1, opts)", "DROPTOL must be a non-negative real scalar");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
437 %! opts.droptol = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
438 %! fail ("ichol (A1, opts)", "DROPTOL must be a non-negative real scalar");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
439 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
440 %! opts.michol = "foo";
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
441 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
442 %! opts.michol = 1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
443 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
444 %! opts.michol = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
445 %! fail ("ichol (A1, opts)", 'MICHOL must be "on"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
446 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
447 %! opts.diagcomp = -1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
448 %! fail ("ichol (A1, opts)", "DIAGCOMP must be a non-negative real scalar");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
449 %! opts.diagcomp = 0.5i;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
450 %! fail ("ichol (A1, opts)", "DIAGCOMP must be a non-negative real scalar");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
451 %! opts.diagcomp = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
452 %! fail ("ichol (A1, opts)", "DIAGCOMP must be a non-negative real scalar");
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
453 %!test
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
454 %! opts.shape = "foo";
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
455 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
456 %! opts.shape = 1;
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
457 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
458 %! opts.shape = [];
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
459 %! fail ("ichol (A1, opts)", 'SHAPE must be "lower"');
38937efbee21 Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents: 19054
diff changeset
460