2538
|
1 ## Copyright (C) 1995, 1996 Kurt Hornik |
3426
|
2 ## |
3922
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
3426
|
9 ## |
3922
|
10 ## Octave is distributed in the hope that it will be useful, but |
2538
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
13 ## General Public License for more details. |
|
14 ## |
2538
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
2538
|
18 |
3321
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Mapping Function} {} xor (@var{x}, @var{y}) |
|
21 ## Return the `exclusive or' of the entries of @var{x} and @var{y}. |
|
22 ## For boolean expressions @var{x} and @var{y}, |
|
23 ## @code{xor (@var{x}, @var{y})} is true if and only if @var{x} or @var{y} |
|
24 ## is true, but not if both @var{x} and @var{y} are true. |
|
25 ## @end deftypefn |
2538
|
26 |
5428
|
27 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
2538
|
28 ## Created: 16 September 1994 |
|
29 ## Adapted-By: jwe |
|
30 |
|
31 function z = xor (x, y) |
|
32 |
2621
|
33 if (nargin == 2) |
6157
|
34 if (isscalar (x) || isscalar (y) || size_equal (x, y)) |
2870
|
35 z = logical ((x | y) - (x & y)); |
2621
|
36 else |
|
37 error ("xor: x and y must be of common size or scalars"); |
|
38 endif |
|
39 else |
6046
|
40 print_usage (); |
2538
|
41 endif |
|
42 |
|
43 endfunction |