annotate libinterp/corefcn/eig.cc @ 23450:855122b993da

maint: Wrap tertiary operator in parentheses "(COND ? x : y)". * Canvas.cc, color-picker.cc, dialog.cc, marker.cc, main-window.cc, Cell.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, bsxfun.cc, call-stack.cc, cellfun.cc, data.cc, defaults.cc, det.cc, eig.cc, error.cc, file-io.cc, filter.cc, find.cc, gammainc.cc, gcd.cc, gl-render.cc, graphics.cc, graphics.in.h, help.cc, hex2num.cc, inv.cc, load-save.cc, lookup.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, lu.cc, max.cc, mex.cc, oct-hist.cc, oct-map.cc, oct-procbuf.cc, oct-stream.cc, pr-output.cc, rand.cc, regexp.cc, schur.cc, str2double.cc, strfns.cc, symtab.cc, sysdep.cc, tril.cc, variables.cc, xdiv.cc, audiodevinfo.cc, audioread.cc, colamd.cc, gzip.cc, ov-base-diag.cc, ov-base-mat.h, ov-base-scalar.h, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-range.cc, ov-range.h, ov-struct.cc, ov-usr-fcn.cc, ov.cc, octave.cc, op-class.cc, pt-eval.cc, pt-funcall.cc, pt-idx.cc, pt-jit.cc, pt-stmt.cc, version.cc, Array-util.cc, Array.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CSparse.cc, Range.cc, Sparse.cc, chNDArray.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dSparse.cc, dim-vector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, idx-vector.cc, idx-vector.h, Faddeeva.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, fEIG.cc, gsvd.cc, lo-specfun.cc, oct-rand.cc, qr.cc, qrp.cc, randgamma.cc, schur.cc, svd.cc, Sparse-diag-op-defs.h, mx-inlines.cc, oct-env.cc, cmd-edit.cc, kpse.cc, oct-inttypes.h, oct-sort.cc: Wrap tertiary operator in parentheses "(COND ? x : y)".
author Rik <rik@octave.org>
date Thu, 27 Apr 2017 17:33:10 -0700
parents ed3d5186ffcf
children 3a730821e4a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
1 /*
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1996-2017 John W. Eaton
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
4 Copyright (C) 2016 Barbara Lócsi
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
5
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
7
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
9 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
10 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
11 (at your option) any later version.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
16 GNU General Public License for more details.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
17
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5829
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5829
diff changeset
20 <http://www.gnu.org/licenses/>.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
21
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
22 */
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
23
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
24 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
25 # include "config.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
26 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
27
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14885
diff changeset
28 #include "defun.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
29 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21024
diff changeset
30 #include "errwarn.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20918
diff changeset
31 #include "ovl.h"
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
32
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
33 #include "EIG.h"
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
34 #include "fEIG.h"
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
35 #include "oct-string.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
36
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14885
diff changeset
37 DEFUN (eig, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
38 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
39 @deftypefn {} {@var{lambda} =} eig (@var{A})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
40 @deftypefnx {} {@var{lambda} =} eig (@var{A}, @var{B})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
41 @deftypefnx {} {[@var{V}, @var{lambda}] =} eig (@var{A})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
42 @deftypefnx {} {[@var{V}, @var{lambda}] =} eig (@var{A}, @var{B})
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
43 @deftypefnx {} {[@var{V}, @var{lambda}, @var{W}] =} eig (@var{A})
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
44 @deftypefnx {} {[@var{V}, @var{lambda}, @var{W}] =} eig (@var{A}, @var{B})
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
45 @deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{balanceOption})
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
46 @deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{B}, @var{algorithm})
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
47 @deftypefnx {} {[@dots{}] =} eig (@dots{}, @var{eigvalOption})
23290
0cf53cd75e13 doc: Fix eig output argument description (bug #50524).
Victor Norton <vic@norton.name>
parents: 23219
diff changeset
48 Compute the eigenvalues (@var{lambda}) and optionally the right eigenvectors
0cf53cd75e13 doc: Fix eig output argument description (bug #50524).
Victor Norton <vic@norton.name>
parents: 23219
diff changeset
49 (@var{V}) and the left eigenvectors (@var{W}) of a matrix or a pair of
0cf53cd75e13 doc: Fix eig output argument description (bug #50524).
Victor Norton <vic@norton.name>
parents: 23219
diff changeset
50 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
51
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
52 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
53
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
54 @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
55 @item @qcode{"balance"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
56 Preliminary balancing is on. (default)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
57
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
58 @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
59 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
60 @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
61
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
62 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
63
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
64 @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
65 @item @qcode{"matrix"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
66 Return the eigenvalues in a diagonal matrix. (default if 2 or 3 outputs
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
67 are specified)
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
68
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
69 @item @qcode{"vector"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
70 Return the eigenvalues in a column vector. (default if 1 output is
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
71 specified, e.g. @var{lambda} = 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
72 @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
73
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
74 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
75
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
76 @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
77 @item @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
78 Uses the Cholesky factorization of B. (default if A is symmetric (Hermitian)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
79 and B is symmetric (Hermitian) positive definite)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
80
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
81 @item @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
82 Uses the QZ algorithm. (When A or B are not symmetric always the
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
83 QZ algorithm will 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
84 @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
85
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
86 @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
87 @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
88 @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
89 @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
90 @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
91 @tab @qcode{"qz"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
92 @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
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 @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
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 @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
97
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
98 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
99 @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
100 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
101 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
102 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
103
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
104 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
105 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
106
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
107 octave_value_list retval;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
108
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
109 octave_value arg_a, arg_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
110
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
111 arg_a = args(0);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
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 if (arg_a.is_empty ())
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
114 return octave_value_list (2, Matrix ());
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
115
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
116 if (! arg_a.is_float_type ())
21129
228b65504557 maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents: 21110
diff changeset
117 err_wrong_type_arg ("eig", arg_a);
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
118
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
119 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
120 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
121
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
122 // 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
123 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
124
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
125 if (! AEPcase)
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
126 {
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
127 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
128
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
129 if (arg_b.is_empty ())
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
130 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
131
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
132 if (! arg_b.is_float_type ())
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
133 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
134
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
135 if (arg_b.rows () != arg_b.columns ())
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
136 err_square_matrix_required ("eig", "B");
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
137 }
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
138
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
139 bool 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
140 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
141 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
142 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
143 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
144 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
145
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
146 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
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 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
149 err_wrong_type_arg ("eig", args(i));
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
150
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
151 std::string arg_i = args(i).string_value ();
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
152 if (octave::string::strcmpi (arg_i, "qz"))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
153 qz_flag = true;
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
154 else if (octave::string::strcmpi (arg_i, "chol"))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
155 chol_flag = true;
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
156 else if (octave::string::strcmpi (arg_i, "balance"))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
157 balance_flag = true;
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
158 else if (octave::string::strcmpi (arg_i, "nobalance"))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
159 no_balance_flag = true;
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
160 else if (octave::string::strcmpi (arg_i, "matrix"))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
161 matrix_flag = true;
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
162 else if (octave::string::strcmpi (arg_i, "vector"))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
163 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
164 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
165 error ("eig: invalid option \"%s\"", arg_i.c_str ());
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
166 }
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
167
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
168 if (balance_flag && no_balance_flag)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
169 error ("eig: \"balance\" and \"nobalance\" options are mutually exclusive");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
170 if (vector_flag && matrix_flag)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
171 error ("eig: \"vector\" and \"matrix\" options are mutually exclusive");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
172 if (qz_flag && chol_flag)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
173 error ("eig: \"qz\" and \"chol\" options are mutually exclusive");
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
174
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
175 if (AEPcase)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
176 {
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 (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
178 error ("eig: invalid \"qz\" option for algebraic eigenvalue problem");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
179 if (chol_flag)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
180 error ("eig: invalid \"chol\" option for algebraic eigenvalue problem");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
181 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
182 else
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 if (balance_flag)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
185 error ("eig: invalid \"balance\" option for generalized eigenvalue problem");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
186 if (no_balance_flag)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
187 error ("eig: invalid \"nobalance\" option for generalized eigenvalue problem");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
188 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
189
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
190 // Default is to balance
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23293
diff changeset
191 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
192 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
193
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
194
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
195 Matrix tmp_a, tmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
196 ComplexMatrix ctmp_a, ctmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
197 FloatMatrix ftmp_a, ftmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
198 FloatComplexMatrix fctmp_a, fctmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
199
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
200 if (arg_a.is_single_type ())
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
201 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
202 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
203 if (AEPcase)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
204 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
205 if (arg_a.is_real_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
206 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
207 ftmp_a = arg_a.float_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
208
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
209 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
210 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
211 else
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 fctmp_a = arg_a.float_complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
214
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
215 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
216 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
217 }
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
218 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
219 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
220 if (arg_a.is_real_type () && arg_b.is_real_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
221 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
222 ftmp_a = arg_a.float_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
223 ftmp_b = arg_b.float_matrix_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
224
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
225 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
226 force_qz);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
227 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
228 else
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 fctmp_a = arg_a.float_complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
231 fctmp_b = arg_b.float_complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
232
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
233 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
234 force_qz);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
235 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
236 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
237
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
238 if (nargout == 0 || nargout == 1)
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
239 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
240 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
241 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
242 else
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 (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 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
245 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
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 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
248 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
249 else
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 (),
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
251 FloatComplexDiagMatrix (result.eigenvalues ()));
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
252 }
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
253 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
254 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
255 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
256 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
257 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
258 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
259 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
260 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
261 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
262 result.left_eigenvectors ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
263 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
264 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
265 else
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
266 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
267 EIG result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
268
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
269 if (AEPcase)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
270 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
271 if (arg_a.is_real_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
272 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
273 tmp_a = arg_a.matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
274
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
275 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
276 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
277 else
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 ctmp_a = arg_a.complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
280
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
281 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
282 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
283 }
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
284 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
285 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
286 if (arg_a.is_real_type () && arg_b.is_real_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
287 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
288 tmp_a = arg_a.matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
289 tmp_b = arg_b.matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
290
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
291 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
292 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
293 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
294 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
295 ctmp_a = arg_a.complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
296 ctmp_b = arg_b.complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
297
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
298 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
299 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
300 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
301
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
302 if (nargout == 0 || nargout == 1)
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
303 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
304 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
305 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
306 else
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 (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 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
309 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
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 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
312 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
313 else
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 (),
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
315 ComplexDiagMatrix (result.eigenvalues ()));
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
316 }
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
317 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
318 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
319 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
320 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
321 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
322 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
323 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
324 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
325 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
326 result.left_eigenvectors ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
327 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
328 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
329
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
330 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
331 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
332
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
333 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
334 %!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
335
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
336 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
337 %! [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
338 %! 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
339 %! 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
340 %! 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
341
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
342 %!test
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
343 %! [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
344 %! 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
345 %! 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
346
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
347 %!test
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
348 %! [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
349 %! 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
350 %! 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
351 %! 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
352
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
353 %!test
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
354 %! [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
355 %! 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
356 %! 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
357
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
358 %!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
359
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
360 %!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
361 %! 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
362
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
363 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
364 %! [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
365 %! 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
366 %! 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
367 %! assert (v, [-x, x; x, x], sqrt (eps ("single")))
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
368
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
369 %!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
370 %! [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
371 %! 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
372 %! assert (w, [-x, x; x, x], sqrt (eps ("single")))
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
373
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
374 %!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
375 %! [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
376 %! 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
377 %! 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
378 %! assert (v, [-x, x; x, x], sqrt (eps ("single")))
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
379
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
380 %!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
381 %! [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
382 %! 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
383 %! 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
384
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
385
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
386 ## 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
387 ## 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
388 ## 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
389 ## 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
390 %!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
391 %! [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
392 %! [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
393 %! [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
394 %! 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
395 %! 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
396 %! 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
397 %! 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
398 %! 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
399 %! 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
400 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
401
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
402 %!test nonsym_chol_2_output ([1, 2; -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
403 %!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
404 %!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
405
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
406 %!test nonsym_chol_2_output (single ([1, 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
407 %! 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
408 %!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
409 %! 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
410 %! 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
411
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
412 %!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
413 %! [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
414 %! [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
415 %! [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
416 %! 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
417 %! 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
418 %! 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
419 %! 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
420 %! 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
421 %! 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
422 %! 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
423 %! 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
424 %! 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
425 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
426
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
427 %!test nonsym_chol_3_output ([1, 2; -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
428 %!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
429 %!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
430
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
431 %!test nonsym_chol_3_output (single ([1, 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
432 %! 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
433 %!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
434 %! 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
435 %! 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
436
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
437 ## 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
438 ## 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
439 ## 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
440 %!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
441 %! [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
442 %! [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
443 %! 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
444 %! 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
445 %! 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
446 %! 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
447 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
448
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
449 %!test sym_chol_2_input ([1, 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
450 %!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
451 %!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
452
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
453 %!test sym_chol_2_input (single ([1, 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
454 %! sqrt (eps ("single")))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
455 %!test sym_chol_2_input (single ([1+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
456 %! 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
457 %!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
458 %! 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
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
460 %!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
461 %! [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
462 %! [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
463 %! 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
464 %! 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
465 %! 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
466 %! 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
467 %! 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
468 %! 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
469 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
470
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
471 %!test sym_chol_3_input ([1, 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
472 %!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
473 %!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
474
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
475 %!test sym_chol_3_input (single ([1, 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
476 %! sqrt (eps ("single")))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
477 %!test sym_chol_3_input (single ([1+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
478 %! 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
479 %!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
480 %! 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
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
482 ## "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
483 ## 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
484 ## while in this case "nobalance" should produce different result
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
485 %!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
486 %! 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
487 %! [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
488 %! [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
489 %! [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
490 %! 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
491 %! 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
492 %! 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
493
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
494 ## 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
495 ## 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
496 ## 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
497 ## 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
498 ## 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
499 ## 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
500 %!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
501 %! [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
502 %! [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
503 %! 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
504 %! 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
505 %! 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
506 %! 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
507 %! 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
508 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
509
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
510 %!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
511 %! 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
512 %! "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
513 %! 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
514 %! {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
515 %! 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
516 %! {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
517 %! endfor
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
518 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
519
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
520 %!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
521 %! 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
522 %! "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
523 %! 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
524 %! {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
525 %! 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
526 %! {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
527 %! endfor
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
528 %!endfunction
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
529
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
530 ## 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
531 ## 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
532 ## 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
533 %!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
534 %! d = eig (args{:});
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
535 %! assert (isvector(d))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
536 %! d2 = eig (args{:}, "vector");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
537 %! assert (isvector(d2))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
538 %! [v, d3] = eig (args{:});
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
539 %! assert (isdiag(d3))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
540 %! d4 = eig (args{:}, "matrix");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
541 %! assert (isdiag(d4))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
542 %! [v, d5, w] = eig (args{:});
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
543 %! assert (isdiag(d5))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
544 %! d6 = eig (args{:}, "matrix");
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
545 %! assert (isdiag(d6))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
546 %! 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
547 %! 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
548 %! assert (d5, d6)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
549 %! assert (d, diag(d3))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
550 %! assert (d, diag(d5))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
551 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
552
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
553 %!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
554 %! 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
555 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
556
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
557 %!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
558 %! 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
559 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
560
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
561 %!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
562 %!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
563
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 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
565 %!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
566
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
567 %!test qz_chol_with_shapes ([1, 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
568 %!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
569 %!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
570
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
571 %!test qz_chol_with_shapes (single ([1, 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
572 %!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
573 %!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
574
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
575 %!test shapes_GEP ([1, 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
576 %!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
577 %!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
578
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
579 %!test shapes_GEP (single ([1, 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
580 %!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
581 %!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
582
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
583 %!function chol_qz_accuracy (A, B, is_qz_accurate, is_chol_accurate)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
584 %! [V1,D1] = eig (A,B, 'qz');
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
585 %! [V2,D2] = eig (A,B); #default is chol
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
586 %! assert (isequal (A*V1,A*V1*D1), is_qz_accurate)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
587 %! 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
588 %!endfunction
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
589
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
590 %!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
591 %! minij_100 = gallery('minij',100);
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
592 %! chol_qz_accuracy (minij_100, minij_100, false, true);
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
593
20490
ff904ae0285b eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents: 20172
diff changeset
594 %!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
595 %! moler_100 = gallery('moler',100);
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
596 %! chol_qz_accuracy (moler_100, moler_100, false, true);
20490
ff904ae0285b eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents: 20172
diff changeset
597
ff904ae0285b eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents: 20172
diff changeset
598 %!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
599 %! A = diag([10^-16, 10^-15]);
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
600 %! 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
601
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
602 %!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
603 %!error eig (false)
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
604 %!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
605
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 <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
607 %! 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
608 %!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
609 %! 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
610 %!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
611 %! 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
612 %!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
613 %! 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
614 %!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
615 %! 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
616 %!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
617 %! 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
618 %!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
619 %! 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
620 %!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
621 %! 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
622 %!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
623 %! 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
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], [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
626 %!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
627 %! 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
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], "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
630 %!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
631 %! 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
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], "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
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], "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
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], "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
638 %!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
639 %! 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
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], false)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
642 %!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
643 %! eig ([1 2 ; 2 3], [1 2 ; 2 3], [1 2 ; 2 3])
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
644 */