annotate libinterp/corefcn/qr.cc @ 31187:0a2bf14dd400

Add "const" qualifier to static variables that hold "fcntl.h" values. * syscalls.cc: Add "const" qualifier to static variables that hold "fcntl.h" values.
author Rik <rik@octave.org>
date Sat, 13 Aug 2022 16:45:48 -0700
parents 7ad60a258a2b
children fa4bb329a51a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30356
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21580
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21280
diff changeset
27 # include "config.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
29
23024
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 22755
diff changeset
30 #include <string>
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 22755
diff changeset
31
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 22755
diff changeset
32 #include "MArray.h"
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 22755
diff changeset
33 #include "Matrix.h"
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
34 #include "qr.h"
21280
ebdf74c15722 better use of templates for qrp classes
John W. Eaton <jwe@octave.org>
parents: 21279
diff changeset
35 #include "qrp.h"
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
36 #include "sparse-qr.h"
7505
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7491
diff changeset
37
28024
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
38 #include "defun.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
39 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21041
diff changeset
40 #include "errwarn.h"
23024
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 22755
diff changeset
41 #include "ov.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
42 #include "ovl.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
43
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
44 OCTAVE_NAMESPACE_BEGIN
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
45
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
46 /*
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
47 ## Restore all rand* "state" values
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
48 %!function restore_rand_states (state)
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
49 %! rand ("state", state.rand);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
50 %! randn ("state", state.randn);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
51 %!endfunction
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
52
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
53 %!shared old_state, restore_state
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
54 %! ## Save and restore the states of both random number generators that are
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
55 %! ## tested by the unit tests in this file.
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
56 %! old_state.rand = rand ("state");
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
57 %! old_state.randn = randn ("state");
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
58 %! restore_state = onCleanup (@() restore_rand_states (old_state));
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
59 */
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
60
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21100
diff changeset
61 template <typename MT>
8869
c3b743b1b1c6 preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents: 8811
diff changeset
62 static octave_value
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
63 get_qr_r (const math::qr<MT>& fact)
8869
c3b743b1b1c6 preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents: 8811
diff changeset
64 {
9715
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9209
diff changeset
65 MT R = fact.R ();
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23586
diff changeset
66 if (R.issquare () && fact.regular ())
9715
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9209
diff changeset
67 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
68 else
9715
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9209
diff changeset
69 return R;
8869
c3b743b1b1c6 preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents: 8811
diff changeset
70 }
c3b743b1b1c6 preset triangular type if possible for lu and qr outputs
Jaroslav Hajek <highegg@gmail.com>
parents: 8811
diff changeset
71
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
72 template <typename T>
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
73 static typename math::qr<T>::type
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
74 qr_type (int nargout, bool economy)
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
75 {
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
76 if (nargout == 0 || nargout == 1)
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
77 return math::qr<T>::raw;
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
78 else if (economy)
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
79 return math::qr<T>::economy;
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
80 else
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
81 return math::qr<T>::std;
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
82 }
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
83
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
84 // dense X
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
85 //
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
86 // [Q, R] = qr (X): form Q unitary and R upper triangular such
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
87 // that Q * R = X
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
88 //
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
89 // [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
90 // 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
91 // computed.
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
92 //
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
93 // [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
94 // P is a permutation matrix such that
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
95 // A * P = Q * R
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
96 //
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
97 // [Q, R, P] = qr (X, 0): form the economy decomposition with
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
98 // permutation vector P such that Q * R = X(:, P)
3372
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
99 //
f16c2ce14886 [project @ 1999-11-23 19:07:09 by jwe]
jwe
parents: 3069
diff changeset
100 // 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
101 // that R = triu (qr (X))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
102 //
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
103 // sparse X
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
104 //
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
105 // X = qr (A, B): if M < N, X is the minimum 2-norm solution of
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
106 // A\B. If M >= N, X is the least squares
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
107 // approximation of A\B. X is calculated by
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
108 // SPQR-function SuiteSparseQR_min2norm.
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
109 //
28024
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
110 DEFUN (qr, args, nargout,
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
111 doc: /* -*- texinfo -*-
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
112 @deftypefn {} {[@var{Q}, @var{R}] =} qr (@var{A})
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
113 @deftypefnx {} {[@var{Q}, @var{R}, @var{P}] =} qr (@var{A})
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
114 @deftypefnx {} {@var{X} =} qr (@var{A}) # non-sparse A
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
115 @deftypefnx {} {@var{R} =} qr (@var{A}) # sparse A
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
116 @deftypefnx {} {@var{X} =} qr (@var{A}, @var{B}) # sparse A
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
117 @deftypefnx {} {[@var{C}, @var{R}] =} qr (@var{A}, @var{B})
22209
cfa684a0539d qr.cc: make use of Texinfo macro @dots instead of ... (bug #46912)
Carnë Draug <carandraug@octave.org>
parents: 22207
diff changeset
118 @deftypefnx {} {[@dots{}] =} qr (@dots{}, 0)
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
119 @deftypefnx {} {[@dots{}] =} qr (@dots{}, "econ")
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
120 @deftypefnx {} {[@dots{}] =} qr (@dots{}, "vector")
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
121 @deftypefnx {} {[@dots{}] =} qr (@dots{}, "matrix")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
122 @cindex QR factorization
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
123 Compute the QR@tie{}factorization of @var{A}, using standard @sc{lapack}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
124 subroutines.
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
125
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
126 The QR@tie{}factorization is
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
127 @tex
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
128 $QR = A$ where $Q$ is an orthogonal matrix and $R$ is upper triangular.
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
129 @end tex
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
130 @ifnottex
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
131
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
132 @example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
133 @var{Q} * @var{R} = @var{A}
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
134 @end example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
135
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
136 @noindent
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
137 where @var{Q} is an orthogonal matrix and @var{R} is upper triangular.
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
138 @end ifnottex
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
139
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
140 For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
141
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
142 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
143 [@var{Q}, @var{R}] = qr (@var{A})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
144 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
145
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
146 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
147 returns
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
148
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
149 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
150 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
151 @var{Q} =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
152
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
153 -0.31623 -0.94868
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
154 -0.94868 0.31623
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
155
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
156 @var{R} =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
157
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
158 -3.16228 -4.42719
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
159 0.00000 -0.63246
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
160 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
161 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
162
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
163 @noindent
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
164 which multiplied together return the original matrix
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
165
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
166 @example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
167 @group
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
168 @var{Q} * @var{R}
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
169 @result{}
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
170 1.0000 2.0000
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
171 3.0000 4.0000
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
172 @end group
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
173 @end example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
174
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
175 If just a single return value is requested then it is either @var{R}, if
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
176 @var{A} is sparse, or @var{X}, such that @code{@var{R} = triu (@var{X})} if
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
177 @var{A} is full. (Note: unlike most commands, the single return value is not
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
178 the first return value when multiple values are requested.)
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
179
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
180 If a third output @var{P} is requested, then @code{qr} calculates the permuted
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
181 QR@tie{}factorization
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
182 @tex
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
183 $QR = AP$ where $Q$ is an orthogonal matrix, $R$ is upper triangular, and $P$
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
184 is a permutation matrix.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
185 @end tex
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
186 @ifnottex
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
187
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
188 @example
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
189 @var{Q} * @var{R} = @var{A} * @var{P}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
190 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
191
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
192 @noindent
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
193 where @var{Q} is an orthogonal matrix, @var{R} is upper triangular, and
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
194 @var{P} is a permutation matrix.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
195 @end ifnottex
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
196
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
197 If @var{A} is dense, the permuted QR@tie{}factorization has the additional
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
198 property that the diagonal entries of @var{R} are ordered by decreasing
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
199 magnitude. In other words, @code{abs (diag (@var{R}))} will be ordered
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
200 from largest to smallest.
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
201
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
202 If @var{A} is sparse, @var{P} is a fill-reducing ordering of the columns
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
203 of @var{A}. In that case, the diagonal entries of @var{R} are not ordered by
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
204 decreasing magnitude.
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
205
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
206 For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
207
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
208 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
209 [@var{Q}, @var{R}, @var{P}] = qr (@var{A})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
210 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
211
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
212 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
213 returns
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
214
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
215 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
216 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
217 @var{Q} =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
218
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
219 -0.44721 -0.89443
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
220 -0.89443 0.44721
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
221
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
222 @var{R} =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
223
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
224 -4.47214 -3.13050
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
225 0.00000 0.44721
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
226
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
227 @var{P} =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
228
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
229 0 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
230 1 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
231 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
232 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
233
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
234 If the input matrix @var{A} is sparse, the sparse QR@tie{}factorization
30354
c980f938fdd8 doc: grammarcheck C++ files in libinterp/ directory ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29961
diff changeset
235 is computed by using @sc{SPQR} or @sc{cxsparse} (e.g., if @sc{SPQR} is not
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
236 available). Because the matrix @var{Q} is, in general, a full matrix, it is
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
237 recommended to request only one return value @var{R}. In that case, the
30356
95c2ac7b43d6 doc: Fix two more instances of long lines in libinterp/ directory.
Rik <rik@octave.org>
parents: 30354
diff changeset
238 computation avoids the construction of @var{Q} and returns a sparse @var{R}
95c2ac7b43d6 doc: Fix two more instances of long lines in libinterp/ directory.
Rik <rik@octave.org>
parents: 30354
diff changeset
239 such that @code{@var{R} = chol (@var{A}' * @var{A})}.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
240
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
241 If @var{A} is dense, an additional matrix @var{B} is supplied and two
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
242 return values are requested, then @code{qr} returns @var{C}, where
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
243 @code{@var{C} = @var{Q}' * @var{B}}. This allows the least squares
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
244 approximation of @code{@var{A} \ @var{B}} to be calculated as
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
245
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
246 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
247 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
248 [@var{C}, @var{R}] = qr (@var{A}, @var{B})
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
249 @var{X} = @var{R} \ @var{C}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
250 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
251 @end example
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
252
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
253 If @var{A} is a sparse MxN matrix and an additional matrix @var{B} is
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
254 supplied, one or two return values are possible. If one return value @var{X}
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
255 is requested and M < N, then @var{X} is the minimum 2-norm solution of
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
256 @w{@code{@var{A} \ @var{B}}}. If M >= N, @var{X} is the least squares
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
257 approximation @w{of @code{@var{A} \ @var{B}}}. If two return values are
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
258 requested, @var{C} and @var{R} have the same meaning as in the dense case
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
259 (@var{C} is dense and @var{R} is sparse).
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
260 The version with one return parameter should be preferred because
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
261 it uses less memory and can handle rank-deficient matrices better.
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
262
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
263 If the final argument is the string @qcode{"vector"} then @var{P} is a
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
264 permutation vector (of the columns of @var{A}) instead of a permutation
30354
c980f938fdd8 doc: grammarcheck C++ files in libinterp/ directory ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29961
diff changeset
265 matrix. In this case, the defining relationship is:
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
266
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
267 @example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
268 @var{Q} * @var{R} = @var{A}(:, @var{P})
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
269 @end example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
270
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
271 The default, however, is to return a permutation matrix and this may be
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
272 explicitly specified by using a final argument of @qcode{"matrix"}.
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
273
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
274 If the final argument is the scalar 0 or the string @qcode{"econ"}, an
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
275 economy factorization is returned. If the original matrix @var{A} has size
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
276 MxN and M > N, then the economy factorization will calculate just N rows in
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
277 @var{R} and N columns in @var{Q} and omit the zeros in @var{R}. If M @leq{}
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
278 N, there is no difference between the economy and standard factorizations.
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
279 When calculating an economy factorization and @var{A} is dense, the output
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
280 @var{P} is always a vector rather than a matrix. If @var{A} is sparse,
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
281 output @var{P} is a sparse permutation matrix.
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
282
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
283 Background: The QR factorization has applications in the solution of least
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
284 squares problems
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
285 @tex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
286 $$
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
287 \min_x \left\Vert A x - b \right\Vert_2
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
288 $$
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
289 @end tex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
290 @ifnottex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
291
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
292 @example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
293 min norm (A*x - b)
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
294 @end example
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
295
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
296 @end ifnottex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
297 for overdetermined systems of equations (i.e.,
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
298 @tex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
299 $A$
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
300 @end tex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
301 @ifnottex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
302 @var{A}
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
303 @end ifnottex
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
304 is a tall, thin matrix).
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
305
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
306 The permuted QR@tie{}factorization
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
307 @code{[@var{Q}, @var{R}, @var{P}] = qr (@var{A})} allows the construction of an
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
308 orthogonal basis of @code{span (A)}.
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
309
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
310 @seealso{chol, hess, lu, qz, schur, svd, qrupdate, qrinsert, qrdelete, qrshift}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
311 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
312 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
313 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
314
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
315 if (nargin < 1 || nargin > 3)
20790
c2d9556d51d0 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
316 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
317
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
318 octave_value_list retval;
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
319
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
320 octave_value arg = args(0);
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
321
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
322 bool economy = false;
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
323 bool is_cmplx = false;
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
324 bool have_b = 0;
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
325 bool vector_p = 0;
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
326
23581
c3075ae020e1 maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents: 23580
diff changeset
327 if (arg.iscomplex ())
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
328 is_cmplx = true;
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
329 if (nargin > 1)
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
330 {
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
331 have_b = true;
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
332 if (args(nargin-1).is_scalar_type ())
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
333 {
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
334 int val = args(nargin-1).int_value ();
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
335 if (val == 0)
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
336 {
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
337 economy = true;
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
338 have_b = (nargin > 2);
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
339 }
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
340 else if (nargin == 3) // argument 3 should be 0 or a string
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
341 print_usage ();
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
342 }
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
343 else if (args(nargin-1).is_string ())
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
344 {
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
345 std::string str = args(nargin-1).string_value ();
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
346 if (str == "vector")
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
347 vector_p = true;
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
348 else if (str == "econ")
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
349 {
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
350 economy = true;
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
351 have_b = (nargin > 2);
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
352 }
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
353 else if (str != "matrix")
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
354 error ("qr: option string must be 'econ' or 'matrix' or " \
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
355 "'vector', not \"%s\"", str.c_str ());
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
356 have_b = (nargin > 2);
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
357 }
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
358 else if (! args(nargin-1).is_matrix_type ())
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
359 err_wrong_type_arg ("qr", args(nargin-1));
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
360 else if (nargin == 3) // should be caught by is_scalar_type or is_string
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
361 print_usage ();
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
362
23581
c3075ae020e1 maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents: 23580
diff changeset
363 if (have_b && args(1).iscomplex ())
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
364 is_cmplx = true;
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
365 }
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
366
23583
b7747a2c88b2 maint: Deprecate is_sparse_type and replace with issparse.
Rik <rik@octave.org>
parents: 23582
diff changeset
367 if (arg.issparse ())
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
368 {
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
369 if (nargout > 3)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
370 error ("qr: too many output arguments");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
371
20909
03e4ddd49396 omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents: 20898
diff changeset
372 if (is_cmplx)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
373 {
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
374 if (have_b && nargout == 1)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
375 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
376 octave_idx_type info;
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
377
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
378 if (! args(1).issparse () && args(1).iscomplex ())
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
379 retval = ovl
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
380 (math::sparse_qr<SparseComplexMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
381 <MArray<Complex>, ComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
382 (arg.sparse_complex_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
383 args(1).complex_matrix_value (), info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
384 else if (args(1).issparse () && args(1).iscomplex ())
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
385 retval = ovl
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
386 (math::sparse_qr<SparseComplexMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
387 <SparseComplexMatrix, SparseComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
388 (arg.sparse_complex_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
389 args(1).sparse_complex_matrix_value (), info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
390 else if (! args(1).issparse () && ! args(1).iscomplex ())
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
391 retval = ovl
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
392 (math::sparse_qr<SparseComplexMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
393 <MArray<double>, ComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
394 (arg.sparse_complex_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
395 args(1).matrix_value (), info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
396 else if (args(1).issparse () && ! args(1).iscomplex ())
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
397 retval = ovl
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
398 (math::sparse_qr<SparseComplexMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
399 <SparseMatrix, SparseComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
400 (arg.sparse_complex_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
401 args(1).sparse_matrix_value (), info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
402 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
403 error ("qr: b is not valid");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
404 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
405 else if (have_b && nargout == 2)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
406 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
407 math::sparse_qr<SparseComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
408 q (arg.sparse_complex_matrix_value (), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
409 retval = ovl (q.C (args(1).complex_matrix_value (), economy),
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
410 q.R (economy));
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
411 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
412 else if (have_b && nargout == 3)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
413 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
414 math::sparse_qr<SparseComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
415 q (arg.sparse_complex_matrix_value ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
416 if (vector_p)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
417 retval = ovl (q.C (args(1).complex_matrix_value (), economy),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
418 q.R (economy), q.E ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
419 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
420 retval = ovl (q.C (args(1).complex_matrix_value (), economy),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
421 q.R (economy), q.E_MAT ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
422 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
423 else
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
424 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
425 if (nargout > 2)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
426 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
427 math::sparse_qr<SparseComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
428 q (arg.sparse_complex_matrix_value ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
429 if (vector_p)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
430 retval = ovl (q.Q (economy), q.R (economy), q.E ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
431 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
432 retval = ovl (q.Q (economy), q.R (economy),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
433 q.E_MAT ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
434 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
435 else if (nargout > 1)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
436 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
437 math::sparse_qr<SparseComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
438 q (arg.sparse_complex_matrix_value (), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
439 retval = ovl (q.Q (economy), q.R (economy));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
440 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
441 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
442 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
443 math::sparse_qr<SparseComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
444 q (arg.sparse_complex_matrix_value (), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
445 retval = ovl (q.R (economy));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
446 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
447 }
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
448 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
449 else
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
450 {
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
451 if (have_b && nargout == 1)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
452 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
453 octave_idx_type info;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
454 if (args(1).issparse () && ! args(1).iscomplex ())
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
455 retval = ovl (math::sparse_qr<SparseMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
456 <SparseMatrix, SparseMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
457 (arg.sparse_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
458 args (1).sparse_matrix_value (), info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
459 else if (! args(1).issparse () && args(1).iscomplex ())
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
460 retval = ovl (math::sparse_qr<SparseMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
461 <MArray<Complex>, ComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
462 (arg.sparse_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
463 args (1).complex_matrix_value (), info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
464 else if (! args(1).issparse () && ! args(1).iscomplex ())
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
465 retval = ovl (math::sparse_qr<SparseMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
466 <MArray<double>, Matrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
467 (arg.sparse_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
468 args (1).matrix_value (), info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
469 else if (args(1).issparse () && args(1).iscomplex ())
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
470 retval = ovl (math::sparse_qr<SparseMatrix>::solve
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
471 <SparseComplexMatrix, SparseComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
472 (arg.sparse_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
473 args(1).sparse_complex_matrix_value (),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
474 info));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
475 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
476 error ("qr: b is not valid");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
477 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
478 else if (have_b && nargout == 2)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
479 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
480 math::sparse_qr<SparseMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
481 q (arg.sparse_matrix_value (), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
482 retval = ovl (q.C (args(1).matrix_value (), economy),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
483 q.R (economy));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
484 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
485 else if (have_b && nargout == 3)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
486 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
487 math::sparse_qr<SparseMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
488 q (arg.sparse_matrix_value ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
489 if (vector_p)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
490 retval = ovl (q.C (args(1).matrix_value (), economy),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
491 q.R (economy), q.E ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
492 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
493 retval = ovl (q.C (args(1).matrix_value (), economy),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
494 q.R (economy), q.E_MAT ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
495 }
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
496
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
497 else
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
498 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
499 if (nargout > 2)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
500 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
501 math::sparse_qr<SparseMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
502 q (arg.sparse_matrix_value ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
503 if (vector_p)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
504 retval = ovl (q.Q (economy), q.R (economy), q.E ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
505 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
506 retval = ovl (q.Q (economy), q.R (economy),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
507 q.E_MAT ());
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
508 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
509 else if (nargout > 1)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
510 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
511 math::sparse_qr<SparseMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
512 q (arg.sparse_matrix_value (), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
513 retval = ovl (q.Q (economy), q.R (economy));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
514 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
515 else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
516 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
517 math::sparse_qr<SparseMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
518 q (arg.sparse_matrix_value (), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
519 retval = ovl (q.R (economy));
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
520 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
521 }
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
522 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
523 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
524 else
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
525 {
29328
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
526 if (have_b && nargout > 2)
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
527 error ("qr: too many output arguments for dense A with B");
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
528
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
529 if (arg.is_single_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
530 {
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
531 if (arg.isreal ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
532 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
533 math::qr<FloatMatrix>::type type
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
534 = qr_type<FloatMatrix> (nargout, economy);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
535
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
536 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
537
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
538 switch (nargout)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
539 {
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
540 case 0:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
541 case 1:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
542 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
543 math::qr<FloatMatrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
544 retval = ovl (fact.R ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
545 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
546 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
547
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
548 case 2:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
549 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
550 math::qr<FloatMatrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
551 retval = ovl (fact.Q (), get_qr_r (fact));
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
552 if (have_b)
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
553 {
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
554 if (is_cmplx)
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
555 retval(0) = fact.Q ().transpose ()
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
556 * args(1).float_complex_matrix_value ();
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
557 else
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
558 retval(0) = fact.Q ().transpose ()
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
559 * args(1).float_matrix_value ();
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
560 }
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
561 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
562 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
563
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
564 default:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
565 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
566 math::qrp<FloatMatrix> fact (m, type);
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
567
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
568 if (economy || vector_p)
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
569 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
570 else
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
571 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
572 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
573 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
574 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
575 }
23581
c3075ae020e1 maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents: 23580
diff changeset
576 else if (arg.iscomplex ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
577 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
578 math::qr<FloatComplexMatrix>::type type
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
579 = qr_type<FloatComplexMatrix> (nargout, economy);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
580
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
581 FloatComplexMatrix m = arg.float_complex_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
582
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
583 switch (nargout)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
584 {
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
585 case 0:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
586 case 1:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
587 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
588 math::qr<FloatComplexMatrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
589 retval = ovl (fact.R ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
590 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
591 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
592
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
593 case 2:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
594 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
595 math::qr<FloatComplexMatrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
596 retval = ovl (fact.Q (), get_qr_r (fact));
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
597 if (have_b)
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
598 retval(0) = conj (fact.Q ().transpose ())
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
599 * args(1).float_complex_matrix_value ();
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
600 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
601 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
602
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
603 default:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
604 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
605 math::qrp<FloatComplexMatrix> fact (m, type);
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
606 if (economy || vector_p)
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
607 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
608 else
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
609 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
610 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
611 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
612 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
613 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
614 }
7505
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7491
diff changeset
615 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
616 {
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
617 if (arg.isreal ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
618 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
619 math::qr<Matrix>::type type
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
620 = qr_type<Matrix> (nargout, economy);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
621
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
622 Matrix m = arg.matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
623
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
624 switch (nargout)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
625 {
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
626 case 0:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
627 case 1:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
628 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
629 math::qr<Matrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
630 retval = ovl (fact.R ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
631 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
632 break;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
633
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
634 case 2:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
635 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
636 math::qr<Matrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
637 retval = ovl (fact.Q (), get_qr_r (fact));
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
638 if (have_b)
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
639 {
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
640 if (is_cmplx)
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
641 retval(0) = fact.Q ().transpose ()
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
642 * args(1).complex_matrix_value ();
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
643 else
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
644 retval(0) = fact.Q ().transpose ()
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
645 * args(1).matrix_value ();
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
646 }
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
647 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
648 break;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
649
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
650 default:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
651 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
652 math::qrp<Matrix> fact (m, type);
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
653 if (economy || vector_p)
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
654 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
655 else
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
656 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
657 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
658 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
659 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
660 }
23581
c3075ae020e1 maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents: 23580
diff changeset
661 else if (arg.iscomplex ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
662 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
663 math::qr<ComplexMatrix>::type type
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
664 = qr_type<ComplexMatrix> (nargout, economy);
21279
eb1524b07fe3 better use of templates for qr classes
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
665
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
666 ComplexMatrix m = arg.complex_matrix_value ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
667
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
668 switch (nargout)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
669 {
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
670 case 0:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
671 case 1:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
672 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
673 math::qr<ComplexMatrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
674 retval = ovl (fact.R ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
675 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
676 break;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
677
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
678 case 2:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
679 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
680 math::qr<ComplexMatrix> fact (m, type);
20859
1f4d6b1f50c1 2015 Code Sprint: qr.cc: use ovl().
Rik <rik@octave.org>
parents: 20853
diff changeset
681 retval = ovl (fact.Q (), get_qr_r (fact));
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
682 if (have_b)
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
683 retval(0) = conj (fact.Q ().transpose ())
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
684 * args(1).complex_matrix_value ();
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
685 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
686 break;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7700
diff changeset
687
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
688 default:
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
689 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
690 math::qrp<ComplexMatrix> fact (m, type);
24371
c9d229f1db04 Correctly return economy or standard QR factorization (bug #52593).
Rik <rik@octave.org>
parents: 23803
diff changeset
691 if (economy || vector_p)
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
692 retval = ovl (fact.Q (), get_qr_r (fact), fact.Pvec ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
693 else
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20859
diff changeset
694 retval = ovl (fact.Q (), get_qr_r (fact), fact.P ());
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
695 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20163
diff changeset
696 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
697 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
698 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
699 else
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21041
diff changeset
700 err_wrong_type_arg ("qr", arg);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9758
diff changeset
701 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
702 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
703
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
704 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
705 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
706
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
707 /*
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
708 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
709 %! 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
710 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
711 %! [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
712 %! [qe, re] = qr (a, 0);
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
713 %! [qe2, re2] = qr (a, "econ");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
714 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
715 %! 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
716 %! assert (qe * re, a, sqrt (eps));
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
717 %! assert (qe2 * re2, a, sqrt (eps));
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
718
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
719 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
720 %! 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
721 %!
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
722 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
723 %! [qe, re] = qr (a, 0);
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
724 %! [qe2, re2] = qr (a, "econ");
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
725 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
726 %! assert (q * r, a, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
727 %! assert (qe * re, a, sqrt (eps));
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
728 %! assert (qe2 * re2, a, sqrt (eps));
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
729
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
730 %!test
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
731 %! a = [0, 2, 1; 2, 1, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
732 %!
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
733 %! [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
734 %! [qe, re, pe] = qr (a, 0);
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
735 %! [qe2, re2, pe2] = qr (a, "econ");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
736 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
737 %! 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
738 %! assert (qe * re, a(:, pe), sqrt (eps));
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
739 %! assert (qe2 * re2, a(:, pe2), sqrt (eps));
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
740
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
741 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
742 %! 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
743 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
744 %! [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
745 %! [qe, re] = qr (a, 0);
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
746 %! [qe2, re2] = qr (a, "econ");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
747 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
748 %! 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
749 %! assert (qe * re, a, sqrt (eps));
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
750 %! assert (qe2 * re2, a, sqrt (eps));
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
751
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
752 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
753 %! 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
754 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
755 %! [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
756 %! [qe, re, pe] = qr (a, 0);
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
757 %! [qe2, re2, pe2] = qr (a, "econ");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
758 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
759 %! 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
760 %! assert (qe * re, a(:, pe), sqrt (eps));
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
761 %! assert (qe2 * re2, a(:, pe2), sqrt (eps));
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
762
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
763 %!test
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
764 %! a = [0, 2, 1; 2, 1, 2; 3, 1, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
765 %! b = [1, 3, 2; 1, 1, 0; 3, 0, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
766 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
767 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
768 %! [c, re] = qr (a, b);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
769 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
770 %! assert (r, re, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
771 %! assert (q'*b, c, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
772
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
773 %!test
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
774 %! a = [0, 2, i; 2, 1, 2; 3, 1, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
775 %! b = [1, 3, 2; 1, i, 0; 3, 0, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
776 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
777 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
778 %! [c, re] = qr (a, b);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
779 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
780 %! assert (r, re, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
781 %! assert (q'*b, c, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
782
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
783 %!test
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
784 %! a = [0, 2, i; 2, 1, 2; 3, 1, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
785 %! b = [1, 3, 2; 1, 1, 0; 3, 0, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
786 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
787 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
788 %! [c, re] = qr (a, b);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
789 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
790 %! assert (r, re, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
791 %! assert (q'*b, c, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
792
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
793 %!test
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
794 %! a = [0, 2, 1; 2, 1, 2; 3, 1, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
795 %! b = [1, 3, 2; 1, i, 0; 3, 0, 2];
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
796 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
797 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
798 %! [c, re] = qr (a, b);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
799 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
800 %! assert (r, re, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
801 %! assert (q'*b, c, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
802
22372
0c0de2205d38 utils.h: deprecated out of date arg_is_empty function.
Carnë Draug <carandraug@octave.org>
parents: 22323
diff changeset
803 %!test
0c0de2205d38 utils.h: deprecated out of date arg_is_empty function.
Carnë Draug <carandraug@octave.org>
parents: 22323
diff changeset
804 %! assert (qr (zeros (0, 0)), zeros (0, 0))
0c0de2205d38 utils.h: deprecated out of date arg_is_empty function.
Carnë Draug <carandraug@octave.org>
parents: 22323
diff changeset
805 %! assert (qr (zeros (1, 0)), zeros (1, 0))
0c0de2205d38 utils.h: deprecated out of date arg_is_empty function.
Carnë Draug <carandraug@octave.org>
parents: 22323
diff changeset
806 %! assert (qr (zeros (0, 1)), zeros (0, 1))
0c0de2205d38 utils.h: deprecated out of date arg_is_empty function.
Carnë Draug <carandraug@octave.org>
parents: 22323
diff changeset
807
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
808 %!error qr ()
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
809 %!error qr ([1, 2; 3, 4], 0, 2)
30923
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
810 %!error <option string must be .*, not "foo"> qr (magic (3), "foo")
7ad60a258a2b Allow "econ" argument to qr() function (bug #62277).
Arun Giridhar <arungiridhar@gmail.com>
parents: 30565
diff changeset
811 %!error <option string must be .*, not "foo"> qr (magic (3), rand (3, 1), "foo")
29328
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
812 %!error <too many output arguments for dense A with B>
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
813 %! [q, r, p] = qr (rand (3, 2), rand (3, 1));
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
814 %!error <too many output arguments for dense A with B>
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
815 %! [q, r, p] = qr (rand (3, 2), rand (3, 1), 0);
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
816
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13971
diff changeset
817 %!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
818 %! 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
819 %! retval = 0;
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
820 %! if (nargin == 3)
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
821 %! 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
822 %! 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
823 %! 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
824 %! else
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
825 %! 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
826 %! 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
827 %! if (isvector (p))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
828 %! 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
829 %! 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
830 %! else
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
831 %! 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
832 %! 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
833 %! endif
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
834 %! endif
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13971
diff changeset
835 %!endfunction
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13971
diff changeset
836
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
837 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
838 %! 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
839 %! j = 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
840 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
841 %! 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
842 %! a = rand (5000, 20);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
843 %! [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
844 %! [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
845 %! [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
846 %! [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
847 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
848 %! 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
849 %! [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
850 %! [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
851 %! [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
852 %! [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
853 %! endif
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
854 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
855 %! 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
856 %! [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
857 %! [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
858 %! [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
859 %! [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
860 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
861 %! 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
862 %! [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
863 %! [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
864 %! [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
865 %! [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
866 %!
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
867 %! 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
868 %! [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
869 %! [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
870 %! [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
871 %! [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
872 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
873 %! a = a+1i*eps;
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
874 %! [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
875 %! [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
876 %! [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
877 %! [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
878 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
879 %! 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
880 %! 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
881 %! -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
882 %! 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
883 %! -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
884 %! -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
885 %! -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
886 %! 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
887 %! [q,r] = qr (a);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
888 %!
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
889 %! 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
890
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
891 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
892 %! 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
893 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
894 %! [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
895 %! [qe, re] = qr (a, 0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
896 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
897 %! 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
898 %! 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
899
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
900 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
901 %! 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
902 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
903 %! [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
904 %! [qe, re, pe] = qr (a, 0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
905 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
906 %! 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
907 %! 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
908
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
909 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
910 %! 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
911 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
912 %! [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
913 %! [qe, re] = qr (a, 0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
914 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
915 %! 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
916 %! 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
917
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
918 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
919 %! 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
920 %!
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
921 %! [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
922 %! [qe, re, pe] = qr (a, 0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
923 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
924 %! 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
925 %! 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
926
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
927 %!test
29328
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
928 %! a = single ([0, 2, 1; 2, 1, 2; 3, 1, 2]);
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
929 %! b = single ([1, 3, 2; 1, 1, 0; 3, 0, 2]);
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
930 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
931 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
932 %! [c, re] = qr (a, b);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
933 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
934 %! assert (r, re, sqrt (eps ("single")));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
935 %! assert (q'*b, c, sqrt (eps ("single")));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
936
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
937 %!test
29328
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
938 %! a = single ([0, 2, i; 2, 1, 2; 3, 1, 2]);
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
939 %! b = single ([1, 3, 2; 1, i, 0; 3, 0, 2]);
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
940 %!
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
941 %! [q, r] = qr (a);
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
942 %! [c, re] = qr (a, b);
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
943 %!
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
944 %! assert (r, re, sqrt (eps ("single")));
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
945 %! assert (q'*b, c, sqrt (eps ("single")));
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
946
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
947 %!test
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
948 %! a = single ([0, 2, i; 2, 1, 2; 3, 1, 2]);
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
949 %! b = single ([1, 3, 2; 1, 1, 0; 3, 0, 2]);
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
950 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
951 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
952 %! [c, re] = qr (a, b);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
953 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
954 %! assert (r, re, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
955 %! assert (q'*b, c, sqrt (eps));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
956
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
957 %!test
29328
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
958 %! a = single ([0, 2, 1; 2, 1, 2; 3, 1, 2]);
4d3cfe193f65 qr: Error for dense A and B with three output arguments (bug #58944).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29261
diff changeset
959 %! b = single ([1, 3, 2; 1, i, 0; 3, 0, 2]);
22206
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
960 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
961 %! [q, r] = qr (a);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
962 %! [c, re] = qr (a, b);
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
963 %!
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
964 %! assert (r, re, sqrt (eps ("single")));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
965 %! assert (q'*b, c, sqrt (eps ("single")));
21684fa513ce Return C = Q'*B not Q when qr has two arguments (bug #41567, bug #46912)
mfasi <mogrob.sanit@gmail.com>
parents: 22022
diff changeset
966
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
967 %!test
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
968 %! 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
969 %! j = 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
970 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
971 %! 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
972 %! a = rand (5000,20);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
973 %! [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
974 %! [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
975 %! [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
976 %! [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
977 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
978 %! 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
979 %! [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
980 %! [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
981 %! [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
982 %! [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
983 %! endif
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
984 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
985 %! 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
986 %! [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
987 %! [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
988 %! [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
989 %! [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
990 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
991 %! 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
992 %! [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
993 %! [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
994 %! [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
995 %! [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
996 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
997 %! 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
998 %! [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
999 %! [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
1000 %! [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
1001 %! [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
1002 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1003 %! 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
1004 %! [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
1005 %! [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
1006 %! [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
1007 %! [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
1008 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1009 %! 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
1010 %! 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
1011 %! -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
1012 %! 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
1013 %! -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
1014 %! -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
1015 %! -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
1016 %! 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
1017 %! [q,r] = qr (a);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1018 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1019 %! 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
1020
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1021 ## 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
1022 ## 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
1023
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1024 %!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1025 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1026 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1027 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1028 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1029 %! 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
1030 %! r = qr (a);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1031 %! 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
1032
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1033 %!testif HAVE_COLAMD; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1034 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1035 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1036 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1037 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1038 %! 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
1039 %! 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
1040 %! 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
1041 %! r = qr (a);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1042 %! 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
1043
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1044 %!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1045 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1046 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1047 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1048 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1049 %! 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
1050 %! [c,r] = qr (a, ones (n,1));
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1051 %! 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
1052
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1053 %!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1054 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1055 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1056 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1057 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1058 %! 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
1059 %! b = randn (n,2);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1060 %! [c,r] = qr (a, b);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1061 %! 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
1062
22737
7abc25e6206a maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 22407
diff changeset
1063 ## Test under-determined systems!!
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1064 %!#testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1065 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1066 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1067 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1068 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1069 %! 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
1070 %! b = randn (n,2);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1071 %! [c,r] = qr (a, b);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1072 %! 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
1073
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1074 %!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1075 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1076 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1077 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1078 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1079 %! 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
1080 %! r = qr (a);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1081 %! 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
1082
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1083 %!testif HAVE_COLAMD; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1084 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1085 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1086 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1087 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1088 %! 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
1089 %! 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
1090 %! 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
1091 %! r = qr (a);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1092 %! 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
1093
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1094 %!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1095 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1096 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1097 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1098 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1099 %! 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
1100 %! [c,r] = qr (a, ones (n,1));
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1101 %! 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
1102
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1103 %!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1104 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1105 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1106 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1107 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1108 %! 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
1109 %! b = randn (n,2);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1110 %! [c,r] = qr (a, b);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1111 %! 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
1112
22737
7abc25e6206a maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 22407
diff changeset
1113 ## Test under-determined systems!!
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1114 %!#testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1115 %! n = 20; d = 0.2;
26517
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1116 %! ## initialize generators to make behavior reproducible
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1117 %! rand ("state", 42);
826d4c26e5e2 qr.cc: Fix state of random number generator in BISTs (bug #55421).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
1118 %! randn ("state", 42);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1119 %! a = 1i*sprandn (n,n+1,d) + speye (n,n+1);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1120 %! b = randn (n, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1121 %! [c, r] = qr (a, b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1122 %! assert (r\c, full (a)\b, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1123
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1124 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1125 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1126 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1127 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1128 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1129 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1130 %! b = randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1131 %! [c, r] = qr (a, b);
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
1132 %! 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
1133
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1134 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1135 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1136 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1137 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1138 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1139 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1140 %! b = sprandn (m, 2, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1141 %! [c, r] = qr (a, b, 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1142 %! [c2, r2] = qr (full (a), full (b), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1143 %! assert (r\c, r2\c2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1144
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1145 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1146 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1147 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1148 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1149 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1150 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1151 %! b = randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1152 %! [c, r, p] = qr (a, b, "matrix");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1153 %! x = p * (r\c);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1154 %! [c2, r2] = qr (full (a), b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1155 %! x2 = r2 \ c2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1156 %! assert (x, x2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1157
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1158 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1159 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1160 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1161 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1162 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1163 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1164 %! [q, r, p] = qr (a, "matrix");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1165 %! assert (q * r, a * p, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1166
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1167 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1168 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1169 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1170 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1171 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1172 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1173 %! b = randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1174 %! x = qr (a, b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1175 %! [c2, r2] = qr (full (a), b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1176 %! assert (x, r2\c2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1177
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1178 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1179 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1180 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1181 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1182 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1183 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1184 %! b = i * randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1185 %! x = qr (a, b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1186 %! [c2, r2] = qr (full (a), b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1187 %! assert (x, r2\c2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1188
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1189 %!#testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1190 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1191 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1192 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1193 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1194 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1195 %! b = i * randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1196 %! [c, r] = qr (a, b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1197 %! [c2, r2] = qr (full (a), b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1198 %! assert (r\c, r2\c2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1199
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1200 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1201 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1202 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1203 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1204 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1205 %! a = sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1206 %! b = i * randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1207 %! [c, r, p] = qr (a, b, "matrix");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1208 %! x = p * (r\c);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1209 %! [c2, r2] = qr (full (a), b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1210 %! x2 = r2 \ c2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1211 %! assert (x, x2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1212
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1213 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1214 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1215 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1216 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1217 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1218 %! a = i * sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1219 %! b = sprandn (m, 2, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1220 %! [c, r] = qr (a, b, 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1221 %! [c2, r2] = qr (full (a), full (b), 0);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1222 %! assert (r\c, r2\c2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1223
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1224 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1225 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1226 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1227 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1228 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1229 %! a = i * sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1230 %! b = randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1231 %! [c, r, p] = qr (a, b, "matrix");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1232 %! x = p * (r\c);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1233 %! [c2, r2] = qr (full (a), b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1234 %! x2 = r2 \ c2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1235 %! assert(x, x2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1236
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1237 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1238 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1239 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1240 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1241 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1242 %! a = i * sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1243 %! [q, r, p] = qr (a, "matrix");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1244 %! assert(q * r, a * p, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1245
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1246 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1247 %! n = 12; m = 20; d = 0.2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1248 %! ## initialize generators to make behavior reproducible
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1249 %! rand ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1250 %! randn ("state", 42);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1251 %! a = i * sprandn (m, n, d);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1252 %! b = randn (m, 2);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1253 %! x = qr (a, b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1254 %! [c2, r2] = qr (full (a), b);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1255 %! assert (x, r2\c2, 10e-10);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1256
29267
1db2a57a42c2 qr.cc: Require CHOLMOD for tests that use SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29262
diff changeset
1257 %!testif HAVE_SPQR, HAVE_CHOLMOD
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1258 %! a = sparse (5, 6);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1259 %! a(3,1) = 0.8;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1260 %! a(2,2) = 1.4;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1261 %! a(1,6) = -0.5;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1262 %! r = qr (a);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 28888
diff changeset
1263 %! assert (r'*r, a'*a, 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
1264 */
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7491
diff changeset
1265
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1266 static
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1267 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
1268 bool allow_ecf = false)
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1269 {
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
1270 octave_idx_type m = q.rows ();
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
1271 octave_idx_type k = r.rows ();
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
1272 octave_idx_type n = r.columns ();
8798
53f8fca6dd69 fix typo in qr.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 8597
diff changeset
1273 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
1274 && (m == k || (allow_ecf && k == n && k < m)));
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1275 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1276
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1277 static
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1278 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
1279 {
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
1280 return ((i.isreal () || i.isinteger ())
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1281 && (i.is_scalar_type () || vector_allowed));
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1282 }
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1283
28024
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1284 DEFUN (qrupdate, args, ,
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1285 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1286 @deftypefn {} {[@var{Q1}, @var{R1}] =} qrupdate (@var{Q}, @var{R}, @var{u}, @var{v})
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1287 Update a QR factorization given update vectors or matrices.
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1288
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1289 Given a QR@tie{}factorization of a real or complex matrix
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1290 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1291 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1292 @w{@var{A} + @var{u}*@var{v}'}, where @var{u} and @var{v} are column vectors
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1293 (rank-1 update) or matrices with equal number of columns
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1294 (rank-k update). Notice that the latter case is done as a sequence of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1295 rank-1 updates; thus, for k large enough, it will be both faster and more
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1296 accurate to recompute the factorization from scratch.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1297
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1298 The QR@tie{}factorization supplied may be either full (Q is square) or
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1299 economized (R is square).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1300
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1301 @seealso{qr, qrinsert, qrdelete, qrshift}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1302 @end deftypefn */)
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1303 {
20812
d9ca869ca124 maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents: 20790
diff changeset
1304 octave_value_list retval;
d9ca869ca124 maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents: 20790
diff changeset
1305
20818
cef0448a6ed2 eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20816
diff changeset
1306 if (args.length () != 4)
20790
c2d9556d51d0 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
1307 print_usage ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1308
7559
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1309 octave_value argq = args(0);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1310 octave_value argr = args(1);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1311 octave_value argu = args(2);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1312 octave_value argv = args(3);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1313
23586
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23583
diff changeset
1314 if (! argq.isnumeric () || ! argr.isnumeric ()
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23583
diff changeset
1315 || ! argu.isnumeric () || ! argv.isnumeric ())
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1316 print_usage ();
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1317
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1318 if (! check_qr_dims (argq, argr, true))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1319 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
1320
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
1321 if (argq.isreal () && argr.isreal () && argu.isreal ()
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
1322 && argv.isreal ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1323 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1324 // all real case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1325 if (argq.is_single_type () || argr.is_single_type ()
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1326 || argu.is_single_type () || argv.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1327 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1328 FloatMatrix Q = argq.float_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1329 FloatMatrix R = argr.float_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1330 FloatMatrix u = argu.float_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1331 FloatMatrix v = argv.float_matrix_value ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1332
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1333 math::qr<FloatMatrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1334 fact.update (u, v);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1335
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1336 retval = ovl (fact.Q (), get_qr_r (fact));
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1337 }
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1338 else
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1339 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1340 Matrix Q = argq.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1341 Matrix R = argr.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1342 Matrix u = argu.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1343 Matrix v = argv.matrix_value ();
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1344
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1345 math::qr<Matrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1346 fact.update (u, v);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1347
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1348 retval = ovl (fact.Q (), get_qr_r (fact));
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1349 }
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1350 }
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1351 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1352 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1353 // complex case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1354 if (argq.is_single_type () || argr.is_single_type ()
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1355 || argu.is_single_type () || argv.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1356 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1357 FloatComplexMatrix Q = argq.float_complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1358 FloatComplexMatrix R = argr.float_complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1359 FloatComplexMatrix u = argu.float_complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1360 FloatComplexMatrix v = argv.float_complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1361
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1362 math::qr<FloatComplexMatrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1363 fact.update (u, v);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1364
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1365 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1366 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1367 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1368 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1369 ComplexMatrix Q = argq.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1370 ComplexMatrix R = argr.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1371 ComplexMatrix u = argu.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1372 ComplexMatrix v = argv.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1373
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1374 math::qr<ComplexMatrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1375 fact.update (u, v);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1376
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1377 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1378 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1379 }
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1380
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1381 return retval;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1382 }
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1383
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1384 /*
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1385 %!shared A, u, v, Ac, uc, vc
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1386 %! A = [0.091364 0.613038 0.999083;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1387 %! 0.594638 0.425302 0.603537;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1388 %! 0.383594 0.291238 0.085574;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1389 %! 0.265712 0.268003 0.238409;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1390 %! 0.669966 0.743851 0.445057 ];
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1391 %!
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1392 %! u = [0.85082;
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1393 %! 0.76426;
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1394 %! 0.42883;
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1395 %! 0.53010;
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1396 %! 0.80683 ];
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1397 %!
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1398 %! v = [0.98810;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1399 %! 0.24295;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1400 %! 0.43167 ];
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1401 %!
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1402 %! 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
1403 %! 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
1404 %! 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
1405 %! 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
1406 %! 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
1407 %!
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1408 %! 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
1409 %! 0.13141 + 0.43708i;
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1410 %! 0.29808 + 0.08789i;
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1411 %! 0.69821 + 0.38844i;
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1412 %! 0.74871 + 0.25821i ];
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1413 %!
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1414 %! 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
1415 %! 0.20820 + 0.93090i;
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1416 %! 0.86184 + 0.34689i ];
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1417 %!
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1418
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1419 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1420 %! [Q,R] = qr (A);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1421 %! [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
1422 %! 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
1423 %! 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
1424 %! 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
1425 %!
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1426 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1427 %! [Q,R] = qr (Ac);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1428 %! [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
1429 %! 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
1430 %! assert (norm (vec (triu (R)-R), Inf) == 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1431 %! assert (norm (vec (Q*R - 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
1432
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1433 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1434 %! [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
1435 %! [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
1436 %! 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
1437 %! assert (norm (vec (triu (R)-R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1438 %! assert (norm (vec (Q*R - single (A) - single (u)*single (v)'), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1439 %! < norm (single (A))*1e1*eps ("single"));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1440 %!
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1441 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1442 %! [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
1443 %! [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
1444 %! 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
1445 %! assert (norm (vec (triu (R)-R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1446 %! assert (norm (vec (Q*R - single (Ac) - single (uc)*single (vc)'), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1447 %! < norm (single (Ac))*1e1*eps ("single"));
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1448 */
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1449
28024
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1450 DEFUN (qrinsert, args, ,
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1451 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1452 @deftypefn {} {[@var{Q1}, @var{R1}] =} qrinsert (@var{Q}, @var{R}, @var{j}, @var{x}, @var{orient})
26046
ff0aa19333c9 doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents: 25113
diff changeset
1453 Update a QR factorization given a row or column to insert in the original
ff0aa19333c9 doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents: 25113
diff changeset
1454 factored matrix.
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1455
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1456
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1457 Given a QR@tie{}factorization of a real or complex matrix
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1458 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1459 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1460 @w{[A(:,1:j-1) x A(:,j:n)]}, where @var{u} is a column vector to be inserted
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1461 into @var{A} (if @var{orient} is @qcode{"col"}), or the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1462 QR@tie{}factorization of @w{[A(1:j-1,:);x;A(:,j:n)]}, where @var{x} is a row
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1463 vector to be inserted into @var{A} (if @var{orient} is @qcode{"row"}).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1464
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1465 The default value of @var{orient} is @qcode{"col"}. If @var{orient} is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1466 @qcode{"col"}, @var{u} may be a matrix and @var{j} an index vector
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1467 resulting in the QR@tie{}factorization of a matrix @var{B} such that
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1468 @w{B(:,@var{j})} gives @var{u} and @w{B(:,@var{j}) = []} gives @var{A}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1469 Notice that the latter case is done as a sequence of k insertions;
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1470 thus, for k large enough, it will be both faster and more accurate to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1471 recompute the factorization from scratch.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1472
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1473 If @var{orient} is @qcode{"col"}, the QR@tie{}factorization supplied may
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1474 be either full (Q is square) or economized (R is square).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1475
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1476 If @var{orient} is @qcode{"row"}, full factorization is needed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1477 @seealso{qr, qrupdate, qrdelete, qrshift}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1478 @end deftypefn */)
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1479 {
20816
b16bcd7a2a33 Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents: 20812
diff changeset
1480 int nargin = args.length ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1481
7559
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1482 if (nargin < 4 || nargin > 5)
20790
c2d9556d51d0 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
1483 print_usage ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1484
7559
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1485 octave_value argq = args(0);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1486 octave_value argr = args(1);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1487 octave_value argj = args(2);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1488 octave_value argx = args(3);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1489
23586
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23583
diff changeset
1490 if (! argq.isnumeric () || ! argr.isnumeric ()
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23583
diff changeset
1491 || ! argx.isnumeric ()
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1492 || (nargin > 4 && ! args(4).is_string ()))
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1493 print_usage ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1494
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1495 std::string orient = (nargin < 5) ? "col" : args(4).string_value ();
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1496 bool col = (orient == "col");
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1497
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1498 if (! col && orient != "row")
23803
90689bdbe048 Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents: 23593
diff changeset
1499 error (R"(qrinsert: ORIENT must be "col" or "row")");
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1500
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1501 if (! check_qr_dims (argq, argr, col) || (! col && argx.rows () != 1))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1502 error ("qrinsert: dimension mismatch");
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1503
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1504 if (! check_index (argj, col))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1505 error ("qrinsert: invalid index J");
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1506
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1507 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1508
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1509 MArray<octave_idx_type> j = argj.octave_idx_type_vector_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1510
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1511 octave_idx_type one = 1;
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1512
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
1513 if (argq.isreal () && argr.isreal () && argx.isreal ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1514 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1515 // real case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1516 if (argq.is_single_type () || argr.is_single_type ()
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1517 || argx.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1518 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1519 FloatMatrix Q = argq.float_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1520 FloatMatrix R = argr.float_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1521 FloatMatrix x = argx.float_matrix_value ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1522
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1523 math::qr<FloatMatrix> fact (Q, R);
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1524
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1525 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1526 fact.insert_col (x, j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1527 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1528 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
1529
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1530 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1531 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1532 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1533 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1534 Matrix Q = argq.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1535 Matrix R = argr.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1536 Matrix x = argx.matrix_value ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1537
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1538 math::qr<Matrix> fact (Q, R);
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1539
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1540 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1541 fact.insert_col (x, j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1542 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1543 fact.insert_row (x.row (0), j(0)-one);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1544
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1545 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1546 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1547 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1548 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1549 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1550 // complex case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1551 if (argq.is_single_type () || argr.is_single_type ()
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1552 || argx.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1553 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26517
diff changeset
1554 FloatComplexMatrix Q = argq.float_complex_matrix_value ();
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26517
diff changeset
1555 FloatComplexMatrix R = argr.float_complex_matrix_value ();
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26517
diff changeset
1556 FloatComplexMatrix x = argx.float_complex_matrix_value ();
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1557
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1558 math::qr<FloatComplexMatrix> fact (Q, R);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1559
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1560 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1561 fact.insert_col (x, j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1562 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1563 fact.insert_row (x.row (0), j(0)-one);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1564
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1565 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1566 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1567 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1568 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1569 ComplexMatrix Q = argq.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1570 ComplexMatrix R = argr.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1571 ComplexMatrix x = argx.complex_matrix_value ();
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1572
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1573 math::qr<ComplexMatrix> fact (Q, R);
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1574
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1575 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1576 fact.insert_col (x, j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1577 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1578 fact.insert_row (x.row (0), j(0)-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1579
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1580 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1581 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1582 }
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1583
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1584 return retval;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1585 }
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1586
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1587 /*
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
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 %! [Q,R] = qr (A);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1590 %! [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
1591 %! 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
1592 %! 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
1593 %! 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
1594 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1595 %! [Q,R] = qr (Ac);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1596 %! [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
1597 %! 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
1598 %! 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
1599 %! 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
1600 %!test
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1601 %! x = [0.85082 0.76426 0.42883 ];
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1602 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1603 %! [Q,R] = qr (A);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1604 %! [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
1605 %! 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
1606 %! 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
1607 %! 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
1608 %!test
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1609 %! 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
1610 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1611 %! [Q,R] = qr (Ac);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1612 %! [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
1613 %! 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
1614 %! 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
1615 %! 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
1616
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1617 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1618 %! [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
1619 %! [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
1620 %! 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
1621 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1622 %! assert (norm (vec (Q*R - single ([A(:,1:2) u A(:,3)])), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1623 %! < 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
1624 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1625 %! [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
1626 %! [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
1627 %! 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
1628 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1629 %! assert (norm (vec (Q*R - single ([Ac(:,1:2) uc Ac(:,3)])), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1630 %! < 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
1631 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1632 %! 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
1633 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1634 %! [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
1635 %! [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
1636 %! 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
1637 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30402
1ef9fca2db06 maint: strip trailing spaces from codebase.
Rik <rik@octave.org>
parents: 30357
diff changeset
1638 %! assert (norm (vec (Q*R - single ([A(1:2,:);x;A(3:5,:)])), Inf)
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1639 %! < 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
1640 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1641 %! 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
1642 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1643 %! [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
1644 %! [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
1645 %! 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
1646 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1647 %! assert (norm (vec (Q*R - single ([Ac(1:2,:);x;Ac(3:5,:)])), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1648 %! < norm (single (Ac))*1e1*eps ("single"));
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1649 */
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1650
28024
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1651 DEFUN (qrdelete, args, ,
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1652 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1653 @deftypefn {} {[@var{Q1}, @var{R1}] =} qrdelete (@var{Q}, @var{R}, @var{j}, @var{orient})
26046
ff0aa19333c9 doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents: 25113
diff changeset
1654 Update a QR factorization given a row or column to delete from the original
ff0aa19333c9 doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents: 25113
diff changeset
1655 factored matrix.
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1656
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1657 Given a QR@tie{}factorization of a real or complex matrix
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1658 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1659 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
1660 @w{[A(:,1:j-1), U, A(:,j:n)]},
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
1661 where @var{u} is a column vector to be inserted into @var{A}
22272
1c840b2fd337 doc: Don't escape " within @qcode macro (bug #48722).
Rik <rik@octave.org>
parents: 22209
diff changeset
1662 (if @var{orient} is @qcode{"col"}),
22207
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
1663 or the QR@tie{}factorization of @w{[A(1:j-1,:);X;A(:,j:n)]},
99454a60bf5e Reconcile qr docs with behaviour. Fix qr(A,B,complex(0)). (bug #46912)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22206
diff changeset
1664 where @var{x} is a row @var{orient} is @qcode{"row"}).
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1665 The default value of @var{orient} is @qcode{"col"}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1666
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1667 If @var{orient} is @qcode{"col"}, @var{j} may be an index vector
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1668 resulting in the QR@tie{}factorization of a matrix @var{B} such that
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1669 @w{A(:,@var{j}) = []} gives @var{B}. Notice that the latter case is done as
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1670 a sequence of k deletions; thus, for k large enough, it will be both faster
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1671 and more accurate to recompute the factorization from scratch.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1672
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1673 If @var{orient} is @qcode{"col"}, the QR@tie{}factorization supplied may
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1674 be either full (Q is square) or economized (R is square).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1675
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1676 If @var{orient} is @qcode{"row"}, full factorization is needed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1677 @seealso{qr, qrupdate, qrinsert, qrshift}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1678 @end deftypefn */)
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1679 {
20816
b16bcd7a2a33 Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents: 20812
diff changeset
1680 int nargin = args.length ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1681
7559
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1682 if (nargin < 3 || nargin > 4)
20790
c2d9556d51d0 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
1683 print_usage ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1684
7559
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1685 octave_value argq = args(0);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1686 octave_value argr = args(1);
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1687 octave_value argj = args(2);
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1688
23586
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23583
diff changeset
1689 if (! argq.isnumeric () || ! argr.isnumeric ()
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1690 || (nargin > 3 && ! args(3).is_string ()))
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1691 print_usage ();
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1692
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1693 std::string orient = (nargin < 4) ? "col" : args(3).string_value ();
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1694 bool col = orient == "col";
7559
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
1695
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1696 if (! col && orient != "row")
23803
90689bdbe048 Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents: 23593
diff changeset
1697 error (R"(qrdelete: ORIENT must be "col" or "row")");
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1698
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1699 if (! check_qr_dims (argq, argr, col))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1700 error ("qrdelete: dimension mismatch");
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8517
diff changeset
1701
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1702 MArray<octave_idx_type> j = argj.octave_idx_type_vector_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1703 if (! check_index (argj, col))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1704 error ("qrdelete: invalid index J");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1705
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1706 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1707
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1708 octave_idx_type one = 1;
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1709
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
1710 if (argq.isreal () && argr.isreal ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1711 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1712 // real case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1713 if (argq.is_single_type () || argr.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1714 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1715 FloatMatrix Q = argq.float_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1716 FloatMatrix R = argr.float_matrix_value ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1717
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1718 math::qr<FloatMatrix> fact (Q, R);
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1719
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1720 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1721 fact.delete_col (j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1722 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1723 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
1724
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1725 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1726 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1727 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1728 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1729 Matrix Q = argq.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1730 Matrix R = argr.matrix_value ();
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1731
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1732 math::qr<Matrix> fact (Q, R);
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1733
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1734 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1735 fact.delete_col (j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1736 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1737 fact.delete_row (j(0)-one);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1738
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1739 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1740 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1741 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1742 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1743 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1744 // complex case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1745 if (argq.is_single_type () || argr.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1746 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26517
diff changeset
1747 FloatComplexMatrix Q = argq.float_complex_matrix_value ();
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26517
diff changeset
1748 FloatComplexMatrix R = argr.float_complex_matrix_value ();
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1749
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1750 math::qr<FloatComplexMatrix> fact (Q, R);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1751
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1752 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1753 fact.delete_col (j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1754 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1755 fact.delete_row (j(0)-one);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1756
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1757 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1758 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1759 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1760 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1761 ComplexMatrix Q = argq.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1762 ComplexMatrix R = argr.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1763
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1764 math::qr<ComplexMatrix> fact (Q, R);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1765
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1766 if (col)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1767 fact.delete_col (j-one);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1768 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1769 fact.delete_row (j(0)-one);
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1770
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1771 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1772 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1773 }
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1774
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1775 return retval;
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1776 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1777
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1778 /*
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1779 %!test
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1780 %! 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
1781 %! 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
1782 %! 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
1783 %! 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
1784 %! 0.669966 0.743851 0.457255 0.445057 ];
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1785 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1786 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1787 %! [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
1788 %! 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
1789 %! 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
1790 %! 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
1791 %!
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1792 %!test
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1793 %! 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
1794 %! 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
1795 %! 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
1796 %! 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
1797 %! 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
1798 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1799 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1800 %! [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
1801 %! 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
1802 %! 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
1803 %! 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
1804 %!
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1805 %!test
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1806 %! 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
1807 %! 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
1808 %! 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
1809 %! 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
1810 %! 0.669966 0.743851 0.457255 0.445057 ];
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1811 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1812 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1813 %! [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
1814 %! 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
1815 %! 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
1816 %! 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
1817 %!
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1818 %!test
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1819 %! 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
1820 %! 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
1821 %! 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
1822 %! 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
1823 %! 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
1824 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1825 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1826 %! [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
1827 %! 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
1828 %! 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
1829 %! 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
1830
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1831 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1832 %! 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
1833 %! 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
1834 %! 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
1835 %! 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
1836 %! 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
1837 %!
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1838 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1839 %! [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
1840 %! 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
1841 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1842 %! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1843 %! < 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
1844 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1845 %!test
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1846 %! 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
1847 %! 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
1848 %! 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
1849 %! 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
1850 %! 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
1851 %!
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1852 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1853 %! [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
1854 %! 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
1855 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1856 %! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1857 %! < norm (AA)*1e1*eps ("single"));
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1858
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1859 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1860 %! 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
1861 %! 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
1862 %! 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
1863 %! 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
1864 %! 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
1865 %!
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1866 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1867 %! [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
1868 %! 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
1869 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1870 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1871 %! < norm (AA)*1e1*eps ("single"));
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1872 %!testif HAVE_QRUPDATE
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
1873 %! ## 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
1874 %! 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
1875 %! 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
1876 %! 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
1877 %! 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
1878 %! 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
1879 %!
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1880 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1881 %! [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
1882 %! 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
1883 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1884 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1885 %! < norm (AA)*1e1*eps ("single"));
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1886 %!
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1887 %!test
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1888 %! 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
1889 %! 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
1890 %! 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
1891 %! 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
1892 %! 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
1893 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1894 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1895 %! [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
1896 %! 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
1897 %! assert (norm (vec (triu (R) - R), Inf) == 0);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1898 %! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf)
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
1899 %! < norm (AA)*1e1*eps ("single"));
7553
56be6f31dd4e implementation of QR factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7505
diff changeset
1900 */
7505
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7491
diff changeset
1901
28024
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1902 DEFUN (qrshift, args, ,
c28b8ba841fb move sparse functions from dldfcn to corefcn directory (bug #57459)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
1903 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1904 @deftypefn {} {[@var{Q1}, @var{R1}] =} qrshift (@var{Q}, @var{R}, @var{i}, @var{j})
26046
ff0aa19333c9 doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents: 25113
diff changeset
1905 Update a QR factorization given a range of columns to shift in the original
ff0aa19333c9 doc: grammarcheck C++ files in libinterp/ directory.
Rik <rik@octave.org>
parents: 25113
diff changeset
1906 factored matrix.
25113
476fc012d09a doc: Shorten very long first sentences of docstrings (bug #53388).
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1907
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1908 Given a QR@tie{}factorization of a real or complex matrix
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1909 @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1910 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1911 of @w{@var{A}(:,p)}, where @w{p} is the permutation @*
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1912 @code{p = [1:i-1, shift(i:j, 1), j+1:n]} if @w{@var{i} < @var{j}} @*
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1913 or @*
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1914 @code{p = [1:j-1, shift(j:i,-1), i+1:n]} if @w{@var{j} < @var{i}}. @*
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1915
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1916 @seealso{qr, qrupdate, qrinsert, qrdelete}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1917 @end deftypefn */)
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1918 {
20818
cef0448a6ed2 eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20816
diff changeset
1919 if (args.length () != 4)
20790
c2d9556d51d0 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
1920 print_usage ();
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1921
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1922 octave_value argq = args(0);
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1923 octave_value argr = args(1);
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1924 octave_value argi = args(2);
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1925 octave_value argj = args(3);
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1926
23586
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23583
diff changeset
1927 if (! argq.isnumeric () || ! argr.isnumeric ())
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1928 print_usage ();
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1929
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1930 if (! check_qr_dims (argq, argr, true))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1931 error ("qrshift: dimensions mismatch");
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1932
21041
63374982750b Usage of corresponding value extractor for octave_idx_type. Improves support
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20940
diff changeset
1933 octave_idx_type i = argi.idx_type_value ();
63374982750b Usage of corresponding value extractor for octave_idx_type. Improves support
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20940
diff changeset
1934 octave_idx_type j = argj.idx_type_value ();
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1935
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1936 if (! check_index (argi) || ! check_index (argj))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1937 error ("qrshift: invalid index I or J");
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1938
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1939 octave_value_list retval;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1940
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23581
diff changeset
1941 if (argq.isreal () && argr.isreal ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1942 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1943 // all real case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1944 if (argq.is_single_type ()
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1945 && argr.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1946 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1947 FloatMatrix Q = argq.float_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1948 FloatMatrix R = argr.float_matrix_value ();
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1949
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1950 math::qr<FloatMatrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1951 fact.shift_cols (i-1, j-1);
20851
0828bf20d105 maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20818
diff changeset
1952
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1953 retval = ovl (fact.Q (), get_qr_r (fact));
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1954 }
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1955 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1956 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1957 Matrix Q = argq.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1958 Matrix R = argr.matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1959
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1960 math::qr<Matrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1961 fact.shift_cols (i-1, j-1);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1962
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1963 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1964 }
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1965 }
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1966 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1967 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1968 // complex case
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1969 if (argq.is_single_type ()
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1970 && argr.is_single_type ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1971 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1972 FloatComplexMatrix Q = argq.float_complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1973 FloatComplexMatrix R = argr.float_complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1974
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1975 math::qr<FloatComplexMatrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1976 fact.shift_cols (i-1, j-1);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1977
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1978 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1979 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1980 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1981 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1982 ComplexMatrix Q = argq.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1983 ComplexMatrix R = argr.complex_matrix_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1984
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1985 math::qr<ComplexMatrix> fact (Q, R);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1986 fact.shift_cols (i-1, j-1);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1987
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1988 retval = ovl (fact.Q (), get_qr_r (fact));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1989 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
1990 }
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1991
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1992 return retval;
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1993 }
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1994
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1995 /*
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
1996 %!test
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
1997 %! AA = A.';
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1998 %! 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
1999 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2000 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2001 %! [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
2002 %! 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
2003 %! 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
2004 %! 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
2005 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2006 %! 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
2007 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2008 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2009 %! [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
2010 %! 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
2011 %! 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
2012 %! 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
2013 %!
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
2014 %!test
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
2015 %! AA = Ac.';
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2016 %! 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
2017 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2018 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2019 %! [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
2020 %! 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
2021 %! 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
2022 %! 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
2023 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2024 %! 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
2025 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2026 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2027 %! [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
2028 %! 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
2029 %! 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
2030 %! 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
2031
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7650
diff changeset
2032 %!test
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
2033 %! AA = single (A).';
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2034 %! 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
2035 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2036 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2037 %! [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
2038 %! 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
2039 %! 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
2040 %! 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
2041 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2042 %! 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
2043 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2044 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2045 %! [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
2046 %! 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
2047 %! 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
2048 %! 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
2049 %!
7886
e3e94982dfd4 Convert qrshift, qrinsert, qrdelete, qrupdate to allow single precision arguments
David Bateman <dbateman@free.fr>
parents: 7814
diff changeset
2050 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2051 %! AA = single (Ac).';
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2052 %! 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
2053 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2054 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2055 %! [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
2056 %! 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
2057 %! 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
2058 %! 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
2059 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2060 %! 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
2061 %!
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2062 %! [Q,R] = qr (AA);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
2063 %! [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
2064 %! 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
2065 %! 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
2066 %! 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
2067 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
2068
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
2069 OCTAVE_NAMESPACE_END