1 Star 0 Fork 1

杂杳/YALMIP

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
and.m 822 Bytes
Copy Edit Raw Blame History
johanlofberg authored 2015-02-20 16:09 +08:00 . Refactoring and tests for #269
function varargout = and(varargin)
%AND (overloaded)
%
% z = and(x,y)
% z = x & y
%
% It is assumed that x and y are binary variables (either explicitely
% declared using BINVAR, or constrained using BINARY.)
%
% See also SDPVAR/OR, SDPVAR/XOR, SDPVAR/NOT, BINVAR, BINARY
switch class(varargin{1})
case 'char'
z = varargin{2};
xy = [];
for i = 3:nargin
xy = [xy varargin{i}];
end
varargout{1} = (xy >= z) + (length(xy)-1+z >= sum(xy)) + (binary(z));
varargout{2} = struct('convexity','none','monotonicity','none','definiteness','none','model','integer');
varargout{3} = xy;
case {'sdpvar','double','logical'}
varargout{1} = vectorizedlogic(@and,varargin{:});
otherwise
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/codeinLinXu/YALMIP.git
git@gitee.com:codeinLinXu/YALMIP.git
codeinLinXu
YALMIP
YALMIP
develop

Search