octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subspace


From: Jaroslav Hajek
Subject: Re: subspace
Date: Thu, 20 Mar 2008 07:31:14 +0100

On Thu, Mar 20, 2008 at 2:29 AM, John W. Eaton <address@hidden> wrote:
> On 17-Mar-2008, Jaroslav Hajek wrote:
>
>  | another one from Matlab's...
>
>  I applied this patch with some additional changes (see below).
>
>  | +## Author: Jaroslav Hajek <address@hidden>
>  | +##
>  | +## reference:
>  | +## [1]  Andrew V. Knyazev, Merico E. Argentati:
>  | +##   Principal Angles between Subspaces in an A-Based Scalar Product:
>  | +##  Algorithms and Perturbation Estimates.
>  | +##  SIAM Journal on Scientific Computing, Vol. 23 no. 6, pp. 2008-2040
>  | +##
>  | +## other texts are also around...
>
>  Extra information like this normally goes below the doc string.
>
>  | +## -*- texinfo -*-
>  | +## @deftypefn{Function File} angle = subspace (A, B)
>
>  You should use
>
>   ## @deftypefn {Function File} address@hidden =} subspace (@var{a}, @var{b})
>
>  | +## determines the largest principal angle between two subspaces
>  | +## (spanned by columns of matrices @var{A}, @var{B}).
>
>  The first sentence of a doc string should be capitalized and written
>  as a command rather than a description.  For example:
>
>   Determine the largest principal angle...
>
>  | +function ang = subspace (A, B)
>
>  We usually prefer to use lower-case variable names.
>
>  | +A = orth (A);
>  | +B = orth (B);
>  | +C = A'*B;
>  | +scos = min (svd (C));
>  | +if (scos^2 > 1/2)
>  | +  if (size (A, 2) >= size (B, 2))
>
>  We generally prefer columns (a) over size (a, 2).  Likewise for rows
>  (a) and size (a, 1).
>
>  | +    C = B - A*C;
>  | +  else
>  | +    C = A - B*C';
>  | +  endif
>  | +  ssin = max (svd (C));
>  | +  ang = asin (min (ssin, 1));
>  | +else
>  | +  ang = acos (scos);
>  | +endif
>  | +
>
>  Please indent the body of the function and end with an "endfunction"
>  keyword.
>

That reminds me again about the "recommended coding practices" text I
wanted. I'm definitely going to do it after Easter :)

A changeset with the checks attached. Btw. is attaching changesets as
files OK, or is it better to include it in the message (as you and Ben
do)?



>  Is this function only supposed to work for 2-d arrays?  If so, there
>  should probably be a check on the number of dimensions of a and b.  I
>  made the above changes but not this one, so if it should only work for
>  2-d arrays, please let me know or submit a patch for the change.
>
>  Thanks,
>
>  jwe
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

Attachment: subspace1.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]