Mercurial > octave
annotate liboctave/numeric/svd.h @ 21273:cbced1c09916
better use of templates for svd classes
* liboctave/numeric/svd.h, liboctave/numeric/svd.cc: New files for svd
classes generated from CmplxSVD.cc, CmplxSVD.h, dbleSVD.cc, dbleSVD.h,
fCmplxSVD.cc, fCmplxSVD.h, floatSVD.cc, and floatSVD.h and converted
to templates.
* liboctave/numeric/module.mk: Update.
* __qp__.cc, svd.cc, CMatrix.cc, CMatrix.h, dDiagMatrix.h, dMatrix.cc,
dMatrix.h, fCMatrix.cc, fCMatrix.h, fDiagMatrix.h, fMatrix.cc,
fMatrix.h, oct-norm.cc, mx-defs.h, mx-ext.h: Use new classes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 16 Feb 2016 14:41:06 -0500 |
parents | liboctave/numeric/dbleSVD.h@1473547f50f5 |
children | 469c817eb256 |
rev | line source |
---|---|
457 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
3 Copyright (C) 1994-2015 John W. Eaton |
457 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
457 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
457 | 20 |
21 */ | |
22 | |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
23 #if ! defined (octave_svd_h) |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
24 #define octave_svd_h 1 |
457 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
27 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
28 #include <iosfwd> |
457 | 29 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
30 template <typename T> |
1880 | 31 class |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
32 svd |
457 | 33 { |
34 public: | |
35 | |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
36 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
|
37 |
537 | 38 enum type |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
39 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
40 std, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 economy, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 sigma_only |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 }; |
537 | 44 |
10601 | 45 enum driver |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
46 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
47 GESVD, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
48 GESDD |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
49 }; |
10601 | 50 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
51 svd (void) |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
52 : type_computed (), left_sm (), sigma (), right_sm () |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
53 { } |
1528 | 54 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
55 svd (const T& a, type svd_type = svd::std, driver svd_driver = svd::GESVD) |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
56 : type_computed (), left_sm (), sigma (), right_sm () |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
57 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
58 init (a, svd_type, svd_driver); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
59 } |
457 | 60 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
61 svd (const T& a, octave_idx_type& info, type svd_type = svd::std, |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
62 driver svd_driver = svd::GESVD) |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
63 : type_computed (), left_sm (), sigma (), right_sm () |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
64 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
65 info = init (a, svd_type, svd_driver); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
66 } |
457 | 67 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
68 svd (const svd& a) |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
69 : type_computed (a.type_computed), left_sm (a.left_sm), |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
70 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
|
71 { } |
457 | 72 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
73 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
|
74 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
75 if (this != &a) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
77 type_computed = a.type_computed; |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
78 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
|
79 sigma = a.sigma; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
80 right_sm = a.right_sm; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 } |
1528 | 82 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 } |
1528 | 85 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
86 ~svd (void) { } |
1930 | 87 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
88 T left_singular_matrix (void) const; |
1528 | 89 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
90 DM_T singular_values (void) const { return sigma; } |
1528 | 91 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
92 T right_singular_matrix (void) const; |
457 | 93 |
94 private: | |
95 | |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
96 svd::type type_computed; |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
97 |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
98 T left_sm; |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
99 DM_T sigma; |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
100 T right_sm; |
1544 | 101 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
102 octave_idx_type |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
103 init (const T& a, type svd_type, driver svd_driver); |
1880 | 104 |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
105 octave_idx_type |
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
106 empty_init (octave_idx_type nr, octave_idx_type nc, type svd_type); |
457 | 107 }; |
108 | |
109 #endif |