Søren Hauberg wrote: > Hi, > > søn, 20 09 2009 kl. 21:07 +0200, skrev Jaiver Enciso: >> I would like to contribute with the divergence function. This function >> is used to compute divergence of vector field and is not included in >> Octave's distribution. So, could you please give a suggestion on where >> to locate the file within the repository? > > The 'divergence' function appears to be a core Matlab function, so I > suppose this function should be part of core Octave. > > For this to happen, you would, however, need to make the coding style > match the one used in Octave. I'll give you a couple of pointers on this > below (I'll only point out things once, though, so you'll need to make > the changes multible times). Could you change the issues I point out and > resend your function to [email protected] ? > > The first comment is that you should indent the function bodies. That > is, write > > function A () > body; > endfunction > > instead of > > function A () > body; > endfunction > >> if nargin < 2 > > Please use parentheses, i.e. write > > if (nargin < 2) > >> print_usage(); >> return > > You don't need the 'return' statement here. In general, please remove > these. It is better if the function only return at one point. Also, > please add a space between parentheses and function names, i.e. > > print_usage (); > > instead of > > print_usage(); > >> [du dump] = gradient(u); > > Add commas in lists, i.e. write > > [du, dump] = gradient(u); > >> end > > Use 'endif' instead of the generic 'end'. This goes in general. > >> else >> print_usage(); >> return >> end > > Do you need this last block? Couldn't you merge this with the first > block, such that you only have one call to 'print_usage' ? > > Also, please end functions with 'endfunction'. > >> error('Matrices must have 2 dimensions'); > > Use " around strings instead of ' > >> msg = 1; > > It seems like this function always returns 'msg = 1'. So, do you need to > return anything in the first place? > >> error('Size of matrices must be equal'); > > Can you use the 'size_equal' for comparing sizes? > > Søren > > P.S. I hope you don't consider these comments too pedantic, but one of > the great parts about the core Octave source code is that all the code > is written in practically the same style.
Hi Søren, Thanks a lot for your advice on Octave's coding style, I wasn't aware of it and certainly I don't consider your comments as pedantic but constructive ;-). Regards, Javier P.S.: The code is ready and I'm about to sent it to the maintainers of Octave. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Octave-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/octave-dev
