annotate liboctave/numeric/svd.cc @ 31605:e88a07dec498 stable

maint: Use macros to begin/end C++ namespaces. * oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE, OCTAVE_END_NAMESPACE) that can be used to start/end a namespace. * mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc, __dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc, auto-shlib.h, balance.cc, base-text-renderer.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, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc, display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h, mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc, pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, 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-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-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-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-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-mi.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, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, 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.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-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, 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-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 14:23:45 -0800
parents d17ee5e7b66c
children aac27ad79be6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30394
diff changeset
3 // Copyright (C) 1994-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21273
diff changeset
27 # include "config.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
28 #endif
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
29
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
30 #include <cassert>
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
31
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
32 #include <algorithm>
29609
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
33 #include <unordered_map>
1631
b0b22b6ce22f [project @ 1995-11-14 20:24:15 by jwe]
jwe
parents: 1545
diff changeset
34
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
35 #include "CMatrix.h"
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
36 #include "dDiagMatrix.h"
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
37 #include "dMatrix.h"
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
38 #include "fCMatrix.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
39 #include "fDiagMatrix.h"
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
40 #include "fMatrix.h"
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
41 #include "lo-error.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22317
diff changeset
42 #include "lo-lapack-proto.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
43 #include "svd.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
44
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
45 // class to compute optimal work space size (lwork) for DGEJSV and SGEJSV
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
46 template<typename T>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
47 class
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
48 gejsv_lwork
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
49 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
50 public:
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
51 gejsv_lwork () = delete;
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
52
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
53 // Unfortunately, dgejsv and sgejsv do not provide estimation of 'lwork'.
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
54 // Thus, we have to estimate it according to corresponding LAPACK
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
55 // documentation and related source codes (e.g. cgejsv).
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
56 // In LAPACKE (C interface to LAPACK), the memory handling code in
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
57 // LAPACKE_dgejsv() (lapacke_dgejsv.c, last visit 2019-02-17) uses
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
58 // the minimum required working space. In contrast, here the optimal
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
59 // working space size is computed, at the cost of much longer code.
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
60
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
61 static F77_INT optimal (char& joba, char& jobu, char& jobv,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
62 F77_INT m, F77_INT n);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
63
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
64 private:
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
65 typedef typename T::element_type P;
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
66
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
67 // functions could be called from GEJSV
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
68 static F77_INT geqp3_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
69 P *a, F77_INT lda,
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
70 F77_INT *jpvt, P *tau, P *work,
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
71 F77_INT lwork, F77_INT& info);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
72
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
73 static F77_INT geqrf_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
74 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
75 P *tau, P *work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
76 F77_INT lwork, F77_INT& info);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
77
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
78 static F77_INT gelqf_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
79 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
80 P *tau, P *work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
81 F77_INT lwork, F77_INT& info);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
82
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
83 static F77_INT ormlq_lwork (char& side, char& trans,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
84 F77_INT m, F77_INT n, F77_INT k,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
85 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
86 P *tau, P *c, F77_INT ldc,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
87 P *work, F77_INT lwork, F77_INT& info);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
88
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
89 static F77_INT ormqr_lwork (char& side, char& trans,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
90 F77_INT m, F77_INT n, F77_INT k,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
91 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
92 P *tau, P *c, F77_INT ldc,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
93 P *work, F77_INT lwork, F77_INT& info);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
94 };
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
95
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
96 #define GEJSV_REAL_QP3_LWORK(f, F) \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
97 F77_XFCN (f, F, (m, n, a, lda, jpvt, tau, work, lwork, info))
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
98
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
99 #define GEJSV_REAL_QR_LWORK(f, F) \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
100 F77_XFCN (f, F, (m, n, a, lda, tau, work, lwork, info))
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
101
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
102 #define GEJSV_REAL_ORM_LWORK(f, F) \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
103 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&side, 1), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
104 F77_CONST_CHAR_ARG2 (&trans, 1), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
105 m, n, k, a, lda, tau, \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
106 c, ldc, work, lwork, info \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
107 F77_CHAR_ARG_LEN (1) \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
108 F77_CHAR_ARG_LEN (1)))
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
109
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
110 // For Matrix
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
111 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
112 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
113 gejsv_lwork<Matrix>::geqp3_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
114 P *a, F77_INT lda,
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
115 F77_INT *jpvt, P *tau, P *work,
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
116 F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
117 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
118 GEJSV_REAL_QP3_LWORK (dgeqp3, DGEQP3);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
119 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
120 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
121
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
122 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
123 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
124 gejsv_lwork<Matrix>::geqrf_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
125 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
126 P *tau, P *work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
127 F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
128 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
129 GEJSV_REAL_QR_LWORK (dgeqrf, DGEQRF);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
130 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
131 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
132
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
133 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
134 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
135 gejsv_lwork<Matrix>::gelqf_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
136 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
137 P *tau, P *work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
138 F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
139 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
140 GEJSV_REAL_QR_LWORK (dgelqf, DGELQF);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
141 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
142 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
143
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
144 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
145 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
146 gejsv_lwork<Matrix>::ormlq_lwork (char& side, char& trans,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
147 F77_INT m, F77_INT n, F77_INT k,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
148 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
149 P *tau, P *c, F77_INT ldc,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
150 P *work, F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
151 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
152 GEJSV_REAL_ORM_LWORK (dormlq, DORMLQ);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
153 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
154 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
155
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
156 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
157 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
158 gejsv_lwork<Matrix>::ormqr_lwork (char& side, char& trans,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
159 F77_INT m, F77_INT n, F77_INT k,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
160 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
161 P *tau, P *c, F77_INT ldc,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
162 P *work, F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
163 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
164 GEJSV_REAL_ORM_LWORK (dormqr, DORMQR);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
165 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
166 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
167
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
168 // For FloatMatrix
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
169 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
170 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
171 gejsv_lwork<FloatMatrix>::geqp3_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
172 P *a, F77_INT lda,
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
173 F77_INT *jpvt, P *tau, P *work,
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
174 F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
175 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
176 GEJSV_REAL_QP3_LWORK (sgeqp3, SGEQP3);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
177 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
178 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
179
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
180 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
181 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
182 gejsv_lwork<FloatMatrix>::geqrf_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
183 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
184 P *tau, P *work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
185 F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
186 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
187 GEJSV_REAL_QR_LWORK (sgeqrf, SGEQRF);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
188 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
189 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
190
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
191 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
192 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
193 gejsv_lwork<FloatMatrix>::gelqf_lwork (F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
194 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
195 P *tau, P *work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
196 F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
197 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
198 GEJSV_REAL_QR_LWORK (sgelqf, SGELQF);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
199 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
200 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
201
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
202 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
203 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
204 gejsv_lwork<FloatMatrix>::ormlq_lwork (char& side, char& trans,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
205 F77_INT m, F77_INT n, F77_INT k,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
206 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
207 P *tau, P *c, F77_INT ldc,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
208 P *work, F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
209 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
210 GEJSV_REAL_ORM_LWORK (sormlq, SORMLQ);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
211 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
212 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
213
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
214 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
215 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
216 gejsv_lwork<FloatMatrix>::ormqr_lwork (char& side, char& trans,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
217 F77_INT m, F77_INT n, F77_INT k,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
218 P *a, F77_INT lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
219 P *tau, P *c, F77_INT ldc,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
220 P *work, F77_INT lwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
221 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
222 GEJSV_REAL_ORM_LWORK (sormqr, SORMQR);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
223 return static_cast<F77_INT> (work[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
224 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
225
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
226 #undef GEJSV_REAL_QP3_LWORK
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
227 #undef GEJSV_REAL_QR_LWORK
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
228 #undef GEJSV_REAL_ORM_LWORK
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
229
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
230 template<typename T>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
231 F77_INT
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
232 gejsv_lwork<T>::optimal (char& joba, char& jobu, char& jobv,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
233 F77_INT m, F77_INT n)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
234 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
235 F77_INT lwork = -1;
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
236 std::vector<P> work (2); // dummy work space
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
237
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
238 // variables that mimic running environment of gejsv
29416
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
239 F77_INT lda = std::max<F77_INT> (m, 1);
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
240 F77_INT ierr = 0;
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
241 char side = 'L';
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
242 char trans = 'N';
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
243 std::vector<P> mat_a (1);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
244 P *a = mat_a.data (); // dummy input matrix
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
245 std::vector<F77_INT> vec_jpvt = {0};
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
246 P *tau = work.data ();
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
247 P *u = work.data ();
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
248 P *v = work.data ();
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
249
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
250 bool need_lsvec = jobu == 'U' || jobu == 'F';
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
251 bool need_rsvec = jobv == 'V' || jobv == 'J';
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
252
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
253 F77_INT lw_pocon = 3 * n; // for [s,d]pocon
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
254 F77_INT lw_geqp3 = geqp3_lwork (m, n, a, lda, vec_jpvt.data (),
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
255 tau, work.data (), -1, ierr);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
256 F77_INT lw_geqrf = geqrf_lwork (m, n, a, lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
257 tau, work.data (), -1, ierr);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
258
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
259 if (! (need_lsvec || need_rsvec) )
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
260 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
261 // only SIGMA is needed
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
262 if (! (joba == 'E' || joba == 'G') )
29416
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
263 lwork = std::max<F77_INT> ({2*m + n, n + lw_geqp3, n + lw_geqrf, 7});
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
264 else
29416
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
265 lwork = std::max<F77_INT> ({2*m + n, n + lw_geqp3, n + lw_geqrf,
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
266 n + n*n + lw_pocon, 7});
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
267 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
268 else if (need_rsvec && ! need_lsvec)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
269 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
270 // SIGMA and the right singular vectors are needed
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
271 F77_INT lw_gelqf = gelqf_lwork (n, n, a, lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
272 tau, work.data (), -1, ierr);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
273 trans = 'T';
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
274 F77_INT lw_ormlq = ormlq_lwork (side, trans, n, n, n, a, lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
275 tau, v, n, work.data (), -1, ierr);
29416
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
276 lwork = std::max<F77_INT> ({2*m + n, n + lw_geqp3, n + lw_pocon,
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
277 n + lw_gelqf, 2*n + lw_geqrf, n + lw_ormlq});
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
278 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
279 else if (need_lsvec && ! need_rsvec)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
280 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
281 // SIGMA and the left singular vectors are needed
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
282 F77_INT n1 = (jobu == 'U') ? n : m; // size of U is m x n1
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
283 F77_INT lw_ormqr = ormqr_lwork (side, trans, m, n1, n, a, lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
284 tau, u, m, work.data (), -1, ierr);
29416
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
285 lwork = std::max<F77_INT> ({2*m + n, n + lw_geqp3, n + lw_pocon,
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
286 2*n + lw_geqrf, n + lw_ormqr});
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
287 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
288 else // full SVD is needed
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
289 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
290 if (jobv == 'V')
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
291 lwork = std::max (2*m + n, 6*n + 2*n*n);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
292 else if (jobv == 'J')
29416
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
293 lwork = std::max<F77_INT> ({2*m + n, 4*n + n*n, 2*n + n*n + 6});
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
294
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
295 F77_INT n1 = (jobu == 'U') ? n : m; // size of U is m x n1
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
296 F77_INT lw_ormqr = ormqr_lwork (side, trans, m, n1, n, a, lda,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
297 tau, u, m, work.data (), -1, ierr);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
298 lwork = std::max (lwork, n + lw_ormqr);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
299 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
300
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
301 return lwork;
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
302 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
303
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31433
diff changeset
304 OCTAVE_BEGIN_NAMESPACE(octave)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31433
diff changeset
305
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31433
diff changeset
306 OCTAVE_BEGIN_NAMESPACE(math)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31433
diff changeset
307
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
308 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
309 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
310 svd<T>::left_singular_matrix (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
311 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
312 if (m_type == svd::Type::sigma_only)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
313 (*current_liboctave_error_handler)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
314 ("svd: U not computed because type == svd::sigma_only");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 19697
diff changeset
315
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
316 return m_left_sm;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
317 }
1543
d6e96e0bc681 [project @ 1995-10-06 05:49:21 by jwe]
jwe
parents: 1368
diff changeset
318
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
319 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
320 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
321 svd<T>::right_singular_matrix (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
322 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
323 if (m_type == svd::Type::sigma_only)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
324 (*current_liboctave_error_handler)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
325 ("svd: V not computed because type == svd::sigma_only");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 19697
diff changeset
326
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
327 return m_right_sm;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
328 }
1543
d6e96e0bc681 [project @ 1995-10-06 05:49:21 by jwe]
jwe
parents: 1368
diff changeset
329
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
330 // GESVD specializations
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
331
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
332 #define GESVD_REAL_STEP(f, F) \
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
333 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobu, 1), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
334 F77_CONST_CHAR_ARG2 (&jobv, 1), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
335 m, n, tmp_data, m1, s_vec, u, m1, vt, \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
336 nrow_vt1, work.data (), lwork, info \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
337 F77_CHAR_ARG_LEN (1) \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
338 F77_CHAR_ARG_LEN (1)))
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
339
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
340 #define GESVD_COMPLEX_STEP(f, F, CMPLX_ARG) \
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
341 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobu, 1), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
342 F77_CONST_CHAR_ARG2 (&jobv, 1), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
343 m, n, CMPLX_ARG (tmp_data), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
344 m1, s_vec, CMPLX_ARG (u), m1, \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
345 CMPLX_ARG (vt), nrow_vt1, \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
346 CMPLX_ARG (work.data ()), \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
347 lwork, rwork.data (), info \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
348 F77_CHAR_ARG_LEN (1) \
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
349 F77_CHAR_ARG_LEN (1)))
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
350
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
351 // DGESVD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
352 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
353 OCTAVE_API void
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
354 svd<Matrix>::gesvd (char& jobu, char& jobv, F77_INT m, F77_INT n,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
355 double *tmp_data, F77_INT m1, double *s_vec,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
356 double *u, double *vt, F77_INT nrow_vt1,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
357 std::vector<double>& work, F77_INT& lwork,
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
358 F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
359 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
360 GESVD_REAL_STEP (dgesvd, DGESVD);
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
361
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
362 lwork = static_cast<F77_INT> (work[0]);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
363 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
364
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
365 GESVD_REAL_STEP (dgesvd, DGESVD);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
366 }
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
367
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
368 // SGESVD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
369 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
370 OCTAVE_API void
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
371 svd<FloatMatrix>::gesvd (char& jobu, char& jobv, F77_INT m, F77_INT n,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
372 float *tmp_data, F77_INT m1, float *s_vec,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
373 float *u, float *vt, F77_INT nrow_vt1,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
374 std::vector<float>& work, F77_INT& lwork,
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
375 F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
376 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
377 GESVD_REAL_STEP (sgesvd, SGESVD);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
378
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
379 lwork = static_cast<F77_INT> (work[0]);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
380 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
381
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
382 GESVD_REAL_STEP (sgesvd, SGESVD);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
383 }
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
384
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
385 // ZGESVD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
386 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
387 OCTAVE_API void
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
388 svd<ComplexMatrix>::gesvd (char& jobu, char& jobv, F77_INT m, F77_INT n,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
389 Complex *tmp_data, F77_INT m1, double *s_vec,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
390 Complex *u, Complex *vt, F77_INT nrow_vt1,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
391 std::vector<Complex>& work, F77_INT& lwork,
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
392 F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
393 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
394 std::vector<double> rwork (5 * std::max (m, n));
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
395
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
396 GESVD_COMPLEX_STEP (zgesvd, ZGESVD, F77_DBLE_CMPLX_ARG);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
397
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
398 lwork = static_cast<F77_INT> (work[0].real ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
399 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
400
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
401 GESVD_COMPLEX_STEP (zgesvd, ZGESVD, F77_DBLE_CMPLX_ARG);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
402 }
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
403
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
404 // CGESVD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
405 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
406 OCTAVE_API void
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
407 svd<FloatComplexMatrix>::gesvd (char& jobu, char& jobv, F77_INT m,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
408 F77_INT n, FloatComplex *tmp_data,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
409 F77_INT m1, float *s_vec, FloatComplex *u,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
410 FloatComplex *vt, F77_INT nrow_vt1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
411 std::vector<FloatComplex>& work,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
412 F77_INT& lwork, F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
413 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
414 std::vector<float> rwork (5 * std::max (m, n));
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
415
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
416 GESVD_COMPLEX_STEP (cgesvd, CGESVD, F77_CMPLX_ARG);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
417
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
418 lwork = static_cast<F77_INT> (work[0].real ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
419 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
420
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
421 GESVD_COMPLEX_STEP (cgesvd, CGESVD, F77_CMPLX_ARG);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
422 }
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
423
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
424 #undef GESVD_REAL_STEP
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
425 #undef GESVD_COMPLEX_STEP
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
426
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
427 // GESDD specializations
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
428
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
429 #define GESDD_REAL_STEP(f, F) \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
430 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobz, 1), \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
431 m, n, tmp_data, m1, s_vec, u, m1, vt, nrow_vt1, \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
432 work.data (), lwork, iwork, info \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
433 F77_CHAR_ARG_LEN (1)))
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
434
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
435 #define GESDD_COMPLEX_STEP(f, F, CMPLX_ARG) \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
436 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobz, 1), m, n, \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
437 CMPLX_ARG (tmp_data), m1, \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
438 s_vec, CMPLX_ARG (u), m1, \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
439 CMPLX_ARG (vt), nrow_vt1, \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
440 CMPLX_ARG (work.data ()), lwork, \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
441 rwork.data (), iwork, info \
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
442 F77_CHAR_ARG_LEN (1)))
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
443
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
444 // DGESDD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
445 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
446 OCTAVE_API void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
447 svd<Matrix>::gesdd (char& jobz, F77_INT m, F77_INT n, double *tmp_data,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
448 F77_INT m1, double *s_vec, double *u, double *vt,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
449 F77_INT nrow_vt1, std::vector<double>& work,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
450 F77_INT& lwork, F77_INT *iwork, F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
451 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
452 GESDD_REAL_STEP (dgesdd, DGESDD);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
453
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
454 lwork = static_cast<F77_INT> (work[0]);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
455 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
456
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
457 GESDD_REAL_STEP (dgesdd, DGESDD);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
458 }
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
459
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
460 // SGESDD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
461 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
462 OCTAVE_API void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
463 svd<FloatMatrix>::gesdd (char& jobz, F77_INT m, F77_INT n, float *tmp_data,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
464 F77_INT m1, float *s_vec, float *u, float *vt,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
465 F77_INT nrow_vt1, std::vector<float>& work,
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
466 F77_INT& lwork, F77_INT *iwork, F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
467 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
468 GESDD_REAL_STEP (sgesdd, SGESDD);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
469
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
470 lwork = static_cast<F77_INT> (work[0]);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
471 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
472
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
473 GESDD_REAL_STEP (sgesdd, SGESDD);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
474 }
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
475
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
476 // ZGESDD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
477 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
478 OCTAVE_API void
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
479 svd<ComplexMatrix>::gesdd (char& jobz, F77_INT m, F77_INT n,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
480 Complex *tmp_data, F77_INT m1, double *s_vec,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
481 Complex *u, Complex *vt, F77_INT nrow_vt1,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
482 std::vector<Complex>& work, F77_INT& lwork,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
483 F77_INT *iwork, F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
484 {
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
485
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
486 F77_INT min_mn = std::min (m, n);
25349
a8a4b6e6e754 Fix lrwork dimension in svd for complex cases (bug #53823).
Marco Caliari <marco.caliari@univr.it>
parents: 25054
diff changeset
487 F77_INT max_mn = std::max (m, n);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
488
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
489 F77_INT lrwork;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
490 if (jobz == 'N')
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
491 lrwork = 7*min_mn;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
492 else
25349
a8a4b6e6e754 Fix lrwork dimension in svd for complex cases (bug #53823).
Marco Caliari <marco.caliari@univr.it>
parents: 25054
diff changeset
493 lrwork = min_mn * std::max (5*min_mn+5, 2*max_mn+2*min_mn+1);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
494
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
495 std::vector<double> rwork (lrwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
496
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
497 GESDD_COMPLEX_STEP (zgesdd, ZGESDD, F77_DBLE_CMPLX_ARG);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
498
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
499 lwork = static_cast<F77_INT> (work[0].real ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
500 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
501
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
502 GESDD_COMPLEX_STEP (zgesdd, ZGESDD, F77_DBLE_CMPLX_ARG);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
503 }
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
504
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
505 // CGESDD
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
506 template<>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
507 OCTAVE_API void
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
508 svd<FloatComplexMatrix>::gesdd (char& jobz, F77_INT m, F77_INT n,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
509 FloatComplex *tmp_data, F77_INT m1,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
510 float *s_vec, FloatComplex *u,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
511 FloatComplex *vt, F77_INT nrow_vt1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
512 std::vector<FloatComplex>& work,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
513 F77_INT& lwork, F77_INT *iwork,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
514 F77_INT& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
515 {
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
516 F77_INT min_mn = std::min (m, n);
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
517 F77_INT max_mn = std::max (m, n);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
518
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
519 F77_INT lrwork;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
520 if (jobz == 'N')
25349
a8a4b6e6e754 Fix lrwork dimension in svd for complex cases (bug #53823).
Marco Caliari <marco.caliari@univr.it>
parents: 25054
diff changeset
521 lrwork = 7*min_mn;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
522 else
25349
a8a4b6e6e754 Fix lrwork dimension in svd for complex cases (bug #53823).
Marco Caliari <marco.caliari@univr.it>
parents: 25054
diff changeset
523 lrwork = min_mn * std::max (5*min_mn+5, 2*max_mn+2*min_mn+1);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
524 std::vector<float> rwork (lrwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
525
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
526 GESDD_COMPLEX_STEP (cgesdd, CGESDD, F77_CMPLX_ARG);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
527
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
528 lwork = static_cast<F77_INT> (work[0].real ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
529 work.reserve (lwork);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
530
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
531 GESDD_COMPLEX_STEP (cgesdd, CGESDD, F77_CMPLX_ARG);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
532 }
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
533
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
534 #undef GESDD_REAL_STEP
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
535 #undef GESDD_COMPLEX_STEP
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
536
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
537 // GEJSV specializations
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
538
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
539 #define GEJSV_REAL_STEP(f, F) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
540 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&joba, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
541 F77_CONST_CHAR_ARG2 (&jobu, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
542 F77_CONST_CHAR_ARG2 (&jobv, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
543 F77_CONST_CHAR_ARG2 (&jobr, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
544 F77_CONST_CHAR_ARG2 (&jobt, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
545 F77_CONST_CHAR_ARG2 (&jobp, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
546 m, n, tmp_data, m1, s_vec, u, m1, v, nrow_v1, \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
547 work.data (), lwork, iwork.data (), info \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
548 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
549 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
550 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
551 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
552 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
553 F77_CHAR_ARG_LEN (1)))
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
554
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
555 #define GEJSV_COMPLEX_STEP(f, F, CMPLX_ARG) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
556 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&joba, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
557 F77_CONST_CHAR_ARG2 (&jobu, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
558 F77_CONST_CHAR_ARG2 (&jobv, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
559 F77_CONST_CHAR_ARG2 (&jobr, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
560 F77_CONST_CHAR_ARG2 (&jobt, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
561 F77_CONST_CHAR_ARG2 (&jobp, 1), \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
562 m, n, CMPLX_ARG (tmp_data), m1, \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
563 s_vec, CMPLX_ARG (u), m1, \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
564 CMPLX_ARG (v), nrow_v1, \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
565 CMPLX_ARG (work.data ()), lwork, \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
566 rwork.data (), lrwork, iwork.data (), info \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
567 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
568 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
569 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
570 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
571 F77_CHAR_ARG_LEN (1) \
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
572 F77_CHAR_ARG_LEN (1)))
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
573
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
574 // DGEJSV
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
575 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
576 void
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
577 svd<Matrix>::gejsv (char& joba, char& jobu, char& jobv,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
578 char& jobr, char& jobt, char& jobp,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
579 F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
580 P *tmp_data, F77_INT m1, DM_P *s_vec, P *u,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
581 P *v, F77_INT nrow_v1, std::vector<P>& work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
582 F77_INT& lwork, std::vector<F77_INT>& iwork,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
583 F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
584 {
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
585 lwork = gejsv_lwork<Matrix>::optimal (joba, jobu, jobv, m, n);
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
586 work.reserve (lwork);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
587
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
588 GEJSV_REAL_STEP (dgejsv, DGEJSV);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
589 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
590
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
591 // SGEJSV
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
592 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
593 void
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
594 svd<FloatMatrix>::gejsv (char& joba, char& jobu, char& jobv,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
595 char& jobr, char& jobt, char& jobp,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
596 F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
597 P *tmp_data, F77_INT m1, DM_P *s_vec, P *u,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
598 P *v, F77_INT nrow_v1, std::vector<P>& work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
599 F77_INT& lwork, std::vector<F77_INT>& iwork,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
600 F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
601 {
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
602 lwork = gejsv_lwork<FloatMatrix>::optimal (joba, jobu, jobv, m, n);
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
603 work.reserve (lwork);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
604
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
605 GEJSV_REAL_STEP (sgejsv, SGEJSV);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
606 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
607
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
608 // ZGEJSV
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
609 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
610 void
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
611 svd<ComplexMatrix>::gejsv (char& joba, char& jobu, char& jobv,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
612 char& jobr, char& jobt, char& jobp,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
613 F77_INT m, F77_INT n,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
614 P *tmp_data, F77_INT m1, DM_P *s_vec, P *u,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
615 P *v, F77_INT nrow_v1, std::vector<P>& work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
616 F77_INT& lwork, std::vector<F77_INT>& iwork,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
617 F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
618 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
619 F77_INT lrwork = -1; // work space size query
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
620 std::vector<double> rwork (1);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
621 work.reserve (2);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
622
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
623 GEJSV_COMPLEX_STEP (zgejsv, ZGEJSV, F77_DBLE_CMPLX_ARG);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
624
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
625 lwork = static_cast<F77_INT> (work[0].real ());
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
626 work.reserve (lwork);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
627
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
628 lrwork = static_cast<F77_INT> (rwork[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
629 rwork.reserve (lrwork);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
630
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
631 F77_INT liwork = static_cast<F77_INT> (iwork[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
632 iwork.reserve (liwork);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
633
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
634 GEJSV_COMPLEX_STEP (zgejsv, ZGEJSV, F77_DBLE_CMPLX_ARG);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
635 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
636
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
637 // CGEJSV
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
638 template<>
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
639 void
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
640 svd<FloatComplexMatrix>::gejsv (char& joba, char& jobu, char& jobv,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
641 char& jobr, char& jobt, char& jobp,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
642 F77_INT m, F77_INT n, P *tmp_data,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
643 F77_INT m1, DM_P *s_vec, P *u, P *v,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
644 F77_INT nrow_v1, std::vector<P>& work,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
645 F77_INT& lwork,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
646 std::vector<F77_INT>& iwork, F77_INT& info)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
647 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
648 F77_INT lrwork = -1; // work space size query
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
649 std::vector<float> rwork (1);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
650 work.reserve (2);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
651
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
652 GEJSV_COMPLEX_STEP (cgejsv, CGEJSV, F77_CMPLX_ARG);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
653
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
654 lwork = static_cast<F77_INT> (work[0].real ());
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
655 work.reserve (lwork);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
656
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
657 lrwork = static_cast<F77_INT> (rwork[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
658 rwork.reserve (lrwork);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
659
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
660 F77_INT liwork = static_cast<F77_INT> (iwork[0]);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
661 iwork.reserve (liwork);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
662
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
663 GEJSV_COMPLEX_STEP (cgejsv, CGEJSV, F77_CMPLX_ARG);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
664 }
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
665
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
666 #undef GEJSV_REAL_STEP
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
667 #undef GEJSV_COMPLEX_STEP
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
668
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
669 template<typename T>
29609
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
670 svd<T>::svd (const T& a, svd::Type type, svd::Driver driver)
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
671 : m_type (type), m_driver (driver), m_left_sm (), m_sigma (),
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
672 m_right_sm ()
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
673 {
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
674 F77_INT info;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
675
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23475
diff changeset
676 F77_INT m = to_f77_int (a.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23475
diff changeset
677 F77_INT n = to_f77_int (a.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
678
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
679 if (m == 0 || n == 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
680 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
681 switch (m_type)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
682 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
683 case svd::Type::std:
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
684 m_left_sm = T (m, m, 0);
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
685 for (F77_INT i = 0; i < m; i++)
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
686 m_left_sm.xelem (i, i) = 1;
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
687 m_sigma = DM_T (m, n);
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
688 m_right_sm = T (n, n, 0);
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
689 for (F77_INT i = 0; i < n; i++)
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
690 m_right_sm.xelem (i, i) = 1;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
691 break;
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
692
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
693 case svd::Type::economy:
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
694 m_left_sm = T (m, 0, 0);
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
695 m_sigma = DM_T (0, 0);
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
696 m_right_sm = T (n, 0, 0);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
697 break;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
698
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
699 case svd::Type::sigma_only:
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
700 default:
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
701 m_sigma = DM_T (0, 1);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
702 break;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
703 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
704 return;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
705 }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
706
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
707 T atmp = a;
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23448
diff changeset
708 P *tmp_data = atmp.fortran_vec ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
709
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
710 F77_INT min_mn = (m < n ? m : n);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
711
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
712 char jobu = 'A';
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
713 char jobv = 'A';
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
714
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
715 F77_INT ncol_u = m;
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
716 F77_INT nrow_vt = n;
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
717 F77_INT nrow_s = m;
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
718 F77_INT ncol_s = n;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
719
22228
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
720 switch (m_type)
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
721 {
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
722 case svd::Type::economy:
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
723 jobu = jobv = 'S';
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
724 ncol_u = nrow_vt = nrow_s = ncol_s = min_mn;
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
725 break;
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
726
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
727 case svd::Type::sigma_only:
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
728
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
729 // Note: for this case, both jobu and jobv should be 'N', but there
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
730 // seems to be a bug in dgesvd from Lapack V2.0. To demonstrate the
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
731 // bug, set both jobu and jobv to 'N' and find the singular values of
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
732 // [eye(3), eye(3)]. The result is [-sqrt(2), -sqrt(2), -sqrt(2)].
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
733 //
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
734 // For Lapack 3.0, this problem seems to be fixed.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
735
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
736 jobu = jobv = 'N';
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
737 ncol_u = nrow_vt = 1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
738 break;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
739
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
740 default:
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
741 break;
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
742 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
743
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
744 if (! (jobu == 'N' || jobu == 'O'))
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
745 m_left_sm.resize (m, ncol_u);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 22135
diff changeset
746
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
747 P *u = m_left_sm.fortran_vec ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
748
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
749 m_sigma.resize (nrow_s, ncol_s);
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
750 DM_P *s_vec = m_sigma.fortran_vec ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
751
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
752 if (! (jobv == 'N' || jobv == 'O'))
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
753 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
754 if (m_driver == svd::Driver::GEJSV)
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
755 m_right_sm.resize (n, nrow_vt);
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
756 else
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
757 m_right_sm.resize (nrow_vt, n);
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
758 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
759
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
760 P *vt = m_right_sm.fortran_vec ();
537
4ecbfd3c3710 [project @ 1994-07-21 22:30:34 by jwe]
jwe
parents: 457
diff changeset
761
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
762 // Query _GESVD for the correct dimension of WORK.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
763
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
764 F77_INT lwork = -1;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
765
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
766 std::vector<P> work (1);
537
4ecbfd3c3710 [project @ 1994-07-21 22:30:34 by jwe]
jwe
parents: 457
diff changeset
767
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
768 const F77_INT f77_int_one = static_cast<F77_INT> (1);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
769 F77_INT m1 = std::max (m, f77_int_one);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
770 F77_INT nrow_vt1 = std::max (nrow_vt, f77_int_one);
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
771
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
772 if (m_driver == svd::Driver::GESVD)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
773 gesvd (jobu, jobv, m, n, tmp_data, m1, s_vec, u, vt, nrow_vt1,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
774 work, lwork, info);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
775 else if (m_driver == svd::Driver::GESDD)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
776 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
777 assert (jobu == jobv);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
778 char jobz = jobu;
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
779
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
780 std::vector<F77_INT> iwork (8 * std::min (m, n));
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
781
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
782 gesdd (jobz, m, n, tmp_data, m1, s_vec, u, vt, nrow_vt1,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
783 work, lwork, iwork.data (), info);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
784 }
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
785 else if (m_driver == svd::Driver::GEJSV)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
786 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
787 bool transposed = false;
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
788 if (n > m)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
789 {
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
790 // GEJSV only accepts m >= n, thus we need to transpose here
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
791 transposed = true;
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
792
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
793 std::swap (m, n);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
794 m1 = std::max (m, f77_int_one);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
795 nrow_vt1 = std::max (n, f77_int_one); // we have m > n
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
796 if (m_type == svd::Type::sigma_only)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
797 nrow_vt1 = 1;
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
798 std::swap (jobu, jobv);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
799
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
800 atmp = atmp.hermitian ();
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
801 tmp_data = atmp.fortran_vec ();
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
802
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
803 // Swap pointers of U and V.
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
804 u = m_right_sm.fortran_vec ();
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
805 vt = m_left_sm.fortran_vec ();
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
806 }
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
807
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
808 // translate jobu and jobv from gesvd to gejsv.
29609
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
809 std::unordered_map<char, std::string> job_svd2jsv;
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
810 job_svd2jsv['A'] = "FJ";
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
811 job_svd2jsv['S'] = "UV";
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
812 job_svd2jsv['O'] = "WW";
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
813 job_svd2jsv['N'] = "NN";
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
814 jobu = job_svd2jsv[jobu][0];
5f46f2aacb82 svd: Use std::unordered_map for mapping of jobu and jobv from gesvd to gejsv.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29418
diff changeset
815 jobv = job_svd2jsv[jobv][1];
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
816
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
817 char joba = 'F'; // 'F': most conservative
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
818 char jobr = 'R'; // 'R' is recommended.
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
819 char jobt = 'N'; // or 'T', but that requires U and V appear together
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
820 char jobp = 'N'; // use 'P' if denormal is poorly implemented.
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
821
29416
3f45f5b6fa7f svd.cc: Use std::max<F77_INT> for Fortran integers (bug #55727).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29412
diff changeset
822 std::vector<F77_INT> iwork (std::max<F77_INT> (m + 3*n, 1));
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
823
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
824 gejsv (joba, jobu, jobv, jobr, jobt, jobp, m, n, tmp_data, m1,
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
825 s_vec, u, vt, nrow_vt1, work, lwork, iwork, info);
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
826
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
827 if (iwork[2] == 1)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
828 (*current_liboctave_warning_with_id_handler)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
829 ("Octave:convergence", "svd: (driver: GEJSV) "
31433
d17ee5e7b66c Fix typos and grammatical mistakes in text exposed to the user
Rafael Laboissiere <rafael@laboissiere.net>
parents: 30564
diff changeset
830 "Denormal occurred, possible loss of accuracy.");
29418
9245ae55b6bd Use Octave coding conventions in patch for GEJSV SVD driver (bug #55727).
Rik <rik@octave.org>
parents: 29416
diff changeset
831
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
832 if (info < 0)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
833 (*current_liboctave_error_handler)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
834 ("svd: (driver: GEJSV) Illegal argument at #%d",
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
835 static_cast<int> (-info));
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
836 else if (info > 0)
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
837 (*current_liboctave_warning_with_id_handler)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
838 ("Octave:convergence", "svd: (driver: GEJSV) "
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
839 "Fail to converge within max sweeps, "
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
840 "possible inaccurate result.");
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
841
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
842 if (transposed) // put things that need to transpose back here
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
843 std::swap (m, n);
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
844 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
845 else
23448
e1c02e7126a9 avoid calling abort if possible; include cstdlib for declaration if needed
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
846 (*current_liboctave_error_handler) ("svd: unknown driver");
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
847
26731
75d79c39ac92 Replace '-0' in sigma matrix from svd() with '+0' (bug #55710).
Rik <rik@octave.org>
parents: 26376
diff changeset
848 // LAPACK can return -0 which is a small problem (bug #55710).
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
849 for (octave_idx_type i = 0; i < m_sigma.diag_length (); i++)
26731
75d79c39ac92 Replace '-0' in sigma matrix from svd() with '+0' (bug #55710).
Rik <rik@octave.org>
parents: 26376
diff changeset
850 {
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
851 if (! m_sigma.dgxelem (i))
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
852 m_sigma.dgxelem (i) = DM_P (0);
26731
75d79c39ac92 Replace '-0' in sigma matrix from svd() with '+0' (bug #55710).
Rik <rik@octave.org>
parents: 26376
diff changeset
853 }
75d79c39ac92 Replace '-0' in sigma matrix from svd() with '+0' (bug #55710).
Rik <rik@octave.org>
parents: 26376
diff changeset
854
29412
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
855 // GESVD and GESDD return VT instead of V, GEJSV return V.
9b6bf68ea663 Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents: 29359
diff changeset
856 if (! (jobv == 'N' || jobv == 'O') && (m_driver != svd::Driver::GEJSV))
30084
77edffa7fb40 maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents: 29609
diff changeset
857 m_right_sm = m_right_sm.hermitian ();
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
858 }
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
859
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
860 // Instantiations we need.
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
861
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
862 template class svd<Matrix>;
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
863
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
864 template class svd<FloatMatrix>;
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
865
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
866 template class svd<ComplexMatrix>;
3336
08ad797989f8 [project @ 1999-11-03 21:41:34 by jwe]
jwe
parents: 3335
diff changeset
867
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
868 template class svd<FloatComplexMatrix>;
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31433
diff changeset
869
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31433
diff changeset
870 OCTAVE_END_NAMESPACE(math)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31433
diff changeset
871 OCTAVE_END_NAMESPACE(octave)