annotate scripts/miscellaneous/xor.m @ 3321:6923abb04e16

[project @ 1999-10-26 18:15:30 by jwe]
author jwe
date Tue, 26 Oct 1999 18:15:41 +0000
parents 3241d0057e78
children f8dde1807dee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2538
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1995, 1996 Kurt Hornik
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
2 ##
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
3 ## This program is free software; you can redistribute it and/or modify
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
4 ## it under the terms of the GNU General Public License as published by
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
5 ## the Free Software Foundation; either version 2, or (at your option)
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
6 ## any later version.
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
7 ##
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
8 ## This program is distributed in the hope that it will be useful, but
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
11 ## General Public License for more details.
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
12 ##
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
13 ## You should have received a copy of the GNU General Public License
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
14 ## along with this file. If not, write to the Free Software Foundation,
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
16
3321
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2870
diff changeset
17 ## -*- texinfo -*-
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2870
diff changeset
18 ## @deftypefn {Mapping Function} {} xor (@var{x}, @var{y})
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2870
diff changeset
19 ## Return the `exclusive or' of the entries of @var{x} and @var{y}.
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2870
diff changeset
20 ## For boolean expressions @var{x} and @var{y},
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2870
diff changeset
21 ## @code{xor (@var{x}, @var{y})} is true if and only if @var{x} or @var{y}
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2870
diff changeset
22 ## is true, but not if both @var{x} and @var{y} are true.
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2870
diff changeset
23 ## @end deftypefn
2538
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
24
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
25 ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at>
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
26 ## Created: 16 September 1994
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
27 ## Adapted-By: jwe
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
28
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
29 function z = xor (x, y)
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
30
2621
337a09dd1c06 [project @ 1997-01-24 21:49:41 by jwe]
jwe
parents: 2538
diff changeset
31 if (nargin == 2)
337a09dd1c06 [project @ 1997-01-24 21:49:41 by jwe]
jwe
parents: 2538
diff changeset
32 if (is_scalar (x) || is_scalar (y) || size (x) == size (y))
2870
3241d0057e78 [project @ 1997-04-19 01:21:29 by jwe]
jwe
parents: 2621
diff changeset
33 z = logical ((x | y) - (x & y));
2621
337a09dd1c06 [project @ 1997-01-24 21:49:41 by jwe]
jwe
parents: 2538
diff changeset
34 else
337a09dd1c06 [project @ 1997-01-24 21:49:41 by jwe]
jwe
parents: 2538
diff changeset
35 error ("xor: x and y must be of common size or scalars");
337a09dd1c06 [project @ 1997-01-24 21:49:41 by jwe]
jwe
parents: 2538
diff changeset
36 endif
337a09dd1c06 [project @ 1997-01-24 21:49:41 by jwe]
jwe
parents: 2538
diff changeset
37 else
2538
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
38 usage ("xor (x, y)");
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
39 endif
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
40
6f71af650490 [project @ 1996-11-19 21:41:48 by jwe]
jwe
parents:
diff changeset
41 endfunction