Mercurial > octave
annotate libinterp/corefcn/eig.cc @ 33617:ec2635a02328 bytecode-interpreter tip
maint: Merge default to bytecode-interpreter.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 21 May 2024 18:29:03 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 // Copyright (C) 1996-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2928 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
2928 | 28 #endif |
29 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14885
diff
changeset
|
30 #include "defun.h" |
2928 | 31 #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
|
32 #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
|
33 #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
|
34 |
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 "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
|
36 #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
|
37 #include "oct-string.h" |
2928 | 38 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
39 OCTAVE_BEGIN_NAMESPACE(octave) |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
40 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14885
diff
changeset
|
41 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
|
42 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
|
43 @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
|
44 @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
|
45 @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
|
46 @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
|
47 @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
|
48 @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
|
49 @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
|
50 @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
|
51 @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
|
52 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
|
53 (@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
|
54 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
55 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
|
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 @table @asis |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
58 @item @qcode{"balance"} (default) |
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
59 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
|
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 @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
|
62 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
|
63 @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
|
64 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
65 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
|
66 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
67 @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
|
68 @item @qcode{"matrix"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
69 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
|
70 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
|
71 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
72 @item @qcode{"vector"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
73 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
|
74 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
|
75 @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
|
76 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
77 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
|
78 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
79 @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
|
80 @item @qcode{"chol"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
81 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
|
82 (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
|
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 @item @qcode{"qz"} |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
85 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
|
86 @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
|
87 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
88 @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
|
89 @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
|
90 @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
|
91 @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
|
92 @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
|
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 @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
|
95 @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
|
96 @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
|
97 @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
|
98 @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
|
99 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
100 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
|
101 @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
|
102 @end deftypefn */) |
2928 | 103 { |
104 int nargin = args.length (); | |
105 | |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
106 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
|
107 print_usage (); |
2928 | 108 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
109 octave_value_list retval; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
110 |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
111 octave_value arg_a, arg_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
112 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
113 arg_a = args(0); |
2928 | 114 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23565
diff
changeset
|
115 if (arg_a.isempty ()) |
2928 | 116 return octave_value_list (2, Matrix ()); |
117 | |
23585
570170b6eb09
maint: Deprecate is_float_type and replace with isfloat.
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
118 if (! arg_a.isfloat ()) |
21129
228b65504557
maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents:
21110
diff
changeset
|
119 err_wrong_type_arg ("eig", arg_a); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
120 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
121 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
|
122 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
|
123 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
124 // 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
|
125 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
|
126 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
127 if (! AEPcase) |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
128 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
129 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
|
130 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23565
diff
changeset
|
131 if (arg_b.isempty ()) |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
132 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
|
133 |
23585
570170b6eb09
maint: Deprecate is_float_type and replace with isfloat.
Rik <rik@octave.org>
parents:
23582
diff
changeset
|
134 if (! arg_b.isfloat ()) |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
135 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
|
136 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
137 if (arg_b.rows () != arg_b.columns ()) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
138 err_square_matrix_required ("eig", "B"); |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
139 } |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
140 |
22305
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 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
148 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
|
149 { |
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 (! 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
|
151 err_wrong_type_arg ("eig", args(i)); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
152 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
153 std::string arg_i = args(i).string_value (); |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
154 if (string::strcmpi (arg_i, "qz")) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
155 qz_flag = true; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
156 else if (string::strcmpi (arg_i, "chol")) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
157 chol_flag = true; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
158 else if (string::strcmpi (arg_i, "balance")) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
159 balance_flag = true; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
160 else if (string::strcmpi (arg_i, "nobalance")) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
161 no_balance_flag = true; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
162 else if (string::strcmpi (arg_i, "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
|
163 matrix_flag = true; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
164 else if (string::strcmpi (arg_i, "vector")) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
165 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
|
166 else |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
167 error (R"(eig: invalid option "%s")", arg_i.c_str ()); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
168 } |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
169 |
22305
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 (balance_flag && no_balance_flag) |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
171 error (R"(eig: "balance" and "nobalance" options are mutually exclusive)"); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
172 if (vector_flag && matrix_flag) |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
173 error (R"(eig: "vector" and "matrix" options are mutually exclusive)"); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
174 if (qz_flag && chol_flag) |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
175 error (R"(eig: "qz" and "chol" options are mutually exclusive)"); |
2928 | 176 |
22305
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 (AEPcase) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
178 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
179 if (qz_flag) |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
180 error (R"(eig: invalid "qz" option for algebraic eigenvalue problem)"); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
181 if (chol_flag) |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
182 error (R"(eig: invalid "chol" option for algebraic eigenvalue problem)"); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
183 } |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
184 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
185 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
186 if (balance_flag) |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
187 error (R"(eig: invalid "balance" option for generalized eigenvalue problem)"); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
188 if (no_balance_flag) |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23585
diff
changeset
|
189 error (R"(eig: invalid "nobalance" option for generalized eigenvalue problem)"); |
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 } |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
191 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
192 // Default is to balance |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23293
diff
changeset
|
193 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
|
194 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
|
195 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
196 |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
197 Matrix tmp_a, tmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
198 ComplexMatrix ctmp_a, ctmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
199 FloatMatrix ftmp_a, ftmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
200 FloatComplexMatrix fctmp_a, fctmp_b; |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
201 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
202 if (arg_a.is_single_type ()) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
203 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
204 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
|
205 if (AEPcase) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
206 { |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
207 if (arg_a.isreal ()) |
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 ftmp_a = arg_a.float_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
210 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
211 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
|
212 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
213 else |
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 fctmp_a = arg_a.float_complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
216 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
217 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
|
218 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
219 } |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
220 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
221 { |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
222 if (arg_a.isreal () && arg_b.isreal ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
223 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
224 ftmp_a = arg_a.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
225 ftmp_b = arg_b.float_matrix_value (); |
2928 | 226 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
227 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
|
228 force_qz); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
229 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
230 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
231 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
232 fctmp_a = arg_a.float_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
233 fctmp_b = arg_b.float_complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
234 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
235 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
|
236 force_qz); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
237 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
238 } |
2928 | 239 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
240 if (nargout == 0 || nargout == 1) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
241 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
242 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
|
243 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
|
244 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
245 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
|
246 } |
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 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
|
248 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
249 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
|
250 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
|
251 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
252 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
|
253 FloatComplexDiagMatrix (result.eigenvalues ())); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
254 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
255 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
256 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
257 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
|
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 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 ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
261 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
262 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
|
263 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
|
264 result.left_eigenvectors ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
265 } |
2928 | 266 } |
267 else | |
268 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
269 EIG result; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
270 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
271 if (AEPcase) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
272 { |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
273 if (arg_a.isreal ()) |
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 tmp_a = arg_a.matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7578
diff
changeset
|
276 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
277 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
|
278 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
279 else |
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 ctmp_a = arg_a.complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
282 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
283 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
|
284 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
285 } |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
286 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
287 { |
23582
0cc2011d800e
maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
288 if (arg_a.isreal () && arg_b.isreal ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
289 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
290 tmp_a = arg_a.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
291 tmp_b = arg_b.matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
292 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
293 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
|
294 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
295 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
296 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
297 ctmp_a = arg_a.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
298 ctmp_b = arg_b.complex_matrix_value (); |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
299 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
300 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
|
301 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
302 } |
2928 | 303 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
304 if (nargout == 0 || nargout == 1) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
305 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
306 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
|
307 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
|
308 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
309 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
|
310 } |
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 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
|
312 { |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
313 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
|
314 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
|
315 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
316 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
|
317 ComplexDiagMatrix (result.eigenvalues ())); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
318 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20490
diff
changeset
|
319 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
320 { |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
321 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
|
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 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 ()); |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
325 else |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
326 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
|
327 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
|
328 result.left_eigenvectors ()); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9307
diff
changeset
|
329 } |
2928 | 330 } |
331 | |
332 return retval; | |
333 } | |
334 | |
335 /* | |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
336 %!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
|
337 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
338 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
339 %! [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
|
340 %! 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
|
341 %! 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
|
342 %! 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
|
343 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
344 %!test |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
345 %! [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
|
346 %! 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
|
347 %! 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
|
348 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
349 %!test |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
350 %! [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
|
351 %! 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
|
352 %! 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
|
353 %! 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
|
354 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
355 %!test |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
356 %! [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
|
357 %! 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
|
358 %! 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
|
359 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
360 %!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
|
361 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
362 %!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
|
363 %! 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
|
364 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
365 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
366 %! [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
|
367 %! 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
|
368 %! 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
|
369 %! assert (v, [-x, x; x, x], sqrt (eps ("single"))) |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
370 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
371 %!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
|
372 %! [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
|
373 %! 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
|
374 %! assert (w, [-x, x; x, x], sqrt (eps ("single"))) |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
375 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
376 %!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
|
377 %! [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
|
378 %! 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
|
379 %! 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
|
380 %! assert (v, [-x, x; x, x], sqrt (eps ("single"))) |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
381 |
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
382 %!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
|
383 %! [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
|
384 %! 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
|
385 %! 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
|
386 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
387 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
388 ## 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
|
389 ## 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
|
390 ## 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
|
391 ## 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
|
392 %!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
|
393 %! [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
|
394 %! [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
|
395 %! [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
|
396 %! 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
|
397 %! 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
|
398 %! 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
|
399 %! 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
|
400 %! 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
|
401 %! 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
|
402 %!endfunction |
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 ([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
|
405 %!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
|
406 %!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
|
407 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
408 %!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
|
409 %! 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
|
410 %!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
|
411 %! 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
|
412 %! 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
|
413 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
414 %!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
|
415 %! [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
|
416 %! [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
|
417 %! [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
|
418 %! 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
|
419 %! 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
|
420 %! 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
|
421 %! 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
|
422 %! 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
|
423 %! 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
|
424 %! 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
|
425 %! 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
|
426 %! 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
|
427 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
428 |
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 ([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
|
430 %!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
|
431 %!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
|
432 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
433 %!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
|
434 %! 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
|
435 %!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
|
436 %! 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
|
437 %! 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
|
438 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
439 ## 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
|
440 ## 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
|
441 ## 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
|
442 %!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
|
443 %! [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
|
444 %! [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
|
445 %! 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
|
446 %! 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
|
447 %! 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
|
448 %! 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
|
449 %!endfunction |
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 ([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
|
452 %!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
|
453 %!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
|
454 |
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, 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
|
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 %!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
|
458 %! 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
|
459 %!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
|
460 %! 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
|
461 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
462 %!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
|
463 %! [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
|
464 %! [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
|
465 %! 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
|
466 %! 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
|
467 %! 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
|
468 %! 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
|
469 %! 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
|
470 %! 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
|
471 %!endfunction |
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 ([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
|
474 %!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
|
475 %!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
|
476 |
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, 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
|
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 %!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
|
480 %! 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
|
481 %!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
|
482 %! 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
|
483 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
484 ## "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
|
485 ## 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
|
486 ## while in this case "nobalance" should produce different result |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
487 %!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
|
488 %! 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
|
489 %! [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
|
490 %! [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
|
491 %! [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
|
492 %! 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
|
493 %! 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
|
494 %! 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
|
495 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
496 ## 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
|
497 ## 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
|
498 ## 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
|
499 ## 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
|
500 ## 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
|
501 ## 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
|
502 %!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
|
503 %! [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
|
504 %! [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
|
505 %! 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
|
506 %! 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
|
507 %! 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
|
508 %! 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
|
509 %! 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
|
510 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
511 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
512 %!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
|
513 %! 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
|
514 %! "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
|
515 %! 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
|
516 %! {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
|
517 %! 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
|
518 %! {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
|
519 %! endfor |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
520 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
521 |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
522 %!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
|
523 %! 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
|
524 %! "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
|
525 %! 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
|
526 %! {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
|
527 %! 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
|
528 %! {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
|
529 %! endfor |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
530 %!endfunction |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
531 |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
532 ## 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
|
533 ## 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
|
534 ## 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
|
535 %!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
|
536 %! d = eig (args{:}); |
28915
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
537 %! assert (isvector (d)) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
538 %! d2 = eig (args{:}, "vector"); |
28915
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
539 %! assert (isvector (d2)) |
22305
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, d3] = eig (args{:}); |
28915
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
541 %! assert (isdiag (d3)) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
542 %! d4 = eig (args{:}, "matrix"); |
28915
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
543 %! assert (isdiag (d4)) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
544 %! [v, d5, w] = eig (args{:}); |
28915
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
545 %! assert (isdiag (d5)) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
546 %! d6 = eig (args{:}, "matrix"); |
28915
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
547 %! assert (isdiag (d6)) |
22305
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, d2) |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
549 %! 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
|
550 %! assert (d5, d6) |
28915
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
551 %! assert (d, diag (d3)) |
c40a367a84c0
maint: Use Octave convention of space after function name in libinterp/.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
552 %! assert (d, diag (d5)) |
22305
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_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
|
556 %! 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
|
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 %!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
|
560 %! 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
|
561 %!endfunction |
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
562 |
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 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
|
564 %!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
|
565 |
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 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
|
567 %!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
|
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 ([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
|
570 %!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
|
571 %!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
|
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 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
|
574 %!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
|
575 %!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
|
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 ([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
|
578 %!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
|
579 %!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
|
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 %!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
|
582 %!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
|
583 %!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
|
584 |
23942
9c736cc2ee94
Fix BIST for eig on Windows 64bit (bug #49470).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23803
diff
changeset
|
585 ## Check if correct default method is used for symmetric input |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
586 %!function chol_qz_accuracy (A, B, is_qz_accurate, is_chol_accurate) |
23942
9c736cc2ee94
Fix BIST for eig on Windows 64bit (bug #49470).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23803
diff
changeset
|
587 %! [V1, D1] = eig (A, B, 'qz'); |
9c736cc2ee94
Fix BIST for eig on Windows 64bit (bug #49470).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23803
diff
changeset
|
588 %! [V2, D2] = eig (A, B); #default is chol |
9c736cc2ee94
Fix BIST for eig on Windows 64bit (bug #49470).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23803
diff
changeset
|
589 %! assert (isequal (A*V1, A*V1*D1), is_qz_accurate) |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
590 %! 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
|
591 %!endfunction |
8339
18c4ded8612a
Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents:
7814
diff
changeset
|
592 %!test |
23942
9c736cc2ee94
Fix BIST for eig on Windows 64bit (bug #49470).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23803
diff
changeset
|
593 %! minij_100 = gallery ('minij', 100); |
22305
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 (minij_100, minij_100, false, true); |
23942
9c736cc2ee94
Fix BIST for eig on Windows 64bit (bug #49470).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23803
diff
changeset
|
595 %! moler_100 = gallery ('moler', 100); |
22305
510886d03ef2
eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
21966
diff
changeset
|
596 %! chol_qz_accuracy (moler_100, moler_100, false, true); |
23942
9c736cc2ee94
Fix BIST for eig on Windows 64bit (bug #49470).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23803
diff
changeset
|
597 %! A = diag([1e-16, 1e-15]); |
22305
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 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
643 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
644 OCTAVE_END_NAMESPACE(octave) |