Mercurial > hg > octave-lyh
diff scripts/linear-algebra/subspace.m @ 11469:c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 12:41:21 -0800 |
parents | eb63fbe60fab |
children | fd0a3ac60b0e |
line wrap: on
line diff
--- a/scripts/linear-algebra/subspace.m +++ b/scripts/linear-algebra/subspace.m @@ -17,9 +17,9 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{angle} =} subspace (@var{a}, @var{B}) +## @deftypefn {Function File} {@var{angle} =} subspace (@var{A}, @var{B}) ## Determine the largest principal angle between two subspaces -## spanned by columns of matrices @var{a} and @var{b}. +## spanned by the columns of matrices @var{A} and @var{B}. ## @end deftypefn ## Author: Jaroslav Hajek <highegg@gmail.com> @@ -32,25 +32,25 @@ ## ## other texts are also around... -function ang = subspace (a, b) +function ang = subspace (A, B) if (nargin != 2) print_usage (); - elseif (ndims (a) != 2 || ndims (b) != 2) + elseif (ndims (A) != 2 || ndims (B) != 2) error ("subspace: expecting A and B to be 2-dimensional arrays"); - elseif (rows (a) != rows (b)) - error ("subspace: column dimensions of a and b must match"); + elseif (rows (A) != rows (B)) + error ("subspace: column dimensions of A and B must match"); endif - a = orth (a); - b = orth (b); - c = a'*b; + A = orth (A); + B = orth (B); + c = A'*B; scos = min (svd (c)); if (scos^2 > 1/2) - if (columns (a) >= columns (b)) - c = b - a*c; + if (columns (A) >= columns (B)) + c = B - A*c; else - c = a - b*c'; + c = A - B*c'; endif ssin = max (svd (c)); ang = asin (min (ssin, 1));