octave-maintainers
[Top][All Lists]
Advanced

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

subspace


From: John W. Eaton
Subject: subspace
Date: Wed, 19 Mar 2008 21:29:02 -0400

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.

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


reply via email to

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