annotate liboctave/fCmplxQR.cc @ 8547:d66c9b6e506a

imported patch qrupdate.diff
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 20 Jan 2009 21:16:42 +0100
parents 4976f66d469b
children a6edd5c23cb5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 1994, 1995, 1996, 1997, 2002, 2003, 2004, 2005, 2007
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 John W. Eaton
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
5 Copyright (C) 2008, 2009 Jaroslav Hajek
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 This file is part of Octave.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 option) any later version.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 for more details.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 <http://www.gnu.org/licenses/>.
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 */
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #include <config.h>
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #endif
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include "fCmplxQR.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "f77-fcn.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "lo-error.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "Range.h"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include "idx-vector.h"
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
34 #include "oct-locbuf.h"
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 extern "C"
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 F77_FUNC (cgeqrf, CGEQRF) (const octave_idx_type&, const octave_idx_type&, FloatComplex*,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 const octave_idx_type&, FloatComplex*, FloatComplex*,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 const octave_idx_type&, octave_idx_type&);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 F77_FUNC (cungqr, CUNGQR) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 FloatComplex*, const octave_idx_type&, FloatComplex*,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 FloatComplex*, const octave_idx_type&, octave_idx_type&);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
48 #ifdef HAVE_QRUPDATE
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 F77_FUNC (cqr1up, CQR1UP) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&,
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
52 FloatComplex*, const octave_idx_type&, FloatComplex*, const octave_idx_type&,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
53 FloatComplex*, FloatComplex*, FloatComplex*, float*);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 F77_FUNC (cqrinc, CQRINC) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&,
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
57 FloatComplex*, const octave_idx_type&, FloatComplex*, const octave_idx_type&,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
58 const octave_idx_type&, const FloatComplex*, float*);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 F77_FUNC (cqrdec, CQRDEC) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&,
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
62 FloatComplex*, const octave_idx_type&, FloatComplex*, const octave_idx_type&,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
63 const octave_idx_type&, float*);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 F77_FUNC (cqrinr, CQRINR) (const octave_idx_type&, const octave_idx_type&,
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
67 FloatComplex*, const octave_idx_type&, FloatComplex*, const octave_idx_type&,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
68 const octave_idx_type&, const FloatComplex*, float*);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 F77_FUNC (cqrder, CQRDER) (const octave_idx_type&, const octave_idx_type&,
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
72 FloatComplex*, const octave_idx_type&, FloatComplex*, const octave_idx_type&,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
73 const octave_idx_type&, FloatComplex*, float*);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 F77_RET_T
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 F77_FUNC (cqrshc, CQRSHC) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&,
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
77 FloatComplex*, const octave_idx_type&, FloatComplex*, const octave_idx_type&,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
78 const octave_idx_type&, const octave_idx_type&,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
79 FloatComplex*, float*);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
80
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
81 #endif
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 FloatComplexQR::FloatComplexQR (const FloatComplexMatrix& a, QR::type qr_type)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 : q (), r ()
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 init (a, qr_type);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 void
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 FloatComplexQR::init (const FloatComplexMatrix& a, QR::type qr_type)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 octave_idx_type m = a.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 octave_idx_type n = a.cols ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 if (m == 0 || n == 0)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 (*current_liboctave_error_handler)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 ("FloatComplexQR must have non-empty matrix");
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 return;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 octave_idx_type min_mn = m < n ? m : n;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 Array<FloatComplex> tau (min_mn);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 FloatComplex *ptau = tau.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 octave_idx_type lwork = 32*n;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 Array<FloatComplex> work (lwork);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 FloatComplex *pwork = work.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 octave_idx_type info = 0;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 FloatComplexMatrix A_fact;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 if (m > n && qr_type != QR::economy)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 A_fact.resize (m, m);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 A_fact.insert (a, 0, 0);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 else
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 A_fact = a;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 FloatComplex *tmp_data = A_fact.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 F77_XFCN (cgeqrf, CGEQRF, (m, n, tmp_data, m, ptau, pwork, lwork, info));
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 if (qr_type == QR::raw)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 for (octave_idx_type j = 0; j < min_mn; j++)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 octave_idx_type limit = j < min_mn - 1 ? j : min_mn - 1;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 for (octave_idx_type i = limit + 1; i < m; i++)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 A_fact.elem (i, j) *= tau.elem (j);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 r = A_fact;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 if (m > n)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139 r.resize (m, n);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 else
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143 octave_idx_type n2 = (qr_type == QR::economy) ? min_mn : m;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145 if (qr_type == QR::economy && m > n)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 r.resize (n, n, 0.0);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 else
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 r.resize (m, n, 0.0);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 for (octave_idx_type j = 0; j < n; j++)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152 octave_idx_type limit = j < min_mn-1 ? j : min_mn-1;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 for (octave_idx_type i = 0; i <= limit; i++)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154 r.elem (i, j) = A_fact.elem (i, j);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 lwork = 32 * n2;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 work.resize (lwork);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 FloatComplex *pwork2 = work.fortran_vec ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 F77_XFCN (cungqr, CUNGQR, (m, n2, min_mn, tmp_data, m, ptau,
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 pwork2, lwork, info));
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 q = A_fact;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165 q.resize (m, n2);
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7792
diff changeset
169 FloatComplexQR::FloatComplexQR (const FloatComplexMatrix& q_arg, const FloatComplexMatrix& r_arg)
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170 {
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7792
diff changeset
171 if (q_arg.columns () != r_arg.rows ())
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 (*current_liboctave_error_handler) ("QR dimensions mismatch");
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 return;
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7792
diff changeset
177 this->q = q_arg;
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7792
diff changeset
178 this->r = r_arg;
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
181 #ifdef HAVE_QRUPDATE
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
182
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
183 void
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
184 FloatComplexQR::update (const FloatComplexColumnVector& u, const FloatComplexColumnVector& v)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
185 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
186 octave_idx_type m = q.rows ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
187 octave_idx_type n = r.columns ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
188 octave_idx_type k = q.columns ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
189
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
190 if (u.length () == m && v.length () == n)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
191 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
192 FloatComplexColumnVector utmp = u, vtmp = v;
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
193 OCTAVE_LOCAL_BUFFER (FloatComplex, w, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
194 OCTAVE_LOCAL_BUFFER (float, rw, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
195 F77_XFCN (cqr1up, CQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
196 utmp.fortran_vec (), vtmp.fortran_vec (), w, rw));
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
197 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
198 else
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
199 (*current_liboctave_error_handler) ("QR update dimensions mismatch");
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
200 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
201
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202 void
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203 FloatComplexQR::update (const FloatComplexMatrix& u, const FloatComplexMatrix& v)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
205 octave_idx_type m = q.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206 octave_idx_type n = r.columns ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 octave_idx_type k = q.columns ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
209 if (u.rows () == m && v.rows () == n && u.cols () == v.cols ())
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
210 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
211 OCTAVE_LOCAL_BUFFER (FloatComplex, w, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
212 OCTAVE_LOCAL_BUFFER (float, rw, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
213 for (octave_idx_type i = 0; i < u.cols (); i++)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
214 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
215 FloatComplexColumnVector utmp = u.column (i), vtmp = v.column (i);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
216 F77_XFCN (cqr1up, CQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
217 utmp.fortran_vec (), vtmp.fortran_vec (), w, rw));
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
218 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
219 }
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
220 else
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
221 (*current_liboctave_error_handler) ("qrupdate: dimensions mismatch");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
223
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224 void
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
225 FloatComplexQR::insert_col (const FloatComplexColumnVector& u, octave_idx_type j)
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
226 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
227 octave_idx_type m = q.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228 octave_idx_type n = r.columns ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
229 octave_idx_type k = q.columns ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
231 if (u.length () != m)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
232 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
233 else if (j < 0 || j > n)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
234 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
235 else
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
236 {
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
237 if (k < m)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
238 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
239 q.resize (m, k+1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
240 r.resize (k+1, n+1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
241 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
242 else
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
243 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
244 r.resize (k, n+1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
245 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
246
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
247 FloatComplexColumnVector utmp = u;
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
248 OCTAVE_LOCAL_BUFFER (float, rw, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
249 F77_XFCN (cqrinc, CQRINC, (m, n, k, q.fortran_vec (), q.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
250 r.fortran_vec (), r.rows (), j + 1,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
251 utmp.data (), rw));
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
252 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
253 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
254
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
255 void
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
256 FloatComplexQR::insert_col (const FloatComplexMatrix& u, const Array<octave_idx_type>& j)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
257 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
258 octave_idx_type m = q.rows ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
259 octave_idx_type n = r.columns ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
260 octave_idx_type k = q.columns ();
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
261
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
262 Array<octave_idx_type> jsi;
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
263 Array<octave_idx_type> js = j.sort (jsi, ASCENDING);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
264 octave_idx_type nj = js.length ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
265 bool dups = false;
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
266 for (octave_idx_type i = 0; i < nj - 1; i++)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
267 dups = dups && js(i) == js(i+1);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
268
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
269 if (dups)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
270 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
271 else if (u.length () != m || u.columns () != nj)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
272 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
273 else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
274 (*current_liboctave_error_handler) ("qrinsert: index out of range");
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
275 else if (nj > 0)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
276 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
277 octave_idx_type kmax = std::min (k + nj, m);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
278 if (k < m)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
279 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
280 q.resize (m, kmax);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
281 r.resize (kmax, n + nj);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
282 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
283 else
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
284 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
285 r.resize (k, n + nj);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
286 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
287
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
288 OCTAVE_LOCAL_BUFFER (float, rw, kmax);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
289 for (octave_idx_type i = 0; i < js.length (); i++)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
290 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
291 F77_XFCN (cqrinc, CQRINC, (m, n + i, std::min (kmax, k + i),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
292 q.fortran_vec (), q.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
293 r.fortran_vec (), r.rows (), js(i) + 1,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
294 u.column (jsi(i)).data (), rw));
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
295 }
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
298
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
299 void
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300 FloatComplexQR::delete_col (octave_idx_type j)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
301 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
302 octave_idx_type m = q.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
303 octave_idx_type k = r.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
304 octave_idx_type n = r.columns ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
305
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
306 if (j < 0 || j > n-1)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
307 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
308 else
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
309 {
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
310 OCTAVE_LOCAL_BUFFER (float, rw, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
311 F77_XFCN (cqrdec, CQRDEC, (m, n, k, q.fortran_vec (), q.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
312 r.fortran_vec (), r.rows (), j + 1, rw));
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
313
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
314 if (k < m)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
315 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
316 q.resize (m, k-1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
317 r.resize (k-1, n-1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
318 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
319 else
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
320 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
321 r.resize (k, n-1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
322 }
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
323 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
324 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 void
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
327 FloatComplexQR::delete_col (const Array<octave_idx_type>& j)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
328 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
329 octave_idx_type m = q.rows ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
330 octave_idx_type n = r.columns ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
331 octave_idx_type k = q.columns ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
332
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
333 Array<octave_idx_type> jsi;
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
334 Array<octave_idx_type> js = j.sort (jsi, DESCENDING);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
335 octave_idx_type nj = js.length ();
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
336 bool dups = false;
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
337 for (octave_idx_type i = 0; i < nj - 1; i++)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
338 dups = dups && js(i) == js(i+1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
339
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
340 if (dups)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
341 (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
342 else if (nj > 0 && (js(0) > n-1 || js(nj-1) < 0))
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
343 (*current_liboctave_error_handler) ("qrinsert: index out of range");
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
344 else if (nj > 0)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
345 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
346 OCTAVE_LOCAL_BUFFER (float, rw, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
347 for (octave_idx_type i = 0; i < js.length (); i++)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
348 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
349 F77_XFCN (cqrdec, CQRDEC, (m, n - i, k == m ? k : k - i,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
350 q.fortran_vec (), q.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
351 r.fortran_vec (), r.rows (), js(i) + 1, rw));
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
352 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
353 if (k < m)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
354 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
355 q.resize (m, k - nj);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
356 r.resize (k - nj, n - nj);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
357 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
358 else
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
359 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
360 r.resize (k, n - nj);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
361 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
362
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
363 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
364 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
365
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
366 void
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
367 FloatComplexQR::insert_row (const FloatComplexRowVector& u, octave_idx_type j)
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
368 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 octave_idx_type m = r.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
370 octave_idx_type n = r.columns ();
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
371 octave_idx_type k = std::min (m, n);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
372
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
373 if (! q.is_square () || u.length () != n)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
374 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
375 else if (j < 0 || j > m)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
376 (*current_liboctave_error_handler) ("qrinsert: index out of range");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377 else
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
378 {
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
379 q.resize (m + 1, m + 1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
380 r.resize (m + 1, n);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
381 FloatComplexRowVector utmp = u;
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
382 OCTAVE_LOCAL_BUFFER (float, rw, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
383 F77_XFCN (cqrinr, CQRINR, (m, n, q.fortran_vec (), q.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
384 r.fortran_vec (), r.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
385 j + 1, utmp.fortran_vec (), rw));
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
386
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
387 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
388 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
389
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
390 void
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
391 FloatComplexQR::delete_row (octave_idx_type j)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
392 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
393 octave_idx_type m = r.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
394 octave_idx_type n = r.columns ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
395
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
396 if (! q.is_square ())
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
397 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
398 else if (j < 0 || j > m-1)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
399 (*current_liboctave_error_handler) ("qrdelete: index out of range");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
400 else
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
401 {
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
402 OCTAVE_LOCAL_BUFFER (FloatComplex, w, m);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
403 OCTAVE_LOCAL_BUFFER (float, rw, m);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
404 F77_XFCN (cqrder, CQRDER, (m, n, q.fortran_vec (), q.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
405 r.fortran_vec (), r.rows (), j + 1,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
406 w, rw));
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
407
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
408 q.resize (m - 1, m - 1);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
409 r.resize (m - 1, n);
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
410 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
411 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
412
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413 void
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
414 FloatComplexQR::shift_cols (octave_idx_type i, octave_idx_type j)
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
415 {
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
416 octave_idx_type m = q.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
417 octave_idx_type k = r.rows ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
418 octave_idx_type n = r.columns ();
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
420 if (i < 0 || i > n-1 || j < 0 || j > n-1)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
421 (*current_liboctave_error_handler) ("qrshift: index out of range");
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422 else
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
423 {
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
424 OCTAVE_LOCAL_BUFFER (FloatComplex, w, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
425 OCTAVE_LOCAL_BUFFER (float, rw, k);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
426 F77_XFCN (cqrshc, CQRSHC, (m, n, k,
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
427 q.fortran_vec (), q.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
428 r.fortran_vec (), r.rows (),
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
429 i + 1, j + 1, w, rw));
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
430 }
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
431 }
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
432
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 7924
diff changeset
433 #endif
7792
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
434
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
435 /*
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
436 ;;; Local Variables: ***
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
437 ;;; mode: C++ ***
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
438 ;;; End: ***
39c1026191e9 add missing files from single-precision merge
John W. Eaton <jwe@octave.org>
parents:
diff changeset
439 */