Mercurial > octave
annotate libinterp/corefcn/eig.cc @ 23565:3a730821e4a2
doc: Peridoc grammarcheck of documentation.
* container.txi, external.txi, install.txi, oop.txi, plot.txi, testfun.txi,
eig.cc, graphics.cc, gsvd.cc, hex2num.cc, pr-output.cc, sub2ind.cc,
__ode15__.cc, Map.m, __publish_html_output__.m, __publish_latex_output__.m,
odeset.m, ode_event_handler.m, runge_kutta_45_dorpri.m, xlim.m, ylim.m, zlim.m,
hgtransform.m, eigs.m, native2unicode.m, unicode2native.m:
grammarcheck documentation.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 08 Jun 2017 17:41:32 -0700 |
parents | 855122b993da |
children | 80c42f4cca13 |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
4 Copyright (C) 2016 Barbara Lócsi |
2928 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
11 (at your option) any later version. |
2928 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 GNU General Public License for more details. |
2928 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2928 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
25 # include "config.h" |
2928 | 26 #endif |
27 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14885
diff
changeset
|
28 #include "defun.h" |
2928 | 29 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
30 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20918
diff
changeset
|
31 #include "ovl.h" |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
32 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
33 #include "EIG.h" |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
34 #include "fEIG.h" |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
35 #include "oct-string.h" |
2928 | 36 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14885
diff
changeset
|
37 DEFUN (eig, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
38 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
39 @deftypefn {} {@var{lambda} =} eig (@var{A}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
40 @deftypefnx {} {@var{lambda} =} eig (@var{A}, @var{B}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
41 @deftypefnx {} {[@var{V}, @var{lambda}] =} eig (@var{A}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
42 @deftypefnx {} {[@var{V}, @var{lambda}] =} eig (@var{A}, @var{B}) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
43 @deftypefnx {} {[@var{V}, @var{lambda}, @var{W}] =} eig (@var{A}) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
44 @deftypefnx {} {[@var{V}, @var{lambda}, @var{W}] =} eig (@var{A}, @var{B}) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
45 @deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{balanceOption}) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
46 @deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{B}, @var{algorithm}) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
47 @deftypefnx {} {[@dots{}] =} eig (@dots{}, @var{eigvalOption}) |
23290
0cf53cd75e13
doc: Fix eig output argument description (bug #50524).
Victor Norton <vic@norton.name>
parents:
23219
diff
changeset
|
48 Compute the eigenvalues (@var{lambda}) and optionally the right eigenvectors |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
49 (@var{V}) and the left eigenvectors (@var{W}) of a matrix or pair of matrices. |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
50 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
51 The flag @var{balanceOption} can be one of: |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
52 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
53 @table @asis |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
54 @item @qcode{"balance"} (default) |
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
55 Preliminary balancing is on. |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
56 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
57 @item @qcode{"nobalance"} |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
58 Disables preliminary balancing. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
59 @end table |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
60 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
61 The flag @var{eigvalOption} can be one of: |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
62 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
63 @table @asis |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
64 @item @qcode{"matrix"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
65 Return the eigenvalues in a diagonal matrix. (default if 2 or 3 outputs |
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
66 are requested) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
67 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
68 @item @qcode{"vector"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
69 Return the eigenvalues in a column vector. (default if only 1 output is |
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
70 requested, e.g., @var{lambda} = eig (@var{A})) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
71 @end table |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
72 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
73 The flag @var{algorithm} can be one of: |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
74 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
75 @table @asis |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
76 @item @qcode{"chol"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
77 Use the Cholesky factorization of B. (default if @var{A} is symmetric |
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
78 (Hermitian) and @var{B} is symmetric (Hermitian) positive definite) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
79 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
80 @item @qcode{"qz"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
81 Use the QZ algorithm. (used whenever @var{A} or @var{B} are not symmetric) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
82 @end table |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
83 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
84 @multitable @columnfractions .31 .23 .23 .23 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
85 @headitem @tab no flag @tab chol @tab qz |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
86 @item both are symmetric |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
87 @tab @qcode{"chol"} |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
88 @tab @qcode{"chol"} |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
89 @tab @qcode{"qz"} |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
90 @item at least one is not symmetric |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
91 @tab @qcode{"qz"} |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
92 @tab @qcode{"qz"} |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
93 @tab @qcode{"qz"} |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
94 @end multitable |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
95 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
96 The eigenvalues returned by @code{eig} are not ordered. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
97 @seealso{eigs, svd} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
98 @end deftypefn */) |
2928 | 99 { |
100 int nargin = args.length (); | |
101 | |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
102 if (nargin > 4 || nargin == 0) |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
103 print_usage (); |
2928 | 104 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
105 octave_value_list retval; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
106 |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
107 octave_value arg_a, arg_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
108 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
109 arg_a = args(0); |
2928 | 110 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
111 if (arg_a.is_empty ()) |
2928 | 112 return octave_value_list (2, Matrix ()); |
113 | |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
114 if (! arg_a.is_float_type ()) |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21110
diff
changeset
|
115 err_wrong_type_arg ("eig", arg_a); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
116 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
117 if (arg_a.rows () != arg_a.columns ()) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
118 err_square_matrix_required ("eig", "A"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
119 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
120 // determine if it's AEP or GEP |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
121 bool AEPcase = nargin == 1 || args(1).is_string (); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
122 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
123 if (! AEPcase) |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
124 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
125 arg_b = args(1); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
126 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
127 if (arg_b.is_empty ()) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
128 return octave_value_list (2, Matrix ()); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
129 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
130 if (! arg_b.is_float_type ()) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
131 err_wrong_type_arg ("eig", arg_b); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
132 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
133 if (arg_b.rows () != arg_b.columns ()) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
134 err_square_matrix_required ("eig", "B"); |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
135 } |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
136 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
137 bool qz_flag = false; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
138 bool chol_flag = false; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
139 bool balance_flag = false; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
140 bool no_balance_flag = false; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
141 bool matrix_flag = false; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
142 bool vector_flag = false; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
143 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
144 for (int i = (AEPcase ? 1 : 2); i < args.length (); ++i) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
145 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
146 if (! args(i).is_string ()) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
147 err_wrong_type_arg ("eig", args(i)); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
148 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
149 std::string arg_i = args(i).string_value (); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
150 if (octave::string::strcmpi (arg_i, "qz")) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
151 qz_flag = true; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
152 else if (octave::string::strcmpi (arg_i, "chol")) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
153 chol_flag = true; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
154 else if (octave::string::strcmpi (arg_i, "balance")) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
155 balance_flag = true; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
156 else if (octave::string::strcmpi (arg_i, "nobalance")) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
157 no_balance_flag = true; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
158 else if (octave::string::strcmpi (arg_i, "matrix")) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
159 matrix_flag = true; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
160 else if (octave::string::strcmpi (arg_i, "vector")) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
161 vector_flag = true; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
162 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
163 error ("eig: invalid option \"%s\"", arg_i.c_str ()); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
164 } |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
165 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
166 if (balance_flag && no_balance_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
167 error ("eig: \"balance\" and \"nobalance\" options are mutually exclusive"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
168 if (vector_flag && matrix_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
169 error ("eig: \"vector\" and \"matrix\" options are mutually exclusive"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
170 if (qz_flag && chol_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
171 error ("eig: \"qz\" and \"chol\" options are mutually exclusive"); |
2928 | 172 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
173 if (AEPcase) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
174 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
175 if (qz_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
176 error ("eig: invalid \"qz\" option for algebraic eigenvalue problem"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
177 if (chol_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
178 error ("eig: invalid \"chol\" option for algebraic eigenvalue problem"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
179 } |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
180 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
181 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
182 if (balance_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
183 error ("eig: invalid \"balance\" option for generalized eigenvalue problem"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
184 if (no_balance_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
185 error ("eig: invalid \"nobalance\" option for generalized eigenvalue problem"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
186 } |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
187 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
188 // Default is to balance |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23293
diff
changeset
|
189 const bool balance = (no_balance_flag ? false : true); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
190 const bool force_qz = qz_flag; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
191 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
192 |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
193 Matrix tmp_a, tmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
194 ComplexMatrix ctmp_a, ctmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
195 FloatMatrix ftmp_a, ftmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
196 FloatComplexMatrix fctmp_a, fctmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
197 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
198 if (arg_a.is_single_type ()) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
199 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
200 FloatEIG result; |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
201 if (AEPcase) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
202 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
203 if (arg_a.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
204 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
205 ftmp_a = arg_a.float_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
206 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
207 result = FloatEIG (ftmp_a, nargout > 1, nargout > 2, balance); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
208 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
209 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
210 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
211 fctmp_a = arg_a.float_complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
212 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
213 result = FloatEIG (fctmp_a, nargout > 1, nargout > 2, balance); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
214 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
215 } |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
216 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
217 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
218 if (arg_a.is_real_type () && arg_b.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
219 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
220 ftmp_a = arg_a.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
221 ftmp_b = arg_b.float_matrix_value (); |
2928 | 222 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
223 result = FloatEIG (ftmp_a, ftmp_b, nargout > 1, nargout > 2, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
224 force_qz); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
225 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
226 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
227 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
228 fctmp_a = arg_a.float_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
229 fctmp_b = arg_b.float_complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
230 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
231 result = FloatEIG (fctmp_a, fctmp_b, nargout > 1, nargout > 2, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
232 force_qz); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
233 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
234 } |
2928 | 235 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
236 if (nargout == 0 || nargout == 1) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
237 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
238 if (matrix_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
239 retval = ovl (FloatComplexDiagMatrix (result.eigenvalues ())); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
240 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
241 retval = ovl (result.eigenvalues ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
242 } |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
243 else if (nargout == 2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
244 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
245 if (vector_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
246 retval = ovl (result.right_eigenvectors (), result.eigenvalues ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
247 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
248 retval = ovl (result.right_eigenvectors (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
249 FloatComplexDiagMatrix (result.eigenvalues ())); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
250 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
251 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
252 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
253 if (vector_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
254 retval = ovl (result.right_eigenvectors (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
255 result.eigenvalues (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
256 result.left_eigenvectors ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
257 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
258 retval = ovl (result.right_eigenvectors (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
259 FloatComplexDiagMatrix (result.eigenvalues ()), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
260 result.left_eigenvectors ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
261 } |
2928 | 262 } |
263 else | |
264 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
265 EIG result; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
266 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
267 if (AEPcase) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
268 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
269 if (arg_a.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
270 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
271 tmp_a = arg_a.matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
272 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
273 result = EIG (tmp_a, nargout > 1, nargout > 2, balance); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
274 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
275 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
276 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
277 ctmp_a = arg_a.complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
278 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
279 result = EIG (ctmp_a, nargout > 1, nargout > 2, balance); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
280 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
281 } |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
282 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
283 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
284 if (arg_a.is_real_type () && arg_b.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
285 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
286 tmp_a = arg_a.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
287 tmp_b = arg_b.matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
288 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
289 result = EIG (tmp_a, tmp_b, nargout > 1, nargout > 2, force_qz); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
290 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
291 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
292 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
293 ctmp_a = arg_a.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
294 ctmp_b = arg_b.complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
295 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
296 result = EIG (ctmp_a, ctmp_b, nargout > 1, nargout > 2, force_qz); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
297 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
298 } |
2928 | 299 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
300 if (nargout == 0 || nargout == 1) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
301 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
302 if (matrix_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
303 retval = ovl (ComplexDiagMatrix (result.eigenvalues ())); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
304 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
305 retval = ovl (result.eigenvalues ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
306 } |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
307 else if (nargout == 2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
308 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
309 if (vector_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
310 retval = ovl (result.right_eigenvectors (), result.eigenvalues ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
311 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
312 retval = ovl (result.right_eigenvectors (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
313 ComplexDiagMatrix (result.eigenvalues ())); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
314 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
315 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
316 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
317 if (vector_flag) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
318 retval = ovl (result.right_eigenvectors (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
319 result.eigenvalues (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
320 result.left_eigenvectors ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
321 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
322 retval = ovl (result.right_eigenvectors (), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
323 ComplexDiagMatrix (result.eigenvalues ()), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
324 result.left_eigenvectors ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
325 } |
2928 | 326 } |
327 | |
328 return retval; | |
329 } | |
330 | |
331 /* | |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
332 %!assert (eig ([1, 2; 2, 1]), [-1; 3], sqrt (eps)) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
333 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
334 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
335 %! [v, d] = eig ([1, 2; 2, 1]); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
336 %! x = 1 / sqrt (2); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
337 %! assert (d, [-1, 0; 0, 3], sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
338 %! assert (v, [-x, x; x, x], sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
339 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
340 %!test |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
341 %! [v, d, w] = eig ([1, 2; 2, 1]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
342 %! x = 1 / sqrt (2); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
343 %! assert (w, [-x, x; x, x], sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
344 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
345 %!test |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
346 %! [v, d] = eig ([1, 2; 2, 1], "balance"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
347 %! x = 1 / sqrt (2); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
348 %! assert (d, [-1, 0; 0, 3], sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
349 %! assert (v, [-x, x; x, x], sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
350 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
351 %!test |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
352 %! [v, d, w] = eig ([1, 2; 2, 1], "balance"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
353 %! x = 1 / sqrt (2); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
354 %! assert (w, [-x, x; x, x], sqrt (eps)); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
355 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
356 %!assert (eig (single ([1, 2; 2, 1])), single ([-1; 3]), sqrt (eps ("single"))) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
357 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
358 %!assert (eig (single ([1, 2; 2, 1]), "balance"), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
359 %! single ([-1; 3]), sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
360 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
361 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
362 %! [v, d] = eig (single ([1, 2; 2, 1])); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
363 %! x = single (1 / sqrt (2)); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
364 %! assert (d, single ([-1, 0; 0, 3]), sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
365 %! assert (v, [-x, x; x, x], sqrt (eps ("single"))) |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
366 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
367 %!test |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
368 %! [v, d, w] = eig (single ([1, 2; 2, 1])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
369 %! x = single (1 / sqrt (2)); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
370 %! assert (w, [-x, x; x, x], sqrt (eps ("single"))) |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
371 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
372 %!test |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
373 %! [v, d] = eig (single ([1, 2; 2, 1]), "balance"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
374 %! x = single (1 / sqrt (2)); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
375 %! assert (d, single ([-1, 0; 0, 3]), sqrt (eps ("single"))); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
376 %! assert (v, [-x, x; x, x], sqrt (eps ("single"))) |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
377 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
378 %!test |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
379 %! [v, d, w] = eig (single ([1, 2; 2, 1]), "balance"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
380 %! x = single (1 / sqrt (2)); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
381 %! assert (w, [-x, x; x, x], sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
382 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
383 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
384 ## If (at least one of) the matrices are non-symmetric, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
385 ## regardless the algorithm flag the qz algorithm should be used. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
386 ## So the results without algorithm flag, with "qz" and with "chol" |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
387 ## should be the same. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
388 %!function nonsym_chol_2_output (A, B, res = sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
389 %! [v, d] = eig (A, B); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
390 %! [v2, d2] = eig (A, B, "qz"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
391 %! [v3, d3] = eig (A, B, "chol"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
392 %! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
393 %! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
394 %! assert (v, v2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
395 %! assert (v, v3) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
396 %! assert (d, d2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
397 %! assert (d, d3) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
398 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
399 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
400 %!test nonsym_chol_2_output ([1, 2; -1, 1], [3, 3; 1, 2]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
401 %!test nonsym_chol_2_output ([1+3i, 2+3i; 3-8i, 8+3i], [8+i, 3+i; 4-9i, 3+i]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
402 %!test nonsym_chol_2_output ([1, 2; 3, 8], [8, 3; 4, 3]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
403 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
404 %!test nonsym_chol_2_output (single ([1, 2; -1, 1]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
405 %! single ([3, 3; 1, 2]), sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
406 %!test nonsym_chol_2_output (single ([1+3i, 2+3i; 3-8i, 8+3i]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
407 %! single ([8+i, 3+i; 4-9i, 3+i]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
408 %! sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
409 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
410 %!function nonsym_chol_3_output (A, B, res = sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
411 %! [v, d, w] = eig (A, B); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
412 %! [v2, d2, w2] = eig (A, B, "qz"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
413 %! [v3, d3, w3] = eig (A, B, "chol"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
414 %! wt = w'; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
415 %! assert (wt(1, :)* A, d(1, 1) * wt(1, :) * B, res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
416 %! assert (wt(2, :)* A, d(2, 2) * wt(2, :) * B, res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
417 %! assert (v, v2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
418 %! assert (v, v3) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
419 %! assert (d, d2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
420 %! assert (d, d3) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
421 %! assert (w, w2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
422 %! assert (w, w3) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
423 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
424 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
425 %!test nonsym_chol_3_output ([1, 2; -1, 1], [3, 3; 1, 2]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
426 %!test nonsym_chol_3_output ([1+3i, 2+3i; 3-8i, 8+3i], [8+i, 3+i; 4-9i, 3+i]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
427 %!test nonsym_chol_3_output ([1, 2; 3, 8], [8, 3; 4, 3]) |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
428 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
429 %!test nonsym_chol_3_output (single ([1, 2; -1, 1]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
430 %! single ([3, 3; 1, 2]), sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
431 %!test nonsym_chol_3_output (single ([1+3i, 2+3i; 3-8i, 8+3i]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
432 %! single ([8+i, 3+i; 4-9i, 3+i]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
433 %! sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
434 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
435 ## If the matrices are symmetric, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
436 ## then the chol method is default. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
437 ## So the results without algorithm flag and with "chol" should be the same. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
438 %!function sym_chol_2_input (A, B, res = sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
439 %! [v, d] = eig (A, B); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
440 %! [v2, d2] = eig (A, B, "chol"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
441 %! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
442 %! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
443 %! assert (v, v2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
444 %! assert (d, d2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
445 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
446 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
447 %!test sym_chol_2_input ([1, 2; 2, 1], [3, -2; -2, 3]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
448 %!test sym_chol_2_input ([1+3i, 2+i; 2-i, 1+3i], [5+9i, 2+i; 2-i, 5+9i]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
449 %!test sym_chol_2_input ([1, 1+i; 1-i, 1], [2, 0; 0, 2]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
450 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
451 %!test sym_chol_2_input (single ([1, 2; 2, 1]), single ([3, -2; -2, 3]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
452 %! sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
453 %!test sym_chol_2_input (single ([1+3i, 2+i; 2-i, 1+3i]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
454 %! single ([5+9i, 2+i; 2-i, 5+9i]), sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
455 %!test sym_chol_2_input (single ([1, 1+i; 1-i, 1]), single ([2, 0; 0, 2]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
456 %! sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
457 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
458 %!function sym_chol_3_input (A, B, res = sqrt (eps)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
459 %! [v, d, w] = eig (A, B); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
460 %! [v2, d2, w2] = eig (A, B, "chol"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
461 %! wt = w'; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
462 %! assert (wt(1, :)* A, d(1, 1) * wt(1, :) * B, res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
463 %! assert (wt(2, :)* A, d(2, 2) * wt(2, :) * B, res) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
464 %! assert (v, v2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
465 %! assert (d, d2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
466 %! assert (w, w2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
467 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
468 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
469 %!test sym_chol_3_input ([1, 2; 2, 1], [3, -2; -2, 3]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
470 %!test sym_chol_3_input ([1+3i, 2+i; 2-i, 1+3i], [5+9i, 2+i; 2-i, 5+9i]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
471 %!test sym_chol_3_input ([1, 1+i; 1-i, 1], [2, 0; 0, 2]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
472 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
473 %!test sym_chol_3_input (single ([1, 2; 2, 1]), single ([3, -2; -2, 3]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
474 %! sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
475 %!test sym_chol_3_input (single ([1+3i, 2+i; 2-i, 1+3i]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
476 %! single ([5+9i, 2+i; 2-i, 5+9i]), sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
477 %!test sym_chol_3_input (single ([1, 1+i; 1-i, 1]), single ([2, 0; 0, 2]), |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
478 %! sqrt (eps ("single"))) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
479 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
480 ## "balance" is always default |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
481 ## so the results with and without "balance" should be the same |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
482 ## while in this case "nobalance" should produce different result |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
483 %!test |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
484 %! A = [3 -2 -0.9 0; -2 4 1 -0; -0 0 -1 0; -0.5 -0.5 0.1 1]; |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
485 %! [V1, D1] = eig (A); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
486 %! [V2, D2] = eig (A, "balance"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
487 %! [V3, D3] = eig (A, "nobalance"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
488 %! assert (V1, V2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
489 %! assert (D1, D2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
490 %! assert (isequal (V2, V3), false) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
491 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
492 ## Testing the flags in all combination. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
493 ## If 2 flags are on, than the result should be the same regardless |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
494 ## of the flags order. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
495 ## option1 represents the first order while option2 represents the other order. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
496 ## d and d2 should be a diagonal matrix if "matrix" flag is on while |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
497 ## these should be column vectors if the "vector" flag is on. |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
498 %!function test_eig_args (args, options1, options2, testd = @() true) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
499 %! [v, d, w] = eig (args{:}, options1{:}); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
500 %! [v2, d2, w2] = eig (args{:}, options2{:}); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
501 %! assert (testd (d)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
502 %! assert (testd (d2)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
503 %! assert (v, v2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
504 %! assert (d, d2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
505 %! assert (w, w2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
506 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
507 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
508 %!function qz_chol_with_shapes (A, B) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
509 %! for shapes = struct ("name", {"vector", "matrix"}, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
510 %! "test", {@isvector, @isdiag}) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
511 %! test_eig_args ({A, B}, {"qz", shapes.name}, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
512 %! {shapes.name, "qz"}, shapes.test); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
513 %! test_eig_args ({A, B}, {"chol", shapes.name}, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
514 %! {shapes.name, "chol"}, shapes.test); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
515 %! endfor |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
516 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
517 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
518 %!function balance_nobalance_with_shapes (A) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
519 %! for shapes = struct ("name", {"vector", "matrix"}, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
520 %! "test", {@isvector, @isdiag}) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
521 %! test_eig_args ({A}, {"balance", shapes.name}, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
522 %! {shapes.name, "balance"}, shapes.test); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
523 %! test_eig_args ({A}, {"nobalance", shapes.name}, |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
524 %! {shapes.name, "nobalance"}, shapes.test); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
525 %! endfor |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
526 %!endfunction |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
527 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
528 ## Default return format: |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
529 ## diagonal matrix if 2 or 3 outputs are specified |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
530 ## column vector if 1 output is specified |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
531 %!function test_shapes (args) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
532 %! d = eig (args{:}); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
533 %! assert (isvector(d)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
534 %! d2 = eig (args{:}, "vector"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
535 %! assert (isvector(d2)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
536 %! [v, d3] = eig (args{:}); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
537 %! assert (isdiag(d3)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
538 %! d4 = eig (args{:}, "matrix"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
539 %! assert (isdiag(d4)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
540 %! [v, d5, w] = eig (args{:}); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
541 %! assert (isdiag(d5)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
542 %! d6 = eig (args{:}, "matrix"); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
543 %! assert (isdiag(d6)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
544 %! assert (d, d2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
545 %! assert (d3, d4) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
546 %! assert (d5, d6) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
547 %! assert (d, diag(d3)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
548 %! assert (d, diag(d5)) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
549 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
550 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
551 %!function shapes_AEP (A) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
552 %! test_shapes({A}); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
553 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
554 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
555 %!function shapes_GEP (A, B) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
556 %! test_shapes({A, B}); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
557 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
558 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
559 %!test balance_nobalance_with_shapes ([1, 2; 2, 1]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
560 %!test balance_nobalance_with_shapes (single ([1, 2; 2, 1])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
561 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
562 %!test shapes_AEP ([1, 2; 2, 1]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
563 %!test shapes_AEP (single ([1, 2; 2, 1])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
564 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
565 %!test qz_chol_with_shapes ([1, 1+i; 1-i, 1], [2, 0; 0, 2]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
566 %!test qz_chol_with_shapes ([1, 2; 3, 8], [8, 3; 4, 3]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
567 %!test qz_chol_with_shapes ([1, 2; -1, 1], [3, 3; 1, 2]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
568 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
569 %!test qz_chol_with_shapes (single ([1, 1+i; 1-i, 1]), single ([2, 0; 0, 2])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
570 %!test qz_chol_with_shapes (single ([1, 2; 3, 8]), single ([8, 3; 4, 3])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
571 %!test qz_chol_with_shapes (single ([1, 2; -1, 1]), single ([3, 3; 1, 2])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
572 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
573 %!test shapes_GEP ([1, 1+i; 1-i, 1], [2, 0; 0, 2]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
574 %!test shapes_GEP ([1, 2; 3, 8], [8, 3; 4, 3]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
575 %!test shapes_GEP ([1, 2; -1, 1], [3, 3; 1, 2]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
576 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
577 %!test shapes_GEP (single ([1, 1+i; 1-i, 1]), single ([2, 0; 0, 2])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
578 %!test shapes_GEP (single ([1, 2; 3, 8]), single ([8, 3; 4, 3])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
579 %!test shapes_GEP (single ([1, 2; -1, 1]), single ([3, 3; 1, 2])); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
580 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
581 %!function chol_qz_accuracy (A, B, is_qz_accurate, is_chol_accurate) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
582 %! [V1,D1] = eig (A,B, 'qz'); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
583 %! [V2,D2] = eig (A,B); #default is chol |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
584 %! assert (isequal (A*V1,A*V1*D1), is_qz_accurate) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
585 %! assert (isequal (A*V2, A*V2*D2), is_chol_accurate) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
586 %!endfunction |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
587 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
588 %!test |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
589 %! minij_100 = gallery('minij',100); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
590 %! chol_qz_accuracy (minij_100, minij_100, false, true); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
591 |
20490
ff904ae0285b
eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents:
20172
diff
changeset
|
592 %!test |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
593 %! moler_100 = gallery('moler',100); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
594 %! chol_qz_accuracy (moler_100, moler_100, false, true); |
20490
ff904ae0285b
eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents:
20172
diff
changeset
|
595 |
ff904ae0285b
eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents:
20172
diff
changeset
|
596 %!test |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
597 %! A = diag([10^-16, 10^-15]); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
598 %! chol_qz_accuracy (A, A, true, false); |
20490
ff904ae0285b
eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents:
20172
diff
changeset
|
599 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
600 %!error eig () |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
601 %!error eig (false) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
602 %!error eig ([1, 2; 3, 4], [4, 3; 2, 1], 1) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
603 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
604 %!error <EIG requires same size matrices> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
605 %! eig ([1, 2; 3, 4], 2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
606 %!error <must be a square matrix> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
607 %! eig ([1, 2; 3, 4; 5, 6]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
608 %!error <wrong type argument> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
609 %! eig ("abcd") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
610 %!error <invalid option "abcd"> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
611 %! eig ([1 2 ; 2 3], "abcd") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
612 %!error <invalid "chol" option for algebraic eigenvalue problem> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
613 %! eig ([1 2 ; 2 3], "chol") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
614 %!error <invalid "qz" option for algebraic eigenvalue problem> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
615 %! eig ([1 2 ; 2 3], "qz") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
616 %!error <wrong type argument> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
617 %! eig (false, [1 2 ; 2 3]) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
618 %!error <invalid option "abcd"> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
619 %! eig ([1 2 ; 2 3], [1 2 ; 2 3], "abcd") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
620 %!error <invalid "qz" option for algebraic eigenvalue problem> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
621 %! eig ([1 2 ; 2 3], "balance", "qz") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
622 %!error <invalid option "abcd"> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
623 %! eig ([1 2 ; 2 3], [1 2 ; 2 3], "vector", "abcd") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
624 %!error <invalid option "abcd"> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
625 %! eig ([1 2 ; 2 3], "balance", "matrix", "abcd") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
626 %!error <"balance" and "nobalance" options are mutually exclusive> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
627 %! eig ([1 2 ; 2 3], "balance", "nobalance") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
628 %!error <"balance" and "nobalance" options are mutually exclusive> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
629 %! eig ([1 2 ; 2 3], "nobalance", "balance") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
630 %!error <"vector" and "matrix" options are mutually exclusive> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
631 %! eig ([1 2 ; 2 3], "matrix", "vector") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
632 %!error <"vector" and "matrix" options are mutually exclusive> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
633 %! eig ([1 2 ; 2 3], "vector", "matrix") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
634 %!error <"vector" and "matrix" options are mutually exclusive> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
635 %! eig ([1 2 ; 2 3], [1 2 ; 2 3], "matrix", "vector") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
636 %!error <"vector" and "matrix" options are mutually exclusive> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
637 %! eig ([1 2 ; 2 3], [1 2 ; 2 3], "vector", "matrix") |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
638 %!error <wrong type argument> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
639 %! eig ([1 2 ; 2 3], [1 2 ; 2 3], false) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
640 %!error <wrong type argument> |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
641 %! eig ([1 2 ; 2 3], [1 2 ; 2 3], [1 2 ; 2 3]) |
2928 | 642 */ |