Mercurial > hg > octave-lyh
changeset 10031:8db5553c24f5
optimize xor
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 26 Dec 2009 21:30:15 +0100 |
parents | 83bb2a78c07d |
children | 691b4ba32425 |
files | scripts/ChangeLog scripts/miscellaneous/xor.m |
diffstat | 2 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-12-26 Jaroslav Hajek <highegg@gmail.com> + + * miscellaneous/xor.m: Optimize. + 2009-12-25 Jaroslav Hajek <highegg@gmail.com> * general/issquare.m: Do not check type.
--- a/scripts/miscellaneous/xor.m +++ b/scripts/miscellaneous/xor.m @@ -33,7 +33,8 @@ if (nargin == 2) if (isscalar (x) || isscalar (y) || size_equal (x, y)) - z = logical ((x | y) - (x & y)); + ## Typecast to logicals is necessary for other numeric types. + z = logical (x) != logical (y); else error ("xor: x and y must be of common size or scalars"); endif