annotate src/DLD-FUNCTIONS/mgorth.cc @ 13141:e81ddf9cacd5

maint: untabify and remove trailing whitespace from source files * bicg.m, gmres.m, pkg.m: Untabify and remove trailing whitespace. * libcruft/Makefile.am, libcruft/blas-xtra/cdotc3.f, libcruft/blas-xtra/cmatm3.f, libcruft/blas-xtra/ddot3.f, libcruft/blas-xtra/dmatm3.f, libcruft/blas-xtra/sdot3.f, libcruft/blas-xtra/smatm3.f, libcruft/blas-xtra/zdotc3.f, libcruft/blas-xtra/zmatm3.f, libcruft/lapack-xtra/crsf2csf.f, libcruft/lapack-xtra/zrsf2csf.f, liboctave/Array.cc, liboctave/DASPK-opts.in, liboctave/DASRT-opts.in, liboctave/DASSL-opts.in, liboctave/LSODE-opts.in, liboctave/Makefile.a,mliboctave/Quad-opts.in, liboctave/Sparse-perm-op-defs.h, scripts/Makefile.a,mscripts/deprecated/glpkmex.m, scripts/general/blkdiag.m, scripts/general/interp1.m, scripts/general/profshow.m, scripts/general/quadl.m, scripts/general/triplequad.m, scripts/help/__makeinfo__.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/linear-algebra/rank.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/private/__xzip__.m, scripts/miscellaneous/tempdir.m, scripts/miscellaneous/unpack.m, scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/cla.m, scripts/plot/clf.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/gca.m, scripts/plot/gcf.m, scripts/plot/hggroup.m, scripts/plot/isfigure.m, scripts/plot/ishghandle.m, scripts/plot/legend.m, scripts/plot/line.m, scripts/plot/loglog.m, scripts/plot/patch.m, scripts/plot/print.m, scripts/plot/private/__quiver__.m, scripts/plot/private/__scatter__.m, scripts/plot/rectangle.m, scripts/plot/semilogx.m, scripts/plot/semilogy.m, scripts/plot/surface.m, scripts/plot/text.m, scripts/plot/title.m, scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/whitebg.m, scripts/plot/xlabel.m, scripts/plot/xlim.m, scripts/plot/ylabel.m, scripts/plot/ylim.m, scripts/plot/zlabel.m, scripts/plot/zlim.m, scripts/polynomial/mkpp.m, scripts/polynomial/polygcd.m, scripts/polynomial/ppint.m, scripts/polynomial/ppjumps.m, scripts/polynomial/ppval.m, scripts/set/setxor.m, scripts/sparse/bicgstab.m, scripts/sparse/cgs.m, scripts/sparse/spconvert.m, scripts/specfun/nthroot.m, scripts/strings/strmatch.m, scripts/strings/untabify.m, scripts/testfun/demo.m, scripts/testfun/example.m, src/DLD-FUNCTIONS/filter.cc, src/DLD-FUNCTIONS/mgorth.cc, src/DLD-FUNCTIONS/quadcc.cc, src/DLD-FUNCTIONS/str2double.cc, src/Makefile.a,msrc/gl-render.cc, src/gl2ps-renderer.cc, src/graphics.cc, src/octave-config.cc.in, src/octave-config.in, src/ov-class.h, src/ov-fcn.h, src/profiler.cc, src/profiler.h, src/pt-binop.cc, src/pt-unop.cc, src/symtab.cc, src/txt-eng-ft.cc: Remove trailing whitespace.
author John W. Eaton <jwe@octave.org>
date Thu, 15 Sep 2011 12:51:10 -0400
parents e742720c5e71
children 72c96de7a403
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12509
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
1 /*
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
2
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
3 Copyright (C) 2009-2011 Carlo de Falco
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
4 Copyright (C) 2010 VZLU Prague
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
5
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
6 This file is part of Octave.
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
7
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
11 option) any later version.
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
12
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
16 for more details.
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
17
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>.
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
21
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
22 */
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
23
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
25 #include <config.h>
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
26 #endif
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
27
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
28 #include "oct-norm.h"
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
29 #include "defun-dld.h"
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
30 #include "error.h"
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
31 #include "gripes.h"
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
32
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
33 template <class ColumnVector, class Matrix, class RowVector>
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12509
diff changeset
34 static void
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12509
diff changeset
35 do_mgorth (ColumnVector& x, const Matrix& V, RowVector& h)
12509
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
36 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
37 octave_idx_type Vc = V.columns ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
38 h = RowVector (Vc + 1);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
39 for (octave_idx_type j = 0; j < Vc; j++)
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
40 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
41 ColumnVector Vcj = V.column (j);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
42 h(j) = RowVector (Vcj.hermitian ()) * x;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
43 x -= h(j) * Vcj;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
44 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
45
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
46 h(Vc) = xnorm (x);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
47 if (real (h(Vc)) > 0)
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
48 x = x / h(Vc);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
49 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
50
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
51 DEFUN_DLD (mgorth, args, nargout,
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
52 "-*- texinfo -*-\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
53 @deftypefn {Loadable Function} {[@var{y}, @var{h}] =} mgorth (@var{x}, @var{v})\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
54 Orthogonalize a given column vector @var{x} with respect to a given\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
55 orthonormal basis @var{v} using a modified Gram-Schmidt orthogonalization. \n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
56 On exit, @var{y} is a unit vector such that:\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
57 \n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
58 @example\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
59 @group\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
60 norm (@var{y}) = 1\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
61 @var{v}' * @var{y} = 0\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
62 @var{x} = @var{h}*[@var{v}, @var{y}]\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
63 @end group\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
64 @end example\n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
65 \n\
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
66 @end deftypefn")
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
67 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
68 octave_value_list retval;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
69
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
70 int nargin = args.length();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
71
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
72 if (nargin != 2 || nargout > 2)
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
73 {
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12509
diff changeset
74 print_usage ();
12509
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
75 return retval;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
76 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
77
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
78 octave_value arg_x = args(0);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
79 octave_value arg_v = args(1);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
80
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
81 if (arg_v.ndims () != 2 || arg_x.ndims () != 2 || arg_x.columns () != 1
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
82 || arg_v.rows () != arg_x.rows ())
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
83 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
84 error ("mgorth: V should me a matrix, and X a column vector with"
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
85 " the same number of rows as V.");
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
86 return retval;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
87 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
88
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
89 if (! arg_x.is_numeric_type () && ! arg_v.is_numeric_type ())
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
90 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
91 error ("mgorth: X and V must be numeric");
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
92 }
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12509
diff changeset
93
12509
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
94 bool iscomplex = (arg_x.is_complex_type () || arg_v.is_complex_type ());
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
95 if (arg_x.is_single_type () || arg_v.is_single_type ())
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
96 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
97 if (iscomplex)
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
98 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
99 FloatComplexColumnVector x = arg_x.float_complex_column_vector_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
100 FloatComplexMatrix V = arg_v.float_complex_matrix_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
101 FloatComplexRowVector h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
102 do_mgorth (x, V, h);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
103 retval(1) = h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
104 retval(0) = x;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
105 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
106 else
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
107 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
108 FloatColumnVector x = arg_x.float_column_vector_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
109 FloatMatrix V = arg_v.float_matrix_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
110 FloatRowVector h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
111 do_mgorth (x, V, h);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
112 retval(1) = h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
113 retval(0) = x;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
114 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
115 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
116 else
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
117 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
118 if (iscomplex)
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
119 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
120 ComplexColumnVector x = arg_x.complex_column_vector_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
121 ComplexMatrix V = arg_v.complex_matrix_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
122 ComplexRowVector h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
123 do_mgorth (x, V, h);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
124 retval(1) = h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
125 retval(0) = x;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
126 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
127 else
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
128 {
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
129 ColumnVector x = arg_x.column_vector_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
130 Matrix V = arg_v.matrix_value ();
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
131 RowVector h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
132 do_mgorth (x, V, h);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
133 retval(1) = h;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
134 retval(0) = x;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
135 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
136 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
137
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
138 return retval;
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
139 }
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
140
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
141 /*
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12509
diff changeset
142
12509
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
143 %!test
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
144 %! for ii=1:100; assert (abs (mgorth (randn (5, 1), eye (5, 4))), [0 0 0 0 1]', eps); endfor
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
145
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
146 %!test
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
147 %! a = hilb (5);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
148 %! a(:, 1) /= norm (a(:, 1));
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
149 %! for ii = 1:5
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
150 %! a(:, ii) = mgorth (a(:, ii), a(:, 1:ii-1));
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
151 %! endfor
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
152 %! assert (a' * a, eye (5), 1e10);
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
153
e742720c5e71 Add mgorth and gmres functions from Octave Forge
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
154 */