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 |
2538
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## 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 |
3922
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
2538
|
19 |
3321
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Mapping Function} {} xor (@var{x}, @var{y}) |
|
22 ## Return the `exclusive or' of the entries of @var{x} and @var{y}. |
|
23 ## For boolean expressions @var{x} and @var{y}, |
|
24 ## @code{xor (@var{x}, @var{y})} is true if and only if @var{x} or @var{y} |
|
25 ## is true, but not if both @var{x} and @var{y} are true. |
|
26 ## @end deftypefn |
2538
|
27 |
5428
|
28 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
2538
|
29 ## Created: 16 September 1994 |
|
30 ## Adapted-By: jwe |
|
31 |
|
32 function z = xor (x, y) |
|
33 |
2621
|
34 if (nargin == 2) |
6157
|
35 if (isscalar (x) || isscalar (y) || size_equal (x, y)) |
2870
|
36 z = logical ((x | y) - (x & y)); |
2621
|
37 else |
|
38 error ("xor: x and y must be of common size or scalars"); |
|
39 endif |
|
40 else |
6046
|
41 print_usage (); |
2538
|
42 endif |
|
43 |
|
44 endfunction |