Mercurial > octave-nkf
annotate libinterp/corefcn/svd.cc @ 17787:175b392e91fe
Use GNU style coding conventions for code in libinterp/
* libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc,
libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc,
libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc,
libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h,
libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc,
libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h,
libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc,
libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc,
libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc,
libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc,
libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h,
libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc,
libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc,
libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h,
libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/input.h, libinterp/corefcn/inv.cc,
libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc,
libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h,
libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc,
libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc,
libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc,
libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc,
libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc,
libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc,
libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h,
libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc,
libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc,
libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h,
libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h,
libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc,
libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h,
libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h,
libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h,
libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h,
libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h,
libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc,
libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h,
libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h,
libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc,
libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc,
libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc,
libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc,
libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc,
libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc,
libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h,
libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc,
libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h,
libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc,
libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc,
libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc,
libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc,
libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc,
libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc,
libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc,
libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc,
libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc,
libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc,
libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc,
libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc,
libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h,
libinterp/octave-value/ov-base-scalar.cc,
libinterp/octave-value/ov-base-scalar.h,
libinterp/octave-value/ov-base-sparse.cc,
libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc,
libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc,
libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc,
libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc,
libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc,
libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc,
libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h,
libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h,
libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h,
libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h,
libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h,
libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-handle.h,
libinterp/octave-value/ov-fcn-inline.cc,
libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h,
libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h,
libinterp/octave-value/ov-flt-complex.cc,
libinterp/octave-value/ov-flt-complex.h,
libinterp/octave-value/ov-flt-cx-diag.cc,
libinterp/octave-value/ov-flt-cx-diag.h,
libinterp/octave-value/ov-flt-cx-mat.cc,
libinterp/octave-value/ov-flt-cx-mat.h,
libinterp/octave-value/ov-flt-re-diag.cc,
libinterp/octave-value/ov-flt-re-diag.h,
libinterp/octave-value/ov-flt-re-mat.cc,
libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc,
libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc,
libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h,
libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h,
libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h,
libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h,
libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc,
libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc,
libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc,
libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc,
libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc,
libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc,
libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc,
libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h,
libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc,
libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h,
libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc,
libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc,
libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc,
libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc,
libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc,
libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc,
libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc,
libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc,
libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc,
libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc,
libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc,
libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc,
libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc,
libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc,
libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc,
libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc,
libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc,
libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc,
libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc,
libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc,
libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc,
libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc,
libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc,
libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc,
libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc,
libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc,
libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc,
libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc,
libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc,
libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc,
libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc,
libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc,
libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc,
libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc,
libinterp/operators/ops.h, libinterp/parse-tree/lex.h,
libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc,
libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc,
libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc,
libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h,
libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc,
libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h,
libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc,
libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h,
libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc,
libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc,
libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h,
libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc,
libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc,
libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h,
libinterp/parse-tree/token.h, libinterp/version.cc:
Use GNU style coding conventions for code in libinterp/
author | Rik <rik@octave.org> |
---|---|
date | Mon, 28 Oct 2013 19:51:46 -0700 |
parents | d63878346099 |
children | 4197fc428c7d |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
2928 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2928 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2928 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "CmplxSVD.h" | |
28 #include "dbleSVD.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
29 #include "fCmplxSVD.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
30 #include "floatSVD.h" |
2928 | 31 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
32 #include "defun.h" |
2928 | 33 #include "error.h" |
34 #include "gripes.h" | |
35 #include "oct-obj.h" | |
36 #include "pr-output.h" | |
37 #include "utils.h" | |
10638
e1559a8a60b4
general mechanism for string enum variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10601
diff
changeset
|
38 #include "variables.h" |
2928 | 39 |
10638
e1559a8a60b4
general mechanism for string enum variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10601
diff
changeset
|
40 static int Vsvd_driver = SVD::GESVD; |
10601 | 41 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
42 DEFUN (svd, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
44 @deftypefn {Built-in Function} {@var{s} =} svd (@var{A})\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
45 @deftypefnx {Built-in Function} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A})\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
46 @deftypefnx {Built-in Function} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A}, @var{econ})\n\ |
3372 | 47 @cindex singular value decomposition\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11533
diff
changeset
|
48 Compute the singular value decomposition of @var{A}\n\ |
3372 | 49 @tex\n\ |
50 $$\n\ | |
12584
7ef7e20057fa
Improve documentation strings in Linear Algebra chapter.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
51 A = U S V^{\\dagger}\n\ |
3372 | 52 $$\n\ |
53 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
54 @ifnottex\n\ |
3372 | 55 \n\ |
56 @example\n\ | |
6620 | 57 A = U*S*V'\n\ |
3372 | 58 @end example\n\ |
10840 | 59 \n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
60 @end ifnottex\n\ |
3372 | 61 \n\ |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10640
diff
changeset
|
62 The function @code{svd} normally returns only the vector of singular values.\n\ |
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10640
diff
changeset
|
63 When called with three return values, it computes\n\ |
3372 | 64 @tex\n\ |
65 $U$, $S$, and $V$.\n\ | |
66 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
67 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11533
diff
changeset
|
68 @var{U}, @var{S}, and @var{V}.\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7814
diff
changeset
|
69 @end ifnottex\n\ |
3372 | 70 For example,\n\ |
71 \n\ | |
72 @example\n\ | |
73 svd (hilb (3))\n\ | |
74 @end example\n\ | |
75 \n\ | |
76 @noindent\n\ | |
77 returns\n\ | |
2928 | 78 \n\ |
3372 | 79 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
80 @group\n\ |
3372 | 81 ans =\n\ |
82 \n\ | |
83 1.4083189\n\ | |
84 0.1223271\n\ | |
85 0.0026873\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
86 @end group\n\ |
3372 | 87 @end example\n\ |
88 \n\ | |
89 @noindent\n\ | |
90 and\n\ | |
91 \n\ | |
92 @example\n\ | |
93 [u, s, v] = svd (hilb (3))\n\ | |
94 @end example\n\ | |
95 \n\ | |
96 @noindent\n\ | |
97 returns\n\ | |
98 \n\ | |
99 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
100 @group\n\ |
3372 | 101 u =\n\ |
2928 | 102 \n\ |
3372 | 103 -0.82704 0.54745 0.12766\n\ |
104 -0.45986 -0.52829 -0.71375\n\ | |
105 -0.32330 -0.64901 0.68867\n\ | |
106 \n\ | |
107 s =\n\ | |
108 \n\ | |
109 1.40832 0.00000 0.00000\n\ | |
110 0.00000 0.12233 0.00000\n\ | |
111 0.00000 0.00000 0.00269\n\ | |
112 \n\ | |
113 v =\n\ | |
114 \n\ | |
115 -0.82704 0.54745 0.12766\n\ | |
116 -0.45986 -0.52829 -0.71375\n\ | |
117 -0.32330 -0.64901 0.68867\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
118 @end group\n\ |
3372 | 119 @end example\n\ |
120 \n\ | |
121 If given a second argument, @code{svd} returns an economy-sized\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11533
diff
changeset
|
122 decomposition, eliminating the unnecessary rows or columns of @var{U} or\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11533
diff
changeset
|
123 @var{V}.\n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15888
diff
changeset
|
124 @seealso{svd_driver, svds, eig, lu, chol, hess, qr, qz}\n\ |
3372 | 125 @end deftypefn") |
2928 | 126 { |
127 octave_value_list retval; | |
128 | |
129 int nargin = args.length (); | |
130 | |
131 if (nargin < 1 || nargin > 2 || nargout == 2 || nargout > 3) | |
132 { | |
5823 | 133 print_usage (); |
2928 | 134 return retval; |
135 } | |
136 | |
137 octave_value arg = args(0); | |
138 | |
5275 | 139 octave_idx_type nr = arg.rows (); |
140 octave_idx_type nc = arg.columns (); | |
2928 | 141 |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
142 if (arg.ndims () != 2) |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
143 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11533
diff
changeset
|
144 error ("svd: A must be a 2-D matrix"); |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
145 return retval; |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
146 } |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
147 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
148 bool isfloat = arg.is_single_type (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
149 |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
150 SVD::type type = ((nargout == 0 || nargout == 1) |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
151 ? SVD::sigma_only |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
152 : (nargin == 2) ? SVD::economy : SVD::std); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
153 |
10638
e1559a8a60b4
general mechanism for string enum variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10601
diff
changeset
|
154 SVD::driver driver = static_cast<SVD::driver> (Vsvd_driver); |
e1559a8a60b4
general mechanism for string enum variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10601
diff
changeset
|
155 |
4478 | 156 if (nr == 0 || nc == 0) |
2928 | 157 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
158 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
159 { |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
160 switch (type) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
161 { |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
162 case SVD::std: |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
163 retval(2) = FloatDiagMatrix (nc, nc, 1.0f); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
164 retval(1) = FloatMatrix (nr, nc); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
165 retval(0) = FloatDiagMatrix (nr, nr, 1.0f); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
166 break; |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
167 case SVD::economy: |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
168 retval(2) = FloatDiagMatrix (0, nc, 1.0f); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
169 retval(1) = FloatMatrix (0, 0); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
170 retval(0) = FloatDiagMatrix (nr, 0, 1.0f); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
171 break; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
172 case SVD::sigma_only: default: |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
173 retval(0) = FloatMatrix (0, 1); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
174 break; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
175 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
176 } |
4478 | 177 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
178 { |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
179 switch (type) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
180 { |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
181 case SVD::std: |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
182 retval(2) = DiagMatrix (nc, nc, 1.0); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
183 retval(1) = Matrix (nr, nc); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
184 retval(0) = DiagMatrix (nr, nr, 1.0); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
185 break; |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
186 case SVD::economy: |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
187 retval(2) = DiagMatrix (0, nc, 1.0); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
188 retval(1) = Matrix (0, 0); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
189 retval(0) = DiagMatrix (nr, 0, 1.0); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
190 break; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
191 case SVD::sigma_only: default: |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
192 retval(0) = Matrix (0, 1); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
193 break; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
194 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
195 } |
2928 | 196 } |
197 else | |
198 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
199 if (isfloat) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
200 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
201 if (arg.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
202 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
203 FloatMatrix tmp = arg.float_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
204 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
205 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
206 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
207 if (tmp.any_element_is_inf_or_nan ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
208 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
209 error ("svd: cannot take SVD of matrix containing Inf or NaN values"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
210 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
211 } |
4478 | 212 |
10601 | 213 FloatSVD result (tmp, type, driver); |
4478 | 214 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
215 FloatDiagMatrix sigma = result.singular_values (); |
4478 | 216 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
217 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
218 { |
15448
0a0912a9ab6e
Replace deprecated DiagArray2<T>::diag calls with DiagArray2<T>::extract_diag
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15195
diff
changeset
|
219 retval(0) = sigma.extract_diag (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
220 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
221 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
222 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
223 retval(2) = result.right_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
224 retval(1) = sigma; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
225 retval(0) = result.left_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
226 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
227 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
228 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
229 else if (arg.is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
230 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
231 FloatComplexMatrix ctmp = arg.float_complex_matrix_value (); |
4478 | 232 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
233 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
234 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
235 if (ctmp.any_element_is_inf_or_nan ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
236 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
237 error ("svd: cannot take SVD of matrix containing Inf or NaN values"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
238 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
239 } |
4478 | 240 |
10601 | 241 FloatComplexSVD result (ctmp, type, driver); |
4478 | 242 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
243 FloatDiagMatrix sigma = result.singular_values (); |
4478 | 244 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
245 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
246 { |
15448
0a0912a9ab6e
Replace deprecated DiagArray2<T>::diag calls with DiagArray2<T>::extract_diag
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15195
diff
changeset
|
247 retval(0) = sigma.extract_diag (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
248 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
249 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
250 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
251 retval(2) = result.right_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
252 retval(1) = sigma; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
253 retval(0) = result.left_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
254 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
255 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
256 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
257 } |
4478 | 258 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
259 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
260 if (arg.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
261 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
262 Matrix tmp = arg.matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
263 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
264 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
265 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
266 if (tmp.any_element_is_inf_or_nan ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
267 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
268 error ("svd: cannot take SVD of matrix containing Inf or NaN values"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
269 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
270 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
271 |
10601 | 272 SVD result (tmp, type, driver); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
273 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
274 DiagMatrix sigma = result.singular_values (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
275 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
276 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
277 { |
15448
0a0912a9ab6e
Replace deprecated DiagArray2<T>::diag calls with DiagArray2<T>::extract_diag
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15195
diff
changeset
|
278 retval(0) = sigma.extract_diag (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
279 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
280 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
281 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
282 retval(2) = result.right_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
283 retval(1) = sigma; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
284 retval(0) = result.left_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
285 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
286 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
287 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
288 else if (arg.is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
289 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
290 ComplexMatrix ctmp = arg.complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
291 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
292 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
293 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
294 if (ctmp.any_element_is_inf_or_nan ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
295 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
296 error ("svd: cannot take SVD of matrix containing Inf or NaN values"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
297 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
298 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
299 |
10601 | 300 ComplexSVD result (ctmp, type, driver); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
301 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
302 DiagMatrix sigma = result.singular_values (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
303 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
304 if (nargout == 0 || nargout == 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
305 { |
15448
0a0912a9ab6e
Replace deprecated DiagArray2<T>::diag calls with DiagArray2<T>::extract_diag
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15195
diff
changeset
|
306 retval(0) = sigma.extract_diag (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
307 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
308 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
309 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
310 retval(2) = result.right_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
311 retval(1) = sigma; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
312 retval(0) = result.left_singular_matrix (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
313 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
314 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
315 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
316 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
317 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
318 gripe_wrong_type_arg ("svd", arg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
319 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
320 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
321 } |
2928 | 322 } |
323 | |
324 return retval; | |
325 } | |
326 | |
327 /* | |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
328 %!assert (svd ([1, 2; 2, 1]), [3; 1], 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
|
329 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
330 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
331 %! [u, s, v] = svd ([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
|
332 %! x = 1 / sqrt (2); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
333 %! assert (u, [-x, -x; -x, x], sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
334 %! assert (s, [3, 0; 0, 1], sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
335 %! assert (v, [-x, x; -x, -x], sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
336 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
337 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
338 %! a = [1, 2, 3; 4, 5, 6]; |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
339 %! [u, s, v] = svd (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
340 %! assert (u * s * v', a, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
341 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
342 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
343 %! a = [1, 2; 3, 4; 5, 6]; |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
344 %! [u, s, v] = svd (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
345 %! assert (u * s * v', a, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
346 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
347 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
348 %! a = [1, 2, 3; 4, 5, 6]; |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
349 %! [u, s, v] = svd (a, 1); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
350 %! assert (u * s * v', a, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
351 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
352 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
353 %! a = [1, 2; 3, 4; 5, 6]; |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
354 %! [u, s, v] = svd (a, 1); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
355 %! assert (u * s * v', a, sqrt (eps)); |
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 (svd (single ([1, 2; 2, 1])), single ([3; 1]), 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 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
359 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
360 %! [u, s, v] = svd (single ([1, 2; 2, 1])); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
361 %! x = single (1 / sqrt (2)); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
362 %! assert (u, [-x, -x; -x, x], sqrt (eps ("single"))); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
363 %! assert (s, single ([3, 0; 0, 1]), sqrt (eps ("single"))); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
364 %! assert (v, [-x, x; -x, -x], 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
|
365 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
366 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
367 %! a = single ([1, 2, 3; 4, 5, 6]); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
368 %! [u, s, v] = svd (a); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
369 %! assert (u * s * v', a, 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
|
370 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
371 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
372 %! a = single ([1, 2; 3, 4; 5, 6]); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
373 %! [u, s, v] = svd (a); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
374 %! assert (u * s * v', a, 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
|
375 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
376 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
377 %! a = single ([1, 2, 3; 4, 5, 6]); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
378 %! [u, s, v] = svd (a, 1); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
379 %! assert (u * s * v', a, 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
|
380 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
381 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
382 %! a = single ([1, 2; 3, 4; 5, 6]); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
383 %! [u, s, v] = svd (a, 1); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
384 %! assert (u * s * v', a, 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
|
385 |
10185
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
386 %!test |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
387 %! a = zeros (0, 5); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
388 %! [u, s, v] = svd (a); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
389 %! assert (size (u), [0, 0]); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
390 %! assert (size (s), [0, 5]); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
391 %! assert (size (v), [5, 5]); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
392 |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
393 %!test |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
394 %! a = zeros (5, 0); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
395 %! [u, s, v] = svd (a, 1); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
396 %! assert (size (u), [5, 0]); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
397 %! assert (size (s), [0, 0]); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
398 %! assert (size (v), [0, 0]); |
455759a5fcbe
fix norm and svd on empty matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10155
diff
changeset
|
399 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
400 %!error svd () |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
401 %!error svd ([1, 2; 4, 5], 2, 3) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
402 %!error [u, v] = svd ([1, 2; 3, 4]) |
2928 | 403 */ |
10601 | 404 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
405 DEFUN (svd_driver, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
406 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
407 @deftypefn {Built-in Function} {@var{val} =} svd_driver ()\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
408 @deftypefnx {Built-in Function} {@var{old_val} =} svd_driver (@var{new_val})\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14501
diff
changeset
|
409 @deftypefnx {Built-in Function} {} svd_driver (@var{new_val}, \"local\")\n\ |
12584
7ef7e20057fa
Improve documentation strings in Linear Algebra chapter.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
410 Query or set the underlying @sc{lapack} driver used by @code{svd}.\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
411 Currently recognized values are @qcode{\"gesvd\"} and @qcode{\"gesdd\"}. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
412 The default is @qcode{\"gesvd\"}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13915
diff
changeset
|
413 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
414 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
415 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
416 The original variable value is restored when exiting the function.\n\ |
10601 | 417 @seealso{svd}\n\ |
418 @end deftypefn") | |
419 { | |
10640
5c594472f75e
determine string enum length by trailing null rather than sizeof
Jaroslav Hajek <highegg@gmail.com>
parents:
10638
diff
changeset
|
420 static const char *driver_names[] = { "gesvd", "gesdd", 0 }; |
10601 | 421 |
10638
e1559a8a60b4
general mechanism for string enum variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10601
diff
changeset
|
422 return SET_INTERNAL_VARIABLE_CHOICES (svd_driver, driver_names); |
10601 | 423 } |
15887
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
424 |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
425 /* |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
426 %!test |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
427 %! A = [1+1i, 1-1i, 0; 0, 2, 0; 1i, 1i, 1+2i]; |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
428 %! old_driver = svd_driver ("gesvd"); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
429 %! [U1, S1, V1] = svd (A); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
430 %! svd_driver ("gesdd"); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
431 %! [U2, S2, V2] = svd (A); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
432 %! assert (U1, U2, 5*eps); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
433 %! assert (S1, S2, 5*eps); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
434 %! assert (V1, V2, 5*eps); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
435 %! svd_driver (old_driver); |
8ced82e96b48
Fix segfaults with gesdd driver for svd (bug #37998).
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
436 */ |