Mercurial > octave
annotate src/DLD-FUNCTIONS/rcond.cc @ 9245:16f53d29049f
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 May 2009 10:46:00 -0400 |
parents | 923c7cb7f13f |
children | 40dfc0c99116 |
rev | line source |
---|---|
7788 | 1 /* |
2 | |
9245 | 3 Copyright (C) 2008, 2009 David Bateman |
7788 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "defun-dld.h" | |
28 #include "error.h" | |
29 #include "gripes.h" | |
30 #include "oct-obj.h" | |
31 #include "utils.h" | |
32 | |
33 DEFUN_DLD (rcond, args, , | |
34 "-*- texinfo -*-\n\ | |
35 @deftypefn {Loadable Function} {@var{c} =} rcond (@var{a})\n\ | |
36 Compute the 1-norm estimate of the reciprocal condition as returned\n\ | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
37 by @sc{lapack}. If the matrix is well-conditioned then @var{c} will be near\n\ |
7788 | 38 1 and if the matrix is poorly conditioned it will be close to zero.\n\ |
39 \n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8286
diff
changeset
|
40 The matrix @var{a} must not be sparse. If the matrix is sparse then\n\ |
7788 | 41 @code{condest (@var{a})} or @code{rcond (full (@var{a}))} should be used\n\ |
42 instead.\n\ | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7797
diff
changeset
|
43 @seealso{inv}\n\ |
7788 | 44 @end deftypefn") |
45 { | |
46 octave_value retval; | |
47 | |
48 int nargin = args.length (); | |
49 | |
50 if (nargin != 1) | |
51 print_usage (); | |
52 else if (args(0).is_sparse_type ()) | |
53 error ("rcond: for sparse matrices use 'rcond (full (a))' or 'condest (a)' instead"); | |
7797
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
54 else if (args(0).is_single_type ()) |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
55 { |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
56 if (args(0).is_complex_type ()) |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
57 { |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
58 FloatComplexMatrix m = args(0).float_complex_matrix_value (); |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
59 MatrixType mattyp; |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
60 retval = m.rcond (mattyp); |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
61 args(0).matrix_type (mattyp); |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
62 } |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
63 else |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
64 { |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
65 FloatMatrix m = args(0).float_matrix_value (); |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
66 MatrixType mattyp; |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
67 retval = m.rcond (mattyp); |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
68 args(0).matrix_type (mattyp); |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
69 } |
f42c6f8d6d8e
Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents:
7788
diff
changeset
|
70 } |
7788 | 71 else if (args(0).is_complex_type ()) |
72 { | |
73 ComplexMatrix m = args(0).complex_matrix_value (); | |
74 MatrixType mattyp; | |
75 retval = m.rcond (mattyp); | |
76 args(0).matrix_type (mattyp); | |
77 } | |
78 else | |
79 { | |
80 Matrix m = args(0).matrix_value (); | |
81 MatrixType mattyp; | |
82 retval = m.rcond (mattyp); | |
83 args(0).matrix_type (mattyp); | |
84 } | |
85 | |
86 return retval; | |
87 } |