From bug-request at octave dot org Sat Dec 31 21:20:03 2005 Subject: Re: rows and columns (functions) From: William Poetra Yoga Hadisoeseno To: "John W. Eaton" Cc: bug at octave dot org Date: Sun, 1 Jan 2006 11:18:29 +0800 ------=_Part_597_14986635.1136085509835 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 12/2/05, John W. Eaton wrote: > Probably because rows and columns were written before Octave's size > command (or even Matlab's) accepted a DIM argument. > > | Even better, making them built-in functions would > | speed up the whole thing, I think. > > Show me the code. :-) > Hi, sorry John, I forgot about this thing and now I think you have modified the rows.m and columns.m scripts to use the latter form. I've written them now, and they're attached in the mail. -- William Poetra Yoga Hadisoeseno ------=_Part_597_14986635.1136085509835 Content-Type: text/plain; name=rows_columns.diff.txt; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rows_columns.diff.txt" Index: src/data.cc =================================================================== RCS file: /cvs/octave/src/data.cc,v retrieving revision 1.146 diff -u -r1.146 data.cc --- src/data.cc 10 Nov 2005 21:40:48 -0000 1.146 +++ src/data.cc 1 Jan 2006 03:02:29 -0000 at @ -1077,6 +1077,42 @@ return retval; } +DEFUN (rows, args, , + "-*- texinfo -*-\n\ + at deftypefn {Built-in Function} {} rows (@var{a})\n\ +Return the number of rows of at var{a} dot \n\ + at end deftypefn\n\ +\n\ + at seealso{size, columns, length, isscalar, isvector, and ismatrix}") +{ + octave_value_list retval; + + if (args.length () == 1) + retval(0) = (args(0).dims ())(0); + else + print_usage ("rows"); + + return retval; +} + +DEFUN (columns, args, , + "-*- texinfo -*-\n\ + at deftypefn {Built-in Function} {} columns (@var{a})\n\ +Return the number of columns of at var{a} dot \n\ + at end deftypefn\n\ +\n\ + at seealso{size, rows, length, isscalar, isvector, and ismatrix}") +{ + octave_value_list retval; + + if (args.length () == 1) + retval(0) = (args(0).dims ())(1); + else + print_usage ("columns"); + + return retval; +} + DEFUN (sum, args, , "-*- texinfo -*-\n\ at deftypefn {Built-in Function} {} sum (@var{x}, @var{dim})\n\ ------=_Part_597_14986635.1136085509835 Content-Type: text/plain; name=rows_columns.ChangeLog.txt; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rows_columns.ChangeLog.txt" 2006-01-01 William Poetra Yoga Hadisoeseno * src/data.cc: Make rows and columns built-in functions, rather than function files. ------=_Part_597_14986635.1136085509835-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------