annotate liboctave/numeric/gsvd.cc @ 22945:eb01d0178188

use F77_INT instead of octave_idx_type for liboctave gsvd class * gsvd.h, gsvd.cc: Use F77_INT instead of octave_idx_type for integer data passed to Fortran subroutines. Use octave_f77_int_type in public header file.
author John W. Eaton <jwe@octave.org>
date Mon, 26 Dec 2016 19:23:31 -0500
parents 3a2b891d0b33
children cd33c785e80e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
1 /*
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
2
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
3 Copyright (C) 2016 Barbara Lócsi
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
4 Copyright (C) 2006 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
5 Copyright (C) 1996, 1997 John W. Eaton
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
6
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
7 This file is part of Octave.
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
8
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
10 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
11 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
12 (at your option) any later version.
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
13
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
14 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
15 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
17 GNU General Public License for more details.
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
18
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
19 You should have received a copy of the GNU General Public License
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
20 along with Octave; see the file COPYING. If not, see
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
21 <http://www.gnu.org/licenses/>.
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
22
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22437
diff changeset
23 */
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
24
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
26 # include <config.h>
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
27 #endif
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
28
22436
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
29 #include <vector>
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
30
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
31 #include "gsvd.h"
22436
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
32
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
33 #include "lo-error.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22297
diff changeset
34 #include "lo-lapack-proto.h"
22436
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
35 #include "dMatrix.h"
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
36 #include "fMatrix.h"
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
37 #include "CMatrix.h"
22436
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
38 #include "fCMatrix.h"
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
39 #include "dDiagMatrix.h"
22436
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
40 #include "fDiagMatrix.h"
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
41
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
42 namespace octave
22436
09005ac7d56c gsvd<T>: add class template support for FloatMatrix and FloatComplexMatrix.
Carnë Draug <carandraug@octave.org>
parents: 22402
diff changeset
43 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
44 namespace math
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 template <>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
47 void
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
48 gsvd<Matrix>::ggsvd (char& jobu, char& jobv, char& jobq, F77_INT m,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
49 F77_INT n, F77_INT p, F77_INT& k, F77_INT& l,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
50 double *tmp_dataA, F77_INT m1, double *tmp_dataB,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
51 F77_INT p1, Matrix& alpha, Matrix& beta, double *u,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
52 F77_INT nrow_u, double *v, F77_INT nrow_v, double *q,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
53 F77_INT nrow_q, Matrix& work, F77_INT* iwork,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
54 F77_INT& info)
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
55 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
56 F77_XFCN (dggsvd, DGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
57 F77_CONST_CHAR_ARG2 (&jobv, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
58 F77_CONST_CHAR_ARG2 (&jobq, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
59 m, n, p, k, l, tmp_dataA, m1,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
60 tmp_dataB, p1, alpha.fortran_vec (),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
61 beta.fortran_vec (), u, nrow_u,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
62 v, nrow_v, q, nrow_q, work.fortran_vec (),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
63 iwork, info
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
64 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
65 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
66 F77_CHAR_ARG_LEN (1)));
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
67 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
68
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
69 template <>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
70 void
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
71 gsvd<FloatMatrix>::ggsvd (char& jobu, char& jobv, char& jobq, F77_INT m,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
72 F77_INT n, F77_INT p, F77_INT& k, F77_INT& l,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
73 float *tmp_dataA, F77_INT m1, float *tmp_dataB,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
74 F77_INT p1, FloatMatrix& alpha,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
75 FloatMatrix& beta, float *u, F77_INT nrow_u,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
76 float *v, F77_INT nrow_v, float *q,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
77 F77_INT nrow_q, FloatMatrix& work,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
78 F77_INT* iwork, F77_INT& info)
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
79 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
80 F77_XFCN (sggsvd, SGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
81 F77_CONST_CHAR_ARG2 (&jobv, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
82 F77_CONST_CHAR_ARG2 (&jobq, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
83 m, n, p, k, l, tmp_dataA, m1,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
84 tmp_dataB, p1, alpha.fortran_vec (),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
85 beta.fortran_vec (), u, nrow_u,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
86 v, nrow_v, q, nrow_q, work.fortran_vec (),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
87 iwork, info
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
88 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
89 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
90 F77_CHAR_ARG_LEN (1)));
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
91 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
92
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
93 template <>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
94 void
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
95 gsvd<ComplexMatrix>::ggsvd (char& jobu, char& jobv, char& jobq,
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
96 F77_INT m, F77_INT n, F77_INT p, F77_INT& k,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
97 F77_INT& l, Complex *tmp_dataA, F77_INT m1,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
98 Complex *tmp_dataB, F77_INT p1, Matrix& alpha,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
99 Matrix& beta, Complex *u, F77_INT nrow_u,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
100 Complex *v, F77_INT nrow_v, Complex *q,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
101 F77_INT nrow_q, ComplexMatrix& work,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
102 F77_INT* iwork, F77_INT& info)
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
103 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
104 Matrix rwork(2*n, 1);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
105 F77_XFCN (zggsvd, ZGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
106 F77_CONST_CHAR_ARG2 (&jobv, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
107 F77_CONST_CHAR_ARG2 (&jobq, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
108 m, n, p, k, l, F77_DBLE_CMPLX_ARG (tmp_dataA),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
109 m1, F77_DBLE_CMPLX_ARG (tmp_dataB), p1,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
110 alpha.fortran_vec (), beta.fortran_vec (),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
111 F77_DBLE_CMPLX_ARG (u), nrow_u,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
112 F77_DBLE_CMPLX_ARG (v), nrow_v,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
113 F77_DBLE_CMPLX_ARG (q), nrow_q,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
114 F77_DBLE_CMPLX_ARG (work.fortran_vec ()),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
115 rwork.fortran_vec (), iwork, info
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
116 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
117 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
118 F77_CHAR_ARG_LEN (1)));
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
119 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
120
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
121 template <>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
122 void
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
123 gsvd<FloatComplexMatrix>::ggsvd (char& jobu, char& jobv, char& jobq,
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
124 F77_INT m, F77_INT n, F77_INT p,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
125 F77_INT& k, F77_INT& l,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
126 FloatComplex *tmp_dataA, F77_INT m1,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
127 FloatComplex *tmp_dataB, F77_INT p1,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
128 FloatMatrix& alpha, FloatMatrix& beta,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
129 FloatComplex *u, F77_INT nrow_u,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
130 FloatComplex *v, F77_INT nrow_v,
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
131 FloatComplex *q, F77_INT nrow_q,
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
132 FloatComplexMatrix& work,
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
133 F77_INT* iwork, F77_INT& info)
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
134 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
135 FloatMatrix rwork(2*n, 1);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
136 F77_XFCN (cggsvd, CGGSVD, (F77_CONST_CHAR_ARG2 (&jobu, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
137 F77_CONST_CHAR_ARG2 (&jobv, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
138 F77_CONST_CHAR_ARG2 (&jobq, 1),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
139 m, n, p, k, l, F77_CMPLX_ARG (tmp_dataA), m1,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
140 F77_CMPLX_ARG (tmp_dataB), p1,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
141 alpha.fortran_vec (), beta.fortran_vec (),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
142 F77_CMPLX_ARG (u), nrow_u,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
143 F77_CMPLX_ARG (v), nrow_v,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
144 F77_CMPLX_ARG (q), nrow_q,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
145 F77_CMPLX_ARG (work.fortran_vec ()),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
146 rwork.fortran_vec (), iwork, info
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
147 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
148 F77_CHAR_ARG_LEN (1)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
149 F77_CHAR_ARG_LEN (1)));
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
150 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
151
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
152 template <typename T>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
153 T
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
154 gsvd<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
155 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
156 if (type == gsvd::Type::sigma_only)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
157 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
158 (*current_liboctave_error_handler)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
159 ("gsvd: U not computed because type == gsvd::sigma_only");
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
160 return T ();
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
161 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
162 else
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
163 return left_smA;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
164 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
165
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
166 template <typename T>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
167 T
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
168 gsvd<T>::left_singular_matrix_B (void) const
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
169 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
170 if (type == gsvd::Type::sigma_only)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
171 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
172 (*current_liboctave_error_handler)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
173 ("gsvd: V not computed because type == gsvd::sigma_only");
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
174 return T ();
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
175 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
176 else
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
177 return left_smB;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
178 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
179
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
180 template <typename T>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
181 T
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
182 gsvd<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
183 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
184 if (type == gsvd::Type::sigma_only)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
185 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
186 (*current_liboctave_error_handler)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
187 ("gsvd: X not computed because type == gsvd::sigma_only");
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
188 return T ();
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
189 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
190 else
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
191 return right_sm;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
192 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
193
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
194 template <typename T>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
195 T
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
196 gsvd<T>::R_matrix (void) const
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
197 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
198 if (type != gsvd::Type::std)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
199 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
200 (*current_liboctave_error_handler)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
201 ("gsvd: R not computed because type != gsvd::std");
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
202 return T ();
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
203 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
204 else
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
205 return R;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
206 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
207
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
208 template <typename T>
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
209 gsvd<T>::gsvd (const T& a, const T& b, gsvd::Type gsvd_type)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
210 {
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
211 F77_INT info;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
212
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
213 F77_INT m = to_f77_int (a.rows ());
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
214 F77_INT n = to_f77_int (a.cols ());
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
215 F77_INT p = to_f77_int (b.rows ());
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
216
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
217 T atmp = a;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
218 P *tmp_dataA = atmp.fortran_vec ();
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
219
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
220 T btmp = b;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
221 P *tmp_dataB = btmp.fortran_vec ();
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
222
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
223 char jobu = 'U';
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
224 char jobv = 'V';
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
225 char jobq = 'Q';
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
226
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
227 F77_INT nrow_u = m;
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
228 F77_INT nrow_v = p;
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
229 F77_INT nrow_q = n;
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
230
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
231 F77_INT k, l;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
232
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
233 switch (gsvd_type)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
234 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
235 case gsvd<T>::Type::sigma_only:
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
236
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
237 // Note: for this case, both jobu and jobv should be 'N', but
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
238 // there seems to be a bug in dgesvd from Lapack V2.0. To
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
239 // demonstrate the bug, set both jobu and jobv to 'N' and find
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
240 // the singular values of [eye(3), eye(3)]. The result is
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
241 // [-sqrt(2), -sqrt(2), -sqrt(2)].
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
242 //
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
243 // For Lapack 3.0, this problem seems to be fixed.
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
244
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
245 jobu = 'N';
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
246 jobv = 'N';
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
247 jobq = 'N';
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
248 nrow_u = nrow_v = nrow_q = 1;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
249 break;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
250
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
251 default:
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
252 break;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
253 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
254
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
255 type = gsvd_type;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
256
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
257 if (! (jobu == 'N' || jobu == 'O'))
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
258 left_smA.resize (nrow_u, m);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
259
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
260 P *u = left_smA.fortran_vec ();
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
261
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
262 if (! (jobv == 'N' || jobv == 'O'))
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
263 left_smB.resize (nrow_v, p);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
264
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
265 P *v = left_smB.fortran_vec ();
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
266
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
267 if (! (jobq == 'N' || jobq == 'O'))
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
268 right_sm.resize (nrow_q, n);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
269
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
270 P *q = right_sm.fortran_vec ();
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
271
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
272 F77_INT lwork = 3*n;
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
273 lwork = lwork > m ? lwork : m;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
274 lwork = (lwork > p ? lwork : p) + n;
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
275
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
276 T work (lwork, 1);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
277 real_matrix alpha (n, 1);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
278 real_matrix beta (n, 1);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
279
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
280 std::vector<F77_INT> iwork (n);
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
281
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
282 gsvd<T>::ggsvd (jobu, jobv, jobq, m, n, p, k, l,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
283 tmp_dataA, m, tmp_dataB, p, alpha, beta, u,
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
284 nrow_u, v, nrow_v, q, nrow_q, work, iwork.data (), info);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
285
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
286 if (f77_exception_encountered)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
287 (*current_liboctave_error_handler) ("unrecoverable error in *ggsvd");
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
288
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
289 if (info < 0)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
290 (*current_liboctave_error_handler) ("*ggsvd.f: argument %d illegal",
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
291 -info);
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
292 else
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
293 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
294 if (info > 0)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
295 (*current_liboctave_error_handler)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
296 ("*ggsvd.f: Jacobi-type procedure failed to converge.");
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
297 else
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
298 {
22945
eb01d0178188 use F77_INT instead of octave_idx_type for liboctave gsvd class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
299 F77_INT i, j;
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
300
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
301 if (gsvd<T>::Type::std == gsvd_type)
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
302 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
303 R.resize(k+l, k+l);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
304 int astart = n-k-l;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
305 if (m - k - l >= 0)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
306 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
307 astart = n-k-l;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
308 // R is stored in A(1:K+L,N-K-L+1:N)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
309 for (i = 0; i < k+l; i++)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
310 for (j = 0; j < k+l; j++)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
311 R.xelem (i, j) = atmp.xelem (i, astart + j);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
312 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
313 else
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
314 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
315 // (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N),
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
316 // ( 0 R22 R23 )
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
317
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
318 for (i = 0; i < m; i++)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
319 for (j = 0; j < k+l; j++)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
320 R.xelem (i, j) = atmp.xelem (i, astart + j);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
321 // and R33 is stored in B(M-K+1:L,N+M-K-L+1:N)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
322 for (i = k+l-1; i >=m; i--)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
323 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
324 for (j = 0; j < m; j++)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
325 R.xelem(i, j) = 0.0;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
326 for (j = m; j < k+l; j++)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
327 R.xelem (i, j) = btmp.xelem (i - k, astart + j);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
328 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
329 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
330 }
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
331
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
332 if (m-k-l >= 0)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
333 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
334 // Fills in C and S
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
335 sigmaA.resize (l, l);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
336 sigmaB.resize (l, l);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
337 for (i = 0; i < l; i++)
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
338 {
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
339 sigmaA.dgxelem(i) = alpha.elem(k+i);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
340 sigmaB.dgxelem(i) = beta.elem(k+i);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
341 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
342 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
343 else
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
344 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
345 // Fills in C and S
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
346 sigmaA.resize (m-k, m-k);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
347 sigmaB.resize (m-k, m-k);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
348 for (i = 0; i < m-k; i++)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
349 {
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
350 sigmaA.dgxelem(i) = alpha.elem(k+i);
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
351 sigmaB.dgxelem(i) = beta.elem(k+i);
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
352 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
353 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
354 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
355 }
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
356 }
22437
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
357
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
358 // Instantiations we need.
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
359 template class gsvd<Matrix>;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
360 template class gsvd<FloatMatrix>;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
361 template class gsvd<ComplexMatrix>;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
362 template class gsvd<FloatComplexMatrix>;
0aee8b620864 gsvd: move new class into the octave::math namespace.
Carnë Draug <carandraug@octave.org>
parents: 22436
diff changeset
363 }
22236
065a44375723 gsvd: reduce code duplication with templates.
Barbara Locsi <locsi.barbara@gmail.com>
parents:
diff changeset
364 }