comparison src/DLD-FUNCTIONS/find.cc @ 11553:01f703952eff

Improve docstrings for functions in DLD-FUNCTIONS directory. Use same variable names in error() strings and in documentation.
author Rik <octave@nomad.inbox5.com>
date Sun, 16 Jan 2011 22:13:23 -0800
parents fd0a3ac60b0e
children 12df7854fa7c
comparison
equal deleted inserted replaced
11552:6b6e9051ecb8 11553:01f703952eff
335 return retval; 335 return retval;
336 } 336 }
337 337
338 DEFUN_DLD (find, args, nargout, 338 DEFUN_DLD (find, args, nargout,
339 "-*- texinfo -*-\n\ 339 "-*- texinfo -*-\n\
340 @deftypefn {Loadable Function} {} find (@var{x})\n\ 340 @deftypefn {Loadable Function} {@var{idx} =} find (@var{x})\n\
341 @deftypefnx {Loadable Function} {} find (@var{x}, @var{n})\n\ 341 @deftypefnx {Loadable Function} {@var{idx} =} find (@var{x}, @var{n})\n\
342 @deftypefnx {Loadable Function} {} find (@var{x}, @var{n}, @var{direction})\n\ 342 @deftypefnx {Loadable Function} {@var{idx} =} find (@var{x}, @var{n}, @var{direction})\n\
343 @deftypefnx {Loadable Function} {[i, j] =} find (@dots{})\n\
344 @deftypefnx {Loadable Function} {[i, j, v]] =} find (@dots{})\n\
343 Return a vector of indices of nonzero elements of a matrix, as a row if\n\ 345 Return a vector of indices of nonzero elements of a matrix, as a row if\n\
344 @var{x} is a row or as a column otherwise. To obtain a single index for\n\ 346 @var{x} is a row or as a column otherwise. To obtain a single index for\n\
345 each matrix element, Octave pretends that the columns of a matrix form one\n\ 347 each matrix element, Octave pretends that the columns of a matrix form one\n\
346 long vector (like Fortran arrays are stored). For example:\n\ 348 long vector (like Fortran arrays are stored). For example:\n\
347 \n\ 349 \n\
391 sz = size(a);\n\ 393 sz = size(a);\n\
392 [i, j, v] = find (a);\n\ 394 [i, j, v] = find (a);\n\
393 b = sparse(i, j, v, sz(1), sz(2));\n\ 395 b = sparse(i, j, v, sz(1), sz(2));\n\
394 @end group\n\ 396 @end group\n\
395 @end example\n\ 397 @end example\n\
396 @seealso{sparse}\n\ 398 @seealso{nonzeros}\n\
397 @end deftypefn") 399 @end deftypefn")
398 { 400 {
399 octave_value_list retval; 401 octave_value_list retval;
400 402
401 int nargin = args.length (); 403 int nargin = args.length ();
412 { 414 {
413 double val = args(1).scalar_value (); 415 double val = args(1).scalar_value ();
414 416
415 if (error_state || (val < 0 || (! xisinf (val) && val != xround (val)))) 417 if (error_state || (val < 0 || (! xisinf (val) && val != xround (val))))
416 { 418 {
417 error ("find: expecting second argument to be a nonnegative integer"); 419 error ("find: N must be a nonnegative integer");
418 return retval; 420 return retval;
419 } 421 }
420 else if (! xisinf (val)) 422 else if (! xisinf (val))
421 n_to_find = val; 423 n_to_find = val;
422 } 424 }
437 direction = -1; 439 direction = -1;
438 } 440 }
439 441
440 if (direction == 0) 442 if (direction == 0)
441 { 443 {
442 error ("find: expecting third argument to be \"first\" or \"last\""); 444 error ("find: DIRECTION must be \"first\" or \"last\"");
443 return retval; 445 return retval;
444 } 446 }
445 } 447 }
446 448
447 octave_value arg = args(0); 449 octave_value arg = args(0);