Mercurial > octave
annotate libinterp/dldfcn/qr.cc @ 21280:ebdf74c15722
better use of templates for qrp classes
* liboctave/numeric/qrp.h, liboctave/numeric/qrp.cc: New files for qrp
classes generated from CmplxQRP.cc, CmplxQRP.h, dbleQRP.cc, dbleQRP.h,
fCmplxQRP.cc, fCmplxQRP.h, floatQRP.cc, and floatQRP.h with classes
converted to templates.
* liboctave/numeric/module.mk: Update.
* qr.cc, mx-defs.h: Use new classes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 17 Feb 2016 02:54:00 -0500 |
parents | eb1524b07fe3 |
children | 40de9f8f23a6 |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18515
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 | |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21176
diff
changeset
|
26 # include <config.h> |
2928 | 27 #endif |
28 | |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
29 #include "qr.h" |
21280
ebdf74c15722
better use of templates for qrp classes
John W. Eaton <jwe@octave.org>
parents:
21279
diff
changeset
|
30 #include "qrp.h" |
21176
791dcb32b657
revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
31 #include "sparse-qr.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
|
32 |
2928 | 33 |
34 #include "defun-dld.h" | |
35 #include "error.h" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21041
diff
changeset
|
36 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
37 #include "ovl.h" |
2928 | 38 #include "utils.h" |
39 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
40 template <typename MT> |
8869
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
41 static octave_value |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
42 get_qr_r (const qr<MT>& fact) |
8869
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
43 { |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
44 MT R = fact.R (); |
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
45 if (R.is_square () && fact.regular ()) |
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
46 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
|
47 else |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9209
diff
changeset
|
48 return R; |
8869
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
49 } |
c3b743b1b1c6
preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
50 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
51 template <typename T> |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
52 static typename qr<T>::type |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
53 qr_type (int nargin, int nargout) |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
54 { |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
55 return ((nargout == 0 || nargout == 1) |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
56 ? qr<T>::raw |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
57 : (nargin == 2) ? qr<T>::economy : qr<T>::std); |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
58 } |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
59 |
3372 | 60 // [Q, R] = qr (X): form Q unitary and R upper triangular such |
61 // that Q * R = X | |
62 // | |
63 // [Q, R] = qr (X, 0): form the economy decomposition such that if X is | |
64 // m by n then only the first n columns of Q are | |
65 // computed. | |
66 // | |
67 // [Q, R, P] = qr (X): form QRP factorization of X where | |
68 // P is a permutation matrix such that | |
69 // A * P = Q * R | |
70 // | |
71 // [Q, R, P] = qr (X, 0): form the economy decomposition with | |
72 // permutation vector P such that Q * R = X (:, P) | |
73 // | |
74 // qr (X) alone returns the output of the LAPACK routine dgeqrf, such | |
75 // that R = triu (qr (X)) | |
76 | |
2928 | 77 DEFUN_DLD (qr, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
78 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
79 @deftypefn {} {[@var{Q}, @var{R}, @var{P}] =} qr (@var{A})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
80 @deftypefnx {} {[@var{Q}, @var{R}, @var{P}] =} qr (@var{A}, '0')\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
81 @deftypefnx {} {[@var{C}, @var{R}] =} qr (@var{A}, @var{B})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
82 @deftypefnx {} {[@var{C}, @var{R}] =} qr (@var{A}, @var{B}, '0')\n\ |
3372 | 83 @cindex QR factorization\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
84 Compute the QR@tie{}factorization of @var{A}, using standard @sc{lapack}\n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
85 subroutines.\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
86 \n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
87 For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},\n\ |
2928 | 88 \n\ |
3372 | 89 @example\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
90 [@var{Q}, @var{R}] = qr (@var{A})\n\ |
3372 | 91 @end example\n\ |
92 \n\ | |
93 @noindent\n\ | |
94 returns\n\ | |
95 \n\ | |
96 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
97 @group\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
98 @var{Q} =\n\ |
3372 | 99 \n\ |
100 -0.31623 -0.94868\n\ | |
101 -0.94868 0.31623\n\ | |
102 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
103 @var{R} =\n\ |
3372 | 104 \n\ |
105 -3.16228 -4.42719\n\ | |
106 0.00000 -0.63246\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
107 @end group\n\ |
3372 | 108 @end example\n\ |
109 \n\ | |
110 The @code{qr} factorization has applications in the solution of least\n\ | |
111 squares problems\n\ | |
112 @tex\n\ | |
113 $$\n\ | |
114 \\min_x \\left\\Vert A x - b \\right\\Vert_2\n\ | |
115 $$\n\ | |
116 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
117 @ifnottex\n\ |
2928 | 118 \n\ |
3372 | 119 @example\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14219
diff
changeset
|
120 min norm(A x - b)\n\ |
3372 | 121 @end example\n\ |
122 \n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
123 @end ifnottex\n\ |
3372 | 124 for overdetermined systems of equations (i.e.,\n\ |
125 @tex\n\ | |
126 $A$\n\ | |
127 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
128 @ifnottex\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
129 @var{A}\n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
130 @end ifnottex\n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
131 is a tall, thin matrix). The QR@tie{}factorization is\n\ |
3372 | 132 @tex\n\ |
133 $QR = A$ where $Q$ is an orthogonal matrix and $R$ is upper triangular.\n\ | |
134 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
8469
diff
changeset
|
135 @ifnottex\n\ |
18502
35100920494f
doc: Update docstring for qr (bug #41641).
Marko Seric <marko.seric@math.uzh.ch>
parents:
17787
diff
changeset
|
136 @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
|
137 @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
|
138 @end ifnottex\n\ |
2928 | 139 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
144 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
|
145 @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
|
146 QR@tie{}factorization such that the diagonal entries of @var{R} are\n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
147 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:
19697
diff
changeset
|
148 @code{a = [1, 2; 3, 4]},\n\ |
3372 | 149 \n\ |
150 @example\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
151 [@var{Q}, @var{R}, @var{P}] = qr (@var{A})\n\ |
3372 | 152 @end example\n\ |
153 \n\ | |
154 @noindent\n\ | |
155 returns\n\ | |
156 \n\ | |
157 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
158 @group\n\ |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
12329
diff
changeset
|
159 @var{Q} =\n\ |
2928 | 160 \n\ |
3372 | 161 -0.44721 -0.89443\n\ |
162 -0.89443 0.44721\n\ | |
163 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
164 @var{R} =\n\ |
3372 | 165 \n\ |
166 -4.47214 -3.13050\n\ | |
167 0.00000 0.44721\n\ | |
168 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
169 @var{P} =\n\ |
3372 | 170 \n\ |
171 0 1\n\ | |
172 1 0\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
173 @end group\n\ |
3372 | 174 @end example\n\ |
175 \n\ | |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
176 The permuted @code{qr} factorization\n\ |
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
177 @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:
19697
diff
changeset
|
178 construction of an orthogonal basis of @code{span (A)}.\n\ |
7491 | 179 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
180 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
|
181 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
|
182 is in general a full matrix, this function returns the @var{Q}-less\n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
183 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:
19697
diff
changeset
|
184 @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
|
185 \n\ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
190 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
|
191 @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
|
192 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
|
193 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
|
194 \n\ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
195 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
196 @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
|
197 [@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
|
198 x = @var{R} \\ @var{C}\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
199 @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
|
200 @end example\n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
201 @seealso{chol, hess, lu, qz, schur, svd, qrupdate, qrinsert, qrdelete, qrshift}\n\ |
3372 | 202 @end deftypefn") |
2928 | 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)) |
20790
c2d9556d51d0
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20678
diff
changeset
|
207 print_usage (); |
2928 | 208 |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
209 octave_value_list retval; |
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
210 |
2928 | 211 octave_value arg = args(0); |
212 | |
213 int arg_is_empty = empty_arg ("qr", arg.rows (), arg.columns ()); | |
214 | |
215 if (arg_is_empty < 0) | |
216 return retval; | |
217 | |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
218 if (arg.is_sparse_type ()) |
2928 | 219 { |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
220 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
|
221 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
|
222 int have_b = 0; |
3068 | 223 |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
224 if (arg.is_complex_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
225 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
|
226 if (nargin > 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
227 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
228 have_b = 1; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
229 if (args(nargin-1).is_scalar_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
230 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
231 int val = args(nargin-1).int_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
232 if (val == 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
233 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
234 economy = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
235 have_b = (nargin > 2 ? 2 : 0); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
236 } |
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 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
|
239 is_cmplx = true; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
240 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
241 |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20898
diff
changeset
|
242 if (is_cmplx) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
243 { |
21176
791dcb32b657
revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
244 sparse_qr<SparseComplexMatrix> q (arg.sparse_complex_matrix_value ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
245 |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
246 if (have_b > 0) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
247 { |
20859 | 248 retval = ovl (q.C (args(have_b).complex_matrix_value ()), |
249 q.R (economy)); | |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
250 if (arg.rows () < arg.columns ()) |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
251 warning ("qr: non minimum norm solution for under-determined problem"); |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
252 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
253 else if (nargout > 1) |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20898
diff
changeset
|
254 retval = ovl (q.Q (), q.R (economy)); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
255 else |
20859 | 256 retval = ovl (q.R (economy)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
257 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
258 else |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
259 { |
21176
791dcb32b657
revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
260 sparse_qr<SparseMatrix> q (arg.sparse_matrix_value ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
261 |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
262 if (have_b > 0) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
263 { |
20859 | 264 retval = ovl (q.C (args(have_b).matrix_value ()), q.R (economy)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
265 if (args(0).rows () < args(0).columns ()) |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
266 warning ("qr: non minimum norm solution for under-determined problem"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
267 } |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
268 else if (nargout > 1) |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20898
diff
changeset
|
269 retval = ovl (q.Q (), q.R (economy)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
270 else |
20859 | 271 retval = ovl (q.R (economy)); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
272 } |
2928 | 273 } |
274 else | |
275 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
276 if (arg.is_single_type ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
277 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
278 if (arg.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
279 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
280 qr<FloatMatrix>::type type |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
281 = qr_type<FloatMatrix> (nargin, nargout); |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
282 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
283 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
|
284 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
285 switch (nargout) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
286 { |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
287 case 0: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
288 case 1: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
289 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
290 qr<FloatMatrix> fact (m, type); |
20859 | 291 retval = ovl (fact.R ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
292 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
293 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
|
294 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
295 case 2: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
296 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
297 qr<FloatMatrix> fact (m, type); |
20859 | 298 retval = ovl (fact.Q (), get_qr_r (fact)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
299 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
300 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
|
301 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
302 default: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
303 { |
21280
ebdf74c15722
better use of templates for qrp classes
John W. Eaton <jwe@octave.org>
parents:
21279
diff
changeset
|
304 qrp<FloatMatrix> fact (m, type); |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
305 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
306 if (type == qr<FloatMatrix>::economy) |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
307 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
308 else |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
309 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
310 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
311 break; |
10154
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 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
314 else if (arg.is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
315 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
316 qr<FloatComplexMatrix>::type type |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
317 = qr_type<FloatComplexMatrix> (nargin, nargout); |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
318 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
319 FloatComplexMatrix m = arg.float_complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
320 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
321 switch (nargout) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
322 { |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
323 case 0: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
324 case 1: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
325 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
326 qr<FloatComplexMatrix> fact (m, type); |
20859 | 327 retval = ovl (fact.R ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
328 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
329 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
|
330 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
331 case 2: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
332 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
333 qr<FloatComplexMatrix> fact (m, type); |
20859 | 334 retval = ovl (fact.Q (), get_qr_r (fact)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
335 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
336 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
|
337 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
338 default: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
339 { |
21280
ebdf74c15722
better use of templates for qrp classes
John W. Eaton <jwe@octave.org>
parents:
21279
diff
changeset
|
340 qrp<FloatComplexMatrix> fact (m, type); |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
341 if (type == qr<FloatComplexMatrix>::economy) |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
342 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
343 else |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
344 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
345 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
346 break; |
10154
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 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
349 } |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
350 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
351 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
352 if (arg.is_real_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
353 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
354 qr<Matrix>::type type = qr_type<Matrix> (nargin, nargout); |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
355 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
356 Matrix m = arg.matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
357 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
358 switch (nargout) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
359 { |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
360 case 0: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
361 case 1: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
362 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
363 qr<Matrix> fact (m, type); |
20859 | 364 retval = ovl (fact.R ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
365 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
366 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
367 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
368 case 2: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
369 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
370 qr<Matrix> fact (m, type); |
20859 | 371 retval = ovl (fact.Q (), get_qr_r (fact)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
372 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
373 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
374 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
375 default: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
376 { |
21280
ebdf74c15722
better use of templates for qrp classes
John W. Eaton <jwe@octave.org>
parents:
21279
diff
changeset
|
377 qrp<Matrix> fact (m, type); |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
378 if (type == qr<Matrix>::economy) |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
379 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
380 else |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
381 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
382 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
383 break; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
384 } |
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 else if (arg.is_complex_type ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
387 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
388 qr<ComplexMatrix>::type type |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
389 = qr_type<ComplexMatrix> (nargin, nargout); |
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
390 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
391 ComplexMatrix m = arg.complex_matrix_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
392 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
393 switch (nargout) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
394 { |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
395 case 0: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
396 case 1: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
397 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
398 qr<ComplexMatrix> fact (m, type); |
20859 | 399 retval = ovl (fact.R ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
400 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
401 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
402 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
403 case 2: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
404 { |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
405 qr<ComplexMatrix> fact (m, type); |
20859 | 406 retval = ovl (fact.Q (), get_qr_r (fact)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
407 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
408 break; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7700
diff
changeset
|
409 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
410 default: |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
411 { |
21280
ebdf74c15722
better use of templates for qrp classes
John W. Eaton <jwe@octave.org>
parents:
21279
diff
changeset
|
412 qrp<ComplexMatrix> fact (m, type); |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
413 if (type == qr<ComplexMatrix>::economy) |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
414 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
415 else |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20859
diff
changeset
|
416 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ()); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
417 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
418 break; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
419 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
420 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
421 else |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21041
diff
changeset
|
422 err_wrong_type_arg ("qr", arg); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
423 } |
2928 | 424 } |
425 | |
426 return retval; | |
427 } | |
428 | |
429 /* | |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
430 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
431 %! 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
|
432 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
433 %! [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
|
434 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
435 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
436 %! 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
|
437 %! 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
|
438 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
439 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
440 %! 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
|
441 %! |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
442 %! [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
|
443 %! [qe, re, pe] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
444 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
445 %! 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
|
446 %! 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
|
447 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
448 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
449 %! 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
|
450 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
451 %! [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
|
452 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
453 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
454 %! 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
|
455 %! 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
|
456 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
457 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
458 %! 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
|
459 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
460 %! [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
|
461 %! [qe, re, pe] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
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 %! 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
|
464 %! 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
|
465 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
466 %!error qr () |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
467 %!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
|
468 |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13971
diff
changeset
|
469 %!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
|
470 %! 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
|
471 %! retval = 0; |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
472 %! if (nargin == 3) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
473 %! 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
|
474 %! 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
|
475 %! 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
|
476 %! else |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
477 %! 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
|
478 %! 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
|
479 %! if (isvector (p)) |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
480 %! 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
|
481 %! 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
|
482 %! else |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
483 %! 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
|
484 %! 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
|
485 %! endif |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
486 %! endif |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13971
diff
changeset
|
487 %!endfunction |
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13971
diff
changeset
|
488 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
489 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
490 %! 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
|
491 %! j = 1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
492 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
493 %! 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
|
494 %! a = rand (5000, 20); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
495 %! [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
|
496 %! [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
|
497 %! [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
|
498 %! [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
|
499 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
500 %! 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
|
501 %! [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
|
502 %! [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
|
503 %! [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
|
504 %! [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
|
505 %! endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
506 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
507 %! 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
|
508 %! [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
|
509 %! [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
|
510 %! [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
|
511 %! [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
|
512 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
513 %! 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
|
514 %! [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
|
515 %! [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
|
516 %! [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
|
517 %! [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
|
518 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
519 %! 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
|
520 %! [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
|
521 %! [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
|
522 %! [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
|
523 %! [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
|
524 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
525 %! a = a+1i*eps; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
526 %! [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
|
527 %! [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
|
528 %! [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
|
529 %! [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
|
530 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
531 %! 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
|
532 %! 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
|
533 %! -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
|
534 %! 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
|
535 %! -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
|
536 %! -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
|
537 %! -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
|
538 %! 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
|
539 %! [q,r] = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
540 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
541 %! 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
|
542 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
543 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
544 %! 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
|
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 %! [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
|
547 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
548 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
549 %! 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
|
550 %! 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
|
551 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
552 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
553 %! 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
|
554 %! |
14501
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); # 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
|
556 %! [qe, re, pe] = qr (a, 0); |
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 %! 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
|
559 %! 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
|
560 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
561 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
562 %! 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
|
563 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
564 %! [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
|
565 %! [qe, re] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
566 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
567 %! 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
|
568 %! 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
|
569 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
570 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
571 %! 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
|
572 %! |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
573 %! [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
|
574 %! [qe, re, pe] = qr (a, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
575 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
576 %! 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
|
577 %! 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
|
578 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
579 %!error qr () |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
580 %!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
|
581 |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
582 %!test |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
583 %! 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
|
584 %! j = 1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
585 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
586 %! 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
|
587 %! a = rand (5000,20); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
588 %! [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
|
589 %! [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
|
590 %! [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
|
591 %! [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
|
592 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
593 %! 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
|
594 %! [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
|
595 %! [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
|
596 %! [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
|
597 %! [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
|
598 %! endif |
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 %! 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
|
601 %! [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
|
602 %! [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
|
603 %! [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
|
604 %! [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
|
605 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
606 %! 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
|
607 %! [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
|
608 %! [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
|
609 %! [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
|
610 %! [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
|
611 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
612 %! 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
|
613 %! [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
|
614 %! [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
|
615 %! [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
|
616 %! [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
|
617 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
618 %! 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
|
619 %! [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
|
620 %! [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
|
621 %! [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
|
622 %! [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
|
623 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
624 %! 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
|
625 %! 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
|
626 %! -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
|
627 %! 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
|
628 %! -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
|
629 %! -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
|
630 %! -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
|
631 %! 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
|
632 %! [q,r] = qr (a); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
633 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
634 %! 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
|
635 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
636 ## 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
|
637 ## 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
|
638 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
639 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
640 %! 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
|
641 %! 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
|
642 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
643 %! 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
|
644 |
12329
5f203b5bbf98
Use testif to only run some sparse tests when necessary libraries are installed.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
645 %!testif HAVE_COLAMD |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
646 %! 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
|
647 %! 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
|
648 %! 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
|
649 %! 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
|
650 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
651 %! 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
|
652 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
653 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
654 %! 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
|
655 %! 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
|
656 %! [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
|
657 %! 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
|
658 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
659 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
660 %! 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
|
661 %! 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
|
662 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
663 %! [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
|
664 %! 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
|
665 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
666 %% 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
|
667 %!#testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
668 %! 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
|
669 %! 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
|
670 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
671 %! [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
|
672 %! 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
|
673 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
674 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
675 %! 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
|
676 %! 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
|
677 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
678 %! 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
|
679 |
12329
5f203b5bbf98
Use testif to only run some sparse tests when necessary libraries are installed.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
680 %!testif HAVE_COLAMD |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
681 %! 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
|
682 %! 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
|
683 %! 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
|
684 %! 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
|
685 %! r = qr (a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
686 %! 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
|
687 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
688 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
689 %! 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
|
690 %! 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
|
691 %! [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
|
692 %! 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
|
693 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
694 %!testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
695 %! 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
|
696 %! 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
|
697 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
698 %! [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
|
699 %! 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
|
700 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
701 %% 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
|
702 %!#testif HAVE_CXSPARSE |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
703 %! 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
|
704 %! 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
|
705 %! b = randn (n,2); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
706 %! [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
|
707 %! 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
|
708 |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
709 */ |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
710 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
711 static |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
712 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
|
713 bool allow_ecf = false) |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
714 { |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
715 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
|
716 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
|
717 octave_idx_type n = r.columns (); |
8798 | 718 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
|
719 && (m == k || (allow_ecf && k == n && k < m))); |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
720 } |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
721 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
722 static |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
723 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
|
724 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
725 return ((i.is_real_type () || i.is_integer_type ()) |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
726 && (i.is_scalar_type () || vector_allowed)); |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
727 } |
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
728 |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
729 DEFUN_DLD (qrupdate, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
730 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
731 @deftypefn {} {[@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
|
732 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
|
733 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
734 @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:
19697
diff
changeset
|
735 @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:
19697
diff
changeset
|
736 (rank-1 update) or matrices with equal number of columns\n\ |
10840 | 737 (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
|
738 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
|
739 to recompute the factorization from scratch.\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
740 \n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
741 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:
19697
diff
changeset
|
742 economized (R is square).\n\ |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
743 \n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
744 @seealso{qr, qrinsert, qrdelete, qrshift}\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
745 @end deftypefn") |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
746 { |
20812
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20790
diff
changeset
|
747 octave_value_list retval; |
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20790
diff
changeset
|
748 |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20816
diff
changeset
|
749 if (args.length () != 4) |
20790
c2d9556d51d0
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20678
diff
changeset
|
750 print_usage (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
751 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
752 octave_value argq = args(0); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
753 octave_value argr = args(1); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
754 octave_value argu = args(2); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
755 octave_value argv = args(3); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
756 |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
757 if (! argq.is_numeric_type () || ! argr.is_numeric_type () |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
758 || ! argu.is_numeric_type () || ! argv.is_numeric_type ()) |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
759 print_usage (); |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
760 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
761 if (! check_qr_dims (argq, argr, true)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
762 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
|
763 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
764 if (argq.is_real_type () && argr.is_real_type () && argu.is_real_type () |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
765 && argv.is_real_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
766 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
767 // all real case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
768 if (argq.is_single_type () || argr.is_single_type () |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
769 || argu.is_single_type () || argv.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
770 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
771 FloatMatrix Q = argq.float_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
772 FloatMatrix R = argr.float_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
773 FloatMatrix u = argu.float_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
774 FloatMatrix v = argv.float_matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
775 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
776 qr<FloatMatrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
777 fact.update (u, v); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
778 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
779 retval = ovl (fact.Q (), get_qr_r (fact)); |
7553
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 else |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
782 { |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
783 Matrix Q = argq.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
784 Matrix R = argr.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
785 Matrix u = argu.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
786 Matrix v = argv.matrix_value (); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
787 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
788 qr<Matrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
789 fact.update (u, v); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
790 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
791 retval = ovl (fact.Q (), get_qr_r (fact)); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
792 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
793 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
794 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
795 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
796 // complex case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
797 if (argq.is_single_type () || argr.is_single_type () |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
798 || argu.is_single_type () || argv.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
799 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
800 FloatComplexMatrix Q = argq.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
801 FloatComplexMatrix R = argr.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
802 FloatComplexMatrix u = argu.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
803 FloatComplexMatrix v = argv.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
804 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
805 qr<FloatComplexMatrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
806 fact.update (u, v); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
807 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
808 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
809 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
810 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
811 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
812 ComplexMatrix Q = argq.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
813 ComplexMatrix R = argr.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
814 ComplexMatrix u = argu.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
815 ComplexMatrix v = argv.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
816 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
817 qr<ComplexMatrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
818 fact.update (u, v); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
819 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
820 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
821 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
822 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
823 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
824 return retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
825 } |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
826 |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
827 /* |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
828 %!shared A, u, v, Ac, uc, vc |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
829 %! A = [0.091364 0.613038 0.999083; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
830 %! 0.594638 0.425302 0.603537; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
831 %! 0.383594 0.291238 0.085574; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
832 %! 0.265712 0.268003 0.238409; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
833 %! 0.669966 0.743851 0.445057 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
834 %! |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
835 %! u = [0.85082; |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
836 %! 0.76426; |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
837 %! 0.42883; |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
838 %! 0.53010; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
839 %! 0.80683 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
840 %! |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
841 %! v = [0.98810; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
842 %! 0.24295; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
843 %! 0.43167 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
844 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
845 %! 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
|
846 %! 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
|
847 %! 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
|
848 %! 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
|
849 %! 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
|
850 %! |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
851 %! 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
|
852 %! 0.13141 + 0.43708i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
853 %! 0.29808 + 0.08789i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
854 %! 0.69821 + 0.38844i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
855 %! 0.74871 + 0.25821i ]; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
856 %! |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
857 %! 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
|
858 %! 0.20820 + 0.93090i; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
859 %! 0.86184 + 0.34689i ]; |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
860 %! |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
861 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
862 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
863 %! [Q,R] = qr (A); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
864 %! [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
|
865 %! 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
|
866 %! 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
|
867 %! 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
|
868 %! |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
869 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
870 %! [Q,R] = qr (Ac); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
871 %! [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
|
872 %! 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
|
873 %! 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
|
874 %! 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
|
875 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
876 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
877 %! [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
|
878 %! [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
|
879 %! 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
|
880 %! 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
|
881 %! 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
|
882 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
883 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
884 %! [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
|
885 %! [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
|
886 %! 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
|
887 %! 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
|
888 %! 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
|
889 */ |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
890 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
891 DEFUN_DLD (qrinsert, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
892 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
893 @deftypefn {} {[@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
|
894 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
|
895 @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
|
896 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of\n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
897 @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:
19697
diff
changeset
|
898 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:
19697
diff
changeset
|
899 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:
19697
diff
changeset
|
900 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
|
901 \n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
902 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:
19697
diff
changeset
|
903 @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
|
904 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
|
905 @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
|
906 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
|
907 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
|
908 recompute the factorization from scratch.\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
909 \n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
910 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:
19697
diff
changeset
|
911 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
|
912 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
913 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
|
914 @seealso{qr, qrupdate, qrdelete, qrshift}\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
915 @end deftypefn") |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
916 { |
20816
b16bcd7a2a33
Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents:
20812
diff
changeset
|
917 int nargin = args.length (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
918 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
919 if (nargin < 4 || nargin > 5) |
20790
c2d9556d51d0
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20678
diff
changeset
|
920 print_usage (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
921 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
922 octave_value argq = args(0); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
923 octave_value argr = args(1); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
924 octave_value argj = args(2); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
925 octave_value argx = args(3); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
926 |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
927 if (! argq.is_numeric_type () || ! argr.is_numeric_type () |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
928 || ! argx.is_numeric_type () |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
929 || (nargin > 4 && ! args(4).is_string ())) |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
930 print_usage (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
931 |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
932 std::string orient = (nargin < 5) ? "col" : args(4).string_value (); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
933 bool col = (orient == "col"); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
934 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
935 if (! col && orient != "row") |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
936 error ("qrinsert: ORIENT must be \"col\" or \"row\""); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
937 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
938 if (! check_qr_dims (argq, argr, col) || (! col && argx.rows () != 1)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
939 error ("qrinsert: dimension mismatch"); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
940 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
941 if (! check_index (argj, col)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
942 error ("qrinsert: invalid index J"); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
943 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
944 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
945 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
946 MArray<octave_idx_type> j = argj.octave_idx_type_vector_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
947 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
948 octave_idx_type one = 1; |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
949 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
950 if (argq.is_real_type () && argr.is_real_type () && argx.is_real_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
951 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
952 // real case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
953 if (argq.is_single_type () || argr.is_single_type () |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
954 || argx.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
955 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
956 FloatMatrix Q = argq.float_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
957 FloatMatrix R = argr.float_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
958 FloatMatrix x = argx.float_matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
959 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
960 qr<FloatMatrix> fact (Q, R); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
961 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
962 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
963 fact.insert_col (x, j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
964 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
965 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
|
966 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
967 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
968 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
969 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
970 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
971 Matrix Q = argq.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
972 Matrix R = argr.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
973 Matrix x = argx.matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
974 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
975 qr<Matrix> fact (Q, R); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
976 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
977 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
978 fact.insert_col (x, j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
979 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
980 fact.insert_row (x.row (0), j(0)-one); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
981 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
982 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
983 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
984 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
985 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
986 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
987 // complex case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
988 if (argq.is_single_type () || argr.is_single_type () |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
989 || argx.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
990 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
991 FloatComplexMatrix Q = |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
992 argq.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
993 FloatComplexMatrix R = |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
994 argr.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
995 FloatComplexMatrix x = |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
996 argx.float_complex_matrix_value (); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
997 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
998 qr<FloatComplexMatrix> fact (Q, R); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
999 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1000 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1001 fact.insert_col (x, j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1002 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1003 fact.insert_row (x.row (0), j(0)-one); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1004 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1005 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1006 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1007 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1008 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1009 ComplexMatrix Q = argq.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1010 ComplexMatrix R = argr.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1011 ComplexMatrix x = argx.complex_matrix_value (); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1012 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1013 qr<ComplexMatrix> fact (Q, R); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1014 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1015 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1016 fact.insert_col (x, j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1017 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1018 fact.insert_row (x.row (0), j(0)-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1019 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1020 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1021 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1022 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1023 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1024 return retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1025 } |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1026 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1027 /* |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1028 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1029 %! [Q,R] = qr (A); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1030 %! [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
|
1031 %! 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
|
1032 %! 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
|
1033 %! 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
|
1034 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1035 %! [Q,R] = qr (Ac); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1036 %! [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
|
1037 %! 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
|
1038 %! 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
|
1039 %! 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
|
1040 %!test |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1041 %! x = [0.85082 0.76426 0.42883 ]; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1042 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1043 %! [Q,R] = qr (A); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1044 %! [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
|
1045 %! 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
|
1046 %! 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
|
1047 %! 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
|
1048 %!test |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1049 %! 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
|
1050 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1051 %! [Q,R] = qr (Ac); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1052 %! [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
|
1053 %! 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
|
1054 %! 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
|
1055 %! 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
|
1056 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1057 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1058 %! [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
|
1059 %! [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
|
1060 %! 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
|
1061 %! 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
|
1062 %! 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
|
1063 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1064 %! [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
|
1065 %! [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
|
1066 %! 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
|
1067 %! 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
|
1068 %! 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
|
1069 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1070 %! 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
|
1071 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1072 %! [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
|
1073 %! [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
|
1074 %! 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
|
1075 %! 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
|
1076 %! 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
|
1077 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1078 %! 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
|
1079 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1080 %! [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
|
1081 %! [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
|
1082 %! 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
|
1083 %! 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
|
1084 %! 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
|
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 DEFUN_DLD (qrdelete, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1088 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
1089 @deftypefn {} {[@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
|
1090 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
|
1091 @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
|
1092 @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
|
1093 @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
|
1094 (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
|
1095 @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
|
1096 @var{orient} is @qcode{\"row\"}).\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1097 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
1098 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
|
1099 \n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1100 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
|
1101 resulting in the QR@tie{}factorization of a matrix @var{B} such that\n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1102 @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:
19697
diff
changeset
|
1103 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:
19697
diff
changeset
|
1104 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
|
1105 \n\ |
20163
075a5e2e1ba5
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1106 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:
19697
diff
changeset
|
1107 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
|
1108 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16920
diff
changeset
|
1109 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
|
1110 @seealso{qr, qrupdate, qrinsert, qrshift}\n\ |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1111 @end deftypefn") |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1112 { |
20816
b16bcd7a2a33
Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents:
20812
diff
changeset
|
1113 int nargin = args.length (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1114 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1115 if (nargin < 3 || nargin > 4) |
20790
c2d9556d51d0
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20678
diff
changeset
|
1116 print_usage (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1117 |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1118 octave_value argq = args(0); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1119 octave_value argr = args(1); |
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1120 octave_value argj = args(2); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1121 |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1122 if (! argq.is_numeric_type () || ! argr.is_numeric_type () |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1123 || (nargin > 3 && ! args(3).is_string ())) |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1124 print_usage (); |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1125 |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1126 std::string orient = (nargin < 4) ? "col" : args(3).string_value (); |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1127 bool col = orient == "col"; |
7559
07522d7dcdf8
fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
1128 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1129 if (! col && orient != "row") |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1130 error ("qrdelete: ORIENT must be \"col\" or \"row\""); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1131 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1132 if (! check_qr_dims (argq, argr, col)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1133 error ("qrdelete: dimension mismatch"); |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8517
diff
changeset
|
1134 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1135 MArray<octave_idx_type> j = argj.octave_idx_type_vector_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1136 if (! check_index (argj, col)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1137 error ("qrdelete: invalid index J"); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1138 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1139 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1140 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1141 octave_idx_type one = 1; |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1142 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1143 if (argq.is_real_type () && argr.is_real_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1144 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1145 // real case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1146 if (argq.is_single_type () || argr.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1147 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1148 FloatMatrix Q = argq.float_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1149 FloatMatrix R = argr.float_matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1150 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1151 qr<FloatMatrix> fact (Q, R); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1152 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1153 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1154 fact.delete_col (j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1155 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1156 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
|
1157 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1158 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1159 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1160 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1161 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1162 Matrix Q = argq.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1163 Matrix R = argr.matrix_value (); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1164 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1165 qr<Matrix> fact (Q, R); |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1166 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1167 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1168 fact.delete_col (j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1169 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1170 fact.delete_row (j(0)-one); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1171 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1172 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1173 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1174 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1175 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1176 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1177 // complex case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1178 if (argq.is_single_type () || argr.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1179 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1180 FloatComplexMatrix Q = |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1181 argq.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1182 FloatComplexMatrix R = |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1183 argr.float_complex_matrix_value (); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1184 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1185 qr<FloatComplexMatrix> fact (Q, R); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1186 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1187 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1188 fact.delete_col (j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1189 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1190 fact.delete_row (j(0)-one); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1191 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1192 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1193 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1194 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1195 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1196 ComplexMatrix Q = argq.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1197 ComplexMatrix R = argr.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1198 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1199 qr<ComplexMatrix> fact (Q, R); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1200 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1201 if (col) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1202 fact.delete_col (j-one); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1203 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1204 fact.delete_row (j(0)-one); |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1205 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1206 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1207 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1208 } |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1209 |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1210 return retval; |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1211 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1212 |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1213 /* |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1214 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1215 %! 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
|
1216 %! 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
|
1217 %! 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
|
1218 %! 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
|
1219 %! 0.669966 0.743851 0.457255 0.445057 ]; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1220 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1221 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1222 %! [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
|
1223 %! 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
|
1224 %! 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
|
1225 %! 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
|
1226 %! |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1227 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1228 %! 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
|
1229 %! 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
|
1230 %! 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
|
1231 %! 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
|
1232 %! 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
|
1233 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1234 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1235 %! [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
|
1236 %! 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
|
1237 %! 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
|
1238 %! 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
|
1239 %! |
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1240 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1241 %! 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
|
1242 %! 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
|
1243 %! 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
|
1244 %! 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
|
1245 %! 0.669966 0.743851 0.457255 0.445057 ]; |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1246 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1247 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1248 %! [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
|
1249 %! 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
|
1250 %! 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
|
1251 %! 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
|
1252 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1253 %!test |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1254 %! 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
|
1255 %! 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
|
1256 %! 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
|
1257 %! 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
|
1258 %! 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
|
1259 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1260 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1261 %! [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
|
1262 %! 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
|
1263 %! 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
|
1264 %! 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
|
1265 |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1266 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1267 %! 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
|
1268 %! 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
|
1269 %! 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
|
1270 %! 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
|
1271 %! 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
|
1272 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1273 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1274 %! [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
|
1275 %! 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
|
1276 %! 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
|
1277 %! 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
|
1278 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1279 %!test |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1280 %! 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
|
1281 %! 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
|
1282 %! 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
|
1283 %! 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
|
1284 %! 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
|
1285 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1286 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1287 %! [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
|
1288 %! 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
|
1289 %! 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
|
1290 %! 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
|
1291 %! |
7553
56be6f31dd4e
implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7505
diff
changeset
|
1292 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1293 %! 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
|
1294 %! 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
|
1295 %! 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
|
1296 %! 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
|
1297 %! 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
|
1298 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1299 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1300 %! [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
|
1301 %! 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
|
1302 %! 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
|
1303 %! 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
|
1304 %!testif HAVE_QRUPDATE |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1305 %! ## 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
|
1306 %! 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
|
1307 %! 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
|
1308 %! 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
|
1309 %! 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
|
1310 %! 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
|
1311 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1312 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1313 %! [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
|
1314 %! 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
|
1315 %! 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
|
1316 %! 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
|
1317 %! |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1318 %!test |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1319 %! 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
|
1320 %! 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
|
1321 %! 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
|
1322 %! 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
|
1323 %! 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
|
1324 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1325 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1326 %! [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
|
1327 %! 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
|
1328 %! 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
|
1329 %! 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
|
1330 */ |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7491
diff
changeset
|
1331 |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1332 DEFUN_DLD (qrshift, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1333 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20851
diff
changeset
|
1334 @deftypefn {} {[@var{Q1}, @var{R1}] =} qrshift (@var{Q}, @var{R}, @var{i}, @var{j})\n\ |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1335 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
|
1336 @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
|
1337 @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
|
1338 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
|
1339 @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
|
1340 or @*\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8869
diff
changeset
|
1341 @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
|
1342 \n\ |
16920
53eaa83e4181
doc: Add seealso links between various factorization forms.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
1343 @seealso{qr, qrupdate, qrinsert, qrdelete}\n\ |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1344 @end deftypefn") |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1345 { |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20816
diff
changeset
|
1346 if (args.length () != 4) |
20790
c2d9556d51d0
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20678
diff
changeset
|
1347 print_usage (); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1348 |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1349 octave_value argq = args(0); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1350 octave_value argr = args(1); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1351 octave_value argi = args(2); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1352 octave_value argj = args(3); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1353 |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1354 if (! argq.is_numeric_type () || ! argr.is_numeric_type ()) |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1355 print_usage (); |
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1356 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1357 if (! check_qr_dims (argq, argr, true)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1358 error ("qrshift: dimensions mismatch"); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1359 |
21041
63374982750b
Usage of corresponding value extractor for octave_idx_type. Improves support
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20940
diff
changeset
|
1360 octave_idx_type i = argi.idx_type_value (); |
63374982750b
Usage of corresponding value extractor for octave_idx_type. Improves support
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20940
diff
changeset
|
1361 octave_idx_type j = argj.idx_type_value (); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1362 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1363 if (! check_index (argi) || ! check_index (argj)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1364 error ("qrshift: invalid index I or J"); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1365 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1366 octave_value_list retval; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1367 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1368 if (argq.is_real_type () && argr.is_real_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1369 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1370 // all real case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1371 if (argq.is_single_type () |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1372 && argr.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1373 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1374 FloatMatrix Q = argq.float_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1375 FloatMatrix R = argr.float_matrix_value (); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1376 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1377 qr<FloatMatrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1378 fact.shift_cols (i-1, j-1); |
20851
0828bf20d105
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20818
diff
changeset
|
1379 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1380 retval = ovl (fact.Q (), get_qr_r (fact)); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1381 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1382 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1383 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1384 Matrix Q = argq.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1385 Matrix R = argr.matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1386 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1387 qr<Matrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1388 fact.shift_cols (i-1, j-1); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1389 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1390 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1391 } |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1392 } |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1393 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1394 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1395 // complex case |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1396 if (argq.is_single_type () |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1397 && argr.is_single_type ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1398 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1399 FloatComplexMatrix Q = argq.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1400 FloatComplexMatrix R = argr.float_complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1401 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1402 qr<FloatComplexMatrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1403 fact.shift_cols (i-1, j-1); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1404 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1405 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1406 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1407 else |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1408 { |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1409 ComplexMatrix Q = argq.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1410 ComplexMatrix R = argr.complex_matrix_value (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1411 |
21279
eb1524b07fe3
better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1412 qr<ComplexMatrix> fact (Q, R); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1413 fact.shift_cols (i-1, j-1); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1414 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1415 retval = ovl (fact.Q (), get_qr_r (fact)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1416 } |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
1417 } |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1418 |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1419 return retval; |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1420 } |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1421 |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1422 /* |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1423 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1424 %! AA = A.'; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1425 %! 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
|
1426 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1427 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1428 %! [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
|
1429 %! 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
|
1430 %! 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
|
1431 %! 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
|
1432 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1433 %! 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
|
1434 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1435 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1436 %! [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
|
1437 %! 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
|
1438 %! 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
|
1439 %! 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
|
1440 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1441 %!test |
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1442 %! AA = Ac.'; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1443 %! 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
|
1444 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1445 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1446 %! [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
|
1447 %! 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
|
1448 %! 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
|
1449 %! 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
|
1450 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1451 %! 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
|
1452 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1453 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1454 %! [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
|
1455 %! 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
|
1456 %! 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
|
1457 %! 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
|
1458 |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7650
diff
changeset
|
1459 %!test |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1460 %! AA = single (A).'; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1461 %! 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
|
1462 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1463 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1464 %! [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
|
1465 %! 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
|
1466 %! 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
|
1467 %! 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
|
1468 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1469 %! 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
|
1470 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1471 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1472 %! [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
|
1473 %! 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
|
1474 %! 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
|
1475 %! 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
|
1476 %! |
7886
e3e94982dfd4
Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1477 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1478 %! AA = single (Ac).'; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1479 %! 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
|
1480 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1481 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1482 %! [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
|
1483 %! 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
|
1484 %! 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
|
1485 %! 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
|
1486 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1487 %! 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
|
1488 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1489 %! [Q,R] = qr (AA); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1490 %! [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
|
1491 %! 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
|
1492 %! 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
|
1493 %! 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
|
1494 */ |