comparison src/DLD-FUNCTIONS/max.cc @ 14501:60e5cf354d80

Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions. * __contourc__.cc, __delaunayn__.cc, __dispatch__.cc, __dsearchn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, __voronoi__.cc, besselj.cc, betainc.cc, bsxfun.cc, cellfun.cc, chol.cc, conv2.cc, convhulln.cc, dassl.cc, det.cc, dlmread.cc, dmperm.cc, dot.cc, eig.cc, eigs.cc, fft.cc, fft2.cc, filter.cc, find.cc, gammainc.cc, gcd.cc, givens.cc, hess.cc, hex2num.cc, inv.cc, kron.cc, lookup.cc, lsode.cc, lu.cc, luinc.cc, matrix_type.cc, max.cc, mgorth.cc, nproc.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, sub2ind.cc, svd.cc, syl.cc, time.cc, tril.cc, tsearch.cc: Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
author Rik <octave@nomad.inbox5.com>
date Tue, 27 Mar 2012 22:46:45 -0700
parents 97883071e8e4
children
comparison
equal deleted inserted replaced
14498:36cfbd23fe9f 14501:60e5cf354d80
356 { 356 {
357 return do_minmax_body (args, nargout, true); 357 return do_minmax_body (args, nargout, true);
358 } 358 }
359 359
360 /* 360 /*
361 361 %!assert (min ([1, 4, 2, 3]), 1)
362 %% test/octave.test/arith/min-1.m 362 %!assert (min ([1; -10; 5; -2]), -10)
363 %!assert (min ([1, 4, 2, 3]) == 1); 363 %!assert (min ([4, i; -2, 2]), [-2, i])
364 %!assert (min ([1; -10; 5; -2]) == -10);
365
366 %% test/octave.test/arith/min-2.m
367 %!assert(all (min ([4, i; -2, 2]) == [-2, i]));
368
369 %% test/octave.test/arith/min-3.m
370 %!error <Invalid call to min> min ();
371
372 %% test/octave.test/arith/min-4.m
373 %!error <Invalid call to min> min (1, 2, 3, 4);
374 364
375 %!test 365 %!test
376 %! x = reshape (1:8,[2,2,2]); 366 %! x = reshape (1:8, [2,2,2]);
377 %! assert (max (x,[],1), reshape ([2, 4, 6, 8], [1,2,2])); 367 %! assert (max (x, [], 1), reshape ([2, 4, 6, 8], [1,2,2]));
378 %! assert (max (x,[],2), reshape ([3, 4, 7, 8], [2,1,2])); 368 %! assert (max (x, [], 2), reshape ([3, 4, 7, 8], [2,1,2]));
379 %! [y, i ] = max (x, [], 3); 369 %! [y, i] = max (x, [], 3);
370 %! assert (ndims (y), 2);
380 %! assert (y, [5, 7; 6, 8]); 371 %! assert (y, [5, 7; 6, 8]);
381 %! assert (ndims(y), 2); 372 %! assert (ndims (i), 2);
382 %! assert (i, [2, 2; 2, 2]); 373 %! assert (i, [2, 2; 2, 2]);
383 %! assert (ndims(i), 2); 374
384 375 %!error min ()
376 %!error min (1, 2, 3, 4)
385 */ 377 */
386 378
387 DEFUN_DLD (max, args, nargout, 379 DEFUN_DLD (max, args, nargout,
388 "-*- texinfo -*-\n\ 380 "-*- texinfo -*-\n\
389 @deftypefn {Loadable Function} {} max (@var{x})\n\ 381 @deftypefn {Loadable Function} {} max (@var{x})\n\
435 { 427 {
436 return do_minmax_body (args, nargout, false); 428 return do_minmax_body (args, nargout, false);
437 } 429 }
438 430
439 /* 431 /*
440 432 %!assert (max ([1, 4, 2, 3]), 4)
441 %% test/octave.test/arith/max-1.m 433 %!assert (max ([1; -10; 5; -2]), 5)
442 %!assert (max ([1, 4, 2, 3]) == 4); 434 %!assert (max ([4, i 4.999; -2, 2, 3+4i]), [4, 2, 3+4i])
443 %!assert (max ([1; -10; 5; -2]) == 5);
444
445 %% test/octave.test/arith/max-2.m
446 %!assert(all (max ([4, i 4.999; -2, 2, 3+4i]) == [4, 2, 3+4i]));
447
448 %% test/octave.test/arith/max-3.m
449 %!error <Invalid call to max> max ();
450
451 %% test/octave.test/arith/max-4.m
452 %!error <Invalid call to max> max (1, 2, 3, 4);
453 435
454 %!test 436 %!test
455 %! x = reshape (1:8,[2,2,2]); 437 %! x = reshape (1:8, [2,2,2]);
456 %! assert (min (x,[],1), reshape ([1, 3, 5, 7], [1,2,2])); 438 %! assert (min (x, [], 1), reshape ([1, 3, 5, 7], [1,2,2]));
457 %! assert (min (x,[],2), reshape ([1, 2, 5, 6], [2,1,2])); 439 %! assert (min (x, [], 2), reshape ([1, 2, 5, 6], [2,1,2]));
458 %! [y, i ] = min (x, [], 3); 440 %! [y, i] = min (x, [], 3);
441 %! assert (ndims(y), 2);
459 %! assert (y, [1, 3; 2, 4]); 442 %! assert (y, [1, 3; 2, 4]);
460 %! assert (ndims(y), 2); 443 %! assert (ndims(i), 2);
461 %! assert (i, [1, 1; 1, 1]); 444 %! assert (i, [1, 1; 1, 1]);
462 %! assert (ndims(i), 2); 445
463 446 %!error max ()
464 447 %!error max (1, 2, 3, 4)
465 */ 448 */
466 449
467 template <class ArrayType> 450 template <class ArrayType>
468 static octave_value_list 451 static octave_value_list
469 do_cumminmax_red_op (const octave_value& arg, 452 do_cumminmax_red_op (const octave_value& arg,