function b=iseven(x) % ISEVEN Checks if input elements are even. Returns 1's if true and 0's % if not. % % [B] = ISEVEN(X), where X can be a number, vector or matrix % % % (C) Gaussian Process Toolbox 1.0 % (C) Copyright 2004-2007, Keith Neo % http://www.hamilton.ie error(nargchk(1,1,nargin)); if ~isnumeric(x) error('Argument must be a numeric array.'); end cls=class(x); if isempty(x) b=feval(cls,x); else switch cls case 'double' b=~mod(x,2); case 'single' b=single(~mod(double(x),2)); case {'uint8','uint16','uint32','uint64'} b=~bitand(x,1); case {'int8','int16','int32','int64'} error('Not implemented for classes int8, int16, int32, int64'); otherwise error('argument is of unrecognized class'); end end