1 ## Copyright (C) 1994-2012 John W. Eaton
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} orth (@var{A})
21 ## @deftypefnx {Function File} {} orth (@var{A}, @var{tol})
22 ## Return an orthonormal basis of the range space of @var{A}.
24 ## The dimension of the range space is taken as the number of singular
25 ## values of @var{A} greater than @var{tol}. If the argument @var{tol} is
26 ## missing, it is computed as
29 ## max (size (@var{A})) * max (svd (@var{A})) * eps
34 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
35 ## Created: 24 December 1993.
38 function retval = orth (A, tol)
40 if (nargin == 1 || nargin == 2)
49 [rows, cols] = size (A);
51 [S_nr, S_nc] = size (S);
53 if (S_nr == 1 || S_nc == 1)
60 if (isa (A, "single"))
61 tol = max (size (A)) * s (1) * eps ("single");
63 tol = max (size (A)) * s (1) * eps;
70 retval = -U (:, 1:rank);
72 retval = zeros (rows, 0);
88 %! assert (V'*V, eye (10), 100*eps)