annotate liboctave/numeric/svd.cc @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents f3f3e3793fb5
children d17ee5e7b66c
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
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22297
diff changeset
304 namespace octave
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22297
diff changeset
305 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
306 namespace math
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
307 {
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) "
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30084
diff changeset
830 "Denormal occured, 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>;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
869 }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
870 }