annotate libinterp/corefcn/eig.cc @ 22407:34ce5be04942

maint: Style check C++ code in libinterp/. * build-env.h, build-env.in.cc, builtins.h, Cell.cc, Cell.h, __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, comment-list.cc, comment-list.h, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, debug.h, defaults.cc, defaults.in.h, defun-dld.h, defun-int.h, defun.h, det.cc, dirfns.cc, dirfns.h, display.cc, display.h, dlmread.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, error.cc, error.h, errwarn.h, event-queue.cc, event-queue.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, file-io.h, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics.cc, graphics.in.h, gripes.h, gsvd.cc, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter.cc, interpreter.h, inv.cc, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, kron.cc, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-hdf5.cc, ls-hdf5.h, ls-mat-ascii.cc, ls-mat-ascii.h, ls-mat4.cc, ls-mat4.h, ls-mat5.h, ls-oct-binary.cc, ls-oct-binary.h, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, matrix_type.cc, max.cc, mex.cc, mex.h, mexproto.h, mgorth.cc, mxarray.in.h, nproc.cc, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hdf5.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-lvalue.cc, oct-lvalue.h, oct-map.h, oct-obj.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct.h, octave-default-image.h, octave-link.h, octave-preserve-stream-state.h, ordschur.cc, pager.cc, pager.h, pinv.cc, pr-output.cc, pr-output.h, procstream.cc, procstream.h, profiler.h, psi.cc, pt-jit.cc, pt-jit.h, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, toplev.h, tril.cc, tsearch.cc, txt-eng.cc, txt-eng.h, typecast.cc, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, workspace-element.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, zfstream.cc, zfstream.h, deprecated-config.h, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, gzip.cc, oct-qhull.h, qr.cc, symbfact.cc, symrcm.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.cc, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int-traits.h, ov-int16.cc, ov-int16.h, ov-int32.cc, ov-int32.h, ov-int64.cc, ov-int64.h, ov-int8.cc, ov-int8.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc, ov-typeinfo.h, ov-uint16.cc, ov-uint16.h, ov-uint32.cc, ov-uint32.h, ov-uint64.cc, ov-uint64.h, ov-uint8.cc, ov-uint8.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-pm.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcm-pm.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fm-pm.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int.h, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-pm.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-cm.cc, op-pm-fcm.cc, op-pm-fm.cc, op-pm-m.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, options-usage.h, lex.h, parse.h, pt-all.h, pt-arg-list.cc, pt-arg-list.h, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.cc, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.cc, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc, pt-stmt.h, pt-unop.cc, pt-unop.h, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Array-jit.cc, Array-tc.cc, version.cc, version.in.h: Style check C++ code in libinterp/
author Rik <rik@octave.org>
date Tue, 30 Aug 2016 21:46:47 -0700
parents bac0d6f07a3e
children 3a2b891d0b33 e9a0469dedd9
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
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22305
diff changeset
3 Copyright (C) 1996-2016 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
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5829
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5829
diff changeset
11 option) any later version.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
12
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
16 for more details.
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})
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
48 Compute the right eigenvalues(V) and optionally the eigenvectors(lambda) and
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
49 the left eigenvalues(W) of a matrix or a pair of matrices.
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
50
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
51 The flag @var{balanceOption} can be one of:
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
52
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
53 @table @asis
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
54 @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
55 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
56
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
57 @item @qcode{"nobalance"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
58 Disables preliminary balancing.
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
59 @end table
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
60
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
61 The flag @var{eigvalOption} can be one of:
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
62
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
63 @table @asis
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
64 @item @qcode{"matrix"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
65 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
66 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
67
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
68 @item @qcode{"vector"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
69 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
70 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
71 @end table
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
72
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
73 The flag @var{algorithm} can be one of:
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
74
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
75 @table @asis
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
76 @item @qcode{"chol"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
77 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
78 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
79
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
80 @item @qcode{"qz"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
81 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
82 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
83 @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
84
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
85 @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
86 @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
87 @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
88 @tab @qcode{"chol"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
89 @tab @qcode{"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{"qz"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
91 @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
92 @tab @qcode{"qz"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
93 @tab @qcode{"qz"}
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
94 @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 @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
96
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
97 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
98 @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
99 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
100 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
101 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
102
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
103 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
104 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
105
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
106 octave_value_list retval;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
107
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
108 octave_value arg_a, arg_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
109
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
110 arg_a = args(0);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
111
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
112 if (arg_a.is_empty ())
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
113 return octave_value_list (2, Matrix ());
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
114
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
115 if (! arg_a.is_float_type ())
21129
228b65504557 maint: Eliminate useless statements after err_XXX.
Rik <rik@octave.org>
parents: 21110
diff changeset
116 err_wrong_type_arg ("eig", arg_a);
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
117
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
118 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
119 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
120
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
121 // 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
122 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
123
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
124 if (! AEPcase)
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
125 {
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
126 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
127
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
128 if (arg_b.is_empty ())
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
129 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
130
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
131 if (! arg_b.is_float_type ())
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
132 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
133
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
134 if (arg_b.rows () != arg_b.columns ())
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
135 err_square_matrix_required ("eig", "B");
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
136 }
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
137
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
138 bool 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
139 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
140 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
141 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
142 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
143 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
144
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
145 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
146 {
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
147 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
148 err_wrong_type_arg ("eig", args(i));
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
149
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
164 error ("eig: invalid option \"%s\"", arg_i.c_str ());
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
165 }
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
166
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
167 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
168 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
169 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
170 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
171 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
172 error ("eig: \"qz\" and \"chol\" options are mutually exclusive");
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
173
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
174 if (AEPcase)
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
175 {
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
176 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
177 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
178 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
179 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
180 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
181 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
182 {
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
183 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
184 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
185 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
186 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
187 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
188
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
189 // Default is to balance
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
190 const bool balance = no_balance_flag ? false : true;
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
191 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
192
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
193
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
194 Matrix tmp_a, tmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
195 ComplexMatrix ctmp_a, ctmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
196 FloatMatrix ftmp_a, ftmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
197 FloatComplexMatrix fctmp_a, fctmp_b;
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
198
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
199 if (arg_a.is_single_type ())
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
200 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
201 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
202 if (AEPcase)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
203 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
204 if (arg_a.is_real_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
205 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
206 ftmp_a = arg_a.float_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
207
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
208 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
209 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
210 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
211 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
212 fctmp_a = arg_a.float_complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
213
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
214 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
215 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
216 }
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
217 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
218 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
219 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
220 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
221 ftmp_a = arg_a.float_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
222 ftmp_b = arg_b.float_matrix_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
223
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
224 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
225 force_qz);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
226 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
227 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
228 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
229 fctmp_a = arg_a.float_complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
230 fctmp_b = arg_b.float_complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
231
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
232 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
233 force_qz);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
234 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
235 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
236
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
237 if (nargout == 0 || nargout == 1)
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
238 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
239 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
240 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
241 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
242 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
243 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
244 else 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
245 {
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
246 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
247 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
248 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
249 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
250 FloatComplexDiagMatrix (result.eigenvalues ()));
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
251 }
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
252 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
253 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
254 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
255 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
256 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
257 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
258 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
259 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
260 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
261 result.left_eigenvectors ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
262 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
263 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
264 else
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
265 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
266 EIG result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
267
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
268 if (AEPcase)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
269 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
270 if (arg_a.is_real_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
271 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
272 tmp_a = arg_a.matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7578
diff changeset
273
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
274 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
275 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
276 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
277 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
278 ctmp_a = arg_a.complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
279
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
280 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
281 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
282 }
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
283 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
284 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
285 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
286 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
287 tmp_a = arg_a.matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
288 tmp_b = arg_b.matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
289
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
290 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
291 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
292 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
293 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
294 ctmp_a = arg_a.complex_matrix_value ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
295 ctmp_b = arg_b.complex_matrix_value ();
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
296
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
297 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
298 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
299 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
300
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
301 if (nargout == 0 || nargout == 1)
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
302 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
303 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
304 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
305 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
306 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
307 }
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
308 else 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
309 {
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
310 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
311 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
312 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
313 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
314 ComplexDiagMatrix (result.eigenvalues ()));
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
315 }
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20490
diff changeset
316 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
317 {
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
318 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
319 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
320 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
321 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
322 else
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
323 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
324 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
325 result.left_eigenvectors ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9307
diff changeset
326 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
327 }
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 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
330 }
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 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
333 %!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
334
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
335 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
336 %! [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
337 %! 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
338 %! 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
339 %! 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
340
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
341 %!test
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
342 %! [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
343 %! 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
344 %! 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
345
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
346 %!test
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
347 %! [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
348 %! 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
349 %! 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
350 %! 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
351
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
352 %!test
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
353 %! [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
354 %! 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
355 %! 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
356
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
357 %!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
358
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
359 %!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
360 %! 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
361
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
362 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
363 %! [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
364 %! 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
365 %! 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
366 %! assert (v, [-x, x; x, x], sqrt (eps ("single")))
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
367
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
368 %!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
369 %! [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
370 %! 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
371 %! assert (w, [-x, x; x, x], sqrt (eps ("single")))
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
372
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
373 %!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
374 %! [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
375 %! 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
376 %! 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
377 %! assert (v, [-x, x; x, x], sqrt (eps ("single")))
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
378
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
379 %!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
380 %! [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
381 %! 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
382 %! 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
383
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
384
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
385 ## 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
386 ## 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
387 ## 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
388 ## 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
389 %!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
390 %! [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
391 %! [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
392 %! [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
393 %! 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
394 %! 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
395 %! 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
396 %! 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
397 %! 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
398 %! 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
399 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
400
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
401 %!test nonsym_chol_2_output ([1, 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
402 %!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
403 %!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
404
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
405 %!test nonsym_chol_2_output (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
406 %! 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
407 %!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
408 %! 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
409 %! sqrt (eps ("single")))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
410
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
411 %!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
412 %! [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
413 %! [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
414 %! [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
415 %! 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
416 %! 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
417 %! 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
418 %! 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
419 %! 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
420 %! 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
421 %! 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
422 %! 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
423 %! 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
424 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
425
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
426 %!test nonsym_chol_3_output ([1, 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
427 %!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
428 %!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
429
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
430 %!test nonsym_chol_3_output (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
431 %! 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
432 %!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
433 %! 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
434 %! sqrt (eps ("single")))
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
435
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
436 ## 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
437 ## 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
438 ## 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
439 %!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
440 %! [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
441 %! [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
442 %! 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
443 %! 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
444 %! 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
445 %! 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
446 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
447
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
448 %!test sym_chol_2_input ([1, 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
449 %!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
450 %!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
451
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
452 %!test sym_chol_2_input (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
453 %! 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
454 %!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
455 %! 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
456 %!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
457 %! 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
458
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
459 %!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
460 %! [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
461 %! [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
462 %! 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
463 %! 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
464 %! 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
465 %! 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
466 %! 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
467 %! 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
468 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
469
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
470 %!test sym_chol_3_input ([1, 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
471 %!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
472 %!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
473
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
474 %!test sym_chol_3_input (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
475 %! 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
476 %!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
477 %! 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
478 %!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
479 %! 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
480
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
481 ## "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
482 ## 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
483 ## while in this case "nobalance" should produce different result
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
484 %!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
485 %! 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
486 %! [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
487 %! [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
488 %! [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
489 %! 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
490 %! 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
491 %! 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
492
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
493 ## 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
494 ## 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
495 ## 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
496 ## 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
497 ## 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
498 ## 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
499 %!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
500 %! [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
501 %! [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
502 %! 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
503 %! 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
504 %! 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
505 %! 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
506 %! 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
507 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
508
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
509 %!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
510 %! 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
511 %! "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
512 %! 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
513 %! {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
514 %! 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
515 %! {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
516 %! endfor
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
517 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
518
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
519 %!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
520 %! 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
521 %! "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
522 %! 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
523 %! {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
524 %! 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
525 %! {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
526 %! endfor
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
527 %!endfunction
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
528
22305
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
529 ## 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
530 ## 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
531 ## 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
532 %!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
533 %! 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
534 %! 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
535 %! 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
536 %! 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
537 %! [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
538 %! 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
539 %! 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
540 %! 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
541 %! [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
542 %! 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
543 %! 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
544 %! 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
545 %! 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
546 %! 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
547 %! 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
548 %! 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
549 %! 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
550 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
551
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
552 %!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
553 %! 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
554 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
555
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
556 %!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
557 %! 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
558 %!endfunction
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
559
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
560 %!test balance_nobalance_with_shapes ([1, 2; 2, 1]);
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
561 %!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
562
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
563 %!test 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
564 %!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
565
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
566 %!test 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
567 %!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
568 %!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
569
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
570 %!test qz_chol_with_shapes (single ([1, 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
571 %!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
572 %!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
573
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
574 %!test shapes_GEP ([1, 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
575 %!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
576 %!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
577
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
578 %!test shapes_GEP (single ([1, 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
579 %!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
580 %!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
581
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
582 %!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
583 %! [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
584 %! [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
585 %! 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
586 %! 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
587 %!endfunction
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
588
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
589 %!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
590 %! 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
591 %! chol_qz_accuracy (minij_100, minij_100, false, true);
8339
18c4ded8612a Add generalized eigenvalue functions
Jarkko Kaleva <d3roga@gmail.com>
parents: 7814
diff changeset
592
20490
ff904ae0285b eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents: 20172
diff changeset
593 %!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
594 %! 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
595 %! 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
596
ff904ae0285b eig: Return correct solution for a pair of hermitian matrices (bug #45511)
Mike Miller <mtmiller@octave.org>
parents: 20172
diff changeset
597 %!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
598 %! 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
599 %! 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
600
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
601 %!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
602 %!error eig (false)
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
603 %!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
604
510886d03ef2 eig: new options for choice of algorithm, balancing, and output (patch #8960)
Barbara Locsi <locsi.barbara@gmail.com>
parents: 21966
diff changeset
605 %!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
606 %! 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
607 %!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
608 %! 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
609 %!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
610 %! 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
611 %!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
612 %! 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
613 %!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
614 %! 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
615 %!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
616 %! 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
617 %!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
618 %! 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
619 %!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
620 %! 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
621 %!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
622 %! 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
623 %!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
624 %! 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
625 %!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
626 %! 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
627 %!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
628 %! 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
629 %!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
630 %! 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
631 %!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
632 %! 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
633 %!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
634 %! 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
635 %!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
636 %! 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
637 %!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
638 %! 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
639 %!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
640 %! 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
641 %!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
642 %! 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
643 */
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
644