annotate scripts/linear-algebra/condest.m @ 22323:bac0d6f07a3e

maint: Update copyright notices for 2016.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Aug 2016 01:05:19 -0400
parents 9fc91bb2aec3
children 3a2b891d0b33 fb913df7babb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22299
diff changeset
1 ## Copyright (C) 2007-2016 Regents of the University of California
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
2 ## Copyright (C) 2016 Marco Caliari
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
3 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
4 ## This file is part of Octave.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
5 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
7 ## under the terms of the GNU General Public License as published by
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
9 ## your option) any later version.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
10 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
14 ## General Public License for more details.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
15 ##
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
18 ## <http://www.gnu.org/licenses/>.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
19
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
20 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20194
diff changeset
21 ## @deftypefn {} {} condest (@var{A})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20194
diff changeset
22 ## @deftypefnx {} {} condest (@var{A}, @var{t})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20194
diff changeset
23 ## @deftypefnx {} {[@var{est}, @var{v}] =} condest (@dots{})
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
24 ## @deftypefnx {} {[@var{est}, @var{v}] =} condest (@var{A}, @var{solvefun}, @var{t}, @var{p1}, @var{p2}, @dots{})
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
25 ## @deftypefnx {} {[@var{est}, @var{v}] =} condest (@var{afun}, @var{solvefun}, @var{t}, @var{p1}, @var{p2}, @dots{})
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
26 ##
20160
03b9d17a2d95 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19700
diff changeset
27 ## Estimate the 1-norm condition number of a matrix @var{A} using @var{t} test
03b9d17a2d95 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19700
diff changeset
28 ## vectors using a randomized 1-norm estimator.
03b9d17a2d95 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19700
diff changeset
29 ##
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
30 ## If @var{t} exceeds 5, then only 5 test vectors are used.
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
31 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
32 ## If the matrix is not explicit, e.g., when estimating the condition
11593
1577c6f80926 Use non-breaking spaces between certain adjectives and their nouns in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
33 ## number of @var{A} given an LU@tie{}factorization, @code{condest} uses the
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
34 ## following functions:
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
35 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
36 ## @itemize @minus
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
37 ## @item @var{afun} which should returns
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
38 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
39 ## @itemize @bullet
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
40 ## @item
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
41 ## the dimension @var{n} of @var{a}, if @var{flag} is @qcode{"dim"}
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
42 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
43 ## @item
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
44 ## true if @var{a} is a real operator, if @var{flag} is @qcode{"real"}
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
45 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
46 ## @item
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
47 ## the result @code{@var{a} * @var{x}}, if @var{flag} is "notransp"
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
48 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
49 ## @item
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
50 ## the result @code{@var{a}' * @var{x}}, if @var{flag} is "transp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
51 ## @end itemize
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
52 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
53 ## @item @var{solvefun} which should returns
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
54 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
55 ## @itemize @bullet
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
56 ## @item
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
57 ## the dimension @var{n} of @var{a}, if @var{flag} is @qcode{"dim"}
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
58 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
59 ## @item
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
60 ## true if @var{a} is a real operator, if @var{flag} is @qcode{"real"}
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
61 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
62 ## @item
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
63 ## the result @code{@var{a} \ @var{x}}, if @var{flag} is "notransp"
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
64 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
65 ## @item
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
66 ## the result @code{@var{a}' \ @var{x}}, if @var{flag} is "transp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
67 ## @end itemize
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
68 ## @end itemize
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
69 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
70 ## The parameters @var{p1}, @var{p2}, @dots{} are arguments of
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
71 ## @code{@var{afun} (@var{flag}, @var{x}, @var{p1}, @var{p2}, @dots{})}
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
72 ## and @code{@var{solvefun} (@var{flag}, @var{x}, @var{p1}, @var{p2},
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
73 ## @dots{})}.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
74 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
75 ## @code{condest} uses a randomized algorithm to approximate the
22299
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
76 ## 1-norms. Therefore, if consistent results are required, the
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
77 ## @qcode{"state"} of the random generator should be fixed before invoking
9fc91bb2aec3 doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents: 22183
diff changeset
78 ## @code{normest1}.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
79 ##
20160
03b9d17a2d95 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19700
diff changeset
80 ## @code{condest} returns the 1-norm condition estimate @var{est} and a vector
03b9d17a2d95 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19700
diff changeset
81 ## @var{v} satisfying @code{norm (A*v, 1) == norm (A, 1) * norm
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
82 ## (@var{v}, 1) / @var{est}}. When @var{est} is large, @var{v} is an
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
83 ## approximate null vector.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
84 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
85 ## References:
16816
12005245b645 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 14522
diff changeset
86 ##
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
87 ## @itemize
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
88 ## @item
19040
0850b5212619 doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents: 17744
diff changeset
89 ## @nospell{N.J. Higham and F. Tisseur}, @cite{A Block Algorithm
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
90 ## for Matrix 1-Norm Estimation, with an Application to 1-Norm
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents: 10687
diff changeset
91 ## Pseudospectra}. SIMAX vol 21, no 4, pp 1185-1201.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
92 ## @url{http://dx.doi.org/10.1137/S0895479899356080}
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
93 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
94 ## @item
19040
0850b5212619 doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents: 17744
diff changeset
95 ## @nospell{N.J. Higham and F. Tisseur}, @cite{A Block Algorithm
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
96 ## for Matrix 1-Norm Estimation, with an Application to 1-Norm
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents: 10687
diff changeset
97 ## Pseudospectra}. @url{http://citeseer.ist.psu.edu/223007.html}
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
98 ## @end itemize
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
99 ##
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
100 ## @seealso{cond, norm, normest1}
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
101 ## @end deftypefn
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
102
20194
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
103 ## Code originally licensed under:
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
104 ##
20194
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
105 ## Copyright (c) 2007, Regents of the University of California
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
106 ## All rights reserved.
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
107 ##
20194
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
108 ## Redistribution and use in source and binary forms, with or without
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
109 ## modification, are permitted provided that the following conditions
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
110 ## are met:
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
111 ##
20194
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
112 ## * Redistributions of source code must retain the above copyright
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
113 ## notice, this list of conditions and the following disclaimer.
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
114 ##
20194
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
115 ## * Redistributions in binary form must reproduce the above
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
116 ## copyright notice, this list of conditions and the following
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
117 ## disclaimer in the documentation and/or other materials provided
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
118 ## with the distribution.
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
119 ##
20194
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
120 ## * Neither the name of the University of California, Berkeley nor
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
121 ## the names of its contributors may be used to endorse or promote
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
122 ## products derived from this software without specific prior
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
123 ## written permission.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
124 ##
20194
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
125 ## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
126 ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
127 ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
128 ## PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
129 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
130 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
131 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
132 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
133 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
134 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
135 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
b0f7ee81d974 doc: Remove extra spaces at start of docstring which show up in Info format.
Rik <rik@octave.org>
parents: 20160
diff changeset
136 ## SUCH DAMAGE.
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
137
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
138 ## Author: Jason Riedy <ejr@cs.berkeley.edu>
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
139 ## Keywords: linear-algebra norm estimation
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
140 ## Version: 0.2
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
141
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
142 function [est, v] = condest (varargin)
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
143
7309
26f42a14d4f6 [project @ 2007-12-12 22:05:38 by jwe]
jwe
parents: 7239
diff changeset
144 if (nargin < 1 || nargin > 6)
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
145 print_usage ();
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
146 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
147
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
148 default_t = 5;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
149
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
150 if ((nargin == 3 && is_function_handle (varargin{3}))
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
151 || (nargin == 4 && is_function_handle (varargin{3})
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
152 && isnumeric (varargin{4})))
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
153 ## onenormest syntax, deprecated in 4.2
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
154 [est, v] = condest_legacy (varargin{:});
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
155 return
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
156 elseif ((nargin >= 5) && is_function_handle (varargin{4}))
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
157 ## onenormest syntax, deprecated in 4.2
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
158 [est, v] = condest_legacy (varargin{:});
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
159 return
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
160 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
161
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
162 have_A = false;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
163 have_t = false;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
164 have_apply_normest1 = false;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
165 have_solve_normest1 = false;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
166
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
167 if (isnumeric (varargin{1}))
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
168 A = varargin{1};
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
169 if (! issquare (A))
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
170 error ("condest: matrix must be square");
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
171 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
172 n = rows (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
173 have_A = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
174 if (nargin > 1)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
175 if (is_function_handle (varargin{2}))
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
176 solve = varargin{2};
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
177 have_solve_normest1 = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
178 if (nargin > 2)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
179 t = varargin{3};
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
180 have_t = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
181 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
182 else
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
183 t = varargin{2};
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
184 have_t = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
185 real_op = isreal (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
186 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
187 else
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
188 real_op = isreal (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
189 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
190 else # varargin{1} is function handle
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
191 apply = varargin{1};
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
192 if (nargin > 1)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
193 solve = varargin{2};
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
194 have_apply_normest1 = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
195 have_solve_normest1 = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
196 n = apply ("dim", [], varargin{4:end});
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
197 if (nargin > 2)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
198 t = varargin{3};
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
199 have_t = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
200 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
201 else
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
202 error("condest: wrong number of input parameters");
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
203 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
204 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
205
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
206 if (! have_t)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
207 t = min (n, default_t);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
208 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
209
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
210 if (! have_solve_normest1)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
211 ## prepare solve in normest1 form
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
212 if (issparse (A))
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
213 [L, U, P, Pc] = lu (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
214 solve = @(flag, x) solve_sparse (flag, x, n, real_op, L, U, P, Pc);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
215 else
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
216 [L, U, P] = lu (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
217 solve = @(flag, x) solve_not_sparse (flag, x, n, real_op, L, U, P);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
218 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
219 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
220
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
221 if (have_A)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
222 Anorm = norm (A, 1);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
223 else
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
224 Anorm = normest1 (apply, t, [], varargin{4:end});
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
225 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
226 [Ainv_norm, v, w] = normest1 (solve, t, [], varargin{4:end});
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
227
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
228 est = Anorm * Ainv_norm;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
229 v = w / norm (w, 1);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
230
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
231 endfunction
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
232
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
233 function value = solve_sparse (flag, x, n, real_op, L , U , P , Pc)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
234 switch flag
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
235 case "dim"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
236 value = n;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
237 case "real"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
238 value = real_op;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
239 case "notransp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
240 value = P' * (L' \ (U' \ (Pc * x)));
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
241 case "transp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
242 value = Pc' * (U \ (L \ (P * x)));
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
243 endswitch
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
244 endfunction
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
245
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
246 function value = solve_not_sparse (flag, x, n, real_op, L, U, P)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
247 switch flag
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
248 case "dim"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
249 value = n;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
250 case "real"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
251 value = real_op;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
252 case "notransp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
253 value = P' * (L' \ (U' \ x));
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
254 case "transp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
255 value = U \ (L \ (P * x));
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
256 endswitch
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
257 endfunction
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
258
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
259 function [est, v] = condest_legacy (varargin) # to be removed after 4.2
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
260
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
261 persistent warned = false;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
262 if (! warned)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
263 warned = true;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
264 warning ("Octave:deprecated-function",
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
265 "condest: this syntax is deprecated, call condest (A, SOLVEFUN, T, P1, P2, ...) instead.");
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
266 endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
267
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
268 default_t = 5;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
269
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
270 have_A = false;
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
271 have_t = false;
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
272 have_solve = false;
19700
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19697
diff changeset
273 if (isnumeric (varargin{1}))
7310
dc9b00ab5aac [project @ 2007-12-12 22:08:58 by jwe]
jwe
parents: 7309
diff changeset
274 A = varargin{1};
9872
72d6e0de76c7 fix qp, condest and krylov
Jaroslav Hajek <highegg@gmail.com>
parents: 9307
diff changeset
275 if (! issquare (A))
8664
e07e93c04080 style fixes
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
276 error ("condest: matrix must be square");
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
277 endif
9872
72d6e0de76c7 fix qp, condest and krylov
Jaroslav Hajek <highegg@gmail.com>
parents: 9307
diff changeset
278 n = rows (A);
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
279 have_A = true;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
280
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
281 if (nargin > 1)
14522
f739e30494c8 condest.m: Fix failing %!test.
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
282 if (! is_function_handle (varargin{2}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
283 t = varargin{2};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
284 have_t = true;
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
285 elseif (nargin > 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
286 solve = varargin{2};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
287 solve_t = varargin{3};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
288 have_solve = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
289 if (nargin > 3)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
290 t = varargin{4};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
291 have_t = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9872
diff changeset
292 endif
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
293 else
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11471
diff changeset
294 error ("condest: must supply both SOLVE and SOLVE_T");
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
295 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
296 endif
7311
1b535aed87e2 [project @ 2007-12-12 22:13:43 by jwe]
jwe
parents: 7310
diff changeset
297 elseif (nargin > 4)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
298 apply = varargin{1};
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
299 apply_t = varargin{2};
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
300 solve = varargin{3};
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
301 solve_t = varargin{4};
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
302 have_solve = true;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
303 n = varargin{5};
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
304 if (! isscalar (n))
8664
e07e93c04080 style fixes
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
305 error ("condest: dimension argument of implicit form must be scalar");
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
306 endif
7309
26f42a14d4f6 [project @ 2007-12-12 22:05:38 by jwe]
jwe
parents: 7239
diff changeset
307 if (nargin > 5)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
308 t = varargin{6};
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
309 have_t = true;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
310 endif
7311
1b535aed87e2 [project @ 2007-12-12 22:13:43 by jwe]
jwe
parents: 7310
diff changeset
311 else
8664
e07e93c04080 style fixes
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
312 error ("condest: implicit form of condest requires at least 5 arguments");
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
313 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
314
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
315 if (! have_t)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
316 t = min (n, default_t);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
317 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
318
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
319 if (! have_solve)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
320 if (issparse (A))
8912
57c3155754d6 fix condest
Jaroslav Hajek <highegg@gmail.com>
parents: 8664
diff changeset
321 [L, U, P, Pc] = lu (A);
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
322 solve = @(x) Pc' * (U \ (L \ (P * x)));
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
323 solve_t = @(x) P' * (L' \ (U' \ (Pc * x)));
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
324 else
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
325 [L, U, P] = lu (A);
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
326 solve = @(x) U \ (L \ (P*x));
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
327 solve_t = @(x) P' * (L' \ (U' \ x));
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
328 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
329 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
330
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
331 ## We already warned about this usage being deprecated. Don't
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
332 ## warn again about onenormest.
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
333 warning ("off", "Octave:deprecated-function", "local");
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
334
7312
1ebbf0924217 [project @ 2007-12-12 22:19:54 by jwe]
jwe
parents: 7311
diff changeset
335 if (have_A)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
336 Anorm = norm (A, 1);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
337 else
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
338 Anorm = onenormest (apply, apply_t, n, t);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
339 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
340
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
341 [Ainv_norm, v, w] = onenormest (solve, solve_t, n, t);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
342
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
343 est = Anorm * Ainv_norm;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
344 v = w / norm (w, 1);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
345
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
346 endfunction
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
347
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
348 ## Yes, these test bounds are really loose. There's
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
349 ## enough randomization to trigger odd cases with hilb().
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
350
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
351 %!function value = apply_fun (flag, x, A, m)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
352 %! if (nargin == 3)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
353 %! m = 1;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
354 %! endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
355 %! switch flag
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
356 %! case "dim"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
357 %! value = length (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
358 %! case "real"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
359 %! value = isreal (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
360 %! case "notransp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
361 %! value = x; for i = 1:m, value = A * value;, endfor
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
362 %! case "transp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
363 %! value = x; for i = 1:m, value = A' * value;, endfor
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
364 %! endswitch
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
365 %!endfunction
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
366 %!function value = solve_fun (flag, x, A, m)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
367 %! if (nargin == 3)
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
368 %! m = 1;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
369 %! endif
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
370 %! switch flag
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
371 %! case "dim"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
372 %! value = length (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
373 %! case "real"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
374 %! value = isreal (A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
375 %! case "notransp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
376 %! value = x; for i = 1:m, value = A \ value;, endfor;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
377 %! case "transp"
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
378 %! value = x; for i = 1:m, value = A' \ value;, endfor;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
379 %! endswitch
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
380 %!endfunction
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
381
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
382 %!test
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
383 %! N = 6;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
384 %! A = hilb (N);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
385 %! cA = condest (A);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
386 %! cA_test = norm (inv (A), 1) * norm (A, 1);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
387 %! assert (cA, cA_test, -2^-8);
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
388
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
389 %!test # to be removed after 4.2
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
390 %! warning ("off", "Octave:deprecated-function", "local");
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
391 %! N = 6;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
392 %! A = hilb (N);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
393 %! solve = @(x) A\x; solve_t = @(x) A'\x;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
394 %! cA = condest (A, solve, solve_t);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
395 %! cA_test = norm (inv (A), 1) * norm (A, 1);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
396 %! assert (cA, cA_test, -2^-8);
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
397
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
398 %!test # to be removed after 4.2
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
399 %! warning ("off", "Octave:deprecated-function", "local");
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
400 %! N = 6;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
401 %! A = hilb (N);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
402 %! apply = @(x) A*x; apply_t = @(x) A'*x;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
403 %! solve = @(x) A\x; solve_t = @(x) A'\x;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
404 %! cA = condest (apply, apply_t, solve, solve_t, N);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
405 %! cA_test = norm (inv (A), 1) * norm (A, 1);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
406 %! assert (cA, cA_test, -2^-6);
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
407
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
408 %!test # to be removed after 4.2
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
409 %! warning ("off", "Octave:deprecated-function", "local");
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
410 %! N = 6;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
411 %! A = hilb (N);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
412 %! apply = @(x) A*x; apply_t = @(x) A'*x;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
413 %! solve = @(x) A\x; solve_t = @(x) A'\x;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
414 %! cA = condest (apply, apply_t, solve, solve_t, N, 2);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
415 %! cA_test = norm (inv (A), 1) * norm (A, 1);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
416 %! assert (cA, cA_test, -2^-6);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
417
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents:
diff changeset
418 %!test
19670
e5facc6eec13 Silence warning messages in %!test code.
Rik <rik@octave.org>
parents: 19040
diff changeset
419 %! warning ("off", "Octave:nearly-singular-matrix", "local");
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
420 %! N = 12;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
421 %! A = hilb (N);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
422 %! [rcondA, v] = condest (A);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
423 %! x = A*v;
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
424 %! assert (norm (x, inf), 0, eps);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
425
22183
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
426 %!test
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
427 %! N = 6;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
428 %! A = hilb (N);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
429 %! solve = @(flag, x) solve_fun (flag, x, A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
430 %! cA = condest (A, solve);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
431 %! cA_test = norm (inv (A), 1) * norm (A, 1);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
432 %! assert (cA, cA_test, -2^-6);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
433 %!test
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
434 %! N = 6;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
435 %! A = hilb (N);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
436 %! apply = @(flag, x) apply_fun (flag, x, A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
437 %! solve = @(flag, x) solve_fun (flag, x, A);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
438 %! cA = condest (apply, solve);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
439 %! cA_test = norm (inv (A), 1) * norm (A, 1);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
440 %! assert (cA, cA_test, -2^-6);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
441
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
442 %!test # parameters for apply and solve functions
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
443 %! N = 6;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
444 %! A = hilb (N);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
445 %! m = 2;
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
446 %! cA = condest (@apply_fun, @solve_fun, [], A, m);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
447 %! cA_test = norm (inv (A^2), 1) * norm (A^2, 1);
bfb1b089c230 New function normest1 as replacement for onenormest (patch #8837)
Marco Caliari <marco.caliari@univr.it>
parents: 20852
diff changeset
448 %! assert (cA, cA_test, -2^-6);