Mercurial > hg > octave-nkf
comparison libinterp/corefcn/data.cc @ 19310:9c5a17d5fc19
Deprecate fmod function.
* NEWS: Announce deprecation.
* scripts/deprecated/fmod.m: New m-file to replace C++ function and issue
deprecated warning.
* scripts/deprecated/module.mk: Add fmod.m to build system.
* data.cc: Remove DEFALIAS of fmod to rem. Replace fmod with rem in %!tests.
* datetick.m: Replace fmod usage with rem.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 20 Sep 2014 20:31:16 -0700 |
parents | ba442cd7f7c3 |
children | 0f9c5a15c8fa |
comparison
equal
deleted
inserted
replaced
19309:a4c226a963c5 | 19310:9c5a17d5fc19 |
---|---|
574 %!assert (all (log2 (pow2 (-1074:1023)) == -1074:1023)) | 574 %!assert (all (log2 (pow2 (-1074:1023)) == -1074:1023)) |
575 */ | 575 */ |
576 | 576 |
577 DEFUN (rem, args, , | 577 DEFUN (rem, args, , |
578 "-*- texinfo -*-\n\ | 578 "-*- texinfo -*-\n\ |
579 @deftypefn {Mapping Function} {} rem (@var{x}, @var{y})\n\ | 579 @deftypefn {Mapping Function} {} rem (@var{x}, @var{y})\n\ |
580 @deftypefnx {Mapping Function} {} fmod (@var{x}, @var{y})\n\ | |
581 Return the remainder of the division @code{@var{x} / @var{y}}, computed\n\ | 580 Return the remainder of the division @code{@var{x} / @var{y}}, computed\n\ |
582 using the expression\n\ | 581 using the expression\n\ |
583 \n\ | 582 \n\ |
584 @example\n\ | 583 @example\n\ |
585 x - y .* fix (x ./ y)\n\ | 584 x - y .* fix (x ./ y)\n\ |
675 | 674 |
676 return retval; | 675 return retval; |
677 } | 676 } |
678 | 677 |
679 /* | 678 /* |
680 %!assert (size (fmod (zeros (0, 2), zeros (0, 2))), [0, 2]) | 679 %!assert (size (rem (zeros (0, 2), zeros (0, 2))), [0, 2]) |
681 %!assert (size (fmod (rand (2, 3, 4), zeros (2, 3, 4))), [2, 3, 4]) | 680 %!assert (size (rem (rand (2, 3, 4), zeros (2, 3, 4))), [2, 3, 4]) |
682 %!assert (size (fmod (rand (2, 3, 4), 1)), [2, 3, 4]) | 681 %!assert (size (rem (rand (2, 3, 4), 1)), [2, 3, 4]) |
683 %!assert (size (fmod (1, rand (2, 3, 4))), [2, 3, 4]) | 682 %!assert (size (rem (1, rand (2, 3, 4))), [2, 3, 4]) |
684 %!assert (size (fmod (1, 2)), [1, 1]) | 683 %!assert (size (rem (1, 2)), [1, 1]) |
685 | 684 |
686 %!assert (rem ([1, 2, 3; -1, -2, -3], 2), [1, 0, 1; -1, 0, -1]) | 685 %!assert (rem ([1, 2, 3; -1, -2, -3], 2), [1, 0, 1; -1, 0, -1]) |
687 %!assert (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)),[1, 0, 1; -1, 0, -1]) | 686 %!assert (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)),[1, 0, 1; -1, 0, -1]) |
688 %!assert (rem (uint8 ([1, 2, 3; -1, -2, -3]), uint8 (2)), uint8 ([1, 0, 1; -1, 0, -1])) | 687 %!assert (rem (uint8 ([1, 2, 3; -1, -2, -3]), uint8 (2)), uint8 ([1, 0, 1; -1, 0, -1])) |
689 %!assert (uint8 (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3))),uint8 ([1, 0, 1; -1, 0, -1])) | 688 %!assert (uint8 (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3))),uint8 ([1, 0, 1; -1, 0, -1])) |
724 %!error rem (i, 1) | 723 %!error rem (i, 1) |
725 | 724 |
726 # bug 42627 | 725 # bug 42627 |
727 %!assert (rem (0.94, 0.01), 0.0); | 726 %!assert (rem (0.94, 0.01), 0.0); |
728 */ | 727 */ |
729 | |
730 DEFALIAS (fmod, rem) | |
731 | 728 |
732 DEFUN (mod, args, , | 729 DEFUN (mod, args, , |
733 "-*- texinfo -*-\n\ | 730 "-*- texinfo -*-\n\ |
734 @deftypefn {Mapping Function} {} mod (@var{x}, @var{y})\n\ | 731 @deftypefn {Mapping Function} {} mod (@var{x}, @var{y})\n\ |
735 Compute the modulo of @var{x} and @var{y}. Conceptually this is given by\n\ | 732 Compute the modulo of @var{x} and @var{y}. Conceptually this is given by\n\ |