annotate libinterp/dldfcn/qr.cc @ 17281:bc924baa2c4e

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