Mercurial > octave
annotate liboctave/numeric/svd.h @ 31249:de6fc38c78c6
Make Jacobian types offered by dlsode.f accessible by lsode (bug #31626).
* liboctave/numeric/LSODE-opts.in: Add options "jacobian type", "lower jacobian
subdiagonals", and "upper jacobian subdiagonals".
* liboctave/numeric/LSODE.cc (file scope, lsode_j,
LSODE::do_integrate (double)): Handle new configurable Jacobian types.
* build-aux/mk-opts.pl: Don't implicitly convert to integer in condition.
author | Olaf Till <olaf.till@uni-jena.de> |
---|---|
date | Fri, 12 Nov 2010 08:53:05 +0100 |
parents | 796f54d4ddbf |
children | e88a07dec498 |
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:
30084
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 | 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 | 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 |
29228
5c14f81e0937
Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
39 OCTAVE_API |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
40 svd |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
41 { |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
42 public: |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
43 |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
44 typedef typename T::real_diag_matrix_type DM_T; |
10601 | 45 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
46 enum class Type |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
47 { |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
48 std, |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22329
diff
changeset
|
49 economy, |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22329
diff
changeset
|
50 sigma_only |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22329
diff
changeset
|
51 }; |
1528 | 52 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
53 enum class Driver |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
54 { |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
55 GESVD, |
29412
9b6bf68ea663
Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents:
29359
diff
changeset
|
56 GESDD, |
9b6bf68ea663
Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents:
29359
diff
changeset
|
57 GEJSV |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22329
diff
changeset
|
58 }; |
457 | 59 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
60 svd (void) |
30084
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
61 : m_type (), m_driver (), m_left_sm (), m_sigma (), m_right_sm () |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
62 { } |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
63 |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
64 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
|
65 svd::Driver driver = svd::Driver::GESVD); |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
66 |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
67 svd (const svd& a) |
30084
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
68 : m_type (a.m_type), m_driver (a.m_driver), m_left_sm (a.m_left_sm), |
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
69 m_sigma (a.m_sigma), m_right_sm (a.m_right_sm) |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
70 { } |
457 | 71 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
72 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
|
73 { |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
74 if (this != &a) |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
75 { |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
76 m_type = a.m_type; |
30084
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
77 m_left_sm = a.m_left_sm; |
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
78 m_sigma = a.m_sigma; |
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
79 m_right_sm = a.m_right_sm; |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
80 m_driver = a.m_driver; |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
81 } |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
82 |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
83 return *this; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 } |
1528 | 85 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
86 ~svd (void) = default; |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
87 |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
88 T left_singular_matrix (void) const; |
1528 | 89 |
30084
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
90 DM_T singular_values (void) const { return m_sigma; } |
1930 | 91 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
92 T right_singular_matrix (void) const; |
1528 | 93 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
94 private: |
457 | 95 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
96 typedef typename T::element_type P; |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
97 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
|
98 |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
99 svd::Type m_type; |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
100 svd::Driver m_driver; |
21273
cbced1c09916
better use of templates for svd classes
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
101 |
30084
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
102 T m_left_sm; |
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
103 DM_T m_sigma; |
77edffa7fb40
maint: use "m_" prefix for member variables in class svd.
Rik <rik@octave.org>
parents:
29412
diff
changeset
|
104 T m_right_sm; |
1880 | 105 |
22944
5126040e8f49
use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 |
22944
5126040e8f49
use F77_INT instead of octave_idx_type for liboctave svd class
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 octave_f77_int_type& info); |
29412
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 void gejsv (char& joba, char& jobu, char& jobv, char& jobr, char& jobt, |
9b6bf68ea663
Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents:
29359
diff
changeset
|
119 char& jobp, octave_f77_int_type m, octave_f77_int_type n, |
9b6bf68ea663
Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents:
29359
diff
changeset
|
120 P *tmp_data, octave_f77_int_type 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
|
121 P *v, octave_f77_int_type 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
|
122 octave_f77_int_type& lwork, |
9b6bf68ea663
Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents:
29359
diff
changeset
|
123 std::vector<octave_f77_int_type>& iwork, |
9b6bf68ea663
Add additional svd driver GEJSV for accurate SVD (bug #55727).
Eddy Xiao <bewantbe@gmail.com>
parents:
29359
diff
changeset
|
124 octave_f77_int_type& info); |
22329
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
125 }; |
7f3c7a8bd131
maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
126 } |
22317
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22249
diff
changeset
|
127 } |
6ca3acf5fad8
move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents:
22249
diff
changeset
|
128 |
457 | 129 #endif |