annotate libinterp/dldfcn/eigs.cc @ 16554:03a28487fa9d

Collect collapsed delimiters in strsplit(). * scripts/strings/strsplit.m: Use regular expression to collect collapsed delimiters for DELIMITERTYPE = "regularexpression" and "simple". Use loop to collect collapsed delimiters for "legacy".
author Ben Abbott <bpabbott@mac.com>
date Tue, 23 Apr 2013 08:14:54 -0400
parents 61822c866ba1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13219
diff changeset
3 Copyright (C) 2005-2012 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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
134 @deftypefn {Loadable Function} {@var{d} =} eigs (@var{A})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
135 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{A}, @var{k})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
136 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{A}, @var{k}, @var{sigma})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
137 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{A}, @var{k}, @var{sigma}, @var{opts})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
138 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{A}, @var{B})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
139 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{A}, @var{B}, @var{k})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
140 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{A}, @var{B}, @var{k}, @var{sigma})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
141 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{A}, @var{B}, @var{k}, @var{sigma}, @var{opts})\n\
9724
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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
143 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{B})\n\
9724
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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
145 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{B}, @var{k})\n\
9724
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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
147 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{B}, @var{k}, @var{sigma})\n\
9724
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\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
149 @deftypefnx {Loadable Function} {@var{d} =} eigs (@var{af}, @var{n}, @var{B}, @var{k}, @var{sigma}, @var{opts})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
150 @deftypefnx {Loadable Function} {[@var{V}, @var{d}] =} eigs (@var{A}, @dots{})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
151 @deftypefnx {Loadable Function} {[@var{V}, @var{d}] =} eigs (@var{af}, @var{n}, @dots{})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
152 @deftypefnx {Loadable Function} {[@var{V}, @var{d}, @var{flag}] =} eigs (@var{A}, @dots{})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
153 @deftypefnx {Loadable Function} {[@var{V}, @var{d}, @var{flag}] =} eigs (@var{af}, @var{n}, @dots{})\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
154 Calculate a limited number of eigenvalues and eigenvectors of @var{A},\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
155 based on a selection criteria. The number of eigenvalues and eigenvectors to\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
156 calculate is given by @var{k} and defaults to 6.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
157 \n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
158 By default, @code{eigs} solve the equation\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
159 @tex\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
160 $A \\nu = \\lambda \\nu$,\n\
8417
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\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
163 @code{A * v = lambda * v},\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
164 @end ifinfo\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
165 where\n\
8417
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\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
175 $A \\nu = \\lambda B \\nu$.\n\
8417
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\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
178 @code{A * v = lambda * B * v}.\n\
8417
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 The argument @var{sigma} determines which eigenvalues are returned.\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
182 @var{sigma} can be either a scalar or a string. When @var{sigma} is a\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
183 scalar, the @var{k} eigenvalues closest to @var{sigma} are returned. If\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
184 @var{sigma} is a string, it must have one of the following values.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
185 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
186 @table @asis\n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
187 @item \"lm\"\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
188 Largest Magnitude (default).\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
189 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
190 @item \"sm\"\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
191 Smallest Magnitude.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
192 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
193 @item \"la\"\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
194 Largest Algebraic (valid only for real symmetric problems).\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
195 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
196 @item \"sa\"\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
197 Smallest Algebraic (valid only for real symmetric problems).\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
198 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
199 @item \"be\"\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
200 Both Ends, with one more from the high-end if @var{k} is odd (valid only for\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
201 real symmetric problems).\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
202 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
203 @item \"lr\"\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
204 Largest Real part (valid only for complex or unsymmetric problems).\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
205 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
206 @item \"sr\"\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
207 Smallest Real part (valid only for complex or unsymmetric problems).\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
208 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
209 @item \"li\"\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
210 Largest Imaginary part (valid only for complex or unsymmetric problems).\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
211 \n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
212 @item \"si\"\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
213 Smallest Imaginary part (valid only for complex or unsymmetric problems).\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
214 @end table\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
215 \n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
216 If @var{opts} is given, it is a structure defining possible options that\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
217 @code{eigs} should use. The fields of the @var{opts} structure are:\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
218 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
219 @table @code\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
220 @item issym\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
221 If @var{af} is given, then flags whether the function @var{af} defines a\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
222 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
223 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
224 @item isreal\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
225 If @var{af} is given, then flags whether the function @var{af} defines a\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
226 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
227 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
228 @item tol\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
229 Defines the required convergence tolerance, calculated as\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
230 @code{tol * norm (A)}. The default is @code{eps}.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
231 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
232 @item maxit\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
233 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
234 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
235 @item p\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
236 The number of Lanzcos basis vectors to use. More vectors will result in\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
237 faster convergence, but a greater use of memory. The optimal value of\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
238 @code{p} is problem dependent and should be in the range @var{k} to @var{n}.\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
239 The default value is @code{2 * @var{k}}.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
240 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
241 @item v0\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
242 The starting vector for the algorithm. An initial vector close to the\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
243 final vector will speed up convergence. The default is for @sc{arpack}\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
244 to randomly generate a starting vector. If specified, @code{v0} must be\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
245 an @var{n}-by-1 vector where @code{@var{n} = rows (@var{A})}\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
246 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
247 @item disp\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
248 The level of diagnostic printout (0|1|2). If @code{disp} is 0 then\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
249 diagnostics are disabled. The default value is 0.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
250 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
251 @item cholB\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
252 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
253 false.\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
254 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
255 @item permB\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
256 The permutation vector of the Cholesky@tie{}factorization of @var{B} if\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
257 @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
258 default is @code{1:@var{n}}.\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
259 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
260 @end table\n\
15007
8f0e3c5bfa5f doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents: 14846
diff changeset
261 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
262 It is also possible to represent @var{A} by a function denoted @var{af}.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
263 @var{af} must be followed by a scalar argument @var{n} defining the length\n\
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
264 of the vector argument accepted by @var{af}. @var{af} can be\n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
265 a function handle, an inline function, or a string. When @var{af} is a\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
266 string it holds the name of the function to use.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
267 \n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
268 @var{af} is a function of the form @code{y = af (x)}\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
269 where the required return value of @var{af} is determined by\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
270 the value of @var{sigma}. The four possible forms are\n\
8417
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\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
274 if @var{sigma} is not given or is a string other than \"sm\".\n\
8417
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\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
277 if @var{sigma} is 0 or \"sm\".\n\
8417
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\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
280 for the standard eigenvalue problem, where @code{I} is the identity matrix of\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
281 the same size as @var{A}.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
282 \n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
283 @item (A - sigma * B) \\ x\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
284 for the general eigenvalue problem.\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
285 @end table\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
286 \n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
287 The return arguments of @code{eigs} depend on the number of return arguments\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
288 requested. With a single return argument, a vector @var{d} of length @var{k}\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
289 is returned containing the @var{k} eigenvalues that have been found. With\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
290 two return arguments, @var{V} is a @var{n}-by-@var{k} matrix whose columns\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
291 are the @var{k} eigenvectors corresponding to the returned eigenvalues. The\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
292 eigenvalues themselves are returned in @var{d} in the form of a\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
293 @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
294 eigenvalues.\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
295 \n\
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
296 Given a third return argument @var{flag}, @code{eigs} returns the status\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
297 of the convergence. If @var{flag} is 0 then all eigenvalues have converged.\n\
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
298 Any other value indicates a failure to converge.\n\
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
299 \n\
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents: 10777
diff changeset
300 This function is based on the @sc{arpack} package, written by R. Lehoucq,\n\
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents: 10777
diff changeset
301 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
302 @url{http://www.caam.rice.edu/software/ARPACK/}.\n\
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
303 \n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9597
diff changeset
304 @seealso{eig, svds}\n\
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9597
diff changeset
305 @end deftypefn")
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
306 {
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
307 octave_value_list retval;
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
308 #ifdef HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
309 int nargin = args.length ();
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
310 std::string fcn_name;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
311 octave_idx_type n = 0;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
312 octave_idx_type k = 6;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
313 Complex sigma = 0.;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
314 double sigmar, sigmai;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
315 bool have_sigma = false;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
316 std::string typ = "LM";
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
317 Matrix amm, bmm, bmt;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
318 ComplexMatrix acm, bcm, bct;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
319 SparseMatrix asmm, bsmm, bsmt;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
320 SparseComplexMatrix ascm, bscm, bsct;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
321 int b_arg = 0;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
322 bool have_b = false;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
323 bool have_a_fun = false;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
324 bool a_is_complex = false;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
325 bool b_is_complex = false;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
326 bool symmetric = false;
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
327 bool sym_tested = false;
8417
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;
15220
61822c866ba1 use std::numeric_limits<T>::epsilon in C++ code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
332 double tol = std::numeric_limits<double>::epsilon ();
8417
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
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
340 warned_imaginary = false;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
341
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9758
diff changeset
342 unwind_protect frame;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
343
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9758
diff changeset
344 frame.protect_var (call_depth);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
345 call_depth++;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
346
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
347 if (call_depth > 1)
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
348 {
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
349 error ("eigs: invalid recursive call");
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
350 if (fcn_name.length ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
351 clear_function (fcn_name);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
352 return retval;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
353 }
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 if (nargin == 0)
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
356 print_usage ();
8683
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
357 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
358 || args(0).is_string ())
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
359 {
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
360 if (args(0).is_string ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
361 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
362 std::string name = args(0).string_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
363 std::string fname = "function y = ";
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
364 fcn_name = unique_symbol_name ("__eigs_fcn_");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
365 fname.append (fcn_name);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
366 fname.append ("(x) y = ");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
367 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
368 "; endfunction");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
369 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
370 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
371 eigs_fcn = args(0).function_value ();
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
372
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
373 if (!eigs_fcn)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
374 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
375 error ("eigs: unknown function");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
376 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
377 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
378
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
379 if (nargin < 2)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
380 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
381 error ("eigs: incorrect number of arguments");
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
382 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
383 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
384 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
385 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
386 n = args(1).nint_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
387 arg_offset = 1;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
388 have_a_fun = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
389 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
390 }
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
391 else
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
392 {
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
393 if (args(0).is_complex_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
394 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
395 if (args(0).is_sparse_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
396 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
397 ascm = (args(0).sparse_complex_matrix_value ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
398 a_is_sparse = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
399 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
400 else
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
401 acm = (args(0).complex_matrix_value ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
402 a_is_complex = true;
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
403 symmetric = false; // ARPACK doesn't special case complex symmetric
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
404 sym_tested = true;
10154
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 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
410 asmm = (args(0).sparse_matrix_value ());
10154
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 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
413 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
414 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
415 amm = (args(0).matrix_value ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
416 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
417 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
418
9593
cf8403208c43 Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents: 9377
diff changeset
419 }
cf8403208c43 Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents: 9377
diff changeset
420
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
421 // Note hold off reading B till later to avoid issues of double
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
422 // copies of the matrix if B is full/real while A is complex.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
423 if (!error_state && nargin > 1 + arg_offset &&
9593
cf8403208c43 Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents: 9377
diff changeset
424 !(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
425 {
cf8403208c43 Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents: 9377
diff changeset
426 if (args(1+arg_offset).is_complex_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
427 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
428 b_arg = 1+arg_offset;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
429 have_b = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
430 b_is_complex = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
431 arg_offset++;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
432 }
9593
cf8403208c43 Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents: 9377
diff changeset
433 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
434 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
435 b_arg = 1+arg_offset;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
436 have_b = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
437 arg_offset++;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
438 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
439 }
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
440
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
441 if (!error_state && nargin > (1+arg_offset))
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
442 k = args(1+arg_offset).nint_value ();
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 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
445 {
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8702
diff changeset
446 if (args(2+arg_offset).is_string ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
447 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
448 typ = args(2+arg_offset).string_value ();
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
449
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
450 // Use STL function to convert to upper case
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
451 transform (typ.begin (), typ.end (), typ.begin (), toupper);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
452
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
453 sigma = 0.;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
454 }
8683
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
455 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
456 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
457 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
458
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
459 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
460 have_sigma = true;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
461 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
462 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
463 error ("eigs: SIGMA must be a scalar or a string");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
464 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
465 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
466 }
8683
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
467 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
468
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
469 sigmar = std::real (sigma);
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
470 sigmai = std::imag (sigma);
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
471
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
472 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
473 {
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
474 if (args(3+arg_offset).is_map ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
475 {
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
476 octave_scalar_map map = args(3+arg_offset).scalar_map_value ();
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
477
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
478 if (! error_state)
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
479 {
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
480 octave_value tmp;
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
481
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
482 // issym is ignored for complex matrix inputs
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
483 tmp = map.getfield ("issym");
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
484 if (tmp.is_defined () && !sym_tested)
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
485 {
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
486 symmetric = tmp.double_value () != 0.;
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
487 sym_tested = true;
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
488 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
489
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
490 // isreal is ignored if A is not a function
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
491 tmp = map.getfield ("isreal");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
492 if (tmp.is_defined () && have_a_fun)
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
493 a_is_complex = ! (tmp.double_value () != 0.);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
494
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
495 tmp = map.getfield ("tol");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
496 if (tmp.is_defined ())
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
497 tol = tmp.double_value ();
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
498
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
499 tmp = map.getfield ("maxit");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
500 if (tmp.is_defined ())
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
501 maxit = tmp.nint_value ();
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
502
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
503 tmp = map.getfield ("p");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
504 if (tmp.is_defined ())
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
505 p = tmp.nint_value ();
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
506
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
507 tmp = map.getfield ("v0");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
508 if (tmp.is_defined ())
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
509 {
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
510 if (a_is_complex || b_is_complex)
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
511 cresid = ComplexColumnVector (tmp.complex_vector_value ());
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
512 else
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
513 resid = ColumnVector (tmp.vector_value ());
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
514 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
515
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
516 tmp = map.getfield ("disp");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
517 if (tmp.is_defined ())
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
518 disp = tmp.nint_value ();
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
519
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
520 tmp = map.getfield ("cholB");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
521 if (tmp.is_defined ())
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
522 cholB = tmp.double_value () != 0.;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
523
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
524 tmp = map.getfield ("permB");
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
525 if (tmp.is_defined ())
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
526 permB = ColumnVector (tmp.vector_value ()) - 1.0;
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
527 }
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
528 else
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
529 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
530 error ("eigs: OPTS argument must be a scalar structure");
11044
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
531 return retval;
757249bb4888 eigs.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
532 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
533 }
8683
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
534 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
535 {
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
536 error ("eigs: OPTS argument must be a structure");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
537 return retval;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
538 }
8683
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
539 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
540
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
541 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
542 {
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
543 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
544 return retval;
e4f89f4a7cf8 eigs.cc (Feigs): avoid warnings; style fixes; return after errors
John W. Eaton <jwe@octave.org>
parents: 8585
diff changeset
545 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
546
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
547 // Test undeclared (no issym) matrix inputs for symmetry
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
548 if (!sym_tested && !have_a_fun)
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
549 {
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
550 if (a_is_sparse)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
551 symmetric = asmm.is_symmetric ();
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
552 else
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
553 symmetric = amm.is_symmetric ();
12649
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
554 }
8579e7a6e6e0 Improve performance (2X) of svds by avoiding issymmetric calculation (bug #33073)
Rik <octave@nomad.inbox5.com>
parents: 12329
diff changeset
555
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
556 if (have_b)
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
557 {
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
558 if (a_is_complex || b_is_complex)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
559 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
560 if (a_is_sparse)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
561 bscm = args(b_arg).sparse_complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
562 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
563 bcm = args(b_arg).complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
564 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
565 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
566 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
567 if (a_is_sparse)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
568 bsmm = args(b_arg).sparse_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
569 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
570 bmm = args(b_arg).matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
571 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
572 }
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
573
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
574 // Mode 1 for SM mode seems unstable for some reason.
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
575 // Use Mode 3 instead, with sigma = 0.
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
576 if (!error_state && !have_sigma && typ == "SM")
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
577 have_sigma = true;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
578
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
579 if (!error_state)
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
580 {
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
581 octave_idx_type nconv;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
582 if (a_is_complex || b_is_complex)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
583 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
584 ComplexMatrix eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
585 ComplexColumnVector eig_val;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
586
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
587
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
588 if (have_a_fun)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
589 nconv = EigsComplexNonSymmetricFunc
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
590 (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
591 cresid, octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
592 else if (have_sigma)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
593 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
594 if (a_is_sparse)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
595 nconv = EigsComplexNonSymmetricMatrixShift
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
596 (ascm, sigma, k, p, info, eig_vec, eig_val, bscm, permB,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
597 cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
598 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
599 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
600 nconv = EigsComplexNonSymmetricMatrixShift
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
601 (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
602 octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
603 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
604 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
605 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
606 if (a_is_sparse)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
607 nconv = EigsComplexNonSymmetricMatrix
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
608 (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
609 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 nconv = EigsComplexNonSymmetricMatrix
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
612 (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
613 octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
614 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
615
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
616 if (nargout < 2)
14844
5bc9b9cb4362 maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
617 retval(0) = eig_val;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
618 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
619 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
620 retval(2) = double (info);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
621 retval(1) = ComplexDiagMatrix (eig_val);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
622 retval(0) = eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
623 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
624 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
625 else if (sigmai != 0.)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
626 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
627 // Promote real problem to a complex one.
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
628 ComplexMatrix eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
629 ComplexColumnVector eig_val;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
630
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
631 if (have_a_fun)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
632 nconv = EigsComplexNonSymmetricFunc
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
633 (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
634 cresid, octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
635 else
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 if (a_is_sparse)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
638 nconv = EigsComplexNonSymmetricMatrixShift
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
639 (SparseComplexMatrix (asmm), sigma, k, p, info, eig_vec,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
640 eig_val, SparseComplexMatrix (bsmm), permB, cresid,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
641 octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
642 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
643 nconv = EigsComplexNonSymmetricMatrixShift
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
644 (ComplexMatrix (amm), sigma, k, p, info, eig_vec,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
645 eig_val, ComplexMatrix (bmm), permB, cresid,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
646 octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
647 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
648
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
649 if (nargout < 2)
14844
5bc9b9cb4362 maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
650 retval(0) = eig_val;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
651 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
652 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
653 retval(2) = double (info);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
654 retval(1) = ComplexDiagMatrix (eig_val);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
655 retval(0) = eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
656 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
657 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
658 else
10154
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 (symmetric)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
661 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
662 Matrix eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
663 ColumnVector eig_val;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
664
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
665 if (have_a_fun)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
666 nconv = EigsRealSymmetricFunc
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
667 (eigs_func, n, typ, sigmar, k, p, info, eig_vec, eig_val,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
668 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
10154
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 else if (have_sigma)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
671 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
672 if (a_is_sparse)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
673 nconv = EigsRealSymmetricMatrixShift
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
674 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm, permB,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
675 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
676 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
677 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
678 nconv = EigsRealSymmetricMatrixShift
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
679 (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
680 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
681 maxit);
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 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
684 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
685 if (a_is_sparse)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
686 nconv = EigsRealSymmetricMatrix
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
687 (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
688 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
689 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
690 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
691 nconv = EigsRealSymmetricMatrix
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
692 (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
693 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
694 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
695 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
696
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
697 if (nargout < 2)
14844
5bc9b9cb4362 maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
698 retval(0) = eig_val;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
699 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
700 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
701 retval(2) = double (info);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
702 retval(1) = DiagMatrix (eig_val);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
703 retval(0) = eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
704 }
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 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
707 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
708 ComplexMatrix eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
709 ComplexColumnVector eig_val;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
710
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
711 if (have_a_fun)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
712 nconv = EigsRealNonSymmetricFunc
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
713 (eigs_func, n, typ, sigmar, k, p, info, eig_vec, eig_val,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
714 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
10154
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 else if (have_sigma)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
717 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
718 if (a_is_sparse)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
719 nconv = EigsRealNonSymmetricMatrixShift
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
720 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm, permB,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
721 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
722 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
723 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
724 nconv = EigsRealNonSymmetricMatrixShift
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
725 (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
726 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
727 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
728 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
729 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
730 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
731 if (a_is_sparse)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
732 nconv = EigsRealNonSymmetricMatrix
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
733 (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
734 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
735 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
736 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
737 nconv = EigsRealNonSymmetricMatrix
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
738 (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
739 resid, octave_stdout, tol, (nargout > 1), cholB, disp,
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
740 maxit);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
741 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
742
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
743 if (nargout < 2)
14844
5bc9b9cb4362 maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents: 14501
diff changeset
744 retval(0) = eig_val;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
745 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
746 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
747 retval(2) = double (info);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
748 retval(1) = ComplexDiagMatrix (eig_val);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
749 retval(0) = eig_vec;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
750 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
751 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
752 }
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
753
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
754 if (nconv <= 0)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
755 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
756 else if (nconv < k)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
757 warning ("eigs: Only %d of the %d requested eigenvalues converged",
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
758 nconv, k);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
759 }
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
760
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
761 if (! fcn_name.empty ())
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
762 clear_function (fcn_name);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
763 #else
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
764 error ("eigs: not available in this version of Octave");
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
765 #endif
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
766
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
767 return retval;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
768 }
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
769
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
770 /* #### SPARSE MATRIX VERSIONS #### */
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
771
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
772 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
773 ## Real positive definite tests, n must be even
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
774 %!shared n, k, A, d0, d2
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
775 %! n = 20;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
776 %! k = 4;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
777 %! 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)]);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
778 %! d0 = eig (A);
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
779 %! d2 = sort (d0);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
780 %! [~, idx] = sort (abs (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
781 %! d0 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
782 %! rand ("state", 42); # initialize generator to make eigs behavior reproducible
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
783 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
784 %! d1 = eigs (A, k);
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
785 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
786 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
787 %! d1 = eigs (A, k+1);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
788 %! assert (d1, d0(end:-1:(end-k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
789 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
790 %! d1 = eigs (A, k, "lm");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
791 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
792 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
793 %! d1 = eigs (A, k, "sm");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
794 %! assert (d1, d0(k:-1:1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
795 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
796 %! d1 = eigs (A, k, "la");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
797 %! assert (d1, d2(end:-1:(end-k+1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
798 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
799 %! d1 = eigs (A, k, "sa");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
800 %! assert (d1, d2(1:k), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
801 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
802 %! d1 = eigs (A, k, "be");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
803 %! assert (d1, d2([1:floor(k/2), (end - ceil(k/2) + 1):end]), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
804 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
805 %! d1 = eigs (A, k+1, "be");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
806 %! assert (d1, d2([1:floor((k+1)/2), (end - ceil((k+1)/2) + 1):end]), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
807 %!testif HAVE_ARPACK, HAVE_UMFPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
808 %! d1 = eigs (A, k, 4.1);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
809 %! [~, idx0] = sort (abs (d0 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
810 %! [~, idx1] = sort (abs (d1 - 4.1));
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
811 %! assert (d1(idx1), d0(idx0(1:k)), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
812 %!testif HAVE_ARPACK, HAVE_CHOLMOD
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
813 %! d1 = eigs (A, speye (n), k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
814 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
815 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
816 %! assert (eigs (A, k, 4.1), eigs (A, speye (n), k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
817 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
818 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
819 %! d1 = eigs (A, speye (n), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
820 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
821 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
822 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
823 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
824 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
825 %! d1 = eigs (A, speye (n)(q,q), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
826 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
827 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
828 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
829 %! d1 = eigs (A, speye (n), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
830 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
831 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
832 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
833 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
834 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
835 %! d1 = eigs (A, speye (n)(q,q), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
836 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
837 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
838 %! assert (eigs (A, k, 4.1), eigs (A, speye (n), k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
839 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
840 %! fn = @(x) A * x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
841 %! opts.issym = 1; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
842 %! d1 = eigs (fn, n, k, "lm", opts);
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
843 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
844 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
845 %! fn = @(x) A \ x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
846 %! opts.issym = 1; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
847 %! d1 = eigs (fn, n, k, "sm", opts);
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
848 %! assert (d1, d0(k:-1:1), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
849 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
850 %! fn = @(x) (A - 4.1 * eye (n)) \ x;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
851 %! opts.issym = 1; opts.isreal = 1;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
852 %! d1 = eigs (fn, n, k, 4.1, opts);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
853 %! assert (d1, eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
854 %!testif HAVE_ARPACK
9593
cf8403208c43 Fix nesting error in options parsing of eigs
David Bateman <dbateman@free.fr>
parents: 9377
diff changeset
855 %! AA = speye (10);
9597
a32f70d8d146 Minor typo in new eigs.cc test
David Bateman <dbateman@free.fr>
parents: 9593
diff changeset
856 %! fn = @(x) AA * x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
857 %! opts.issym = 1; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
858 %! assert (eigs (fn, 10, AA, 3, "lm", opts), [1; 1; 1], 10*eps);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
859 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
860 %! [v1,d1] = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
861 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
862 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
863 %! 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
864 %! endfor
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
865 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
866 %! [v1,d1] = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
867 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
868 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
869 %! 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
870 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
871 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
872 %! [v1,d1] = eigs (A, k, "la");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
873 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
874 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
875 %! 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
876 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
877 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
878 %! [v1,d1] = eigs (A, k, "sa");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
879 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
880 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
881 %! 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
882 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
883 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
884 %! [v1,d1] = eigs (A, k, "be");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
885 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
886 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
887 %! 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
888 %! endfor
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
889 */
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
890
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
891 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
892 ## Real unsymmetric tests
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
893 %!shared n, k, A, d0
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
894 %! n = 20;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
895 %! k = 4;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
896 %! 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)]);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
897 %! d0 = eig (A);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
898 %! [~, idx] = sort (abs (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
899 %! d0 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
900 %! rand ("state", 42); % initialize generator to make eigs behavior reproducible
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
901 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
902 %! d1 = eigs (A, k);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
903 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
904 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
905 %! d1 = eigs (A, k+1);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
906 %! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
907 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
908 %! d1 = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
909 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
910 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
911 %! d1 = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
912 %! assert (abs (d1), abs (d0(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
913 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
914 %! d1 = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
915 %! [~, idx] = sort (real (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
916 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
917 %! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
918 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
919 %! d1 = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
920 %! [~, idx] = sort (real (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
921 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
922 %! assert (real (d1), real (d2(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
923 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
924 %! d1 = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
925 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
926 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
927 %! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
928 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
929 %! d1 = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
930 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
931 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
932 %! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
933 %!testif HAVE_ARPACK, HAVE_UMFPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
934 %! d1 = eigs (A, k, 4.1);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
935 %! [~, idx0] = sort (abs (d0 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
936 %! [~, idx1] = sort (abs (d1 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
937 %! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
938 %! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
939 %!testif HAVE_ARPACK, HAVE_CHOLMOD
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
940 %! d1 = eigs (A, speye (n), k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
941 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
942 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
943 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
944 %! d1 = eigs (A, speye (n), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
945 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
946 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
947 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
948 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
949 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
950 %! d1 = eigs (A, speye (n)(q,q), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
951 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
952 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
953 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
954 %! d1 = eigs (A, speye (n), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
955 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
956 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
957 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
958 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
959 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
960 %! d1 = eigs (A, speye (n)(q,q), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
961 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
962 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
963 %! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, speye (n), k, 4.1)), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
964 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
965 %! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, speye (n), k, 4.1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
966 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
967 %! fn = @(x) A * x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
968 %! opts.issym = 0; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
969 %! d1 = eigs (fn, n, k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
970 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
971 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
972 %! fn = @(x) A \ x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
973 %! opts.issym = 0; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
974 %! d1 = eigs (fn, n, k, "sm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
975 %! assert (abs (d1), d0(1:k), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
976 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
977 %! fn = @(x) (A - 4.1 * eye (n)) \ x;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
978 %! opts.issym = 0; opts.isreal = 1;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
979 %! d1 = eigs (fn, n, k, 4.1, opts);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
980 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
981 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
982 %! [v1,d1] = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
983 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
984 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
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
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
987 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
988 %! [v1,d1] = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
989 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
990 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
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
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
993 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
994 %! [v1,d1] = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
995 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
996 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
997 %! 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
998 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
999 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1000 %! [v1,d1] = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1001 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1002 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1003 %! 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
1004 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1005 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1006 %! [v1,d1] = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1007 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1008 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1009 %! 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
1010 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1011 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1012 %! [v1,d1] = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1013 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1014 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1015 %! 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
1016 %! endfor
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1017 */
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1018
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1019 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1020 ## Complex hermitian tests
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1021 %!shared n, k, A, d0
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1022 %! n = 20;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1023 %! k = 4;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1024 %! 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)]);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1025 %! d0 = eig (A);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1026 %! [~, idx] = sort (abs (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1027 %! d0 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1028 %! rand ("state", 42); % initialize generator to make eigs behavior reproducible
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1029 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1030 %! d1 = eigs (A, k);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1031 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1032 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1033 %! d1 = eigs (A, k+1);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1034 %! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1035 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1036 %! d1 = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1037 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1038 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1039 %! d1 = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1040 %! assert (abs (d1), abs (d0(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1041 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1042 %! d1 = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1043 %! [~, idx] = sort (real (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1044 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1045 %! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1046 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1047 %! d1 = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1048 %! [~, idx] = sort (real (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1049 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1050 %! assert (real (d1), real (d2(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1051 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1052 %! d1 = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1053 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1054 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1055 %! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1056 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1057 %! d1 = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1058 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1059 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1060 %! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1061 %!testif HAVE_ARPACK, HAVE_UMFPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1062 %! d1 = eigs (A, k, 4.1);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1063 %! [~, idx0] = sort (abs (d0 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1064 %! [~, idx1] = sort (abs (d1 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1065 %! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1066 %! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1067 %!testif HAVE_ARPACK, HAVE_CHOLMOD
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1068 %! d1 = eigs (A, speye (n), k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1069 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1070 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1071 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1072 %! d1 = eigs (A, speye (n), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1073 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1074 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1075 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1076 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1077 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1078 %! d1 = eigs (A, speye (n)(q,q), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1079 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1080 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1081 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1082 %! d1 = eigs (A, speye (n), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1083 %! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1084 %! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1085 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1086 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1087 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1088 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1089 %! d1 = eigs (A, speye (n)(q,q), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1090 %! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1091 %! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1092 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1093 %! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, speye (n), k, 4.1)), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1094 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1095 %! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, speye (n), k, 4.1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1096 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1097 %! fn = @(x) A * x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1098 %! opts.issym = 0; opts.isreal = 0;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1099 %! d1 = eigs (fn, n, k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1100 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1101 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1102 %! fn = @(x) A \ x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1103 %! opts.issym = 0; opts.isreal = 0;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1104 %! d1 = eigs (fn, n, k, "sm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1105 %! assert (abs (d1), d0(1:k), 1e-11);
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1106 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1107 %! fn = @(x) (A - 4.1 * eye (n)) \ x;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1108 %! opts.issym = 0; opts.isreal = 0;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1109 %! d1 = eigs (fn, n, k, 4.1, opts);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1110 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1111 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1112 %! [v1,d1] = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1113 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1114 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1115 %! 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
1116 %! endfor
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14144
diff changeset
1117 %!testif HAVE_ARPACK, HAVE_UMFPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1118 %! [v1,d1] = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1119 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1120 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1121 %! 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
1122 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1123 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1124 %! [v1,d1] = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1125 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1126 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1127 %! 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
1128 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1129 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1130 %! [v1,d1] = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1131 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1132 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1133 %! 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
1134 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1135 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1136 %! [v1,d1] = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1137 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1138 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1139 %! 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
1140 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1141 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1142 %! [v1,d1] = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1143 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1144 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1145 %! 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
1146 %! endfor
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1147 */
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1148
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1149 /* #### FULL MATRIX VERSIONS #### */
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1150
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1151 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1152 ## Real positive definite tests, n must be even
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1153 %!shared n, k, A, d0, d2
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1154 %! n = 20;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1155 %! k = 4;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1156 %! 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)]));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1157 %! d0 = eig (A);
10667
6769fbfec739 eigs.cc: Improve documentation string.
Rik <octave@nomad.inbox5.com>
parents: 10155
diff changeset
1158 %! d2 = sort (d0);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1159 %! [~, idx] = sort (abs (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1160 %! d0 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1161 %! rand ("state", 42); % initialize generator to make eigs behavior reproducible
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1162 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1163 %! d1 = eigs (A, k);
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1164 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1165 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1166 %! d1 = eigs (A, k+1);
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1167 %! assert (d1, d0(end:-1:(end-k)),1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1168 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1169 %! d1 = eigs (A, k, "lm");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1170 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1171 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1172 %! d1 = eigs (A, k, "sm");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1173 %! assert (d1, d0(k:-1:1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1174 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1175 %! d1 = eigs (A, k, "la");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1176 %! assert (d1, d2(end:-1:(end-k+1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1177 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1178 %! d1 = eigs (A, k, "sa");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1179 %! assert (d1, d2(1:k), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1180 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1181 %! d1 = eigs (A, k, "be");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1182 %! assert (d1, d2([1:floor(k/2), (end - ceil(k/2) + 1):end]), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1183 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1184 %! d1 = eigs (A, k+1, "be");
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1185 %! assert (d1, d2([1:floor((k+1)/2), (end - ceil((k+1)/2) + 1):end]), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1186 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1187 %! d1 = eigs (A, k, 4.1);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1188 %! [~, idx0] = sort (abs (d0 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1189 %! [~, idx1] = sort (abs (d1 - 4.1));
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1190 %! assert (d1(idx1), d0(idx0(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1191 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1192 %! d1 = eigs (A, eye (n), k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1193 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1194 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1195 %! assert (eigs (A, k, 4.1), eigs (A, eye (n), k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1196 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1197 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1198 %! d1 = eigs (A, eye (n), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1199 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1200 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1201 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1202 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1203 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1204 %! d1 = eigs (A, eye (n)(q,q), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1205 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1206 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1207 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1208 %! d1 = eigs (A, eye (n), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1209 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1210 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1211 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1212 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1213 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1214 %! d1 = eigs (A, eye (n)(q,q), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1215 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1216 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1217 %! assert (eigs (A, k, 4.1), eigs (A, eye (n), k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1218 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1219 %! fn = @(x) A * x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1220 %! opts.issym = 1; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1221 %! d1 = eigs (fn, n, k, "lm", opts);
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1222 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1223 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1224 %! fn = @(x) A \ x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1225 %! opts.issym = 1; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1226 %! d1 = eigs (fn, n, k, "sm", opts);
8702
3c4628550318 eigs.cc: increase tolerance
John W. Eaton <jwe@octave.org>
parents: 8683
diff changeset
1227 %! assert (d1, d0(k:-1:1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1228 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1229 %! fn = @(x) (A - 4.1 * eye (n)) \ x;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1230 %! opts.issym = 1; opts.isreal = 1;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1231 %! d1 = eigs (fn, n, k, 4.1, opts);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1232 %! assert (d1, eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1233 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1234 %! [v1,d1] = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1235 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1236 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1237 %! 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
1238 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1239 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1240 %! [v1,d1] = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1241 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1242 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1243 %! 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
1244 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1245 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1246 %! [v1,d1] = eigs (A, k, "la");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1247 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1248 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1249 %! 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
1250 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1251 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1252 %! [v1,d1] = eigs (A, k, "sa");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1253 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1254 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1255 %! 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
1256 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1257 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1258 %! [v1,d1] = eigs (A, k, "be");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1259 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1260 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1261 %! 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
1262 %! endfor
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1263 */
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1264
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1265 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1266 ## Real unsymmetric tests
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1267 %!shared n, k, A, d0
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1268 %! n = 20;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1269 %! k = 4;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1270 %! 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)]));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1271 %! d0 = eig (A);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1272 %! [~, idx] = sort (abs (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1273 %! d0 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1274 %! rand ("state", 42); % initialize generator to make eigs behavior reproducible
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1275 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1276 %! d1 = eigs (A, k);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1277 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1278 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1279 %! d1 = eigs (A, k+1);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1280 %! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1281 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1282 %! d1 = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1283 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1284 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1285 %! d1 = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1286 %! assert (abs (d1), abs (d0(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1287 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1288 %! d1 = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1289 %! [~, idx] = sort (real (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1290 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1291 %! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1292 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1293 %! d1 = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1294 %! [~, idx] = sort (real (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1295 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1296 %! assert (real (d1), real (d2(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1297 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1298 %! d1 = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1299 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1300 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1301 %! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1302 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1303 %! d1 = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1304 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1305 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1306 %! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1307 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1308 %! d1 = eigs (A, k, 4.1);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1309 %! [~, idx0] = sort (abs (d0 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1310 %! [~, idx1] = sort (abs (d1 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1311 %! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1312 %! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1313 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1314 %! d1 = eigs (A, eye (n), k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1315 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1316 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1317 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1318 %! d1 = eigs (A, eye (n), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1319 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1320 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1321 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1322 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1323 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1324 %! d1 = eigs (A, eye (n)(q,q), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1325 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1326 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1327 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1328 %! d1 = eigs (A, eye (n), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1329 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1330 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1331 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1332 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1333 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1334 %! d1 = eigs (A, eye (n)(q,q), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1335 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1336 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1337 %! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, eye (n), k, 4.1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1338 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1339 %! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, eye (n), k, 4.1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1340 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1341 %! fn = @(x) A * x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1342 %! opts.issym = 0; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1343 %! d1 = eigs (fn, n, k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1344 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1345 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1346 %! fn = @(x) A \ x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1347 %! opts.issym = 0; opts.isreal = 1;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1348 %! d1 = eigs (fn, n, k, "sm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1349 %! assert (abs (d1), d0(1:k), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1350 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1351 %! fn = @(x) (A - 4.1 * eye (n)) \ x;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1352 %! opts.issym = 0; opts.isreal = 1;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1353 %! d1 = eigs (fn, n, k, 4.1, opts);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1354 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1355 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1356 %! [v1,d1] = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1357 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1358 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1359 %! 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
1360 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1361 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1362 %! [v1,d1] = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1363 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1364 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1365 %! 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
1366 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1367 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1368 %! [v1,d1] = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1369 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1370 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1371 %! 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
1372 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1373 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1374 %! [v1,d1] = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1375 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1376 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1377 %! 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
1378 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1379 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1380 %! [v1,d1] = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1381 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1382 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1383 %! 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
1384 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1385 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1386 %! [v1,d1] = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1387 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1388 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1389 %! 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
1390 %! endfor
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1391 */
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1392
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1393 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1394 ## Complex hermitian tests
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1395 %!shared n, k, A, d0
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1396 %! n = 20;
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1397 %! k = 4;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1398 %! 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)]));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1399 %! d0 = eig (A);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1400 %! [~, idx] = sort (abs (d0));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1401 %! d0 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1402 %! rand ("state", 42); % initialize generator to make eigs behavior reproducible
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1403 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1404 %! d1 = eigs (A, k);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1405 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1406 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1407 %! d1 = eigs (A, k+1);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1408 %! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1409 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1410 %! d1 = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1411 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1412 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1413 %! d1 = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1414 %! assert (abs (d1), abs (d0(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1415 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1416 %! d1 = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1417 %! [~, idx] = sort (real (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1418 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1419 %! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1420 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1421 %! d1 = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1422 %! [~, idx] = sort (real (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1423 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1424 %! assert (real (d1), real (d2(1:k)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1425 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1426 %! d1 = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1427 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1428 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1429 %! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1430 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1431 %! d1 = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1432 %! [~, idx] = sort (imag (abs (d0)));
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1433 %! d2 = d0(idx);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1434 %! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1435 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1436 %! d1 = eigs (A, k, 4.1);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1437 %! [~, idx0] = sort (abs (d0 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1438 %! [~, idx1] = sort (abs (d1 - 4.1));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1439 %! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1440 %! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1441 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1442 %! d1 = eigs (A, eye (n), k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1443 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1444 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1445 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1446 %! d1 = eigs (A, eye (n), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1447 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1448 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1449 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1450 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1451 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1452 %! d1 = eigs (A, eye (n)(q,q), k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1453 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1454 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1455 %! opts.cholB = true;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1456 %! d1 = eigs (A, eye (n), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1457 %! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1458 %! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1459 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1460 %! opts.cholB = true;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1461 %! q = [2:n,1];
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1462 %! opts.permB = q;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1463 %! d1 = eigs (A, eye (n)(q,q), k, 4.1, opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1464 %! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1465 %! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1466 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1467 %! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, eye (n), k, 4.1)), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1468 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1469 %! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, eye (n), k, 4.1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1470 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1471 %! fn = @(x) A * x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1472 %! opts.issym = 0; opts.isreal = 0;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1473 %! d1 = eigs (fn, n, k, "lm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1474 %! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1475 %!testif HAVE_ARPACK
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1476 %! fn = @(x) A \ x;
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1477 %! opts.issym = 0; opts.isreal = 0;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1478 %! d1 = eigs (fn, n, k, "sm", opts);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1479 %! assert (abs (d1), d0(1:k), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1480 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1481 %! fn = @(x) (A - 4.1 * eye (n)) \ x;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1482 %! opts.issym = 0; opts.isreal = 0;
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1483 %! d1 = eigs (fn, n, k, 4.1, opts);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1484 %! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1485 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1486 %! [v1,d1] = eigs (A, k, "lm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1487 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1488 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1489 %! 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
1490 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1491 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1492 %! [v1,d1] = eigs (A, k, "sm");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1493 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1494 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1495 %! 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
1496 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1497 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1498 %! [v1,d1] = eigs (A, k, "lr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1499 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1500 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1501 %! 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
1502 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1503 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1504 %! [v1,d1] = eigs (A, k, "sr");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1505 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1506 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1507 %! 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
1508 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1509 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1510 %! [v1,d1] = eigs (A, k, "li");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1511 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1512 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1513 %! 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
1514 %! endfor
14144
834df9f10963 remove ARPACK files from sources and restore configure checks for external ARPACK library
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1515 %!testif HAVE_ARPACK
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1516 %! [v1,d1] = eigs (A, k, "si");
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1517 %! d1 = diag (d1);
8417
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1518 %! for i=1:k
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14361
diff changeset
1519 %! 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
1520 %! endfor
654bcfb937bf Add the eigs and svds functions
David Bateman <dbateman@free.fr>
parents:
diff changeset
1521 */