annotate liboctave/numeric/svd.h @ 22317:6ca3acf5fad8

move some new numeric classes to namespace octave::math * aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, hess.cc, hess.h, lu.cc, lu.h, qr.cc, qr.h, qrp.cc, qrp.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-dmsolve.cc,sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h: Move classes to namespace octave::math. * __luinc__.cc, __qp__.cc, balance.cc, hess.cc, lu.cc, qz.cc, schur.cc, sqrtm.cc, svd.cc, chol.cc, dmperm.cc, qr.cc, lex.h, CMatrix.cc, CSparse.cc, dMatrix.cc, dSparse.cc, fCMatrix.cc, fMatrix.cc, eigs-base.cc, oct-norm.cc: Update for new namespaces.
author John W. Eaton <jwe@octave.org>
date Tue, 16 Aug 2016 15:48:22 -0400
parents da201af35c97
children bac0d6f07a3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
1 /*
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
2
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
3 Copyright (C) 2016 Carnë Draug
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17822
diff changeset
4 Copyright (C) 1994-2015 John W. Eaton
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
5
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
7
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
11 option) any later version.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
12
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
16 for more details.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
17
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
20 <http://www.gnu.org/licenses/>.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
21
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
22 */
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
23
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
24 #if ! defined (octave_svd_h)
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
25 #define octave_svd_h 1
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
26
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
27 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
28
22249
da201af35c97 maint: properly include <vector> in svd classes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22248
diff changeset
29 #include <vector>
22248
60986498af9e svd: use std::vector instead of Matrix when a std::vector is enough.
Carnë Draug <carandraug@octave.org>
parents: 22230
diff changeset
30
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
31 namespace octave
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
32 {
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
33 namespace math
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
34 {
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
35
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
36 template <typename T>
1880
cbdbec67ad60 [project @ 1996-02-05 17:10:31 by jwe]
jwe
parents: 1544
diff changeset
37 class
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
38 svd
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
39 {
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
40 public:
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
41
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
42 typedef typename T::real_diag_matrix_type DM_T;
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
43
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
44 enum class Type
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
45 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
46 std,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
47 economy,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
48 sigma_only
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
49 };
537
4ecbfd3c3710 [project @ 1994-07-21 22:30:34 by jwe]
jwe
parents: 457
diff changeset
50
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
51 enum class Driver
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
52 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
53 GESVD,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
54 GESDD
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
55 };
10601
3ce0c530a9c9 implement svd_driver
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
56
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
57 svd (void)
22228
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
58 : m_type (), m_driver (), left_sm (), sigma (), right_sm ()
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
59 { }
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
60
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
61 svd (const T& a, svd::Type type = svd::Type::std,
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
62 svd::Driver driver = svd::Driver::GESVD);
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
63
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
64 svd (const svd& a)
22228
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
65 : m_type (a.m_type), m_driver (a.m_driver), left_sm (a.left_sm),
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
66 sigma (a.sigma), right_sm (a.right_sm)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
67 { }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
68
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
69 svd& operator = (const svd& a)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
70 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
71 if (this != &a)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
72 {
22228
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
73 m_type = a.m_type;
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
74 left_sm = a.left_sm;
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
75 sigma = a.sigma;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
76 right_sm = a.right_sm;
22228
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
77 m_driver = a.m_driver;
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
78 }
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
79
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
80 return *this;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
81 }
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
82
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
83 ~svd (void) { }
1930
d20ab06301e8 [project @ 1996-02-11 22:30:18 by jwe]
jwe
parents: 1881
diff changeset
84
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
85 T left_singular_matrix (void) const;
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
86
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
87 DM_T singular_values (void) const { return sigma; }
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
88
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
89 T right_singular_matrix (void) const;
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
90
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
91 private:
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
92
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
93 typedef typename T::element_type P;
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
94 typedef typename DM_T::element_type DM_P;
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
95
22228
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
96 svd::Type m_type;
4afe3705ea75 svd: do not shadow member variables with local variables.
Carnë Draug <carandraug@octave.org>
parents: 22204
diff changeset
97 svd::Driver m_driver;
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
98
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
99 T left_sm;
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
100 DM_T sigma;
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
101 T right_sm;
1544
f1931fc63ce9 [project @ 1995-10-06 05:57:56 by jwe]
jwe
parents: 1543
diff changeset
102
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
103 void gesvd (char& jobu, char& jobv, octave_idx_type m, octave_idx_type n,
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
104 P* tmp_data, octave_idx_type m1, DM_P* s_vec, P* u, P* vt,
22248
60986498af9e svd: use std::vector instead of Matrix when a std::vector is enough.
Carnë Draug <carandraug@octave.org>
parents: 22230
diff changeset
105 octave_idx_type nrow_vt1, std::vector<P>& work, octave_idx_type& lwork,
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
106 octave_idx_type& info);
1880
cbdbec67ad60 [project @ 1996-02-05 17:10:31 by jwe]
jwe
parents: 1544
diff changeset
107
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
108 void gesdd (char& jobz, octave_idx_type m, octave_idx_type n,
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
109 P* tmp_data, octave_idx_type m1, DM_P* s_vec, P* u, P* vt,
22248
60986498af9e svd: use std::vector instead of Matrix when a std::vector is enough.
Carnë Draug <carandraug@octave.org>
parents: 22230
diff changeset
110 octave_idx_type nrow_vt1, std::vector<P>& work,
60986498af9e svd: use std::vector instead of Matrix when a std::vector is enough.
Carnë Draug <carandraug@octave.org>
parents: 22230
diff changeset
111 octave_idx_type& lwork,
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
112 octave_idx_type* iwork, octave_idx_type& info);
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
113
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
114 };
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
115
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
116 }
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
117 }
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
118
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
119 #endif