Mercurial > hg > octave-nkf
annotate libinterp/dldfcn/qr.cc @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 075a5e2e1ba5 |
children |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18583
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
11523 | 4 Copyright (C) 2008-2009 Jaroslav Hajek |
5 Copyright (C) 2008-2009 VZLU Prague | |
2928 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
2928 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
2928 | 22 |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 #include <config.h> | |
27 #endif | |
28 | |
29 #include "CmplxQR.h" | |
30 #include "CmplxQRP.h" | |
31 #include "dbleQR.h" | |
32 #include "dbleQRP.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
33 #include "fCmplxQR.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
34 #include "fCmplxQRP.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
35 #include "floatQR.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
36 #include "floatQRP.h" |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
37 #include "SparseQR.h" |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
38 #include "SparseCmplxQR.h" |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
39 |
2928 | 40 |
41 #include "defun-dld.h" | |
42 #include "error.h" | |
43 #include "gripes.h" | |
44 #include "oct-obj.h" | |
45 #include "utils.h" | |
46 | |
8869
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
47 template <class MT> |
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
48 static octave_value |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
49 get_qr_r (const base_qr<MT>& fact) |
8869
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
50 { |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
51 MT R = fact.R (); |
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
52 if (R.is_square () && fact.regular ()) |
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
53 return octave_value (R, MatrixType (MatrixType::Upper)); |
8869
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
54 else |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
55 return R; |
8869
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
56 } |
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
57 |
3372 | 58 // [Q, R] = qr (X): form Q unitary and R upper triangular such |
59 // that Q * R = X | |
60 // | |
61 // [Q, R] = qr (X, 0): form the economy decomposition such that if X is | |
62 // m by n then only the first n columns of Q are | |
63 // computed. | |
64 // | |
65 // [Q, R, P] = qr (X): form QRP factorization of X where | |
66 // P is a permutation matrix such that | |
67 // A * P = Q * R | |
68 // | |
69 // [Q, R, P] = qr (X, 0): form the economy decomposition with | |
70 // permutation vector P such that Q * R = X (:, P) | |
71 // | |
72 // qr (X) alone returns the output of the LAPACK routine dgeqrf, such | |
73 // that R = triu (qr (X)) | |
74 | |
2928 | 75 DEFUN_DLD (qr, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 "-*- texinfo -*-\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
77 @deftypefn {Loadable Function} {[@var{Q}, @var{R}, @var{P}] =} qr (@var{A})\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
78 @deftypefnx {Loadable Function} {[@var{Q}, @var{R}, @var{P}] =} qr (@var{A}, '0')\n\ |
12908
12defc71072c
doc: Remove reference to spqr in qr documentation (Bug #33922)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
12642
diff
changeset
|
79 @deftypefnx {Loadable Function} {[@var{C}, @var{R}] =} qr (@var{A}, @var{B})\n\ |
12defc71072c
doc: Remove reference to spqr in qr documentation (Bug #33922)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
12642
diff
changeset
|
80 @deftypefnx {Loadable Function} {[@var{C}, @var{R}] =} qr (@var{A}, @var{B}, '0')\n\ |
3372 | 81 @cindex QR factorization\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
82 Compute the QR@tie{}factorization of @var{A}, using standard @sc{lapack}\n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
83 subroutines.\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
84 \n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
85 For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},\n\ |
2928 | 86 \n\ |
3372 | 87 @example\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
88 [@var{Q}, @var{R}] = qr (@var{A})\n\ |
3372 | 89 @end example\n\ |
90 \n\ | |
91 @noindent\n\ | |
92 returns\n\ | |
93 \n\ | |
94 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
95 @group\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
96 @var{Q} =\n\ |
3372 | 97 \n\ |
98 -0.31623 -0.94868\n\ | |
99 -0.94868 0.31623\n\ | |
100 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
101 @var{R} =\n\ |
3372 | 102 \n\ |
103 -3.16228 -4.42719\n\ | |
104 0.00000 -0.63246\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
105 @end group\n\ |
3372 | 106 @end example\n\ |
107 \n\ | |
108 The @code{qr} factorization has applications in the solution of least\n\ | |
109 squares problems\n\ | |
110 @tex\n\ | |
111 $$\n\ | |
112 \\min_x \\left\\Vert A x - b \\right\\Vert_2\n\ | |
113 $$\n\ | |
114 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
115 @ifnottex\n\ |
2928 | 116 \n\ |
3372 | 117 @example\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14219
diff
changeset
|
118 min norm(A x - b)\n\ |
3372 | 119 @end example\n\ |
120 \n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
121 @end ifnottex\n\ |
3372 | 122 for overdetermined systems of equations (i.e.,\n\ |
123 @tex\n\ | |
124 $A$\n\ | |
125 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
126 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
127 @var{A}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
128 @end ifnottex\n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
129 is a tall, thin matrix). The QR@tie{}factorization is\n\ |
3372 | 130 @tex\n\ |
131 $QR = A$ where $Q$ is an orthogonal matrix and $R$ is upper triangular.\n\ | |
132 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
133 @ifnottex\n\ |
18570
35100920494f
doc: Update docstring for qr (bug #41641).
Marko Seric <marko.seric@math.uzh.ch>
parents:
17787
diff
changeset
|
134 @code{@var{Q} * @var{R} = @var{A}} where @var{Q} is an orthogonal matrix and\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
135 @var{R} is upper triangular.\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
136 @end ifnottex\n\ |
2928 | 137 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
138 If given a second argument of @qcode{'0'}, @code{qr} returns an economy-sized\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
139 QR@tie{}factorization, omitting zero rows of @var{R} and the corresponding\n\ |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
140 columns of @var{Q}.\n\ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
141 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
142 If the matrix @var{A} is full, the permuted QR@tie{}factorization\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
143 @code{[@var{Q}, @var{R}, @var{P}] = qr (@var{A})} forms the\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
144 QR@tie{}factorization such that the diagonal entries of @var{R} are\n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
145 decreasing in magnitude order. For example, given the matrix\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
146 @code{a = [1, 2; 3, 4]},\n\ |
3372 | 147 \n\ |
148 @example\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
149 [@var{Q}, @var{R}, @var{P}] = qr (@var{A})\n\ |
3372 | 150 @end example\n\ |
151 \n\ | |
152 @noindent\n\ | |
153 returns\n\ | |
154 \n\ | |
155 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
156 @group\n\ |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
12329
diff
changeset
|
157 @var{Q} =\n\ |
2928 | 158 \n\ |
3372 | 159 -0.44721 -0.89443\n\ |
160 -0.89443 0.44721\n\ | |
161 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
162 @var{R} =\n\ |
3372 | 163 \n\ |
164 -4.47214 -3.13050\n\ | |
165 0.00000 0.44721\n\ | |
166 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
167 @var{P} =\n\ |
3372 | 168 \n\ |
169 0 1\n\ | |
170 1 0\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
171 @end group\n\ |
3372 | 172 @end example\n\ |
173 \n\ | |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
174 The permuted @code{qr} factorization\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
175 @code{[@var{Q}, @var{R}, @var{P}] = qr (@var{A})} factorization allows the\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
176 construction of an orthogonal basis of @code{span (A)}.\n\ |
7491 | 177 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
178 If the matrix @var{A} is sparse, then compute the sparse\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
179 QR@tie{}factorization of @var{A}, using @sc{CSparse}. As the matrix @var{Q}\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
180 is in general a full matrix, this function returns the @var{Q}-less\n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
181 factorization @var{R} of @var{A}, such that\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
182 @code{@var{R} = chol (@var{A}' * @var{A})}.\n\ |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
183 \n\ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
184 If the final argument is the scalar @code{0} and the number of rows is\n\ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
185 larger than the number of columns, then an economy factorization is\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
186 returned. That is @var{R} will have only @code{size (@var{A},1)} rows.\n\ |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
187 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
188 If an additional matrix @var{B} is supplied, then @code{qr} returns\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
189 @var{C}, where @code{@var{C} = @var{Q}' * @var{B}}. This allows the\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
190 least squares approximation of @code{@var{A} \\ @var{B}} to be calculated\n\ |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
191 as\n\ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
192 \n\ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
193 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
194 @group\n\ |
12908
12defc71072c
doc: Remove reference to spqr in qr documentation (Bug #33922)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
12642
diff
changeset
|
195 [@var{C}, @var{R}] = qr (@var{A}, @var{B})\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
196 x = @var{R} \\ @var{C}\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
197 @end group\n\ |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
198 @end example\n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
199 @seealso{chol, hess, lu, qz, schur, svd, qrupdate, qrinsert, qrdelete, qrshift}\n\ |
3372 | 200 @end deftypefn") |
2928 | 201 { |
202 octave_value_list retval; | |
203 | |
204 int nargin = args.length (); | |
205 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
206 if (nargin < 1 || nargin > (args(0).is_sparse_type () ? 3 : 2)) |
2928 | 207 { |
5823 | 208 print_usage (); |
2928 | 209 return retval; |
210 } | |
211 | |
212 octave_value arg = args(0); | |
213 | |
214 int arg_is_empty = empty_arg ("qr", arg.rows (), arg.columns ()); | |
215 | |
216 if (arg_is_empty < 0) | |
217 return retval; | |
218 | |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
219 if (arg.is_sparse_type ()) |
2928 | 220 { |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
221 bool economy = false; |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
222 bool is_cmplx = false; |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
223 int have_b = 0; |
3068 | 224 |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
225 if (arg.is_complex_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
226 is_cmplx = true; |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
227 if (nargin > 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
228 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
229 have_b = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
230 if (args(nargin-1).is_scalar_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
231 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
232 int val = args(nargin-1).int_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
233 if (val == 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
234 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
235 economy = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
236 have_b = (nargin > 2 ? 2 : 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
237 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
238 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
239 if (have_b > 0 && args(have_b).is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
240 is_cmplx = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
241 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
242 |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
243 if (!error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
244 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
245 if (have_b && nargout < 2) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
246 error ("qr: incorrect number of output arguments"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
247 else if (is_cmplx) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
248 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
249 SparseComplexQR q (arg.sparse_complex_matrix_value ()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
250 if (!error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
251 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
252 if (have_b > 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
253 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
254 retval(1) = q.R (economy); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
255 retval(0) = q.C (args(have_b).complex_matrix_value ()); |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
256 if (arg.rows () < arg.columns ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
257 warning ("qr: non minimum norm solution for under-determined problem"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
258 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
259 else if (nargout > 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
260 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
261 retval(1) = q.R (economy); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
262 retval(0) = q.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
263 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
264 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
265 retval(0) = q.R (economy); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
266 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
267 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
268 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
269 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
270 SparseQR q (arg.sparse_matrix_value ()); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
271 if (!error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
272 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
273 if (have_b > 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
274 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
275 retval(1) = q.R (economy); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
276 retval(0) = q.C (args(have_b).matrix_value ()); |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
277 if (args(0).rows () < args(0).columns ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
278 warning ("qr: non minimum norm solution for under-determined problem"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
279 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
280 else if (nargout > 1) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
281 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
282 retval(1) = q.R (economy); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
283 retval(0) = q.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
284 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
285 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
286 retval(0) = q.R (economy); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
287 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
288 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
289 } |
2928 | 290 } |
291 else | |
292 { | |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
293 QR::type type = (nargout == 0 || nargout == 1) ? QR::raw |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
294 : nargin == 2 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
295 ? QR::economy : QR::std; |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
296 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
297 if (arg.is_single_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
298 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
299 if (arg.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
300 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
301 FloatMatrix m = arg.float_matrix_value (); |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
302 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
303 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
304 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
305 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
306 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
307 case 0: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
308 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
309 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
310 FloatQR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
311 retval(0) = fact.R (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
312 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
313 break; |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
314 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
315 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
316 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
317 FloatQR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
318 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
319 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
320 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
321 break; |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
322 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
323 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
324 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
325 FloatQRP fact (m, type); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
326 if (type == QR::economy) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
327 retval(2) = fact.Pvec (); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
328 else |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
329 retval(2) = fact.P (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
330 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
331 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
332 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
333 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
334 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
335 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
336 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
337 else if (arg.is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
338 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
339 FloatComplexMatrix m = arg.float_complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
340 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
341 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
342 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
343 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
344 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
345 case 0: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
346 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
347 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
348 FloatComplexQR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
349 retval(0) = fact.R (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
350 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
351 break; |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
352 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
353 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
354 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
355 FloatComplexQR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
356 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
357 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
358 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
359 break; |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
360 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
361 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
362 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
363 FloatComplexQRP fact (m, type); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
364 if (type == QR::economy) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
365 retval(2) = fact.Pvec (); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
366 else |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
367 retval(2) = fact.P (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
368 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
369 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
370 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
371 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
372 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
373 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
374 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
375 } |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
376 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
377 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
378 if (arg.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
379 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
380 Matrix m = arg.matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
381 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
382 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
383 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
384 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
385 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
386 case 0: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
387 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
388 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
389 QR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
390 retval(0) = fact.R (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
391 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
392 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
393 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
394 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
395 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
396 QR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
397 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
398 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
399 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
400 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
401 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
402 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
403 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
404 QRP fact (m, type); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
405 if (type == QR::economy) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
406 retval(2) = fact.Pvec (); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
407 else |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
408 retval(2) = fact.P (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
409 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
410 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
411 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
412 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
413 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
414 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
415 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
416 else if (arg.is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
417 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
418 ComplexMatrix m = arg.complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
419 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
420 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
421 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
422 switch (nargout) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
423 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
424 case 0: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
425 case 1: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
426 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
427 ComplexQR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
428 retval(0) = fact.R (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
429 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
430 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
431 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
432 case 2: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
433 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
434 ComplexQR fact (m, type); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
435 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
436 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
437 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
438 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
439 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
440 default: |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
441 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
442 ComplexQRP fact (m, type); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
443 if (type == QR::economy) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
444 retval(2) = fact.Pvec (); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
445 else |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7924
diff
changeset
|
446 retval(2) = fact.P (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
447 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
448 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
449 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
450 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
451 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
452 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
453 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
454 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
455 gripe_wrong_type_arg ("qr", arg); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
456 } |
2928 | 457 } |
458 | |
459 return retval; | |
460 } | |
461 | |
462 /* | |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
463 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
464 %! a = [0, 2, 1; 2, 1, 2]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
465 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
466 %! [q, r] = qr (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
467 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
468 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
469 %! assert (q * r, a, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
470 %! assert (qe * re, a, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
471 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
472 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
473 %! a = [0, 2, 1; 2, 1, 2]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
474 %! |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
475 %! [q, r, p] = qr (a); # FIXME: not giving right dimensions. |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
476 %! [qe, re, pe] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
477 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
478 %! assert (q * r, a * p, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
479 %! assert (qe * re, a(:, pe), sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
480 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
481 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
482 %! a = [0, 2; 2, 1; 1, 2]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
483 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
484 %! [q, r] = qr (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
485 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
486 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
487 %! assert (q * r, a, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
488 %! assert (qe * re, a, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
489 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
490 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
491 %! a = [0, 2; 2, 1; 1, 2]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
492 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
493 %! [q, r, p] = qr (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
494 %! [qe, re, pe] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
495 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
496 %! assert (q * r, a * p, sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
497 %! assert (qe * re, a(:, pe), sqrt (eps)); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
498 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
499 %!error qr () |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
500 %!error qr ([1, 2; 3, 4], 0, 2) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
501 |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13971
diff
changeset
|
502 %!function retval = __testqr (q, r, a, p) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
503 %! tol = 100*eps (class (q)); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
504 %! retval = 0; |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
505 %! if (nargin == 3) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
506 %! n1 = norm (q*r - a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
507 %! n2 = norm (q'*q - eye (columns (q))); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
508 %! retval = (n1 < tol && n2 < tol); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
509 %! else |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
510 %! n1 = norm (q'*q - eye (columns (q))); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
511 %! retval = (n1 < tol); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
512 %! if (isvector (p)) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
513 %! n2 = norm (q*r - a(:,p)); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
514 %! retval = (retval && n2 < tol); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
515 %! else |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
516 %! n2 = norm (q*r - a*p); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
517 %! retval = (retval && n2 < tol); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
518 %! endif |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
519 %! endif |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13971
diff
changeset
|
520 %!endfunction |
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13971
diff
changeset
|
521 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
522 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
523 %! t = ones (24, 1); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
524 %! j = 1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
525 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
526 %! if (false) # eliminate big matrix tests |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
527 %! a = rand (5000, 20); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
528 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
529 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
530 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
531 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
532 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
533 %! a = a+1i*eps; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
534 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
535 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
536 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
537 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a', p); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
538 %! endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
539 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
540 %! a = [ ones(1,15); sqrt(eps)*eye(15) ]; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
541 %! [q,r] = qr (a); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
542 %! [q,r] = qr (a'); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
543 %! [q,r,p] = qr (a); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
544 %! [q,r,p] = qr (a'); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
545 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
546 %! a = a+1i*eps; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
547 %! [q,r] = qr (a); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
548 %! [q,r] = qr (a'); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
549 %! [q,r,p] = qr (a); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
550 %! [q,r,p] = qr (a'); t(j++) = __testqr (q, r, a', p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
551 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
552 %! a = [ ones(1,15); sqrt(eps)*eye(15) ]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
553 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
554 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
555 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
556 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
557 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
558 %! a = a+1i*eps; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
559 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
560 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
561 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
562 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
563 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
564 %! a = [ 611 196 -192 407 -8 -52 -49 29 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
565 %! 196 899 113 -192 -71 -43 -8 -44 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
566 %! -192 113 899 196 61 49 8 52 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
567 %! 407 -192 196 611 8 44 59 -23 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
568 %! -8 -71 61 8 411 -599 208 208 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
569 %! -52 -43 49 44 -599 411 208 208 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
570 %! -49 -8 8 59 208 208 99 -911 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
571 %! 29 -44 52 -23 208 208 -911 99 ]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
572 %! [q,r] = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
573 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
574 %! assert (all (t) && norm (q*r - a) < 5000*eps); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
575 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
576 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
577 %! a = single ([0, 2, 1; 2, 1, 2]); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
578 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
579 %! [q, r] = qr (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
580 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
581 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
582 %! assert (q * r, a, sqrt (eps ("single"))); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
583 %! assert (qe * re, a, sqrt (eps ("single"))); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
584 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
585 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
586 %! a = single ([0, 2, 1; 2, 1, 2]); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
587 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
588 %! [q, r, p] = qr (a); # FIXME: not giving right dimensions. |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
589 %! [qe, re, pe] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
590 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
591 %! assert (q * r, a * p, sqrt (eps ("single"))); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
592 %! assert (qe * re, a(:, pe), sqrt (eps ("single"))); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
593 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
594 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
595 %! a = single ([0, 2; 2, 1; 1, 2]); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
596 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
597 %! [q, r] = qr (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
598 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
599 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
600 %! assert (q * r, a, sqrt (eps ("single"))); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
601 %! assert (qe * re, a, sqrt (eps ("single"))); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
602 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
603 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
604 %! a = single ([0, 2; 2, 1; 1, 2]); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
605 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
606 %! [q, r, p] = qr (a); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
607 %! [qe, re, pe] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
608 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
609 %! assert (q * r, a * p, sqrt (eps ("single"))); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
610 %! assert (qe * re, a(:, pe), sqrt (eps ("single"))); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
611 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
612 %!error qr () |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
613 %!error qr ([1, 2; 3, 4], 0, 2) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
614 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
615 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
616 %! t = ones (24, 1); |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
617 %! j = 1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
618 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
619 %! if (false) # eliminate big matrix tests |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
620 %! a = rand (5000,20); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
621 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
622 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
623 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
624 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
625 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
626 %! a = a+1i*eps ("single"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
627 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
628 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
629 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
630 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a', p); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
631 %! endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
632 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
633 %! a = [ ones(1,15); sqrt(eps("single"))*eye(15) ]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
634 %! [q,r] = qr (a); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
635 %! [q,r] = qr (a'); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
636 %! [q,r,p] = qr (a); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
637 %! [q,r,p] = qr (a'); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
638 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
639 %! a = a+1i*eps ("single"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
640 %! [q,r] = qr (a); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
641 %! [q,r] = qr (a'); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
642 %! [q,r,p] = qr (a); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
643 %! [q,r,p] = qr (a'); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
644 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
645 %! a = [ ones(1,15); sqrt(eps("single"))*eye(15) ]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
646 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
647 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
648 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
649 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a', p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
650 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
651 %! a = a+1i*eps ("single"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
652 %! [q,r] = qr (a, 0); t(j++) = __testqr (q, r, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
653 %! [q,r] = qr (a',0); t(j++) = __testqr (q, r, a'); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
654 %! [q,r,p] = qr (a, 0); t(j++) = __testqr (q, r, a, p); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
655 %! [q,r,p] = qr (a',0); t(j++) = __testqr (q, r, a',p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
656 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
657 %! a = [ 611 196 -192 407 -8 -52 -49 29 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
658 %! 196 899 113 -192 -71 -43 -8 -44 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
659 %! -192 113 899 196 61 49 8 52 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
660 %! 407 -192 196 611 8 44 59 -23 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
661 %! -8 -71 61 8 411 -599 208 208 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
662 %! -52 -43 49 44 -599 411 208 208 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
663 %! -49 -8 8 59 208 208 99 -911 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
664 %! 29 -44 52 -23 208 208 -911 99 ]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
665 %! [q,r] = qr (a); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
666 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
667 %! assert (all (t) && norm (q*r-a) < 5000*eps ("single")); |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
668 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
669 ## The deactivated tests below can't be tested till rectangular back-subs is |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
670 ## implemented for sparse matrices. |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
671 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
672 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
673 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
674 %! a = sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
675 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
676 %! assert (r'*r, a'*a, 1e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
677 |
12329
5f203b5bbf98
Use testif to only run some sparse tests when necessary libraries are installed.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
678 %!testif HAVE_COLAMD |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
679 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
680 %! a = sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
681 %! q = symamd (a); |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
682 %! a = a(q,q); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
683 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
684 %! assert (r'*r, a'*a, 1e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
685 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
686 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
687 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
688 %! a = sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
689 %! [c,r] = qr (a, ones (n,1)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
690 %! assert (r\c, full (a)\ones (n,1), 10e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
691 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
692 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
693 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
694 %! a = sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
695 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
696 %! [c,r] = qr (a, b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
697 %! assert (r\c, full (a)\b, 10e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
698 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
699 %% Test under-determined systems!! |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
700 %!#testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
701 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
702 %! a = sprandn (n,n+1,d) + speye (n,n+1); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
703 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
704 %! [c,r] = qr (a, b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
705 %! assert (r\c, full (a)\b, 10e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
706 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
707 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
708 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
709 %! a = 1i*sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
710 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
711 %! assert (r'*r,a'*a,1e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
712 |
12329
5f203b5bbf98
Use testif to only run some sparse tests when necessary libraries are installed.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
713 %!testif HAVE_COLAMD |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
714 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
715 %! a = 1i*sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
716 %! q = symamd (a); |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
717 %! a = a(q,q); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
718 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
719 %! assert (r'*r, a'*a, 1e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
720 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
721 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
722 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
723 %! a = 1i*sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
724 %! [c,r] = qr (a, ones (n,1)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
725 %! assert (r\c, full (a)\ones (n,1), 10e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
726 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
727 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
728 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
729 %! a = 1i*sprandn (n,n,d) + speye (n,n); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
730 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
731 %! [c,r] = qr (a, b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
732 %! assert (r\c, full (a)\b, 10e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
733 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
734 %% Test under-determined systems!! |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
735 %!#testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
736 %! n = 20; d = 0.2; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
737 %! a = 1i*sprandn (n,n+1,d) + speye (n,n+1); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
738 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
739 %! [c,r] = qr (a, b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
740 %! assert (r\c, full (a)\b, 10e-10) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
741 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
742 %!error qr (sprandn (10,10,0.2), ones (10,1)) |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
743 */ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
744 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
745 static |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
746 bool check_qr_dims (const octave_value& q, const octave_value& r, |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
747 bool allow_ecf = false) |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
748 { |
18099
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
749 octave_idx_type m = q.rows (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
750 octave_idx_type k = r.rows (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
751 octave_idx_type n = r.columns (); |
8798 | 752 return ((q.ndims () == 2 && r.ndims () == 2 && k == q.columns ()) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
753 && (m == k || (allow_ecf && k == n && k < m))); |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
754 } |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
755 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
756 static |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
757 bool check_index (const octave_value& i, bool vector_allowed = false) |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
758 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
759 return ((i.is_real_type () || i.is_integer_type ()) |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
760 && (i.is_scalar_type () || vector_allowed)); |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
761 } |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
762 |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
763 DEFUN_DLD (qrupdate, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
764 "-*- texinfo -*-\n\ |
7650 | 765 @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrupdate (@var{Q}, @var{R}, @var{u}, @var{v})\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
766 Given a QR@tie{}factorization of a real or complex matrix\n\ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
767 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
768 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
769 @w{@var{A} + @var{u}*@var{v}'}, where @var{u} and @var{v} are column vectors\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
770 (rank-1 update) or matrices with equal number of columns\n\ |
10840 | 771 (rank-k update). Notice that the latter case is done as a sequence of rank-1\n\ |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
772 updates; thus, for k large enough, it will be both faster and more accurate\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
773 to recompute the factorization from scratch.\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
774 \n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
775 The QR@tie{}factorization supplied may be either full (Q is square) or\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
776 economized (R is square).\n\ |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
777 \n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
778 @seealso{qr, qrinsert, qrdelete, qrshift}\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
779 @end deftypefn") |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
780 { |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
781 octave_idx_type nargin = args.length (); |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
782 octave_value_list retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
783 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
784 if (nargin != 4) |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
785 { |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
786 print_usage (); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
787 return retval; |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
788 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
789 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
790 octave_value argq = args(0); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
791 octave_value argr = args(1); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
792 octave_value argu = args(2); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
793 octave_value argv = args(3); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
794 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
795 if (argq.is_numeric_type () && argr.is_numeric_type () |
8469
830a03b5f165
qr.cc: require args to be numeric, not necessarily matrix objects
John W. Eaton <jwe@octave.org>
parents:
8367
diff
changeset
|
796 && argu.is_numeric_type () && argv.is_numeric_type ()) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
797 { |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
798 if (check_qr_dims (argq, argr, true)) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
799 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
800 if (argq.is_real_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
801 && argr.is_real_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
802 && argu.is_real_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
803 && argv.is_real_type ()) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
804 { |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
805 // all real case |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
806 if (argq.is_single_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
807 || argr.is_single_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
808 || argu.is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
809 || argv.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
810 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
811 FloatMatrix Q = argq.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
812 FloatMatrix R = argr.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
813 FloatMatrix u = argu.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
814 FloatMatrix v = argv.float_matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
815 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
816 FloatQR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
817 fact.update (u, v); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
818 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
819 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
820 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
821 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
822 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
823 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
824 Matrix Q = argq.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
825 Matrix R = argr.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
826 Matrix u = argu.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
827 Matrix v = argv.matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
828 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
829 QR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
830 fact.update (u, v); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
831 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
832 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
833 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
834 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
835 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
836 else |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
837 { |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
838 // complex case |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
839 if (argq.is_single_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
840 || argr.is_single_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
841 || argu.is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
842 || argv.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
843 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
844 FloatComplexMatrix Q = argq.float_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
845 FloatComplexMatrix R = argr.float_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
846 FloatComplexMatrix u = argu.float_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
847 FloatComplexMatrix v = argv.float_complex_matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
848 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
849 FloatComplexQR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
850 fact.update (u, v); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
851 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
852 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
853 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
854 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
855 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
856 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
857 ComplexMatrix Q = argq.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
858 ComplexMatrix R = argr.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
859 ComplexMatrix u = argu.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
860 ComplexMatrix v = argv.complex_matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
861 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
862 ComplexQR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
863 fact.update (u, v); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
864 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
865 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
866 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
867 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
868 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
869 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
870 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
871 error ("qrupdate: Q and R dimensions don't match"); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
872 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
873 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
874 error ("qrupdate: Q, R, U, and V must be numeric"); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
875 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
876 return retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
877 } |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
878 |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
879 /* |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
880 %!shared A, u, v, Ac, uc, vc |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
881 %! A = [0.091364 0.613038 0.999083; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
882 %! 0.594638 0.425302 0.603537; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
883 %! 0.383594 0.291238 0.085574; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
884 %! 0.265712 0.268003 0.238409; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
885 %! 0.669966 0.743851 0.445057 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
886 %! |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
887 %! u = [0.85082; |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
888 %! 0.76426; |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
889 %! 0.42883; |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
890 %! 0.53010; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
891 %! 0.80683 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
892 %! |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
893 %! v = [0.98810; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
894 %! 0.24295; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
895 %! 0.43167 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
896 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
897 %! Ac = [0.620405 + 0.956953i 0.480013 + 0.048806i 0.402627 + 0.338171i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
898 %! 0.589077 + 0.658457i 0.013205 + 0.279323i 0.229284 + 0.721929i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
899 %! 0.092758 + 0.345687i 0.928679 + 0.241052i 0.764536 + 0.832406i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
900 %! 0.912098 + 0.721024i 0.049018 + 0.269452i 0.730029 + 0.796517i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
901 %! 0.112849 + 0.603871i 0.486352 + 0.142337i 0.355646 + 0.151496i ]; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
902 %! |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
903 %! uc = [0.20351 + 0.05401i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
904 %! 0.13141 + 0.43708i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
905 %! 0.29808 + 0.08789i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
906 %! 0.69821 + 0.38844i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
907 %! 0.74871 + 0.25821i ]; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
908 %! |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
909 %! vc = [0.85839 + 0.29468i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
910 %! 0.20820 + 0.93090i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
911 %! 0.86184 + 0.34689i ]; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
912 %! |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
913 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
914 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
915 %! [Q,R] = qr (A); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
916 %! [Q,R] = qrupdate (Q, R, u, v); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
917 %! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
918 %! assert (norm (vec (triu (R)-R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
919 %! assert (norm (vec (Q*R - A - u*v'), Inf) < norm (A)*1e1*eps); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
920 %! |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
921 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
922 %! [Q,R] = qr (Ac); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
923 %! [Q,R] = qrupdate (Q, R, uc, vc); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
924 %! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
925 %! assert (norm (vec (triu (R)-R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
926 %! assert (norm (vec (Q*R - Ac - uc*vc'), Inf) < norm (Ac)*1e1*eps); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
927 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
928 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
929 %! [Q,R] = qr (single (A)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
930 %! [Q,R] = qrupdate (Q, R, single (u), single (v)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
931 %! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
932 %! assert (norm (vec (triu (R)-R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
933 %! assert (norm (vec (Q*R - single (A) - single (u)*single (v)'), Inf) < norm (single (A))*1e1*eps ("single")); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
934 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
935 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
936 %! [Q,R] = qr (single (Ac)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
937 %! [Q,R] = qrupdate (Q, R, single (uc), single (vc)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
938 %! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
939 %! assert (norm (vec (triu (R)-R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
940 %! assert (norm (vec (Q*R - single (Ac) - single (uc)*single (vc)'), Inf) < norm (single (Ac))*1e1*eps ("single")); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
941 */ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
942 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
943 DEFUN_DLD (qrinsert, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
944 "-*- texinfo -*-\n\ |
7650 | 945 @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrinsert (@var{Q}, @var{R}, @var{j}, @var{x}, @var{orient})\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
946 Given a QR@tie{}factorization of a real or complex matrix\n\ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
947 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
948 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of\n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
949 @w{[A(:,1:j-1) x A(:,j:n)]}, where @var{u} is a column vector to be inserted\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
950 into @var{A} (if @var{orient} is @qcode{\"col\"}), or the\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
951 QR@tie{}factorization of @w{[A(1:j-1,:);x;A(:,j:n)]}, where @var{x} is a row\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
952 vector to be inserted into @var{A} (if @var{orient} is @qcode{\"row\"}).\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
953 \n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
954 The default value of @var{orient} is @qcode{\"col\"}. If @var{orient} is\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
955 @qcode{\"col\"}, @var{u} may be a matrix and @var{j} an index vector\n\ |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
956 resulting in the QR@tie{}factorization of a matrix @var{B} such that\n\ |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
957 @w{B(:,@var{j})} gives @var{u} and @w{B(:,@var{j}) = []} gives @var{A}.\n\ |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
958 Notice that the latter case is done as a sequence of k insertions;\n\ |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
959 thus, for k large enough, it will be both faster and more accurate to\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
960 recompute the factorization from scratch.\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
961 \n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
962 If @var{orient} is @qcode{\"col\"}, the QR@tie{}factorization supplied may\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
963 be either full (Q is square) or economized (R is square).\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
964 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
965 If @var{orient} is @qcode{\"row\"}, full factorization is needed.\n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
966 @seealso{qr, qrupdate, qrdelete, qrshift}\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
967 @end deftypefn") |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
968 { |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
969 octave_idx_type nargin = args.length (); |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
970 octave_value_list retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
971 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
972 if (nargin < 4 || nargin > 5) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
973 { |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
974 print_usage (); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
975 return retval; |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
976 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
977 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
978 octave_value argq = args(0); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
979 octave_value argr = args(1); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
980 octave_value argj = args(2); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
981 octave_value argx = args(3); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
982 |
8469
830a03b5f165
qr.cc: require args to be numeric, not necessarily matrix objects
John W. Eaton <jwe@octave.org>
parents:
8367
diff
changeset
|
983 if (argq.is_numeric_type () && argr.is_numeric_type () |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
984 && argx.is_numeric_type () |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
985 && (nargin < 5 || args(4).is_string ())) |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
986 { |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
987 std::string orient = (nargin < 5) ? "col" : args(4).string_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
988 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
989 bool col = orient == "col"; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
990 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
991 if (col || orient == "row") |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
992 if (check_qr_dims (argq, argr, col) |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
993 && (col || argx.rows () == 1)) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
994 { |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
995 if (check_index (argj, col)) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
996 { |
8811 | 997 MArray<octave_idx_type> j |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
998 = argj.octave_idx_type_vector_value (); |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
999 |
10258 | 1000 octave_idx_type one = 1; |
1001 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1002 if (argq.is_real_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1003 && argr.is_real_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1004 && argx.is_real_type ()) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1005 { |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1006 // real case |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1007 if (argq.is_single_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1008 || argr.is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1009 || argx.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1010 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1011 FloatMatrix Q = argq.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1012 FloatMatrix R = argr.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1013 FloatMatrix x = argx.float_matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1014 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1015 FloatQR fact (Q, R); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1016 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1017 if (col) |
10258 | 1018 fact.insert_col (x, j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1019 else |
10258 | 1020 fact.insert_row (x.row (0), j(0)-one); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1021 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1022 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1023 retval(0) = fact.Q (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1024 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1025 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1026 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1027 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1028 Matrix Q = argq.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1029 Matrix R = argr.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1030 Matrix x = argx.matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1031 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1032 QR fact (Q, R); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1033 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1034 if (col) |
10258 | 1035 fact.insert_col (x, j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1036 else |
10258 | 1037 fact.insert_row (x.row (0), j(0)-one); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1038 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1039 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1040 retval(0) = fact.Q (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1041 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1042 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1043 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1044 else |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1045 { |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1046 // complex case |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1047 if (argq.is_single_type () |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1048 || argr.is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1049 || argx.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1050 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1051 FloatComplexMatrix Q = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1052 argq.float_complex_matrix_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1053 FloatComplexMatrix R = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1054 argr.float_complex_matrix_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1055 FloatComplexMatrix x = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1056 argx.float_complex_matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1057 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1058 FloatComplexQR fact (Q, R); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1059 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1060 if (col) |
10258 | 1061 fact.insert_col (x, j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1062 else |
10258 | 1063 fact.insert_row (x.row (0), j(0)-one); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1064 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1065 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1066 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1067 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1068 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1069 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1070 ComplexMatrix Q = argq.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1071 ComplexMatrix R = argr.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1072 ComplexMatrix x = argx.complex_matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1073 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1074 ComplexQR fact (Q, R); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1075 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1076 if (col) |
10258 | 1077 fact.insert_col (x, j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1078 else |
10258 | 1079 fact.insert_row (x.row (0), j(0)-one); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1080 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1081 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1082 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1083 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1084 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1085 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1086 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1087 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
1088 error ("qrinsert: invalid index J"); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1089 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1090 else |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1091 error ("qrinsert: dimension mismatch"); |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1092 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1093 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
1094 error ("qrinsert: ORIENT must be \"col\" or \"row\""); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1095 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1096 else |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1097 print_usage (); |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1098 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1099 return retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1100 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1101 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1102 /* |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1103 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1104 %! [Q,R] = qr (A); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1105 %! [Q,R] = qrinsert (Q, R, 3, u); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1106 %! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1107 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1108 %! assert (norm (vec (Q*R - [A(:,1:2) u A(:,3)]), Inf) < norm (A)*1e1*eps); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1109 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1110 %! [Q,R] = qr (Ac); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1111 %! [Q,R] = qrinsert (Q, R, 3, uc); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1112 %! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1113 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1114 %! assert (norm (vec (Q*R - [Ac(:,1:2) uc Ac(:,3)]), Inf) < norm (Ac)*1e1*eps); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1115 %!test |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1116 %! x = [0.85082 0.76426 0.42883 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1117 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1118 %! [Q,R] = qr (A); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1119 %! [Q,R] = qrinsert (Q, R, 3, x, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1120 %! assert (norm (vec (Q'*Q - eye (6)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1121 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1122 %! assert (norm (vec (Q*R - [A(1:2,:);x;A(3:5,:)]), Inf) < norm (A)*1e1*eps); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1123 %!test |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1124 %! x = [0.20351 + 0.05401i 0.13141 + 0.43708i 0.29808 + 0.08789i ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1125 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1126 %! [Q,R] = qr (Ac); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1127 %! [Q,R] = qrinsert (Q, R, 3, x, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1128 %! assert (norm (vec (Q'*Q - eye (6)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1129 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1130 %! assert (norm (vec (Q*R - [Ac(1:2,:);x;Ac(3:5,:)]), Inf) < norm (Ac)*1e1*eps); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1131 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1132 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1133 %! [Q,R] = qr (single (A)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1134 %! [Q,R] = qrinsert (Q, R, 3, single (u)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1135 %! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1136 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1137 %! assert (norm (vec (Q*R - single ([A(:,1:2) u A(:,3)])), Inf) < norm (single (A))*1e1*eps ("single")); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1138 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1139 %! [Q,R] = qr (single (Ac)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1140 %! [Q,R] = qrinsert (Q, R, 3, single (uc)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1141 %! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1142 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1143 %! assert (norm (vec (Q*R - single ([Ac(:,1:2) uc Ac(:,3)])), Inf) < norm (single (Ac))*1e1*eps ("single")); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1144 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1145 %! x = single ([0.85082 0.76426 0.42883 ]); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1146 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1147 %! [Q,R] = qr (single (A)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1148 %! [Q,R] = qrinsert (Q, R, 3, x, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1149 %! assert (norm (vec (Q'*Q - eye (6,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1150 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1151 %! assert (norm (vec (Q*R - single ([A(1:2,:);x;A(3:5,:)])), Inf) < norm (single (A))*1e1*eps ("single")); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1152 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1153 %! x = single ([0.20351 + 0.05401i 0.13141 + 0.43708i 0.29808 + 0.08789i ]); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1154 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1155 %! [Q,R] = qr (single (Ac)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1156 %! [Q,R] = qrinsert (Q, R, 3, x, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1157 %! assert (norm (vec (Q'*Q - eye (6,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1158 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1159 %! assert (norm (vec (Q*R - single ([Ac(1:2,:);x;Ac(3:5,:)])), Inf) < norm (single (Ac))*1e1*eps ("single")); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1160 */ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1161 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1162 DEFUN_DLD (qrdelete, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1163 "-*- texinfo -*-\n\ |
7650 | 1164 @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrdelete (@var{Q}, @var{R}, @var{j}, @var{orient})\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1165 Given a QR@tie{}factorization of a real or complex matrix\n\ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1166 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1167 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
1168 @w{[A(:,1:j-1) A(:,j+1:n)]}, i.e., @var{A} with one column deleted\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
1169 (if @var{orient} is @qcode{\"col\"}), or the QR@tie{}factorization of\n\ |
14219
addec4a8a787
Fix typo in qrdelete docstring.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1170 @w{[A(1:j-1,:);A(j+1:n,:)]}, i.e., @var{A} with one row deleted (if\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
1171 @var{orient} is @qcode{\"row\"}).\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1172 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
1173 The default value of @var{orient} is @qcode{\"col\"}.\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1174 \n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
1175 If @var{orient} is @qcode{\"col\"}, @var{j} may be an index vector\n\ |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1176 resulting in the QR@tie{}factorization of a matrix @var{B} such that\n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
1177 @w{A(:,@var{j}) = []} gives @var{B}. Notice that the latter case is done as\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
1178 a sequence of k deletions; thus, for k large enough, it will be both faster\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
1179 and more accurate to recompute the factorization from scratch.\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1180 \n\ |
20373
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
1181 If @var{orient} is @qcode{\"col\"}, the QR@tie{}factorization supplied may\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
1182 be either full (Q is square) or economized (R is square).\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1183 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
1184 If @var{orient} is @qcode{\"row\"}, full factorization is needed.\n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
1185 @seealso{qr, qrupdate, qrinsert, qrshift}\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1186 @end deftypefn") |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1187 { |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1188 octave_idx_type nargin = args.length (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1189 octave_value_list retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1190 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1191 if (nargin < 3 || nargin > 4) |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1192 { |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1193 print_usage (); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1194 return retval; |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1195 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1196 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1197 octave_value argq = args(0); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1198 octave_value argr = args(1); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1199 octave_value argj = args(2); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1200 |
8469
830a03b5f165
qr.cc: require args to be numeric, not necessarily matrix objects
John W. Eaton <jwe@octave.org>
parents:
8367
diff
changeset
|
1201 if (argq.is_numeric_type () && argr.is_numeric_type () |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1202 && (nargin < 4 || args(3).is_string ())) |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1203 { |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1204 std::string orient = (nargin < 4) ? "col" : args(3).string_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1205 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1206 bool col = orient == "col"; |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1207 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1208 if (col || orient == "row") |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1209 if (check_qr_dims (argq, argr, col)) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1210 { |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1211 if (check_index (argj, col)) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1212 { |
8811 | 1213 MArray<octave_idx_type> j |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1214 = argj.octave_idx_type_vector_value (); |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1215 |
10258 | 1216 octave_idx_type one = 1; |
1217 | |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1218 if (argq.is_real_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1219 && argr.is_real_type ()) |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1220 { |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1221 // real case |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1222 if (argq.is_single_type () |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1223 || argr.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1224 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1225 FloatMatrix Q = argq.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1226 FloatMatrix R = argr.float_matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1227 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1228 FloatQR fact (Q, R); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1229 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1230 if (col) |
10258 | 1231 fact.delete_col (j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1232 else |
10258 | 1233 fact.delete_row (j(0)-one); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1234 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1235 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1236 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1237 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1238 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1239 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1240 Matrix Q = argq.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1241 Matrix R = argr.matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1242 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1243 QR fact (Q, R); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1244 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1245 if (col) |
10258 | 1246 fact.delete_col (j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1247 else |
10258 | 1248 fact.delete_row (j(0)-one); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1249 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1250 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1251 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1252 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1253 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1254 else |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1255 { |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1256 // complex case |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1257 if (argq.is_single_type () |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1258 || argr.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1259 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1260 FloatComplexMatrix Q = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1261 argq.float_complex_matrix_value (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1262 FloatComplexMatrix R = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1263 argr.float_complex_matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1264 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1265 FloatComplexQR fact (Q, R); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1266 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1267 if (col) |
10258 | 1268 fact.delete_col (j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1269 else |
10258 | 1270 fact.delete_row (j(0)-one); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1271 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1272 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1273 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1274 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1275 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1276 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1277 ComplexMatrix Q = argq.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1278 ComplexMatrix R = argr.complex_matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1279 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1280 ComplexQR fact (Q, R); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1281 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1282 if (col) |
10258 | 1283 fact.delete_col (j-one); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1284 else |
10258 | 1285 fact.delete_row (j(0)-one); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1286 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1287 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1288 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1289 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1290 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1291 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1292 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
1293 error ("qrdelete: invalid index J"); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1294 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1295 else |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1296 error ("qrdelete: dimension mismatch"); |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1297 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1298 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
1299 error ("qrdelete: ORIENT must be \"col\" or \"row\""); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1300 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1301 else |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1302 print_usage (); |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1303 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1304 return retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1305 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1306 |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1307 /* |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1308 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1309 %! AA = [0.091364 0.613038 0.027504 0.999083; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1310 %! 0.594638 0.425302 0.562834 0.603537; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1311 %! 0.383594 0.291238 0.742073 0.085574; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1312 %! 0.265712 0.268003 0.783553 0.238409; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1313 %! 0.669966 0.743851 0.457255 0.445057 ]; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1314 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1315 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1316 %! [Q,R] = qrdelete (Q, R, 3); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1317 %! assert (norm (vec (Q'*Q - eye (5)), Inf) < 16*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1318 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1319 %! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1320 %! |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1321 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1322 %! AA = [0.364554 + 0.993117i 0.669818 + 0.510234i 0.426568 + 0.041337i 0.847051 + 0.233291i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1323 %! 0.049600 + 0.242783i 0.448946 + 0.484022i 0.141155 + 0.074420i 0.446746 + 0.392706i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1324 %! 0.581922 + 0.657416i 0.581460 + 0.030016i 0.219909 + 0.447288i 0.201144 + 0.069132i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1325 %! 0.694986 + 0.000571i 0.682327 + 0.841712i 0.807537 + 0.166086i 0.192767 + 0.358098i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1326 %! 0.945002 + 0.066788i 0.350492 + 0.642638i 0.579629 + 0.048102i 0.600170 + 0.636938i ] * I; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1327 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1328 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1329 %! [Q,R] = qrdelete (Q, R, 3); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1330 %! assert (norm (vec (Q'*Q - eye (5)), Inf) < 16*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1331 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1332 %! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1333 %! |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1334 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1335 %! AA = [0.091364 0.613038 0.027504 0.999083; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1336 %! 0.594638 0.425302 0.562834 0.603537; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1337 %! 0.383594 0.291238 0.742073 0.085574; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1338 %! 0.265712 0.268003 0.783553 0.238409; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1339 %! 0.669966 0.743851 0.457255 0.445057 ]; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1340 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1341 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1342 %! [Q,R] = qrdelete (Q, R, 3, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1343 %! assert (norm (vec (Q'*Q - eye (4)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1344 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1345 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1346 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1347 %!test |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1348 %! AA = [0.364554 + 0.993117i 0.669818 + 0.510234i 0.426568 + 0.041337i 0.847051 + 0.233291i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1349 %! 0.049600 + 0.242783i 0.448946 + 0.484022i 0.141155 + 0.074420i 0.446746 + 0.392706i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1350 %! 0.581922 + 0.657416i 0.581460 + 0.030016i 0.219909 + 0.447288i 0.201144 + 0.069132i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1351 %! 0.694986 + 0.000571i 0.682327 + 0.841712i 0.807537 + 0.166086i 0.192767 + 0.358098i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1352 %! 0.945002 + 0.066788i 0.350492 + 0.642638i 0.579629 + 0.048102i 0.600170 + 0.636938i ] * I; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1353 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1354 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1355 %! [Q,R] = qrdelete (Q, R, 3, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1356 %! assert (norm (vec (Q'*Q - eye (4)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1357 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1358 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1359 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1360 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1361 %! AA = single ([0.091364 0.613038 0.027504 0.999083; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1362 %! 0.594638 0.425302 0.562834 0.603537; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1363 %! 0.383594 0.291238 0.742073 0.085574; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1364 %! 0.265712 0.268003 0.783553 0.238409; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1365 %! 0.669966 0.743851 0.457255 0.445057 ]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1366 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1367 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1368 %! [Q,R] = qrdelete (Q, R, 3); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1369 %! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1370 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1371 %! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps ("single")); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1372 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1373 %!test |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1374 %! AA = single ([0.364554 + 0.993117i 0.669818 + 0.510234i 0.426568 + 0.041337i 0.847051 + 0.233291i; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1375 %! 0.049600 + 0.242783i 0.448946 + 0.484022i 0.141155 + 0.074420i 0.446746 + 0.392706i; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1376 %! 0.581922 + 0.657416i 0.581460 + 0.030016i 0.219909 + 0.447288i 0.201144 + 0.069132i; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1377 %! 0.694986 + 0.000571i 0.682327 + 0.841712i 0.807537 + 0.166086i 0.192767 + 0.358098i; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1378 %! 0.945002 + 0.066788i 0.350492 + 0.642638i 0.579629 + 0.048102i 0.600170 + 0.636938i ]) * I; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1379 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1380 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1381 %! [Q,R] = qrdelete (Q, R, 3); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1382 %! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1383 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1384 %! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps ("single")); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1385 %! |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1386 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1387 %! AA = single ([0.091364 0.613038 0.027504 0.999083; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1388 %! 0.594638 0.425302 0.562834 0.603537; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1389 %! 0.383594 0.291238 0.742073 0.085574; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1390 %! 0.265712 0.268003 0.783553 0.238409; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1391 %! 0.669966 0.743851 0.457255 0.445057 ]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1392 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1393 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1394 %! [Q,R] = qrdelete (Q, R, 3, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1395 %! assert (norm (vec (Q'*Q - eye (4,"single")), Inf) < 1.5e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1396 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1397 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1398 %!testif HAVE_QRUPDATE |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1399 %! ## Same test as above but with more precicision |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1400 %! AA = single ([0.091364 0.613038 0.027504 0.999083; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1401 %! 0.594638 0.425302 0.562834 0.603537; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1402 %! 0.383594 0.291238 0.742073 0.085574; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1403 %! 0.265712 0.268003 0.783553 0.238409; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1404 %! 0.669966 0.743851 0.457255 0.445057 ]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1405 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1406 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1407 %! [Q,R] = qrdelete (Q, R, 3, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1408 %! assert (norm (vec (Q'*Q - eye (4,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1409 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1410 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1411 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1412 %!test |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1413 %! AA = single ([0.364554 + 0.993117i 0.669818 + 0.510234i 0.426568 + 0.041337i 0.847051 + 0.233291i; |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1414 %! 0.049600 + 0.242783i 0.448946 + 0.484022i 0.141155 + 0.074420i 0.446746 + 0.392706i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1415 %! 0.581922 + 0.657416i 0.581460 + 0.030016i 0.219909 + 0.447288i 0.201144 + 0.069132i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1416 %! 0.694986 + 0.000571i 0.682327 + 0.841712i 0.807537 + 0.166086i 0.192767 + 0.358098i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1417 %! 0.945002 + 0.066788i 0.350492 + 0.642638i 0.579629 + 0.048102i 0.600170 + 0.636938i ]) * I; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1418 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1419 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1420 %! [Q,R] = qrdelete (Q, R, 3, "row"); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1421 %! assert (norm (vec (Q'*Q - eye (4,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1422 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1423 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps ("single")); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1424 */ |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
1425 |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1426 DEFUN_DLD (qrshift, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1427 "-*- texinfo -*-\n\ |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1428 @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrshift (@var{Q}, @var{R}, @var{i}, @var{j})\n\ |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1429 Given a QR@tie{}factorization of a real or complex matrix\n\ |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1430 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1431 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization\n\ |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1432 of @w{@var{A}(:,p)}, where @w{p} is the permutation @*\n\ |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1433 @code{p = [1:i-1, shift(i:j, 1), j+1:n]} if @w{@var{i} < @var{j}} @*\n\ |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1434 or @*\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
1435 @code{p = [1:j-1, shift(j:i,-1), i+1:n]} if @w{@var{j} < @var{i}}. @*\n\ |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1436 \n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
1437 @seealso{qr, qrupdate, qrinsert, qrdelete}\n\ |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1438 @end deftypefn") |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1439 { |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1440 octave_idx_type nargin = args.length (); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1441 octave_value_list retval; |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1442 |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1443 if (nargin != 4) |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1444 { |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1445 print_usage (); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1446 return retval; |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1447 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1448 |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1449 octave_value argq = args(0); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1450 octave_value argr = args(1); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1451 octave_value argi = args(2); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1452 octave_value argj = args(3); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1453 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1454 if (argq.is_numeric_type () && argr.is_numeric_type ()) |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1455 { |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1456 if (check_qr_dims (argq, argr, true)) |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1457 { |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1458 if (check_index (argi) && check_index (argj)) |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1459 { |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1460 octave_idx_type i = argi.int_value (); |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1461 octave_idx_type j = argj.int_value (); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1462 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1463 if (argq.is_real_type () |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1464 && argr.is_real_type ()) |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1465 { |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1466 // all real case |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1467 if (argq.is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1468 && argr.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1469 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1470 FloatMatrix Q = argq.float_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1471 FloatMatrix R = argr.float_matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1472 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1473 FloatQR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1474 fact.shift_cols (i-1, j-1); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1475 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1476 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1477 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1478 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1479 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1480 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1481 Matrix Q = argq.matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1482 Matrix R = argr.matrix_value (); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1483 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1484 QR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1485 fact.shift_cols (i-1, j-1); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1486 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1487 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1488 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1489 } |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1490 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1491 else |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1492 { |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1493 // complex case |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1494 if (argq.is_single_type () |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1495 && argr.is_single_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1496 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1497 FloatComplexMatrix Q = argq.float_complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1498 FloatComplexMatrix R = argr.float_complex_matrix_value (); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1499 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1500 FloatComplexQR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1501 fact.shift_cols (i-1, j-1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1502 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1503 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1504 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1505 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1506 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1507 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1508 ComplexMatrix Q = argq.complex_matrix_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1509 ComplexMatrix R = argr.complex_matrix_value (); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1510 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1511 ComplexQR fact (Q, R); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1512 fact.shift_cols (i-1, j-1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1513 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1514 retval(1) = get_qr_r (fact); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1515 retval(0) = fact.Q (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1516 } |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1517 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1518 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1519 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
1520 error ("qrshift: invalid index I or J"); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1521 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1522 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
1523 error ("qrshift: dimensions mismatch"); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1524 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1525 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
1526 error ("qrshift: Q and R must be numeric"); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1527 |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1528 return retval; |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1529 } |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1530 |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1531 /* |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1532 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1533 %! AA = A.'; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1534 %! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5]; |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1535 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1536 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1537 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1538 %! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1539 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1540 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1541 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1542 %! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5]; |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1543 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1544 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1545 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1546 %! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1547 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1548 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1549 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1550 %!test |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1551 %! AA = Ac.'; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1552 %! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5]; |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1553 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1554 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1555 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1556 %! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1557 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1558 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1559 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1560 %! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5]; |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1561 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1562 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1563 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1564 %! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1565 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1566 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1567 |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1568 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1569 %! AA = single (A).'; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1570 %! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5]; |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1571 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1572 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1573 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1574 %! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1575 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1576 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single")); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1577 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1578 %! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5]; |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1579 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1580 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1581 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1582 %! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1583 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1584 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single")); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1585 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1586 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1587 %! AA = single (Ac).'; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1588 %! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5]; |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1589 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1590 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1591 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1592 %! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1593 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1594 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single")); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1595 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1596 %! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5]; |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1597 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1598 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1599 %! [Q,R] = qrshift (Q, R, i, j); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1600 %! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single")); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1601 %! assert (norm (vec (triu (R) - R), Inf) == 0); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1602 %! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single")); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1603 */ |