annotate libinterp/dldfcn/qr.cc @ 18502:35100920494f stable

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