Mercurial > hg > octave-lyh
annotate src/DLD-FUNCTIONS/eigs.cc @ 10155:d0ce5e973937
DLD-FUNCTIONS/*.cc: delete Emacs local-variables settings
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 20 Jan 2010 17:40:53 -0500 |
parents | 40dfc0c99116 |
children | 6769fbfec739 |
rev | line source |
---|---|
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1 /* |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
2 |
8920 | 3 Copyright (C) 2005, 2008, 2009 David Bateman |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
4 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
5 This file is part of Octave. |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
6 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
10 option) any later version. |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
11 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
15 for more details. |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
16 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
20 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
21 */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
22 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
24 #include <config.h> |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
25 #endif |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
26 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
27 #include "ov.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
28 #include "defun-dld.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
29 #include "error.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
30 #include "gripes.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
31 #include "quit.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
32 #include "variables.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
33 #include "ov-re-sparse.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
34 #include "ov-cx-sparse.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
35 #include "oct-map.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
36 #include "pager.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
37 #include "unwind-prot.h" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
38 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 #include "eigs-base.cc" |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
40 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
41 // Global pointer for user defined function. |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
42 static octave_function *eigs_fcn = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
43 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
44 // Have we warned about imaginary values returned from user function? |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
45 static bool warned_imaginary = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
46 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
47 // Is this a recursive call? |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
48 static int call_depth = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
49 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
50 ColumnVector |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
51 eigs_func (const ColumnVector &x, int &eigs_error) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
52 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
53 ColumnVector retval; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
54 octave_value_list args; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
55 args(0) = x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
56 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
57 if (eigs_fcn) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
58 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
59 octave_value_list tmp = eigs_fcn->do_multi_index_op (1, args); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
60 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
61 if (error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
62 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
63 eigs_error = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
64 gripe_user_supplied_eval ("eigs"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
65 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
66 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
67 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
68 if (tmp.length () && tmp(0).is_defined ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
69 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
70 if (! warned_imaginary && tmp(0).is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
71 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
72 warning ("eigs: ignoring imaginary part returned from user-supplied function"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
73 warned_imaginary = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
74 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
75 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
76 retval = ColumnVector (tmp(0).vector_value ()); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
77 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
78 if (error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
79 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
80 eigs_error = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
81 gripe_user_supplied_eval ("eigs"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
82 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
83 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
84 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
85 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
86 eigs_error = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
87 gripe_user_supplied_eval ("eigs"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
88 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
89 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
90 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
91 return retval; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
92 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
93 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
94 ComplexColumnVector |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
95 eigs_complex_func (const ComplexColumnVector &x, int &eigs_error) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
96 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
97 ComplexColumnVector retval; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
98 octave_value_list args; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
99 args(0) = x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
100 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
101 if (eigs_fcn) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
102 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
103 octave_value_list tmp = eigs_fcn->do_multi_index_op (1, args); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
104 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
105 if (error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
106 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
107 eigs_error = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
108 gripe_user_supplied_eval ("eigs"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
109 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
110 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
111 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
112 if (tmp.length () && tmp(0).is_defined ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
113 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
114 retval = ComplexColumnVector (tmp(0).complex_vector_value ()); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
115 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
116 if (error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
117 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
118 eigs_error = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
119 gripe_user_supplied_eval ("eigs"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
120 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
121 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
122 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
123 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
124 eigs_error = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
125 gripe_user_supplied_eval ("eigs"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
126 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
127 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
128 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
129 return retval; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
130 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
131 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
132 DEFUN_DLD (eigs, args, nargout, |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
133 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
134 @deftypefn {Loadable Function} {@var{d} =} eigs (@var{a})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
135 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{a}, @var{k})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
136 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{a}, @var{k}, @var{sigma})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
137 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{a}, @var{k}, @var{sigma},@var{opts})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
138 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{a}, @var{b})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
139 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{a}, @var{b}, @var{k})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
140 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{a}, @var{b}, @var{k}, @var{sigma})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
141 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{a}, @var{b}, @var{k}, @var{sigma}, @var{opts})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
142 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
143 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{b})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
144 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{k})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
145 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{b}, @var{k})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
146 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{k}, @var{sigma})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
147 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{b}, @var{k}, @var{sigma})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
148 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{k}, @var{sigma}, @var{opts})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
149 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{b}, @var{k}, @var{sigma}, @var{opts})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
150 @deftypefnx {Loadable Function} {[@var{v}, @var{d}] =} eigs (@var{a}, @dots{})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
151 @deftypefnx {Loadable Function} {[@var{v}, @var{d}] =} eigs (@var{af}, @var{n}, @dots{})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
152 @deftypefnx {Loadable Function} {[@var{v}, @var{d}, @var{flag}] =} eigs (@var{a}, @dots{})\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
153 @deftypefnx {Loadable Function} {[@var{v}, @var{d}, @var{flag}] =} eigs (@var{af}, @var{n}, @dots{})\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
154 Calculate a limited number of eigenvalues and eigenvectors of @var{a},\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
155 based on a selection criteria. The number eigenvalues and eigenvectors to\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
156 calculate is given by @var{k} whose default value is 6.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
157 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
158 By default @code{eigs} solve the equation\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
159 @tex\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
160 $A \\nu = \\lambda \\nu$\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
161 @end tex\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
162 @ifinfo\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
163 @code{A * v = lambda * v}\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
164 @end ifinfo\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
165 , where\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
166 @tex\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
167 $\\lambda$ is a scalar representing one of the eigenvalues, and $\\nu$\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
168 @end tex\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
169 @ifinfo\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
170 @code{lambda} is a scalar representing one of the eigenvalues, and @code{v}\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
171 @end ifinfo\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
172 is the corresponding eigenvector. If given the positive definite matrix\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
173 @var{B} then @code{eigs} solves the general eigenvalue equation\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
174 @tex\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
175 $A \\nu = \\lambda B \\nu$\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
176 @end tex\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
177 @ifinfo\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
178 @code{A * v = lambda * B * v}\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
179 @end ifinfo\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
180 .\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
181 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
182 The argument @var{sigma} determines which eigenvalues are returned.\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
183 @var{sigma} can be either a scalar or a string. When @var{sigma} is a scalar,\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
184 the @var{k} eigenvalues closest to @var{sigma} are returned. If @var{sigma}\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
185 is a string, it must have one of the values\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
186 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
187 @table @asis\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
188 @item 'lm'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
189 Largest magnitude (default).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
190 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
191 @item 'sm'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
192 Smallest magnitude.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
193 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
194 @item 'la'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
195 Largest Algebraic (valid only for real symmetric problems).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
196 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
197 @item 'sa'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
198 Smallest Algebraic (valid only for real symmetric problems).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
199 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
200 @item 'be'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
201 Both ends, with one more from the high-end if @var{k} is odd (valid only for\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
202 real symmetric problems).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
203 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
204 @item 'lr'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
205 Largest real part (valid only for complex or unsymmetric problems).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
206 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
207 @item 'sr'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
208 Smallest real part (valid only for complex or unsymmetric problems).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
209 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
210 @item 'li'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
211 Largest imaginary part (valid only for complex or unsymmetric problems).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
212 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
213 @item 'si'\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
214 Smallest imaginary part (valid only for complex or unsymmetric problems).\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
215 @end table\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
216 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
217 If @var{opts} is given, it is a structure defining some of the options that\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
218 @code{eigs} should use. The fields of the structure @var{opts} are\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
219 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
220 @table @code\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
221 @item issym\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
222 If @var{af} is given, then flags whether the function @var{af} defines a\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
223 symmetric problem. It is ignored if @var{a} is given. The default is false.\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
224 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
225 @item isreal\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
226 If @var{af} is given, then flags whether the function @var{af} defines a\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
227 real problem. It is ignored if @var{a} is given. The default is true.\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
228 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
229 @item tol\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
230 Defines the required convergence tolerance, given as @code{tol * norm (A)}.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
231 The default is @code{eps}.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
232 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
233 @item maxit\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
234 The maximum number of iterations. The default is 300.\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
235 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
236 @item p\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
237 The number of Lanzcos basis vectors to use. More vectors will result in\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
238 faster convergence, but a larger amount of memory. The optimal value of 'p'\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
239 is problem dependent and should be in the range @var{k} to @var{n}. The\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
240 default value is @code{2 * @var{k}}.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
241 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
242 @item v0\n\ |
9758
09da0bd91412
Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents:
9724
diff
changeset
|
243 The starting vector for the computation. The default is to have @sc{arpack}\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
244 randomly generate a starting vector.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
245 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
246 @item disp\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
247 The level of diagnostic printout. If @code{disp} is 0 then there is no\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
248 printout. The default value is 1.\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
249 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
250 @item cholB\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
251 Flag if @code{chol (@var{b})} is passed rather than @var{b}. The default is\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
252 false.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
253 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
254 @item permB\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
255 The permutation vector of the Cholesky factorization of @var{b} if\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
256 @code{cholB} is true. That is @code{chol ( @var{b} (permB, permB))}. The\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
257 default is @code{1:@var{n}}.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
258 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
259 @end table\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
260 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
261 It is also possible to represent @var{a} by a function denoted @var{af}.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
262 @var{af} must be followed by a scalar argument @var{n} defining the length\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
263 of the vector argument accepted by @var{af}. @var{af} can be passed either\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
264 as an inline function, function handle or as a string. In the case where\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
265 @var{af} is passed as a string, the name of the string defines the function\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
266 to use.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
267 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
268 @var{af} is a function of the form @code{function y = af (x), y = @dots{};\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
269 endfunction}, where the required return value of @var{af} is determined by\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
270 the value of @var{sigma}, and are\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
271 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
272 @table @code\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
273 @item A * x\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
274 If @var{sigma} is not given or is a string other than 'sm'.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
275 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
276 @item A \\ x\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
277 If @var{sigma} is 'sm'.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
278 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
279 @item (A - sigma * I) \\ x\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
280 for standard eigenvalue problem, where @code{I} is the identity matrix of\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
281 the same size as @code{A}. If @var{sigma} is zero, this reduces the\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
282 @code{A \\ x}.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
283 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
284 @item (A - sigma * B) \\ x\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
285 for the general eigenvalue problem.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
286 @end table\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
287 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
288 The return arguments of @code{eigs} depends on the number of return\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
289 arguments. With a single return argument, a vector @var{d} of length @var{k}\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
290 is returned, represent the @var{k} eigenvalues that have been found. With two\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
291 return arguments, @var{v} is a @var{n}-by-@var{k} matrix whose columns are\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
292 the @var{k} eigenvectors corresponding to the returned eigenvalues. The\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
293 eigenvalues themselves are then returned in @var{d} in the form of a\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
294 @var{n}-by-@var{k} matrix, where the elements on the diagonal are the\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
295 eigenvalues.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
296 \n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
297 Given a third return argument @var{flag}, @code{eigs} also returns the status\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
298 of the convergence. If @var{flag} is 0, then all eigenvalues have converged,\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
299 otherwise not.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
300 \n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
301 This function is based on the @sc{arpack} package, written by R Lehoucq,\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
302 K Maschhoff, D Sorensen and C Yang. For more information see\n\ |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
303 @url{http://www.caam.rice.edu/software/ARPACK/}.\n\ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
304 \n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
305 @seealso{eig, svds}\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9597
diff
changeset
|
306 @end deftypefn") |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
307 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
308 octave_value_list retval; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
309 #ifdef HAVE_ARPACK |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
310 int nargin = args.length (); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
311 std::string fcn_name; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
312 octave_idx_type n = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
313 octave_idx_type k = 6; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
314 Complex sigma = 0.; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
315 double sigmar, sigmai; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
316 bool have_sigma = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
317 std::string typ = "LM"; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
318 Matrix amm, bmm, bmt; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
319 ComplexMatrix acm, bcm, bct; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
320 SparseMatrix asmm, bsmm, bsmt; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
321 SparseComplexMatrix ascm, bscm, bsct; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
322 int b_arg = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
323 bool have_b = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
324 bool have_a_fun = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
325 bool a_is_complex = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
326 bool b_is_complex = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
327 bool symmetric = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
328 bool cholB = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
329 bool a_is_sparse = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
330 ColumnVector permB; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
331 int arg_offset = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
332 double tol = DBL_EPSILON; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
333 int maxit = 300; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
334 int disp = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
335 octave_idx_type p = -1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
336 ColumnVector resid; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
337 ComplexColumnVector cresid; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
338 octave_idx_type info = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
339 char bmat = 'I'; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
340 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
341 warned_imaginary = false; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
342 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9758
diff
changeset
|
343 unwind_protect frame; |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
344 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9758
diff
changeset
|
345 frame.protect_var (call_depth); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
346 call_depth++; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
347 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
348 if (call_depth > 1) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
349 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
350 error ("eigs: invalid recursive call"); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
351 if (fcn_name.length()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
352 clear_function (fcn_name); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
353 return retval; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
354 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
355 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
356 if (nargin == 0) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
357 print_usage (); |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
358 else if (args(0).is_function_handle () || args(0).is_inline_function () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
359 || args(0).is_string ()) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
360 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
361 if (args(0).is_string ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
362 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
363 std::string name = args(0).string_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
364 std::string fname = "function y = "; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
365 fcn_name = unique_symbol_name ("__eigs_fcn_"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
366 fname.append (fcn_name); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
367 fname.append ("(x) y = "); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
368 eigs_fcn = extract_function (args(0), "eigs", fcn_name, fname, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
369 "; endfunction"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
370 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
371 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
372 eigs_fcn = args(0).function_value (); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
373 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
374 if (!eigs_fcn) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
375 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
376 error ("eigs: unknown function"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
377 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
378 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
379 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
380 if (nargin < 2) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
381 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
382 error ("eigs: incorrect number of arguments"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
383 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
384 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
385 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
386 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
387 n = args(1).nint_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
388 arg_offset = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
389 have_a_fun = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
390 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
391 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
392 else |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
393 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
394 if (args(0).is_complex_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
395 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
396 if (args(0).is_sparse_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
397 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
398 ascm = (args(0).sparse_complex_matrix_value()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
399 a_is_sparse = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
400 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
401 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
402 acm = (args(0).complex_matrix_value()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
403 a_is_complex = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
404 symmetric = false; // ARAPACK doesn't special case complex symmetric |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
405 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
406 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
407 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
408 if (args(0).is_sparse_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
409 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
410 asmm = (args(0).sparse_matrix_value()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
411 a_is_sparse = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
412 symmetric = asmm.is_symmetric(); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
413 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
414 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
415 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
416 amm = (args(0).matrix_value()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
417 symmetric = amm.is_symmetric(); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
418 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
419 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
420 |
9593
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
421 } |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
422 |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
423 // Note hold off reading B till later to avoid issues of double |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
424 // copies of the matrix if B is full/real while A is complex.. |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
425 if (!error_state && nargin > 1 + arg_offset && |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
426 !(args(1 + arg_offset).is_real_scalar ())) |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
427 { |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
428 if (args(1+arg_offset).is_complex_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
429 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
430 b_arg = 1+arg_offset; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
431 have_b = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
432 bmat = 'G'; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
433 b_is_complex = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
434 arg_offset++; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
435 } |
9593
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
436 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
437 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
438 b_arg = 1+arg_offset; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
439 have_b = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
440 bmat = 'G'; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
441 arg_offset++; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
442 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
443 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
444 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
445 if (!error_state && nargin > (1+arg_offset)) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
446 k = args(1+arg_offset).nint_value (); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
447 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
448 if (!error_state && nargin > (2+arg_offset)) |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
449 { |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8702
diff
changeset
|
450 if (args(2+arg_offset).is_string ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
451 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
452 typ = args(2+arg_offset).string_value (); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
453 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
454 // Use STL function to convert to upper case |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
455 transform (typ.begin (), typ.end (), typ.begin (), toupper); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
456 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
457 sigma = 0.; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
458 } |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
459 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
460 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
461 sigma = args(2+arg_offset).complex_value (); |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8702
diff
changeset
|
462 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
463 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
464 have_sigma = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
465 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
466 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
467 error ("eigs: sigma must be a scalar or a string"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
468 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
469 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
470 } |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
471 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
472 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
473 sigmar = std::real (sigma); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
474 sigmai = std::imag (sigma); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
475 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
476 if (!error_state && nargin > (3+arg_offset)) |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
477 { |
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
478 if (args(3+arg_offset).is_map ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
479 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
480 Octave_map map = args(3+arg_offset).map_value (); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
481 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
482 // issym is ignored if A is not a function |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
483 if (map.contains ("issym") && have_a_fun) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
484 symmetric = map.contents ("issym")(0).double_value () != 0.; |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
485 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
486 // isreal is ignored if A is not a function |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
487 if (map.contains ("isreal") && have_a_fun) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
488 a_is_complex = ! (map.contents ("isreal")(0).double_value () != 0.); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
489 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
490 if (map.contains ("tol")) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
491 tol = map.contents ("tol")(0).double_value (); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
492 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
493 if (map.contains ("maxit")) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
494 maxit = map.contents ("maxit")(0).nint_value (); |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
495 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
496 if (map.contains ("p")) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
497 p = map.contents ("p")(0).nint_value (); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
498 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
499 if (map.contains ("v0")) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
500 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
501 if (a_is_complex || b_is_complex) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
502 cresid = ComplexColumnVector |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
503 (map.contents ("v0")(0).complex_vector_value()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
504 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
505 resid = ColumnVector (map.contents ("v0")(0).vector_value()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
506 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
507 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
508 if (map.contains ("disp")) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
509 disp = map.contents ("disp")(0).nint_value (); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
510 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
511 if (map.contains ("cholB")) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
512 cholB = map.contents ("cholB")(0).double_value () != 0.; |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
513 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
514 if (map.contains ("permB")) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
515 permB = ColumnVector (map.contents ("permB")(0).vector_value ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
516 - 1.0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
517 } |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
518 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
519 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
520 error ("eigs: options argument must be a structure"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
521 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
522 } |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
523 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
524 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
525 if (nargin > (4+arg_offset)) |
8683
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
526 { |
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
527 error ("eigs: incorrect number of arguments"); |
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
528 return retval; |
e4f89f4a7cf8
eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents:
8585
diff
changeset
|
529 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
530 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
531 if (have_b) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
532 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
533 if (a_is_complex || b_is_complex) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
534 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
535 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
536 bscm = args(b_arg).sparse_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
537 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
538 bcm = args(b_arg).complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
539 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
540 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
541 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
542 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
543 bsmm = args(b_arg).sparse_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
544 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
545 bmm = args(b_arg).matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
546 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
547 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
548 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
549 // Mode 1 for SM mode seems unstable for some reason. |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
550 // Use Mode 3 instead, with sigma = 0. |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
551 if (!error_state && !have_sigma && typ == "SM") |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
552 have_sigma = true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
553 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
554 if (!error_state) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
555 { |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
556 octave_idx_type nconv; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
557 if (a_is_complex || b_is_complex) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
558 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
559 ComplexMatrix eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
560 ComplexColumnVector eig_val; |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
561 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
562 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
563 if (have_a_fun) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
564 nconv = EigsComplexNonSymmetricFunc |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
565 (eigs_complex_func, n, typ, sigma, k, p, info, eig_vec, eig_val, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
566 cresid, octave_stdout, tol, (nargout > 1), cholB, disp, maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
567 else if (have_sigma) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
568 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
569 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
570 nconv = EigsComplexNonSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
571 (ascm, sigma, k, p, info, eig_vec, eig_val, bscm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
572 cresid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
573 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
574 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
575 nconv = EigsComplexNonSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
576 (acm, sigma, k, p, info, eig_vec, eig_val, bcm, permB, cresid, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
577 octave_stdout, tol, (nargout > 1), cholB, disp, maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
578 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
579 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
580 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
581 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
582 nconv = EigsComplexNonSymmetricMatrix |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
583 (ascm, typ, k, p, info, eig_vec, eig_val, bscm, permB, cresid, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
584 octave_stdout, tol, (nargout > 1), cholB, disp, maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
585 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
586 nconv = EigsComplexNonSymmetricMatrix |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
587 (acm, typ, k, p, info, eig_vec, eig_val, bcm, permB, cresid, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
588 octave_stdout, tol, (nargout > 1), cholB, disp, maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
589 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
590 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
591 if (nargout < 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
592 retval (0) = eig_val; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
593 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
594 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
595 retval(2) = double (info); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
596 retval(1) = ComplexDiagMatrix (eig_val); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
597 retval(0) = eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
598 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
599 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
600 else if (sigmai != 0.) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
601 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
602 // Promote real problem to a complex one. |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
603 ComplexMatrix eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
604 ComplexColumnVector eig_val; |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
605 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
606 if (have_a_fun) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
607 nconv = EigsComplexNonSymmetricFunc |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
608 (eigs_complex_func, n, typ, sigma, k, p, info, eig_vec, eig_val, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
609 cresid, octave_stdout, tol, (nargout > 1), cholB, disp, maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
610 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
611 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
612 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
613 nconv = EigsComplexNonSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
614 (SparseComplexMatrix (asmm), sigma, k, p, info, eig_vec, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
615 eig_val, SparseComplexMatrix (bsmm), permB, cresid, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
616 octave_stdout, tol, (nargout > 1), cholB, disp, maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
617 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
618 nconv = EigsComplexNonSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
619 (ComplexMatrix (amm), sigma, k, p, info, eig_vec, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
620 eig_val, ComplexMatrix (bmm), permB, cresid, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
621 octave_stdout, tol, (nargout > 1), cholB, disp, maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
622 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
623 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
624 if (nargout < 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
625 retval (0) = eig_val; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
626 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
627 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
628 retval(2) = double (info); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
629 retval(1) = ComplexDiagMatrix (eig_val); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
630 retval(0) = eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
631 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
632 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
633 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
634 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
635 if (symmetric) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
636 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
637 Matrix eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
638 ColumnVector eig_val; |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
639 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
640 if (have_a_fun) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
641 nconv = EigsRealSymmetricFunc |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
642 (eigs_func, n, typ, sigmar, k, p, info, eig_vec, eig_val, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
643 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
644 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
645 else if (have_sigma) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
646 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
647 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
648 nconv = EigsRealSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
649 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
650 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
651 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
652 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
653 nconv = EigsRealSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
654 (amm, sigmar, k, p, info, eig_vec, eig_val, bmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
655 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
656 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
657 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
658 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
659 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
660 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
661 nconv = EigsRealSymmetricMatrix |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
662 (asmm, typ, k, p, info, eig_vec, eig_val, bsmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
663 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
664 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
665 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
666 nconv = EigsRealSymmetricMatrix |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
667 (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
668 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
669 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
670 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
671 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
672 if (nargout < 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
673 retval (0) = eig_val; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
674 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
675 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
676 retval(2) = double (info); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
677 retval(1) = DiagMatrix (eig_val); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
678 retval(0) = eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
679 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
680 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
681 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
682 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
683 ComplexMatrix eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
684 ComplexColumnVector eig_val; |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
685 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
686 if (have_a_fun) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
687 nconv = EigsRealNonSymmetricFunc |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
688 (eigs_func, n, typ, sigmar, k, p, info, eig_vec, eig_val, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
689 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
690 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
691 else if (have_sigma) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
692 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
693 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
694 nconv = EigsRealNonSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
695 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
696 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
697 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
698 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
699 nconv = EigsRealNonSymmetricMatrixShift |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
700 (amm, sigmar, k, p, info, eig_vec, eig_val, bmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
701 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
702 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
703 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
704 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
705 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
706 if (a_is_sparse) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
707 nconv = EigsRealNonSymmetricMatrix |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
708 (asmm, typ, k, p, info, eig_vec, eig_val, bsmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
709 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
710 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
711 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
712 nconv = EigsRealNonSymmetricMatrix |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
713 (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
714 resid, octave_stdout, tol, (nargout > 1), cholB, disp, |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
715 maxit); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
716 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
717 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
718 if (nargout < 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
719 retval (0) = eig_val; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
720 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
721 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
722 retval(2) = double (info); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
723 retval(1) = ComplexDiagMatrix (eig_val); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
724 retval(0) = eig_vec; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
725 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
726 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
727 } |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
728 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
729 if (nconv <= 0) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
730 warning ("eigs: None of the %d requested eigenvalues converged", k); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
731 else if (nconv < k) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
732 warning ("eigs: Only %d of the %d requested eigenvalues converged", |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
733 nconv, k); |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
734 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
735 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
736 if (! fcn_name.empty ()) |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
737 clear_function (fcn_name); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
738 #else |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
739 error ("eigs: not available in this version of Octave"); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
740 #endif |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
741 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
742 return retval; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
743 } |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
744 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
745 /* #### SPARSE MATRIX VERSIONS #### */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
746 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
747 /* |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
748 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
749 %% Real positive definite tests, n must be even |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
750 %!shared n, k, A, d0, d2 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
751 %! n = 20; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
752 %! k = 4; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
753 %! A = sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),4*ones(1,n),ones(1,n-2)]); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
754 %! d0 = eig (A); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
755 %! d2 = sort(d0); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
756 %! [dum, idx] = sort( abs(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
757 %! d0 = d0(idx); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
758 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
759 %! d1 = eigs (A, k); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
760 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
761 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
762 %! d1 = eigs (A,k+1); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
763 %! assert (d1, d0(end:-1:(end-k)),1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
764 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
765 %! d1 = eigs (A, k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
766 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
767 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
768 %! d1 = eigs (A, k, 'sm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
769 %! assert (d1, d0(k:-1:1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
770 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
771 %! d1 = eigs (A, k, 'la'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
772 %! assert (d1, d2(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
773 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
774 %! d1 = eigs (A, k, 'sa'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
775 %! assert (d1, d2(1:k), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
776 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
777 %! d1 = eigs (A, k, 'be'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
778 %! assert (d1, d2([1:floor(k/2), (end - ceil(k/2) + 1):end]), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
779 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
780 %! d1 = eigs (A, k+1, 'be'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
781 %! assert (d1, d2([1:floor((k+1)/2), (end - ceil((k+1)/2) + 1):end]), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
782 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
783 %! d1 = eigs (A, k, 4.1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
784 %! [dum,idx0] = sort (abs(d0 - 4.1)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
785 %! [dum,idx1] = sort (abs(d1 - 4.1)); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
786 %! assert (d1(idx1), d0(idx0(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
787 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
788 %! d1 = eigs(A, speye(n), k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
789 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
790 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
791 %! assert (eigs(A,k,4.1), eigs(A,speye(n),k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
792 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
793 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
794 %! d1 = eigs(A, speye(n), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
795 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
796 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
797 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
798 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
799 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
800 %! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
801 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
802 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
803 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
804 %! d1 = eigs(A, speye(n), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
805 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
806 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
807 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
808 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
809 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
810 %! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
811 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
812 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
813 %! assert (eigs(A,k,4.1), eigs(A,speye(n),k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
814 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
815 %! fn = @(x) A * x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
816 %! opts.issym = 1; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
817 %! d1 = eigs (fn, n, k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
818 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
819 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
820 %! fn = @(x) A \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
821 %! opts.issym = 1; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
822 %! d1 = eigs (fn, n, k, 'sm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
823 %! assert (d1, d0(k:-1:1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
824 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
825 %! fn = @(x) (A - 4.1 * eye(n)) \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
826 %! opts.issym = 1; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
827 %! d1 = eigs (fn, n, k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
828 %! assert (d1, eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
829 %!testif HAVE_ARPACK |
9593
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
830 %! AA = speye (10); |
9597
a32f70d8d146
Minor typo in new eigs.cc test
David Bateman <dbateman@free.fr>
parents:
9593
diff
changeset
|
831 %! fn = @(x) AA * x; |
9593
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
832 %! opts.issym = 1; opts.isreal = 1; |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
833 %! assert (eigs (fn, 10, AA, 3, 'lm', opts), [1; 1; 1]); |
cf8403208c43
Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents:
9377
diff
changeset
|
834 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
835 %! [v1,d1] = eigs(A, k, 'lm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
836 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
837 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
838 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
839 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
840 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
841 %! [v1,d1] = eigs(A, k, 'sm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
842 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
843 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
844 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
845 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
846 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
847 %! [v1,d1] = eigs(A, k, 'la'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
848 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
849 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
850 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
851 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
852 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
853 %! [v1,d1] = eigs(A, k, 'sa'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
854 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
855 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
856 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
857 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
858 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
859 %! [v1,d1] = eigs(A, k, 'be'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
860 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
861 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
862 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
863 %! endfor |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
864 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
865 */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
866 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
867 /* |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
868 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
869 %% Real unsymmetric tests |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
870 %!shared n, k, A, d0 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
871 %! n = 20; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
872 %! k = 4; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
873 %! A = sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
874 %! d0 = eig (A); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
875 %! [dum, idx] = sort(abs(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
876 %! d0 = d0(idx); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
877 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
878 %! d1 = eigs (A, k); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
879 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
880 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
881 %! d1 = eigs (A,k+1); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
882 %! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
883 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
884 %! d1 = eigs (A, k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
885 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
886 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
887 %! d1 = eigs (A, k, 'sm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
888 %! assert (abs(d1), abs(d0(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
889 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
890 %! d1 = eigs (A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
891 %! [dum, idx] = sort (real(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
892 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
893 %! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
894 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
895 %! d1 = eigs (A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
896 %! [dum, idx] = sort (real(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
897 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
898 %! assert (real(d1), real(d2(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
899 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
900 %! d1 = eigs (A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
901 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
902 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
903 %! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
904 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
905 %! d1 = eigs (A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
906 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
907 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
908 %! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
909 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
910 %! d1 = eigs (A, k, 4.1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
911 %! [dum,idx0] = sort (abs(d0 - 4.1)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
912 %! [dum,idx1] = sort (abs(d1 - 4.1)); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
913 %! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
914 %! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
915 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
916 %! d1 = eigs(A, speye(n), k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
917 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
918 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
919 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
920 %! d1 = eigs(A, speye(n), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
921 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
922 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
923 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
924 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
925 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
926 %! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
927 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
928 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
929 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
930 %! d1 = eigs(A, speye(n), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
931 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
932 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
933 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
934 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
935 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
936 %! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
937 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
938 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
939 %! assert (abs(eigs(A,k,4.1)), abs(eigs(A,speye(n),k,4.1)), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
940 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
941 %! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,speye(n),k,4.1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
942 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
943 %! fn = @(x) A * x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
944 %! opts.issym = 0; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
945 %! d1 = eigs (fn, n, k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
946 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
947 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
948 %! fn = @(x) A \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
949 %! opts.issym = 0; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
950 %! d1 = eigs (fn, n, k, 'sm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
951 %! assert (abs(d1), d0(1:k), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
952 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
953 %! fn = @(x) (A - 4.1 * eye(n)) \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
954 %! opts.issym = 0; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
955 %! d1 = eigs (fn, n, k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
956 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
957 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
958 %! [v1,d1] = eigs(A, k, 'lm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
959 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
960 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
961 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
962 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
963 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
964 %! [v1,d1] = eigs(A, k, 'sm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
965 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
966 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
967 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
968 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
969 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
970 %! [v1,d1] = eigs(A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
971 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
972 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
973 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
974 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
975 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
976 %! [v1,d1] = eigs(A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
977 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
978 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
979 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
980 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
981 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
982 %! [v1,d1] = eigs(A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
983 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
984 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
985 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
986 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
987 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
988 %! [v1,d1] = eigs(A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
989 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
990 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
991 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
992 %! endfor |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
993 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
994 */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
995 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
996 /* |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
997 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
998 %% Complex hermitian tests |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
999 %!shared n, k, A, d0 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1000 %! n = 20; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1001 %! k = 4; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1002 %! A = sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[1i*ones(1,n-2),4*ones(1,n),-1i*ones(1,n-2)]); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1003 %! d0 = eig (A); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1004 %! [dum, idx] = sort(abs(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1005 %! d0 = d0(idx); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1006 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1007 %! d1 = eigs (A, k); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1008 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1009 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1010 %! d1 = eigs (A,k+1); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1011 %! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1012 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1013 %! d1 = eigs (A, k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1014 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1015 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1016 %! d1 = eigs (A, k, 'sm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1017 %! assert (abs(d1), abs(d0(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1018 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1019 %! d1 = eigs (A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1020 %! [dum, idx] = sort (real(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1021 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1022 %! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1023 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1024 %! d1 = eigs (A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1025 %! [dum, idx] = sort (real(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1026 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1027 %! assert (real(d1), real(d2(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1028 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1029 %! d1 = eigs (A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1030 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1031 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1032 %! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1033 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1034 %! d1 = eigs (A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1035 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1036 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1037 %! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1038 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1039 %! d1 = eigs (A, k, 4.1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1040 %! [dum,idx0] = sort (abs(d0 - 4.1)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1041 %! [dum,idx1] = sort (abs(d1 - 4.1)); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1042 %! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1043 %! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1044 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1045 %! d1 = eigs(A, speye(n), k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1046 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1047 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1048 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1049 %! d1 = eigs(A, speye(n), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1050 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1051 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1052 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1053 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1054 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1055 %! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1056 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1057 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1058 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1059 %! d1 = eigs(A, speye(n), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1060 %! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1061 %! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1062 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1063 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1064 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1065 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1066 %! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1067 %! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1068 %! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1069 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1070 %! assert (abs(eigs(A,k,4.1)), abs(eigs(A,speye(n),k,4.1)), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1071 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1072 %! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,speye(n),k,4.1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1073 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1074 %! fn = @(x) A * x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1075 %! opts.issym = 0; opts.isreal = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1076 %! d1 = eigs (fn, n, k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1077 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1078 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1079 %! fn = @(x) A \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1080 %! opts.issym = 0; opts.isreal = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1081 %! d1 = eigs (fn, n, k, 'sm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1082 %! assert (abs(d1), d0(1:k), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1083 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1084 %! fn = @(x) (A - 4.1 * eye(n)) \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1085 %! opts.issym = 0; opts.isreal = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1086 %! d1 = eigs (fn, n, k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1087 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1088 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1089 %! [v1,d1] = eigs(A, k, 'lm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1090 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1091 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1092 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1093 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1094 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1095 %! [v1,d1] = eigs(A, k, 'sm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1096 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1097 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1098 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1099 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1100 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1101 %! [v1,d1] = eigs(A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1102 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1103 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1104 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1105 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1106 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1107 %! [v1,d1] = eigs(A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1108 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1109 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1110 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1111 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1112 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1113 %! [v1,d1] = eigs(A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1114 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1115 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1116 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1117 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1118 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1119 %! [v1,d1] = eigs(A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1120 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1121 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1122 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1123 %! endfor |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1124 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1125 */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1126 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1127 /* #### FULL MATRIX VERSIONS #### */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1128 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1129 /* |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1130 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1131 %% Real positive definite tests, n must be even |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1132 %!shared n, k, A, d0, d2 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1133 %! n = 20; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1134 %! k = 4; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1135 %! A = full(sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),4*ones(1,n),ones(1,n-2)])); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1136 %! d0 = eig (A); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1137 %! d2 = sort(d0); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1138 %! [dum, idx] = sort( abs(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1139 %! d0 = d0(idx); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1140 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1141 %! d1 = eigs (A, k); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1142 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1143 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1144 %! d1 = eigs (A,k+1); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1145 %! assert (d1, d0(end:-1:(end-k)),1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1146 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1147 %! d1 = eigs (A, k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1148 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1149 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1150 %! d1 = eigs (A, k, 'sm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1151 %! assert (d1, d0(k:-1:1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1152 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1153 %! d1 = eigs (A, k, 'la'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1154 %! assert (d1, d2(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1155 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1156 %! d1 = eigs (A, k, 'sa'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1157 %! assert (d1, d2(1:k), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1158 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1159 %! d1 = eigs (A, k, 'be'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1160 %! assert (d1, d2([1:floor(k/2), (end - ceil(k/2) + 1):end]), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1161 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1162 %! d1 = eigs (A, k+1, 'be'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1163 %! assert (d1, d2([1:floor((k+1)/2), (end - ceil((k+1)/2) + 1):end]), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1164 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1165 %! d1 = eigs (A, k, 4.1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1166 %! [dum,idx0] = sort (abs(d0 - 4.1)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1167 %! [dum,idx1] = sort (abs(d1 - 4.1)); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1168 %! assert (d1(idx1), d0(idx0(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1169 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1170 %! d1 = eigs(A, eye(n), k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1171 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1172 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1173 %! assert (eigs(A,k,4.1), eigs(A,eye(n),k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1174 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1175 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1176 %! d1 = eigs(A, eye(n), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1177 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1178 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1179 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1180 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1181 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1182 %! d1 = eigs(A, eye(n)(q,q), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1183 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1184 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1185 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1186 %! d1 = eigs(A, eye(n), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1187 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1188 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1189 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1190 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1191 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1192 %! d1 = eigs(A, eye(n)(q,q), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1193 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1194 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1195 %! assert (eigs(A,k,4.1), eigs(A,eye(n),k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1196 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1197 %! fn = @(x) A * x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1198 %! opts.issym = 1; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1199 %! d1 = eigs (fn, n, k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1200 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1201 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1202 %! fn = @(x) A \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1203 %! opts.issym = 1; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1204 %! d1 = eigs (fn, n, k, 'sm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1205 %! assert (d1, d0(k:-1:1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1206 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1207 %! fn = @(x) (A - 4.1 * eye(n)) \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1208 %! opts.issym = 1; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1209 %! d1 = eigs (fn, n, k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1210 %! assert (d1, eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1211 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1212 %! [v1,d1] = eigs(A, k, 'lm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1213 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1214 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1215 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1216 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1217 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1218 %! [v1,d1] = eigs(A, k, 'sm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1219 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1220 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1221 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1222 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1223 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1224 %! [v1,d1] = eigs(A, k, 'la'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1225 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1226 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1227 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1228 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1229 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1230 %! [v1,d1] = eigs(A, k, 'sa'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1231 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1232 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1233 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1234 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1235 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1236 %! [v1,d1] = eigs(A, k, 'be'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1237 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1238 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1239 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1240 %! endfor |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1241 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1242 */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1243 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1244 /* |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1245 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1246 %% Real unsymmetric tests |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1247 %!shared n, k, A, d0 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1248 %! n = 20; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1249 %! k = 4; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1250 %! A = full(sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)])); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1251 %! d0 = eig (A); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1252 %! [dum, idx] = sort(abs(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1253 %! d0 = d0(idx); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1254 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1255 %! d1 = eigs (A, k); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1256 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1257 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1258 %! d1 = eigs (A,k+1); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1259 %! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1260 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1261 %! d1 = eigs (A, k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1262 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1263 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1264 %! d1 = eigs (A, k, 'sm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1265 %! assert (abs(d1), abs(d0(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1266 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1267 %! d1 = eigs (A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1268 %! [dum, idx] = sort (real(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1269 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1270 %! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1271 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1272 %! d1 = eigs (A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1273 %! [dum, idx] = sort (real(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1274 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1275 %! assert (real(d1), real(d2(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1276 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1277 %! d1 = eigs (A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1278 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1279 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1280 %! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1281 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1282 %! d1 = eigs (A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1283 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1284 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1285 %! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1286 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1287 %! d1 = eigs (A, k, 4.1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1288 %! [dum,idx0] = sort (abs(d0 - 4.1)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1289 %! [dum,idx1] = sort (abs(d1 - 4.1)); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1290 %! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1291 %! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1292 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1293 %! d1 = eigs(A, eye(n), k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1294 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1295 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1296 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1297 %! d1 = eigs(A, eye(n), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1298 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1299 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1300 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1301 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1302 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1303 %! d1 = eigs(A, eye(n)(q,q), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1304 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1305 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1306 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1307 %! d1 = eigs(A, eye(n), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1308 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1309 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1310 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1311 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1312 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1313 %! d1 = eigs(A, eye(n)(q,q), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1314 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1315 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1316 %! assert (abs(eigs(A,k,4.1)), abs(eigs(A,eye(n),k,4.1)), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1317 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1318 %! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,eye(n),k,4.1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1319 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1320 %! fn = @(x) A * x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1321 %! opts.issym = 0; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1322 %! d1 = eigs (fn, n, k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1323 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1324 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1325 %! fn = @(x) A \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1326 %! opts.issym = 0; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1327 %! d1 = eigs (fn, n, k, 'sm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1328 %! assert (abs(d1), d0(1:k), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1329 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1330 %! fn = @(x) (A - 4.1 * eye(n)) \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1331 %! opts.issym = 0; opts.isreal = 1; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1332 %! d1 = eigs (fn, n, k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1333 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1334 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1335 %! [v1,d1] = eigs(A, k, 'lm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1336 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1337 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1338 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1339 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1340 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1341 %! [v1,d1] = eigs(A, k, 'sm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1342 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1343 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1344 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1345 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1346 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1347 %! [v1,d1] = eigs(A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1348 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1349 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1350 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1351 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1352 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1353 %! [v1,d1] = eigs(A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1354 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1355 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1356 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1357 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1358 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1359 %! [v1,d1] = eigs(A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1360 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1361 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1362 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1363 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1364 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1365 %! [v1,d1] = eigs(A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1366 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1367 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1368 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1369 %! endfor |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1370 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1371 */ |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1372 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1373 /* |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1374 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1375 %% Complex hermitian tests |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1376 %!shared n, k, A, d0 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1377 %! n = 20; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1378 %! k = 4; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1379 %! A = full(sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[1i*ones(1,n-2),4*ones(1,n),-1i*ones(1,n-2)])); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1380 %! d0 = eig (A); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1381 %! [dum, idx] = sort(abs(d0)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1382 %! d0 = d0(idx); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1383 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1384 %! d1 = eigs (A, k); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1385 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1386 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1387 %! d1 = eigs (A,k+1); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1388 %! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1389 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1390 %! d1 = eigs (A, k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1391 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1392 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1393 %! d1 = eigs (A, k, 'sm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1394 %! assert (abs(d1), abs(d0(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1395 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1396 %! d1 = eigs (A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1397 %! [dum, idx] = sort (real(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1398 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1399 %! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1400 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1401 %! d1 = eigs (A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1402 %! [dum, idx] = sort (real(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1403 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1404 %! assert (real(d1), real(d2(1:k)), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1405 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1406 %! d1 = eigs (A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1407 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1408 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1409 %! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1410 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1411 %! d1 = eigs (A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1412 %! [dum, idx] = sort (imag(abs(d0))); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1413 %! d2 = d0(idx); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1414 %! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1415 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1416 %! d1 = eigs (A, k, 4.1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1417 %! [dum,idx0] = sort (abs(d0 - 4.1)); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1418 %! [dum,idx1] = sort (abs(d1 - 4.1)); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1419 %! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1420 %! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1421 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1422 %! d1 = eigs(A, eye(n), k, 'lm'); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1423 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1424 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1425 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1426 %! d1 = eigs(A, eye(n), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1427 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1428 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1429 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1430 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1431 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1432 %! d1 = eigs(A, eye(n)(q,q), k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1433 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1434 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1435 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1436 %! d1 = eigs(A, eye(n), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1437 %! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1438 %! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1439 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1440 %! opts.cholB=true; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1441 %! q = [2:n,1]; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1442 %! opts.permB=q; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1443 %! d1 = eigs(A, eye(n)(q,q), k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1444 %! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11); |
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1445 %! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1446 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1447 %! assert (abs(eigs(A,k,4.1)), abs(eigs(A,eye(n),k,4.1)), 1e-11); |
8585
e6497be3f3d6
Skip tests if ARPACK is missing.
Ben Abbott <bpabbott@mac.com>
parents:
8420
diff
changeset
|
1448 %!testif HAVE_ARPACK |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1449 %! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,eye(n),k,4.1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1450 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1451 %! fn = @(x) A * x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1452 %! opts.issym = 0; opts.isreal = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1453 %! d1 = eigs (fn, n, k, 'lm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1454 %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1455 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1456 %! fn = @(x) A \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1457 %! opts.issym = 0; opts.isreal = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1458 %! d1 = eigs (fn, n, k, 'sm', opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1459 %! assert (abs(d1), d0(1:k), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1460 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1461 %! fn = @(x) (A - 4.1 * eye(n)) \ x; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1462 %! opts.issym = 0; opts.isreal = 0; |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1463 %! d1 = eigs (fn, n, k, 4.1, opts); |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1464 %! assert (abs(d1), eigs(A,k,4.1), 1e-11); |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1465 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1466 %! [v1,d1] = eigs(A, k, 'lm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1467 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1468 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1469 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1470 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1471 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1472 %! [v1,d1] = eigs(A, k, 'sm'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1473 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1474 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1475 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1476 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1477 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1478 %! [v1,d1] = eigs(A, k, 'lr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1479 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1480 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1481 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1482 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1483 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1484 %! [v1,d1] = eigs(A, k, 'sr'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1485 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1486 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1487 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1488 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1489 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1490 %! [v1,d1] = eigs(A, k, 'li'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1491 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1492 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1493 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1494 %! endfor |
8420
9038f311c1a8
eigs.cc: skip tests if ARPACK is missing
John W. Eaton <jwe@octave.org>
parents:
8417
diff
changeset
|
1495 %!testif HAVE_ARPACK |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1496 %! [v1,d1] = eigs(A, k, 'si'); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1497 %! d1 = diag(d1); |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1498 %! for i=1:k |
8702
3c4628550318
eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents:
8683
diff
changeset
|
1499 %! assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11) |
8417
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1500 %! endfor |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1501 |
654bcfb937bf
Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1502 */ |