annotate liboctave/numeric/qr.cc @ 23593:a8361bc2361a

maint: Deprecate is_square and replace with issquare. * Array.h (is_square): Use OCTAVE_DEPRECATED macro around function. * Array.h (issquare): New function. * Sparse.h (is_square): Use OCTAVE_DEPRECATED macro around function. * Sparse.h (issquare): New function. * lu.cc, qr.cc, CMatrix.cc, dMatrix.cc, fCMatrix.cc, fMatrix.cc, chol.cc, qr.cc: Replace instances of is_square with issquare.
author Rik <rik@octave.org>
date Tue, 13 Jun 2017 22:05:03 -0700
parents 80c42f4cca13
children 08036a7f3660
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9713
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
1 /*
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1994-2017 John W. Eaton
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
4 Copyright (C) 2008-2009 Jaroslav Hajek
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
5 Copyright (C) 2009 VZLU Prague
9713
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7 This file is part of Octave.
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
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: 22402
diff changeset
11 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 (at your option) any later version.
9713
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
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: 22402
diff changeset
15 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
17 GNU General Public License for more details.
9713
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21 <http://www.gnu.org/licenses/>.
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
23 */
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
24
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
25 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21285
diff changeset
26 # include "config.h"
9713
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27 #endif
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
29 #include <algorithm>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
30
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
31 #include "Array.h"
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
32 #include "CColVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
33 #include "CMatrix.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
34 #include "CRowVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
35 #include "dColVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
36 #include "dMatrix.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
37 #include "dRowVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
38 #include "fCColVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
39 #include "fCMatrix.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
40 #include "fCRowVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
41 #include "fColVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
42 #include "fMatrix.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
43 #include "fRowVector.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
44 #include "lo-error.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22317
diff changeset
45 #include "lo-lapack-proto.h"
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22317
diff changeset
46 #include "lo-qrupdate-proto.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
47 #include "oct-cmplx.h"
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
48 #include "oct-locbuf.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23450
diff changeset
49 #include "oct-sort.h"
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
50 #include "qr.h"
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
51
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
52 namespace octave
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
53 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
54 namespace math
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
55 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
56 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
57 qr<T>::qr (const T& q_arg, const T& r_arg)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
58 : q (q_arg), r (r_arg)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
59 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
60 octave_idx_type q_nr = q.rows ();
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
61 octave_idx_type q_nc = q.cols ();
11505
9a308e96194e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 9715
diff changeset
62
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
63 octave_idx_type r_nr = r.rows ();
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
64 octave_idx_type r_nc = r.cols ();
9713
7918eb15040c refactor the QR classes onto a templated base
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
66 if (! (q_nc == r_nr && (q_nr == q_nc || (q_nr > q_nc && r_nr == r_nc))))
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
67 (*current_liboctave_error_handler) ("QR dimensions mismatch");
13217
08ba694723f5 fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
68 }
9715
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9713
diff changeset
69
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
70 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
71 typename qr<T>::type
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
72 qr<T>::get_type (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
73 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
74 type retval;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
75
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
76 if (! q.isempty () && q.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
77 retval = qr<T>::std;
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
78 else if (q.rows () > q.cols () && r.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
79 retval = qr<T>::economy;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
80 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
81 retval = qr<T>::raw;
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 retval;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
84 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
85
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
86 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
87 bool
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
88 qr<T>::regular (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
89 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
90 bool retval = true;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
91
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
92 octave_idx_type k = std::min (r.rows (), r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
93
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
94 for (octave_idx_type i = 0; i < k; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
95 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
96 if (r(i, i) == ELT_T ())
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
97 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
98 retval = false;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
99 break;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
100 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
101 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
102
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
103 return retval;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
104 }
9715
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9713
diff changeset
105
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
106 #if ! defined (HAVE_QRUPDATE)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
107
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
108 // Replacement update methods.
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
109
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
110 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
111 warn_qrupdate_once (void)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
112 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
113 static bool warned = false;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
114
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
115 if (! warned)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
116 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
117 (*current_liboctave_warning_with_id_handler)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
118 ("Octave:missing-dependency",
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
119 "In this version of Octave, QR & Cholesky updating routines "
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
120 "simply update the matrix and recalculate factorizations. "
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
121 "To use fast algorithms, link Octave with the qrupdate library. "
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
122 "See <http://sourceforge.net/projects/qrupdate>.");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
123
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
124 warned = true;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
125 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
126 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
127
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
128 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
129 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
130 qr<T>::update (const CV_T& u, const CV_T& v)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
131 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
132 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
133
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
134 octave_idx_type m = q.rows ();
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
135 octave_idx_type n = r.cols ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
136
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
137 if (u.numel () != m || v.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
138 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
139
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
140 init (q*r + T (u) * T (v).hermitian (), get_type ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
141 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
142
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
143 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
144 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
145 qr<T>::update (const T& u, const T& v)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
146 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
147 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
148
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
149 octave_idx_type m = q.rows ();
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
150 octave_idx_type n = r.cols ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
151
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
152 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ())
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
153 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
154
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
155 init (q*r + u * v.hermitian (), get_type ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
156 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
157
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
158 template <typename T, typename CV_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
159 static
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
160 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
161 insert_col (const T& a, octave_idx_type i, const CV_T& x)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
162 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
163 T retval (a.rows (), a.cols () + 1);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
164 retval.assign (idx_vector::colon, idx_vector (0, i),
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
165 a.index (idx_vector::colon, idx_vector (0, i)));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
166 retval.assign (idx_vector::colon, idx_vector (i), x);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
167 retval.assign (idx_vector::colon, idx_vector (i+1, retval.cols ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
168 a.index (idx_vector::colon, idx_vector (i, a.cols ())));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
169 return retval;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
170 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
171
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
172 template <typename T, typename RV_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
173 static
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
174 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
175 insert_row (const T& a, octave_idx_type i, const RV_T& x)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
176 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
177 T retval (a.rows () + 1, a.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
178 retval.assign (idx_vector (0, i), idx_vector::colon,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
179 a.index (idx_vector (0, i), idx_vector::colon));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
180 retval.assign (idx_vector (i), idx_vector::colon, x);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
181 retval.assign (idx_vector (i+1, retval.rows ()), idx_vector::colon,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
182 a.index (idx_vector (i, a.rows ()), idx_vector::colon));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
183 return retval;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
184 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
185
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
186 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
187 static
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
188 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
189 delete_col (const T& a, octave_idx_type i)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
190 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
191 T retval = a;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
192 retval.delete_elements (1, idx_vector (i));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
193 return retval;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
194 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
195
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
196 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
197 static
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
198 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
199 delete_row (const T& a, octave_idx_type i)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
200 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
201 T retval = a;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
202 retval.delete_elements (0, idx_vector (i));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
203 return retval;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
204 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
205
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
206 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
207 static
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
208 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
209 shift_cols (const T& a, octave_idx_type i, octave_idx_type j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
210 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
211 octave_idx_type n = a.cols ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
212 Array<octave_idx_type> p (dim_vector (n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
213 for (octave_idx_type k = 0; k < n; k++) p(k) = k;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
214 if (i < j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
215 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
216 for (octave_idx_type k = i; k < j; k++) p(k) = k+1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
217 p(j) = i;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
218 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
219 else if (j < i)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
220 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
221 p(j) = i;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
222 for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
223 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
224
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
225 return a.index (idx_vector::colon, idx_vector (p));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
226 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
227
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
228 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
229 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
230 qr<T>::insert_col (const CV_T& u, octave_idx_type j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
231 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
232 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
233
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
234 octave_idx_type m = q.rows ();
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
235 octave_idx_type n = r.cols ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
236
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
237 if (u.numel () != m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
238 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
239
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
240 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
241 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
242
22393
026067ffcf66 fix build with minimal dependencies
John W. Eaton <jwe@octave.org>
parents: 22329
diff changeset
243 init (octave::math::insert_col (q*r, j, u), get_type ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
244 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
245
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
246 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
247 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
248 qr<T>::insert_col (const T& u, const Array<octave_idx_type>& j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
249 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
250 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
251
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
252 octave_idx_type m = q.rows ();
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
253 octave_idx_type n = r.cols ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
254
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
255 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
256 Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
257 octave_idx_type nj = js.numel ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
258 bool dups = false;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
259 for (octave_idx_type i = 0; i < nj - 1; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
260 dups = dups && js(i) == js(i+1);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
261
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
262 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
263 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
264
22984
45dba14ca7af * qr.cc: Fix error in previous change. (bug #49957)
John W. Eaton <jwe@octave.org>
parents: 22958
diff changeset
265 if (u.numel () != m || u.cols () != nj)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
266 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
267
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
268 if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
269 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
270
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
271 if (nj > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
272 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
273 T a = q*r;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
274 for (octave_idx_type i = 0; i < nj; i++)
22393
026067ffcf66 fix build with minimal dependencies
John W. Eaton <jwe@octave.org>
parents: 22329
diff changeset
275 a = octave::math::insert_col (a, js(i), u.column (i));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
276
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
277 init (a, get_type ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
278 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
279 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
280
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
281 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
282 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
283 qr<T>::delete_col (octave_idx_type j)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
284 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
285 warn_qrupdate_once ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
286
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
287 octave_idx_type n = r.cols ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
288
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
289 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
290 (*current_liboctave_error_handler) ("qrdelete: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
291
22393
026067ffcf66 fix build with minimal dependencies
John W. Eaton <jwe@octave.org>
parents: 22329
diff changeset
292 init (octave::math::delete_col (q*r, j), get_type ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
293 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
294
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
295 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
296 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
297 qr<T>::delete_col (const Array<octave_idx_type>& j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
298 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
299 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
300
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
301 octave_idx_type n = r.cols ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
302
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
303 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
304 Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
305 octave_idx_type nj = js.numel ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
306 bool dups = false;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
307 for (octave_idx_type i = 0; i < nj - 1; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
308 dups = dups && js(i) == js(i+1);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
309
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
310 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
311 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
312
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
313 if (nj > 0 && (js(0) > n-1 || js(nj-1) < 0))
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
314 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
315
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
316 if (nj > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
317 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
318 T a = q*r;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
319 for (octave_idx_type i = 0; i < nj; i++)
22393
026067ffcf66 fix build with minimal dependencies
John W. Eaton <jwe@octave.org>
parents: 22329
diff changeset
320 a = octave::math::delete_col (a, js(i));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
321
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
322 init (a, get_type ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
323 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
324 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
325
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
326 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
327 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
328 qr<T>::insert_row (const RV_T& u, octave_idx_type j)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
329 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
330 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
331
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
332 octave_idx_type m = r.rows ();
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
333 octave_idx_type n = r.cols ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
334
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
335 if (! q.issquare () || u.numel () != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
336 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
337
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
338 if (j < 0 || j > m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
339 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
340
22393
026067ffcf66 fix build with minimal dependencies
John W. Eaton <jwe@octave.org>
parents: 22329
diff changeset
341 init (octave::math::insert_row (q*r, j, u), get_type ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
342 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
343
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
344 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
345 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
346 qr<T>::delete_row (octave_idx_type j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
347 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
348 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
349
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
350 octave_idx_type m = r.rows ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
351
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
352 if (! q.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
353 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
354
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
355 if (j < 0 || j > m-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
356 (*current_liboctave_error_handler) ("qrdelete: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
357
22393
026067ffcf66 fix build with minimal dependencies
John W. Eaton <jwe@octave.org>
parents: 22329
diff changeset
358 init (octave::math::delete_row (q*r, j), get_type ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
359 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
360
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
361 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
362 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
363 qr<T>::shift_cols (octave_idx_type i, octave_idx_type j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
364 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
365 warn_qrupdate_once ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
366
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
367 octave_idx_type n = r.cols ();
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
368
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
369 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
370 (*current_liboctave_error_handler) ("qrshift: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
371
22393
026067ffcf66 fix build with minimal dependencies
John W. Eaton <jwe@octave.org>
parents: 22329
diff changeset
372 init (octave::math::shift_cols (q*r, i, j), get_type ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
373 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
374
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
375 #endif
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
376
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
377 // Specializations.
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
378
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
379 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
380 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
381 qr<Matrix>::form (octave_idx_type n_arg, Matrix& afact, double *tau,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
382 type qr_type)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
383 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
384 F77_INT n = octave::to_f77_int (n_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
385 F77_INT m = octave::to_f77_int (afact.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
386 F77_INT min_mn = std::min (m, n);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
387 F77_INT info;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
388
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
389 if (qr_type == qr<Matrix>::raw)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
390 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
391 for (F77_INT j = 0; j < min_mn; j++)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
392 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
393 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
394 for (F77_INT i = limit + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
395 afact.elem (i, j) *= tau[j];
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
396 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
397
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
398 r = afact;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
399 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
400 else
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
401 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
402 // Attempt to minimize copying.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
403 if (m >= n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
404 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
405 // afact will become q.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
406 q = afact;
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
407 F77_INT k = (qr_type == qr<Matrix>::economy ? n : m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
408 r = Matrix (k, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
409 for (F77_INT j = 0; j < n; j++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
410 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
411 F77_INT i = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
412 for (; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
413 r.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
414 for (; i < k; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
415 r.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
416 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
417 afact = Matrix (); // optimize memory
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
418 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
419 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
420 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
421 // afact will become r.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
422 q = Matrix (m, m);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
423 for (F77_INT j = 0; j < m; j++)
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
424 for (F77_INT i = j + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
425 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
426 q.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
427 afact.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
428 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
429 r = afact;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
430 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
431
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
432 if (m > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
433 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
434 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
435 // workspace query.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
436 double rlwork;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
437 F77_XFCN (dorgqr, DORGQR, (m, k, min_mn, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
438 tau, &rlwork, -1, info));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
439
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
440 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
441 F77_INT lwork = static_cast<F77_INT> (rlwork);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
442 lwork = std::max (lwork, static_cast<F77_INT> (1));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
443 OCTAVE_LOCAL_BUFFER (double, work, lwork);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
444 F77_XFCN (dorgqr, DORGQR, (m, k, min_mn, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
445 tau, work, lwork, info));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
446 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
447 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
448 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
449
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
450 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
451 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
452 qr<Matrix>::init (const Matrix& a, type qr_type)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
453 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
454 F77_INT m = octave::to_f77_int (a.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
455 F77_INT n = octave::to_f77_int (a.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
456
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
457 F77_INT min_mn = (m < n ? m : n);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
458 OCTAVE_LOCAL_BUFFER (double, tau, min_mn);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
459
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
460 F77_INT info = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
461
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
462 Matrix afact = a;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
463 if (m > n && qr_type == qr<Matrix>::std)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
464 afact.resize (m, m);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
465
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
466 if (m > 0)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
467 {
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
468 // workspace query.
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
469 double rlwork;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
470 F77_XFCN (dgeqrf, DGEQRF, (m, n, afact.fortran_vec (), m, tau,
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
471 &rlwork, -1, info));
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
472
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
473 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
474 F77_INT lwork = static_cast<F77_INT> (rlwork);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
475 lwork = std::max (lwork, static_cast<F77_INT> (1));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
476 OCTAVE_LOCAL_BUFFER (double, work, lwork);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
477 F77_XFCN (dgeqrf, DGEQRF, (m, n, afact.fortran_vec (), m, tau,
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
478 work, lwork, info));
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
479 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
480
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
481 form (n, afact, tau, qr_type);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
482 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
483
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
484 #if defined (HAVE_QRUPDATE)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
485
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
486 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
487 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
488 qr<Matrix>::update (const ColumnVector& u, const ColumnVector& v)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
489 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
490 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
491 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
492 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
493
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
494 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
495 F77_INT v_nel = octave::to_f77_int (v.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
496
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
497 if (u_nel != m || v_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
498 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
499
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
500 ColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
501 ColumnVector vtmp = v;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
502 OCTAVE_LOCAL_BUFFER (double, w, 2*k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
503 F77_XFCN (dqr1up, DQR1UP, (m, n, k, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
504 r.fortran_vec (), k, utmp.fortran_vec (),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
505 vtmp.fortran_vec (), w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
506 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
507
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
508 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
509 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
510 qr<Matrix>::update (const Matrix& u, const Matrix& v)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
511 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
512 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
513 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
514 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
515
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
516 F77_INT u_rows = octave::to_f77_int (u.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
517 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
518
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
519 F77_INT v_rows = octave::to_f77_int (v.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
520 F77_INT v_cols = octave::to_f77_int (v.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
521
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
522 if (u_rows != m || v_rows != n || u_cols != v_cols)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
523 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
524
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
525 OCTAVE_LOCAL_BUFFER (double, w, 2*k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
526 for (volatile F77_INT i = 0; i < u_cols; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
527 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
528 ColumnVector utmp = u.column (i);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
529 ColumnVector vtmp = v.column (i);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
530 F77_XFCN (dqr1up, DQR1UP, (m, n, k, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
531 r.fortran_vec (), k, utmp.fortran_vec (),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
532 vtmp.fortran_vec (), w));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
533 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
534 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
535
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
536 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
537 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
538 qr<Matrix>::insert_col (const ColumnVector& u, octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
539 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
540 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
541
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
542 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
543 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
544 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
545
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
546 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
547
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
548 if (u_nel != m)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
549 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
550
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
551 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
552 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
553
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
554 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
555 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
556 q.resize (m, k+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
557 r.resize (k+1, n+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
558 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
559 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
560 r.resize (k, n+1);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
561
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
562 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
563 F77_INT ldr = octave::to_f77_int (r.rows ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
564
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
565 ColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
566 OCTAVE_LOCAL_BUFFER (double, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
567 F77_XFCN (dqrinc, DQRINC, (m, n, k, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
568 r.fortran_vec (), ldr, j + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
569 utmp.data (), w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
570 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
571
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
572 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
573 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
574 qr<Matrix>::insert_col (const Matrix& u, const Array<octave_idx_type>& j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
575 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
576 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
577 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
578 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
579
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
580 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
581 Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
582 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
583 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
584 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
585 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
586
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
587 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
588 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
589
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
590 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
591 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
592
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
593 if (u_nel != m || u_cols != nj)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
594 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
595
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
596 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
597 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
598
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
599 if (nj > 0 && (js_beg < 0 || js_end > n))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
600 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
601
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
602 if (nj > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
603 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
604 F77_INT kmax = std::min (k + nj, m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
605 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
606 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
607 q.resize (m, kmax);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
608 r.resize (kmax, n + nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
609 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
610 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
611 r.resize (k, n + nj);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
612
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
613 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
614 F77_INT ldr = octave::to_f77_int (r.rows ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
615
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
616 OCTAVE_LOCAL_BUFFER (double, w, kmax);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
617 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
618 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
619 F77_INT ii = i;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
620 ColumnVector utmp = u.column (jsi(i));
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
621 F77_INT js_elt = octave::to_f77_int (js(ii));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
622 F77_XFCN (dqrinc, DQRINC, (m, n + ii, std::min (kmax, k + ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
623 q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
624 r.fortran_vec (), ldr, js_elt + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
625 utmp.data (), w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
626 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
627 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
628 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
629
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
630 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
631 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
632 qr<Matrix>::delete_col (octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
633 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
634 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
635
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
636 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
637 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
638 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
639
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
640 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
641 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
642
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
643 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
644 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
645
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
646 OCTAVE_LOCAL_BUFFER (double, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
647 F77_XFCN (dqrdec, DQRDEC, (m, n, k, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
648 r.fortran_vec (), ldr, j + 1, w));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
649
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
650 if (k < m)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
651 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
652 q.resize (m, k-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
653 r.resize (k-1, n-1);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
654 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
655 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
656 r.resize (k, n-1);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
657 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
658
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
659 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
660 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
661 qr<Matrix>::delete_col (const Array<octave_idx_type>& j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
662 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
663 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
664 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
665 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
666
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
667 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
668 Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
669 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
670 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
671 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
672 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
673
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
674 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
675 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
676
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
677 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
678 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
679
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
680 if (nj > 0 && (js_beg > n-1 || js_end < 0))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
681 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
682
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
683 if (nj > 0)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
684 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
685 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
686 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
687
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
688 OCTAVE_LOCAL_BUFFER (double, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
689 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
690 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
691 F77_INT ii = i;
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
692 F77_INT js_elt = octave::to_f77_int (js(ii));
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
693 F77_XFCN (dqrdec, DQRDEC, (m, n - ii, (k == m ? k : k - ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
694 q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
695 r.fortran_vec (), ldr,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
696 js_elt + 1, w));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
697 }
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
698
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
699 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
700 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
701 q.resize (m, k - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
702 r.resize (k - nj, n - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
703 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
704 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
705 r.resize (k, n - nj);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
706 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
707 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
708
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
709 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
710 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
711 qr<Matrix>::insert_row (const RowVector& u, octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
712 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
713 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
714
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
715 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
716 F77_INT n = octave::to_f77_int (r.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
717 F77_INT k = std::min (m, n);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
718
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
719 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
720
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
721 if (! q.issquare () || u_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
722 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
723
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
724 if (j < 0 || j > m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
725 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
726
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
727 q.resize (m + 1, m + 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
728 r.resize (m + 1, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
729
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
730 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
731 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
732
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
733 RowVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
734 OCTAVE_LOCAL_BUFFER (double, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
735 F77_XFCN (dqrinr, DQRINR, (m, n, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
736 r.fortran_vec (), ldr,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
737 j + 1, utmp.fortran_vec (), w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
738
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
739 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
740
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
741 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
742 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
743 qr<Matrix>::delete_row (octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
744 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
745 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
746
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
747 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
748 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
749
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
750 if (! q.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
751 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
752
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
753 if (j < 0 || j > m-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
754 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
755
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
756 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
757 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
758
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
759 OCTAVE_LOCAL_BUFFER (double, w, 2*m);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
760 F77_XFCN (dqrder, DQRDER, (m, n, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
761 r.fortran_vec (), ldr, j + 1, w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
762
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
763 q.resize (m - 1, m - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
764 r.resize (m - 1, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
765 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
766
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
767 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
768 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
769 qr<Matrix>::shift_cols (octave_idx_type i_arg, octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
770 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
771 F77_INT i = octave::to_f77_int (i_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
772 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
773
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
774 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
775 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
776 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
777
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
778 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
779 (*current_liboctave_error_handler) ("qrshift: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
780
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
781 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
782 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
783
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
784 OCTAVE_LOCAL_BUFFER (double, w, 2*k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
785 F77_XFCN (dqrshc, DQRSHC, (m, n, k,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
786 q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
787 r.fortran_vec (), ldr,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
788 i + 1, j + 1, w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
789 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
790
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
791 #endif
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
792
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
793 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
794 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
795 qr<FloatMatrix>::form (octave_idx_type n_arg, FloatMatrix& afact,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
796 float *tau, type qr_type)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
797 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
798 F77_INT n = octave::to_f77_int (n_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
799 F77_INT m = octave::to_f77_int (afact.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
800 F77_INT min_mn = std::min (m, n);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
801 F77_INT info;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
802
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
803 if (qr_type == qr<FloatMatrix>::raw)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
804 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
805 for (F77_INT j = 0; j < min_mn; j++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
806 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
807 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
808 for (F77_INT i = limit + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
809 afact.elem (i, j) *= tau[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
810 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
811
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
812 r = afact;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
813 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
814 else
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
815 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
816 // Attempt to minimize copying.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
817 if (m >= n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
818 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
819 // afact will become q.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
820 q = afact;
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
821 F77_INT k = (qr_type == qr<FloatMatrix>::economy ? n : m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
822 r = FloatMatrix (k, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
823 for (F77_INT j = 0; j < n; j++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
824 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
825 F77_INT i = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
826 for (; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
827 r.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
828 for (; i < k; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
829 r.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
830 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
831 afact = FloatMatrix (); // optimize memory
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
832 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
833 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
834 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
835 // afact will become r.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
836 q = FloatMatrix (m, m);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
837 for (F77_INT j = 0; j < m; j++)
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
838 for (F77_INT i = j + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
839 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
840 q.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
841 afact.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
842 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
843 r = afact;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
844 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
845
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
846 if (m > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
847 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
848 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
849 // workspace query.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
850 float rlwork;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
851 F77_XFCN (sorgqr, SORGQR, (m, k, min_mn, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
852 tau, &rlwork, -1, info));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
853
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
854 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
855 F77_INT lwork = static_cast<F77_INT> (rlwork);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
856 lwork = std::max (lwork, static_cast<F77_INT> (1));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
857 OCTAVE_LOCAL_BUFFER (float, work, lwork);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
858 F77_XFCN (sorgqr, SORGQR, (m, k, min_mn, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
859 tau, work, lwork, info));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
860 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
861 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
862 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
863
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
864 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
865 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
866 qr<FloatMatrix>::init (const FloatMatrix& a, type qr_type)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
867 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
868 F77_INT m = octave::to_f77_int (a.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
869 F77_INT n = octave::to_f77_int (a.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
870
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
871 F77_INT min_mn = (m < n ? m : n);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
872 OCTAVE_LOCAL_BUFFER (float, tau, min_mn);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
873
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
874 F77_INT info = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
875
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
876 FloatMatrix afact = a;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
877 if (m > n && qr_type == qr<FloatMatrix>::std)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
878 afact.resize (m, m);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
879
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
880 if (m > 0)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
881 {
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
882 // workspace query.
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
883 float rlwork;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
884 F77_XFCN (sgeqrf, SGEQRF, (m, n, afact.fortran_vec (), m, tau,
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
885 &rlwork, -1, info));
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
886
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
887 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
888 F77_INT lwork = static_cast<F77_INT> (rlwork);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
889 lwork = std::max (lwork, static_cast<F77_INT> (1));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
890 OCTAVE_LOCAL_BUFFER (float, work, lwork);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
891 F77_XFCN (sgeqrf, SGEQRF, (m, n, afact.fortran_vec (), m, tau,
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
892 work, lwork, info));
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
893 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
894
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
895 form (n, afact, tau, qr_type);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
896 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
897
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
898 #if defined (HAVE_QRUPDATE)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
899
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
900 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
901 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
902 qr<FloatMatrix>::update (const FloatColumnVector& u, const FloatColumnVector& v)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
903 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
904 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
905 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
906 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
907
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
908 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
909 F77_INT v_nel = octave::to_f77_int (v.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
910
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
911 if (u_nel != m || v_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
912 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
913
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
914 FloatColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
915 FloatColumnVector vtmp = v;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
916 OCTAVE_LOCAL_BUFFER (float, w, 2*k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
917 F77_XFCN (sqr1up, SQR1UP, (m, n, k, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
918 r.fortran_vec (), k, utmp.fortran_vec (),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
919 vtmp.fortran_vec (), w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
920 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
921
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
922 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
923 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
924 qr<FloatMatrix>::update (const FloatMatrix& u, const FloatMatrix& v)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
925 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
926 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
927 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
928 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
929
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
930 F77_INT u_rows = octave::to_f77_int (u.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
931 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
932
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
933 F77_INT v_rows = octave::to_f77_int (v.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
934 F77_INT v_cols = octave::to_f77_int (v.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
935
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
936 if (u_rows != m || v_rows != n || u_cols != v_cols)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
937 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
938
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
939 OCTAVE_LOCAL_BUFFER (float, w, 2*k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
940 for (volatile F77_INT i = 0; i < u_cols; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
941 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
942 FloatColumnVector utmp = u.column (i);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
943 FloatColumnVector vtmp = v.column (i);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
944 F77_XFCN (sqr1up, SQR1UP, (m, n, k, q.fortran_vec (), m,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
945 r.fortran_vec (), k, utmp.fortran_vec (),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
946 vtmp.fortran_vec (), w));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
947 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
948 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
949
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
950 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
951 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
952 qr<FloatMatrix>::insert_col (const FloatColumnVector& u,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
953 octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
954 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
955 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
956
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
957 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
958 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
959 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
960
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
961 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
962
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
963 if (u_nel != m)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
964 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
965
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
966 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
967 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
968
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
969 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
970 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
971 q.resize (m, k+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
972 r.resize (k+1, n+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
973 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
974 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
975 r.resize (k, n+1);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
976
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
977 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
978 F77_INT ldr = octave::to_f77_int (r.rows ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
979
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
980 FloatColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
981 OCTAVE_LOCAL_BUFFER (float, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
982 F77_XFCN (sqrinc, SQRINC, (m, n, k, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
983 r.fortran_vec (), ldr, j + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
984 utmp.data (), w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
985 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
986
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
987 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
988 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
989 qr<FloatMatrix>::insert_col (const FloatMatrix& u,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
990 const Array<octave_idx_type>& j)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
991 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
992 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
993 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
994 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
995
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
996 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
997 Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
998 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
999 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1000 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1001 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1002
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1003 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1004 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1005
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1006 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1007 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1008
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1009 if (u_nel != m || u_cols != nj)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1010 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1011
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1012 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1013 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1014
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1015 if (nj > 0 && (js_beg < 0 || js_end > n))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1016 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1017
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1018 if (nj > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1019 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1020 F77_INT kmax = std::min (k + nj, m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1021 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1022 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1023 q.resize (m, kmax);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1024 r.resize (kmax, n + nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1025 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1026 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1027 r.resize (k, n + nj);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1028
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1029 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1030 F77_INT ldr = octave::to_f77_int (r.rows ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1031
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1032 OCTAVE_LOCAL_BUFFER (float, w, kmax);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1033 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1034 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1035 F77_INT ii = i;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1036 FloatColumnVector utmp = u.column (jsi(i));
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1037 F77_INT js_elt = octave::to_f77_int (js(ii));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1038 F77_XFCN (sqrinc, SQRINC, (m, n + ii, std::min (kmax, k + ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1039 q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1040 r.fortran_vec (), ldr, js_elt + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1041 utmp.data (), w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1042 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1043 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1044 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1045
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1046 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1047 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1048 qr<FloatMatrix>::delete_col (octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1049 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1050 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1051
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1052 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1053 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1054 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1055
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1056 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1057 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1058
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1059 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1060 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1061
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1062 OCTAVE_LOCAL_BUFFER (float, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1063 F77_XFCN (sqrdec, SQRDEC, (m, n, k, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1064 r.fortran_vec (), ldr, j + 1, w));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1065
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1066 if (k < m)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1067 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1068 q.resize (m, k-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1069 r.resize (k-1, n-1);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1070 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1071 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1072 r.resize (k, n-1);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1073 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1074
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1075 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1076 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1077 qr<FloatMatrix>::delete_col (const Array<octave_idx_type>& j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1078 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1079 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1080 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1081 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1082
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1083 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1084 Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1085 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1086 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1087 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1088 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1089
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1090 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1091 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1092
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1093 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1094 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1095
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1096 if (nj > 0 && (js_beg > n-1 || js_end < 0))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1097 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1098
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1099 if (nj > 0)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1100 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1101 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1102 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1103
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1104 OCTAVE_LOCAL_BUFFER (float, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1105 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1106 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1107 F77_INT ii = i;
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1108 F77_INT js_elt = octave::to_f77_int (js(ii));
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1109 F77_XFCN (sqrdec, SQRDEC, (m, n - ii, (k == m ? k : k - ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1110 q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1111 r.fortran_vec (), ldr,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1112 js_elt + 1, w));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1113 }
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1114
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1115 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1116 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1117 q.resize (m, k - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1118 r.resize (k - nj, n - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1119 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1120 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1121 r.resize (k, n - nj);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1122 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1123 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1124
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1125 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1126 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1127 qr<FloatMatrix>::insert_row (const FloatRowVector& u,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1128 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1129 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1130 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1131
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1132 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1133 F77_INT n = octave::to_f77_int (r.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1134 F77_INT k = std::min (m, n);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1135
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1136 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1137
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
1138 if (! q.issquare () || u_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1139 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1140
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1141 if (j < 0 || j > m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1142 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1143
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1144 q.resize (m + 1, m + 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1145 r.resize (m + 1, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1146
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1147 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1148 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1149
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1150 FloatRowVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1151 OCTAVE_LOCAL_BUFFER (float, w, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1152 F77_XFCN (sqrinr, SQRINR, (m, n, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1153 r.fortran_vec (), ldr,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1154 j + 1, utmp.fortran_vec (), w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1155
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1156 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1157
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1158 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1159 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1160 qr<FloatMatrix>::delete_row (octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1161 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1162 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1163
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1164 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1165 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1166
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
1167 if (! q.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1168 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1169
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1170 if (j < 0 || j > m-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1171 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1172
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1173 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1174 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1175
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1176 OCTAVE_LOCAL_BUFFER (float, w, 2*m);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1177 F77_XFCN (sqrder, SQRDER, (m, n, q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1178 r.fortran_vec (), ldr, j + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1179 w));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1180
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1181 q.resize (m - 1, m - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1182 r.resize (m - 1, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1183 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1184
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1185 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1186 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1187 qr<FloatMatrix>::shift_cols (octave_idx_type i_arg, octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1188 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1189 F77_INT i = octave::to_f77_int (i_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1190 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1191
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1192 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1193 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1194 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1195
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1196 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1197 (*current_liboctave_error_handler) ("qrshift: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1198
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1199 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1200 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1201
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1202 OCTAVE_LOCAL_BUFFER (float, w, 2*k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1203 F77_XFCN (sqrshc, SQRSHC, (m, n, k,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1204 q.fortran_vec (), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1205 r.fortran_vec (), ldr,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1206 i + 1, j + 1, w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1207 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1208
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1209 #endif
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1210
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1211 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1212 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1213 qr<ComplexMatrix>::form (octave_idx_type n_arg, ComplexMatrix& afact,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1214 Complex *tau, type qr_type)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1215 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1216 F77_INT n = octave::to_f77_int (n_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1217 F77_INT m = octave::to_f77_int (afact.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1218 F77_INT min_mn = std::min (m, n);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1219 F77_INT info;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1220
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1221 if (qr_type == qr<ComplexMatrix>::raw)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1222 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1223 for (F77_INT j = 0; j < min_mn; j++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1224 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1225 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1226 for (F77_INT i = limit + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1227 afact.elem (i, j) *= tau[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1228 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1229
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1230 r = afact;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1231 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1232 else
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1233 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1234 // Attempt to minimize copying.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1235 if (m >= n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1236 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1237 // afact will become q.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1238 q = afact;
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1239 F77_INT k = (qr_type == qr<ComplexMatrix>::economy ? n : m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1240 r = ComplexMatrix (k, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1241 for (F77_INT j = 0; j < n; j++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1242 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1243 F77_INT i = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1244 for (; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1245 r.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1246 for (; i < k; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1247 r.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1248 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1249 afact = ComplexMatrix (); // optimize memory
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1250 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1251 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1252 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1253 // afact will become r.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1254 q = ComplexMatrix (m, m);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1255 for (F77_INT j = 0; j < m; j++)
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1256 for (F77_INT i = j + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1257 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1258 q.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1259 afact.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1260 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1261 r = afact;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1262 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1263
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1264 if (m > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1265 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1266 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1267 // workspace query.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1268 Complex clwork;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1269 F77_XFCN (zungqr, ZUNGQR, (m, k, min_mn,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1270 F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1271 m, F77_DBLE_CMPLX_ARG (tau),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1272 F77_DBLE_CMPLX_ARG (&clwork), -1,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1273 info));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1274
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1275 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1276 F77_INT lwork = static_cast<F77_INT> (clwork.real ());
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1277 lwork = std::max (lwork, static_cast<F77_INT> (1));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1278 OCTAVE_LOCAL_BUFFER (Complex, work, lwork);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1279 F77_XFCN (zungqr, ZUNGQR, (m, k, min_mn,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1280 F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1281 m, F77_DBLE_CMPLX_ARG (tau),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1282 F77_DBLE_CMPLX_ARG (work), lwork,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1283 info));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1284 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1285 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1286 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1287
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1288 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1289 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1290 qr<ComplexMatrix>::init (const ComplexMatrix& a, type qr_type)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1291 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1292 F77_INT m = octave::to_f77_int (a.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1293 F77_INT n = octave::to_f77_int (a.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1294
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1295 F77_INT min_mn = (m < n ? m : n);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1296 OCTAVE_LOCAL_BUFFER (Complex, tau, min_mn);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1297
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1298 F77_INT info = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1299
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1300 ComplexMatrix afact = a;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1301 if (m > n && qr_type == qr<ComplexMatrix>::std)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1302 afact.resize (m, m);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1303
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1304 if (m > 0)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1305 {
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1306 // workspace query.
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1307 Complex clwork;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1308 F77_XFCN (zgeqrf, ZGEQRF, (m, n,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1309 F77_DBLE_CMPLX_ARG (afact.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1310 m, F77_DBLE_CMPLX_ARG (tau),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1311 F77_DBLE_CMPLX_ARG (&clwork), -1, info));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1312
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1313 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1314 F77_INT lwork = static_cast<F77_INT> (clwork.real ());
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1315 lwork = std::max (lwork, static_cast<F77_INT> (1));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1316 OCTAVE_LOCAL_BUFFER (Complex, work, lwork);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1317 F77_XFCN (zgeqrf, ZGEQRF, (m, n,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1318 F77_DBLE_CMPLX_ARG (afact.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1319 m, F77_DBLE_CMPLX_ARG (tau),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1320 F77_DBLE_CMPLX_ARG (work), lwork, info));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1321 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1322
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1323 form (n, afact, tau, qr_type);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1324 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1325
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1326 #if defined (HAVE_QRUPDATE)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1327
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1328 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1329 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1330 qr<ComplexMatrix>::update (const ComplexColumnVector& u,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1331 const ComplexColumnVector& v)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1332 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1333 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1334 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1335 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1336
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1337 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1338 F77_INT v_nel = octave::to_f77_int (v.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1339
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1340 if (u_nel != m || v_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1341 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1342
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1343 ComplexColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1344 ComplexColumnVector vtmp = v;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1345 OCTAVE_LOCAL_BUFFER (Complex, w, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1346 OCTAVE_LOCAL_BUFFER (double, rw, k);
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1347 F77_XFCN (zqr1up, ZQR1UP, (m, n, k, F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1348 m, F77_DBLE_CMPLX_ARG (r.fortran_vec ()), k,
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1349 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1350 F77_DBLE_CMPLX_ARG (vtmp.fortran_vec ()),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1351 F77_DBLE_CMPLX_ARG (w), rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1352 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1353
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1354 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1355 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1356 qr<ComplexMatrix>::update (const ComplexMatrix& u, const ComplexMatrix& v)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1357 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1358 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1359 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1360 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1361
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1362 F77_INT u_rows = octave::to_f77_int (u.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1363 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1364
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1365 F77_INT v_rows = octave::to_f77_int (v.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1366 F77_INT v_cols = octave::to_f77_int (v.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1367
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1368 if (u_rows != m || v_rows != n || u_cols != v_cols)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1369 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1370
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1371 OCTAVE_LOCAL_BUFFER (Complex, w, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1372 OCTAVE_LOCAL_BUFFER (double, rw, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1373 for (volatile F77_INT i = 0; i < u_cols; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1374 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1375 ComplexColumnVector utmp = u.column (i);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1376 ComplexColumnVector vtmp = v.column (i);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1377 F77_XFCN (zqr1up, ZQR1UP, (m, n, k,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1378 F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1379 m, F77_DBLE_CMPLX_ARG (r.fortran_vec ()), k,
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1380 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1381 F77_DBLE_CMPLX_ARG (vtmp.fortran_vec ()),
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1382 F77_DBLE_CMPLX_ARG (w), rw));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1383 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1384 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1385
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1386 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1387 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1388 qr<ComplexMatrix>::insert_col (const ComplexColumnVector& u,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1389 octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1390 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1391 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1392
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1393 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1394 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1395 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1396
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1397 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1398
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1399 if (u_nel != m)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1400 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1401
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1402 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1403 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1404
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1405 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1406 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1407 q.resize (m, k+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1408 r.resize (k+1, n+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1409 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1410 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1411 r.resize (k, n+1);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1412
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1413 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1414 F77_INT ldr = octave::to_f77_int (r.rows ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1415
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1416 ComplexColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1417 OCTAVE_LOCAL_BUFFER (double, rw, k);
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1418 F77_XFCN (zqrinc, ZQRINC, (m, n, k, F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1419 ldq, F77_DBLE_CMPLX_ARG (r.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1420 ldr, j + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1421 F77_CONST_DBLE_CMPLX_ARG (utmp.data ()), rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1422 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1423
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1424 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1425 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1426 qr<ComplexMatrix>::insert_col (const ComplexMatrix& u,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1427 const Array<octave_idx_type>& j)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1428 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1429 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1430 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1431 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1432
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1433 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1434 Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1435 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1436 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1437 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1438 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1439
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1440 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1441 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1442
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1443 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1444 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1445
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1446 if (u_nel != m || u_cols != nj)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1447 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1448
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1449 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1450 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1451
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1452 if (nj > 0 && (js_beg < 0 || js_end > n))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1453 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1454
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1455 if (nj > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1456 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1457 F77_INT kmax = std::min (k + nj, m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1458 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1459 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1460 q.resize (m, kmax);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1461 r.resize (kmax, n + nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1462 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1463 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1464 r.resize (k, n + nj);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1465
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1466 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1467 F77_INT ldr = octave::to_f77_int (r.rows ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1468
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1469 OCTAVE_LOCAL_BUFFER (double, rw, kmax);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1470 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1471 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1472 F77_INT ii = i;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1473 ComplexColumnVector utmp = u.column (jsi(i));
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1474 F77_INT js_elt = octave::to_f77_int (js(ii));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1475 F77_XFCN (zqrinc, ZQRINC, (m, n + ii, std::min (kmax, k + ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1476 F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1477 ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1478 F77_DBLE_CMPLX_ARG (r.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1479 ldr, js_elt + 1,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1480 F77_CONST_DBLE_CMPLX_ARG (utmp.data ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1481 rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1482 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1483 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1484 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1485
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1486 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1487 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1488 qr<ComplexMatrix>::delete_col (octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1489 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1490 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1491
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1492 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1493 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1494 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1495
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1496 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1497 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1498
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1499 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1500 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1501
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1502 OCTAVE_LOCAL_BUFFER (double, rw, k);
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1503 F77_XFCN (zqrdec, ZQRDEC, (m, n, k, F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1504 ldq, F77_DBLE_CMPLX_ARG (r.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1505 ldr, j + 1, rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1506
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1507 if (k < m)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1508 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1509 q.resize (m, k-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1510 r.resize (k-1, n-1);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1511 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1512 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1513 r.resize (k, n-1);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1514 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1515
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1516 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1517 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1518 qr<ComplexMatrix>::delete_col (const Array<octave_idx_type>& j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1519 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1520 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1521 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1522 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1523
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1524 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1525 Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1526 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1527 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1528 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1529 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1530
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1531 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1532 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1533
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1534 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1535 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1536
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1537 if (nj > 0 && (js_beg > n-1 || js_end < 0))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1538 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1539
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1540 if (nj > 0)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1541 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1542 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1543 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1544
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1545 OCTAVE_LOCAL_BUFFER (double, rw, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1546 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1547 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1548 F77_INT ii = i;
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1549 F77_INT js_elt = octave::to_f77_int (js(ii));
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1550 F77_XFCN (zqrdec, ZQRDEC, (m, n - ii, (k == m ? k : k - ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1551 F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1552 ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1553 F77_DBLE_CMPLX_ARG (r.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1554 ldr, js_elt + 1, rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1555 }
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1556
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1557 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1558 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1559 q.resize (m, k - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1560 r.resize (k - nj, n - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1561 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1562 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1563 r.resize (k, n - nj);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1564 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1565 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1566
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1567 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1568 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1569 qr<ComplexMatrix>::insert_row (const ComplexRowVector& u,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1570 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1571 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1572 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1573
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1574 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1575 F77_INT n = octave::to_f77_int (r.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1576 F77_INT k = std::min (m, n);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1577
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1578 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1579
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
1580 if (! q.issquare () || u_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1581 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1582
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1583 if (j < 0 || j > m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1584 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1585
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1586 q.resize (m + 1, m + 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1587 r.resize (m + 1, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1588
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1589 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1590 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1591
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1592 ComplexRowVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1593 OCTAVE_LOCAL_BUFFER (double, rw, k);
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1594 F77_XFCN (zqrinr, ZQRINR, (m, n, F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1595 ldq, F77_DBLE_CMPLX_ARG (r.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1596 ldr, j + 1,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1597 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()), rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1598
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1599 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1600
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1601 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1602 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1603 qr<ComplexMatrix>::delete_row (octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1604 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1605 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1606
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1607 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1608 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1609
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
1610 if (! q.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1611 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1612
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1613 if (j < 0 || j > m-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1614 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1615
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1616 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1617 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1618
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1619 OCTAVE_LOCAL_BUFFER (Complex, w, m);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1620 OCTAVE_LOCAL_BUFFER (double, rw, m);
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1621 F77_XFCN (zqrder, ZQRDER, (m, n, F77_DBLE_CMPLX_ARG (q.fortran_vec ()),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1622 ldq, F77_DBLE_CMPLX_ARG (r.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1623 ldr, j + 1, F77_DBLE_CMPLX_ARG (w), rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1624
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1625 q.resize (m - 1, m - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1626 r.resize (m - 1, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1627 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1628
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1629 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1630 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1631 qr<ComplexMatrix>::shift_cols (octave_idx_type i_arg,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1632 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1633 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1634 F77_INT i = octave::to_f77_int (i_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1635 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1636
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1637 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1638 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1639 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1640
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1641 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1642 (*current_liboctave_error_handler) ("qrshift: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1643
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1644 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1645 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1646
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1647 OCTAVE_LOCAL_BUFFER (Complex, w, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1648 OCTAVE_LOCAL_BUFFER (double, rw, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1649 F77_XFCN (zqrshc, ZQRSHC, (m, n, k,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1650 F77_DBLE_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1651 F77_DBLE_CMPLX_ARG (r.fortran_vec ()), ldr,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1652 i + 1, j + 1, F77_DBLE_CMPLX_ARG (w), rw));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1653 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1654
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1655 #endif
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1656
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1657 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1658 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1659 qr<FloatComplexMatrix>::form (octave_idx_type n_arg, FloatComplexMatrix& afact,
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1660 FloatComplex *tau, type qr_type)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1661 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1662 F77_INT n = octave::to_f77_int (n_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1663 F77_INT m = octave::to_f77_int (afact.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1664 F77_INT min_mn = std::min (m, n);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1665 F77_INT info;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1666
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1667 if (qr_type == qr<FloatComplexMatrix>::raw)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1668 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1669 for (F77_INT j = 0; j < min_mn; j++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1670 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1671 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1672 for (F77_INT i = limit + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1673 afact.elem (i, j) *= tau[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1674 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1675
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1676 r = afact;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1677 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1678 else
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1679 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1680 // Attempt to minimize copying.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1681 if (m >= n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1682 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1683 // afact will become q.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1684 q = afact;
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1685 F77_INT k = (qr_type == qr<FloatComplexMatrix>::economy ? n : m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1686 r = FloatComplexMatrix (k, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1687 for (F77_INT j = 0; j < n; j++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1688 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1689 F77_INT i = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1690 for (; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1691 r.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1692 for (; i < k; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1693 r.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1694 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1695 afact = FloatComplexMatrix (); // optimize memory
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1696 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1697 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1698 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1699 // afact will become r.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1700 q = FloatComplexMatrix (m, m);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1701 for (F77_INT j = 0; j < m; j++)
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1702 for (F77_INT i = j + 1; i < m; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1703 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1704 q.xelem (i, j) = afact.xelem (i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1705 afact.xelem (i, j) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1706 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1707 r = afact;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1708 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1709
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1710 if (m > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1711 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1712 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1713 // workspace query.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1714 FloatComplex clwork;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1715 F77_XFCN (cungqr, CUNGQR, (m, k, min_mn,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1716 F77_CMPLX_ARG (q.fortran_vec ()), m,
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1717 F77_CMPLX_ARG (tau),
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1718 F77_CMPLX_ARG (&clwork), -1, info));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1719
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1720 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1721 F77_INT lwork = static_cast<F77_INT> (clwork.real ());
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1722 lwork = std::max (lwork, static_cast<F77_INT> (1));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1723 OCTAVE_LOCAL_BUFFER (FloatComplex, work, lwork);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1724 F77_XFCN (cungqr, CUNGQR, (m, k, min_mn,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1725 F77_CMPLX_ARG (q.fortran_vec ()), m,
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1726 F77_CMPLX_ARG (tau),
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1727 F77_CMPLX_ARG (work), lwork, info));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1728 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1729 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1730 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1731
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1732 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1733 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1734 qr<FloatComplexMatrix>::init (const FloatComplexMatrix& a, type qr_type)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1735 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1736 F77_INT m = octave::to_f77_int (a.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1737 F77_INT n = octave::to_f77_int (a.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1738
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1739 F77_INT min_mn = (m < n ? m : n);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1740 OCTAVE_LOCAL_BUFFER (FloatComplex, tau, min_mn);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1741
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1742 F77_INT info = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1743
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1744 FloatComplexMatrix afact = a;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1745 if (m > n && qr_type == qr<FloatComplexMatrix>::std)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1746 afact.resize (m, m);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1747
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1748 if (m > 0)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1749 {
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1750 // workspace query.
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1751 FloatComplex clwork;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1752 F77_XFCN (cgeqrf, CGEQRF, (m, n, F77_CMPLX_ARG (afact.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1753 m, F77_CMPLX_ARG (tau),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1754 F77_CMPLX_ARG (&clwork), -1, info));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1755
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1756 // allocate buffer and do the job.
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1757 F77_INT lwork = static_cast<F77_INT> (clwork.real ());
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1758 lwork = std::max (lwork, static_cast<F77_INT> (1));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1759 OCTAVE_LOCAL_BUFFER (FloatComplex, work, lwork);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1760 F77_XFCN (cgeqrf, CGEQRF, (m, n, F77_CMPLX_ARG (afact.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1761 m, F77_CMPLX_ARG (tau),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1762 F77_CMPLX_ARG (work), lwork, info));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1763 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1764
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1765 form (n, afact, tau, qr_type);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1766 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1767
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1768 #if defined (HAVE_QRUPDATE)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1769
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1770 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1771 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1772 qr<FloatComplexMatrix>::update (const FloatComplexColumnVector& u,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1773 const FloatComplexColumnVector& v)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1774 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1775 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1776 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1777 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1778
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1779 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1780 F77_INT v_nel = octave::to_f77_int (v.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1781
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1782 if (u_nel != m || v_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1783 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1784
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1785 FloatComplexColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1786 FloatComplexColumnVector vtmp = v;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1787 OCTAVE_LOCAL_BUFFER (FloatComplex, w, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1788 OCTAVE_LOCAL_BUFFER (float, rw, k);
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1789 F77_XFCN (cqr1up, CQR1UP, (m, n, k, F77_CMPLX_ARG (q.fortran_vec ()),
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1790 m, F77_CMPLX_ARG (r.fortran_vec ()), k,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1791 F77_CMPLX_ARG (utmp.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1792 F77_CMPLX_ARG (vtmp.fortran_vec ()),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1793 F77_CMPLX_ARG (w), rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1794 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1795
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1796 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1797 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1798 qr<FloatComplexMatrix>::update (const FloatComplexMatrix& u,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1799 const FloatComplexMatrix& v)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1800 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1801 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1802 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1803 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1804
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1805 F77_INT u_rows = octave::to_f77_int (u.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1806 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1807
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1808 F77_INT v_rows = octave::to_f77_int (v.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1809 F77_INT v_cols = octave::to_f77_int (v.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1810
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1811 if (u_rows != m || v_rows != n || u_cols != v_cols)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1812 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1813
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1814 OCTAVE_LOCAL_BUFFER (FloatComplex, w, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1815 OCTAVE_LOCAL_BUFFER (float, rw, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1816 for (volatile F77_INT i = 0; i < u_cols; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1817 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1818 FloatComplexColumnVector utmp = u.column (i);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1819 FloatComplexColumnVector vtmp = v.column (i);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1820 F77_XFCN (cqr1up, CQR1UP, (m, n, k, F77_CMPLX_ARG (q.fortran_vec ()),
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1821 m, F77_CMPLX_ARG (r.fortran_vec ()), k,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1822 F77_CMPLX_ARG (utmp.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1823 F77_CMPLX_ARG (vtmp.fortran_vec ()),
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1824 F77_CMPLX_ARG (w), rw));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1825 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1826 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1827
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1828 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1829 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1830 qr<FloatComplexMatrix>::insert_col (const FloatComplexColumnVector& u,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1831 octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1832 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1833 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1834
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1835 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1836 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1837 F77_INT k = octave::to_f77_int (q.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1838
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1839 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1840
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1841 if (u_nel != m)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1842 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1843
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1844 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1845 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1846
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1847 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1848 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1849 q.resize (m, k+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1850 r.resize (k+1, n+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1851 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1852 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1853 r.resize (k, n+1);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1854
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1855 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1856 F77_INT ldr = octave::to_f77_int (r.rows ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1857
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1858 FloatComplexColumnVector utmp = u;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1859 OCTAVE_LOCAL_BUFFER (float, rw, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1860 F77_XFCN (cqrinc, CQRINC, (m, n, k, F77_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1861 F77_CMPLX_ARG (r.fortran_vec ()), ldr, j + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1862 F77_CONST_CMPLX_ARG (utmp.data ()), rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1863 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1864
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1865 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1866 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1867 qr<FloatComplexMatrix>::insert_col (const FloatComplexMatrix& u,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
1868 const Array<octave_idx_type>& j)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1869 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1870 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1871 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1872 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1873
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1874 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1875 Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1876 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1877 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1878 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1879 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1880
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1881 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1882 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1883
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1884 F77_INT u_nel = octave::to_f77_int (u.numel ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1885 F77_INT u_cols = octave::to_f77_int (u.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1886
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1887 if (u_nel != m || u_cols != nj)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1888 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1889
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1890 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1891 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1892
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1893 if (nj > 0 && (js_beg < 0 || js_end > n))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1894 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1895
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1896 if (nj > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1897 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1898 F77_INT kmax = std::min (k + nj, m);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1899 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1900 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1901 q.resize (m, kmax);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1902 r.resize (kmax, n + nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1903 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1904 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1905 r.resize (k, n + nj);
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1906
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1907 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1908 F77_INT ldr = octave::to_f77_int (r.rows ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1909
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1910 OCTAVE_LOCAL_BUFFER (float, rw, kmax);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1911 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1912 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1913 F77_INT ii = i;
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1914 F77_INT js_elt = octave::to_f77_int (js(ii));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1915 F77_XFCN (cqrinc, CQRINC, (m, n + ii, std::min (kmax, k + ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1916 F77_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1917 F77_CMPLX_ARG (r.fortran_vec ()), ldr,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1918 js_elt + 1,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1919 F77_CONST_CMPLX_ARG (u.column (jsi(i)).data ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1920 rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1921 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1922 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1923 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1924
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1925 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1926 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1927 qr<FloatComplexMatrix>::delete_col (octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1928 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1929 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1930
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1931 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1932 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1933 F77_INT n = octave::to_f77_int (r.cols ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1934
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1935 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1936 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1937
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1938 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1939 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1940
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1941 OCTAVE_LOCAL_BUFFER (float, rw, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1942 F77_XFCN (cqrdec, CQRDEC, (m, n, k, F77_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1943 F77_CMPLX_ARG (r.fortran_vec ()), ldr, j + 1,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1944 rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1945
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1946 if (k < m)
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1947 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1948 q.resize (m, k-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1949 r.resize (k-1, n-1);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1950 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1951 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1952 r.resize (k, n-1);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1953 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1954
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1955 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1956 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1957 qr<FloatComplexMatrix>::delete_col (const Array<octave_idx_type>& j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1958 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1959 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1960 F77_INT n = octave::to_f77_int (r.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1961 F77_INT k = octave::to_f77_int (q.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1962
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1963 Array<octave_idx_type> jsi;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1964 Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1965 F77_INT nj = octave::to_f77_int (js.numel ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1966 bool dups = false;
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1967 for (F77_INT i = 0; i < nj - 1; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1968 dups = dups && js(i) == js(i+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1969
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1970 if (dups)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1971 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1972
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1973 F77_INT js_beg = octave::to_f77_int (js(0));
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1974 F77_INT js_end = octave::to_f77_int (js(nj-1));
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1975
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1976 if (nj > 0 && (js_beg > n-1 || js_end < 0))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1977 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1978
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1979 if (nj > 0)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1980 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1981 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1982 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1983
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1984 OCTAVE_LOCAL_BUFFER (float, rw, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1985 for (volatile F77_INT i = 0; i < nj; i++)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1986 {
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1987 F77_INT ii = i;
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
1988 F77_INT js_elt = octave::to_f77_int (js(ii));
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1989 F77_XFCN (cqrdec, CQRDEC, (m, n - ii, (k == m ? k : k - ii),
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1990 F77_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1991 F77_CMPLX_ARG (r.fortran_vec ()), ldr,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1992 js_elt + 1, rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1993 }
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1994
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1995 if (k < m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1996 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1997 q.resize (m, k - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1998 r.resize (k - nj, n - nj);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1999 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2000 else
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2001 r.resize (k, n - nj);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2002 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2003 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2004
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2005 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2006 void
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22393
diff changeset
2007 qr<FloatComplexMatrix>::insert_row (const FloatComplexRowVector& u,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2008 octave_idx_type j_arg)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2009 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2010 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2011
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2012 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2013 F77_INT n = octave::to_f77_int (r.cols ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2014 F77_INT k = std::min (m, n);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2015
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2016 F77_INT u_nel = octave::to_f77_int (u.numel ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2017
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
2018 if (! q.issquare () || u_nel != n)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2019 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2020
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2021 if (j < 0 || j > m)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2022 (*current_liboctave_error_handler) ("qrinsert: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2023
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2024 q.resize (m + 1, m + 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2025 r.resize (m + 1, n);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2026
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2027 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2028 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2029
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2030 FloatComplexRowVector utmp = u;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2031 OCTAVE_LOCAL_BUFFER (float, rw, k);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2032 F77_XFCN (cqrinr, CQRINR, (m, n, F77_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2033 F77_CMPLX_ARG (r.fortran_vec ()), ldr,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2034 j + 1, F77_CMPLX_ARG (utmp.fortran_vec ()),
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2035 rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2036
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2037 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2038
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2039 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2040 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2041 qr<FloatComplexMatrix>::delete_row (octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2042 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2043 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2044
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2045 F77_INT m = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2046 F77_INT n = octave::to_f77_int (r.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2047
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23577
diff changeset
2048 if (! q.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2049 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch");
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2050
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2051 if (j < 0 || j > m-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2052 (*current_liboctave_error_handler) ("qrdelete: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2053
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2054 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2055 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2056
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2057 OCTAVE_LOCAL_BUFFER (FloatComplex, w, m);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2058 OCTAVE_LOCAL_BUFFER (float, rw, m);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2059 F77_XFCN (cqrder, CQRDER, (m, n, F77_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2060 F77_CMPLX_ARG (r.fortran_vec ()), ldr, j + 1,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2061 F77_CMPLX_ARG (w), rw));
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2062
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2063 q.resize (m - 1, m - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2064 r.resize (m - 1, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2065 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2066
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2067 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2068 void
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2069 qr<FloatComplexMatrix>::shift_cols (octave_idx_type i_arg,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2070 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2071 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2072 F77_INT i = octave::to_f77_int (i_arg);
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2073 F77_INT j = octave::to_f77_int (j_arg);
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2074
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2075 F77_INT m = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2076 F77_INT k = octave::to_f77_int (r.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2077 F77_INT n = octave::to_f77_int (r.cols ());
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2078
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2079 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2080 (*current_liboctave_error_handler) ("qrshift: index out of range");
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2081
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2082 F77_INT ldq = octave::to_f77_int (q.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22984
diff changeset
2083 F77_INT ldr = octave::to_f77_int (r.rows ());
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2084
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2085 OCTAVE_LOCAL_BUFFER (FloatComplex, w, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2086 OCTAVE_LOCAL_BUFFER (float, rw, k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2087 F77_XFCN (cqrshc, CQRSHC, (m, n, k,
22958
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2088 F77_CMPLX_ARG (q.fortran_vec ()), ldq,
12e4534d68b1 use F77_INT instead of octave_idx_type for liboctave QR class
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2089 F77_CMPLX_ARG (r.fortran_vec ()), ldr,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2090 i + 1, j + 1, F77_CMPLX_ARG (w), rw));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2091 }
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2092
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2093 #endif
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2094
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2095 // Instantiations we need.
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2096
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2097 template class qr<Matrix>;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2098
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2099 template class qr<FloatMatrix>;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2100
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2101 template class qr<ComplexMatrix>;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
2102
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2103 template class qr<FloatComplexMatrix>;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2104 }
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
2105 }