annotate liboctave/numeric/svd.h @ 27923:bd51beb6205e

update formatting of copyright notices * Use <https://octave.org/copyright/> instead of <https://octave.org/COPYRIGHT.html/>. * For consistency with other comments in the Octave sources, use C++-style comments for copyright blocks in C and C++ files. * Use delimiters above and below copyright blocks that are appropriate for the language used in the file. * Eliminate extra spacing inside copyright blocks. * lex.ll (looks_like_copyright): Also allow newlines and carriage returns before the word "Copyright". * scripts/mk-doc.pl (gethelp): Also skip empty comment lines. * bp-table.cc, type.m: Adjust tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Jan 2020 11:59:41 -0500
parents 1891570abac8
children 5c14f81e0937 0a5b15007766
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 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1994-2020 The Octave Project Developers
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
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
26 #if ! defined (octave_svd_h)
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
27 #define octave_svd_h 1
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
30
22249
da201af35c97 maint: properly include <vector> in svd classes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22248
diff changeset
31 #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
32
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
33 namespace octave
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22249
diff changeset
34 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
35 namespace math
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
36 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
37 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
38 class
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
39 svd
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
40 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
41 public:
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
42
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
43 typedef typename T::real_diag_matrix_type DM_T;
10601
3ce0c530a9c9 implement svd_driver
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
44
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
45 enum class Type
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
46 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
47 std,
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
48 economy,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
49 sigma_only
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
50 };
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
51
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
52 enum class Driver
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
53 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
54 GESVD,
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
55 GESDD
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
56 };
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
57
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
58 svd (void)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
59 : m_type (), m_driver (), left_sm (), sigma (), right_sm ()
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
60 { }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
61
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
62 svd (const T& a, svd::Type type = svd::Type::std,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
63 svd::Driver driver = svd::Driver::GESVD);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
64
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
65 svd (const svd& a)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
66 : m_type (a.m_type), m_driver (a.m_driver), left_sm (a.left_sm),
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
67 sigma (a.sigma), right_sm (a.right_sm)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
68 { }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
69
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
70 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
71 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
72 if (this != &a)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
73 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
74 m_type = a.m_type;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
75 left_sm = a.left_sm;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
76 sigma = a.sigma;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
77 right_sm = a.right_sm;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
78 m_driver = a.m_driver;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
79 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
80
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
81 return *this;
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
82 }
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
83
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
84 ~svd (void) = default;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
85
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
86 T left_singular_matrix (void) const;
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
87
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
88 DM_T singular_values (void) const { return sigma; }
1930
d20ab06301e8 [project @ 1996-02-11 22:30:18 by jwe]
jwe
parents: 1881
diff changeset
89
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
90 T right_singular_matrix (void) const;
1528
dc527156c38c [project @ 1995-10-05 01:44:18 by jwe]
jwe
parents: 1315
diff changeset
91
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
92 private:
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
93
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
94 typedef typename T::element_type P;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
95 typedef typename DM_T::element_type DM_P;
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
96
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
97 svd::Type m_type;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
98 svd::Driver m_driver;
21273
cbced1c09916 better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
99
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
100 T left_sm;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
101 DM_T sigma;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
102 T right_sm;
1880
cbdbec67ad60 [project @ 1996-02-05 17:10:31 by jwe]
jwe
parents: 1544
diff changeset
103
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
104 void gesvd (char& jobu, char& jobv, octave_f77_int_type m,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
105 octave_f77_int_type n, P *tmp_data, octave_f77_int_type m1,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
106 DM_P *s_vec, P *u, P *vt, octave_f77_int_type nrow_vt1,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
107 std::vector<P>& work, octave_f77_int_type& lwork,
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
108 octave_f77_int_type& info);
22204
469c817eb256 svd: reduce code duplication with more use of template and macro.
Carnë Draug <carandraug@octave.org>
parents: 21273
diff changeset
109
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
110 void gesdd (char& jobz, octave_f77_int_type m, octave_f77_int_type n,
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
111 P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
112 P *vt, octave_f77_int_type nrow_vt1, std::vector<P>& work,
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
113 octave_f77_int_type& lwork, octave_f77_int_type *iwork,
22944
5126040e8f49 use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
114 octave_f77_int_type& info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
115 };
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
116 }
22317
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