Hi

I'm sorry about the late reply, but I have just been painfully busy
lately :-(

lør, 12 06 2010 kl. 17:07 -0400, skrev Kyle Winfree:
>      I have made most of the comments you have requested.  I retained 
> the switch case so that it will handle null input and because I don't 
> see how to change line 44 to work for the general and the vector case.  

I think having more explicit error checking would be good. Something
like

  if (!all (cellfun (@isvector, varargin)))
    error ("gramian: all input arguments must be vectors");
  endif

  if (!size_equal (varargin {:}))
    error ("gramian: all input vectors must be of the same size");
  endif

should do the trick (warning: the code is untested).

Then I think you can write your code as

  N = numel (varargin {1});
  M = zeros (N, narargin);
  for k = 1:narargin
    M (:, k) = varargin {k};
  endfor
  G = M.' * M;

(I think you were missing a transposition in your code, right?)

> I didn't implement the optional definition of the dot product yet, as I 
> wasn't sure how to do that.  Would it be best to accept an optional flag 
> for a separate function that gramian could then use?

I think you should just allow the user to pass a function handle as the
last argument (or first). I don't think you'll be able to vectorise that
though.

>   Vectorizing the 
> ast loop makes this function look trivial to me.  If I can figure out 
> exactly how to implement the optional dot product definition, then that 
> could add some value to it, but otherwise there just really isn't much 
> to it.  Your thoughts?

Many functions in Octave are actually trivial. The reason why we have
them anyway is that they are not always trivial to all users and they
can actually make your code more readable. So I still think it is
useful.

Søren


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to