annotate liboctave/numeric/qr.cc @ 23450:855122b993da

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