annotate liboctave/numeric/gsvd.h @ 22437:0aee8b620864

gsvd: move new class into the octave::math namespace.
author Carnë Draug <carandraug@octave.org>
date Sun, 04 Sep 2016 17:37:35 +0100
parents 09005ac7d56c
children 7abc25e6206a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22236
diff changeset
1 // Copyright (C) 2016 Barbara Lócsi
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
2 // Copyright (C) 2006 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22236
diff changeset
3 // Copyright (C) 1996, 1997 John W. Eaton
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
4 //
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
5 // This program is free software; you can redistribute it and/or modify it under
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
6 // the terms of the GNU General Public License as published by the Free Software
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
7 // Foundation; either version 3 of the License, or (at your option) any later
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
8 // version.
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
9 //
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
10 // This program is distributed in the hope that it will be useful, but WITHOUT
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
13 // details.
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
14 //
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
15 // You should have received a copy of the GNU General Public License along with
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
16 // this program; if not, see <http://www.gnu.org/licenses/>.
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
17
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
18 #if !defined (octave_gsvd_h)
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
19 #define octave_gsvd_h 1
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
20
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
21 #include "octave-config.h"
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
22
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
23 namespace octave
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
24 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
25 namespace math
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
26 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
27 template <typename T>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
28 class
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
29 gsvd
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
30 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
31 public:
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
32
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
33 enum class Type
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
34 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
35 std,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
36 economy,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
37 sigma_only
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
38 };
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
39
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
40 gsvd (void) : sigmaA (), sigmaB (), left_smA (), left_smB (), right_sm ()
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
41 { }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
42
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
43 gsvd (const T& a, const T& b,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
44 gsvd::Type gsvd_type = gsvd<T>::Type::economy);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
45
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
46 gsvd (const gsvd& a)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
47 : type (a.type),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
48 sigmaA (a.sigmaA), sigmaB (a.sigmaB),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
49 left_smA (a.left_smA), left_smB (a.left_smB), right_sm (a.right_sm),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
50 R(a.R) { }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
51
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
52 gsvd& operator = (const gsvd& a)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
53 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
54 if (this != &a)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
55 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
56 type = a.type;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
57 sigmaA = a.sigmaA;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
58 sigmaB = a.sigmaB;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
59 left_smA = a.left_smA;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
60 left_smB = a.left_smB;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
61 right_sm = a.right_sm;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
62 R = a.R;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
63 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
64
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
65 return *this;
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
67
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
68 ~gsvd (void) { }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
69
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
70 typename T::real_diag_matrix_type
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
71 singular_values_A (void) const { return sigmaA; }
22436
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
72
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
73 typename T::real_diag_matrix_type
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
74 singular_values_B (void) const { return sigmaB; }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
75
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
76 T left_singular_matrix_A (void) const;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
77 T left_singular_matrix_B (void) const;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
78
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
79 T right_singular_matrix (void) const;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
80 T R_matrix (void) const;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
81
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
82 private:
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
83 typedef typename T::value_type P;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
84 typedef typename T::real_matrix_type real_matrix;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
85
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
86 gsvd::Type type;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
87 typename T::real_diag_matrix_type sigmaA, sigmaB;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
88 T left_smA, left_smB;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
89 T right_sm, R;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
90
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
91 void ggsvd (char& jobu, char& jobv, char& jobq, octave_idx_type m,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
92 octave_idx_type n, octave_idx_type p, octave_idx_type& k,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
93 octave_idx_type& l, P *tmp_dataA, octave_idx_type m1,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
94 P *tmp_dataB, octave_idx_type p1, real_matrix& alpha,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
95 real_matrix& beta, P *u, octave_idx_type nrow_u, P *v,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
96 octave_idx_type nrow_v, P *q, octave_idx_type nrow_q, T& work,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
97 octave_idx_type* iwork, octave_idx_type& info);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
98 };
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
99 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
100 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
101
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
102 #endif