⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diff.m

📁 GloptiPoly 3: moments, optimization and semidefinite programming. Gloptipoly 3 is intended to so
💻 M
字号:
function d = diff(p,v)% @MPOL/DIFF - Differentiate%% DIFF(P,V) differentiates a scalar, vector or matrix polynomial P% with respect to the variable V%% If V is a vector of several variables, then DIFF(P,V) returns% the Jacobian of the scalar or vector polynomial P with respect to V,% that is, the matrix whose (i,j)-th entry is DIFF(P(i),V(j))%% DIFF(P) returns the Jacobian with respect to all variables in P% D. Henrion, 21 April 2006if nargin < 2 v = indvar(p);else if ~isa(v,'mpol')  error('Invalid second input argument') end v = indvar(v);end[nr,nc] = size(p);if min(nr,nc) == 0  d = [];else   if (min(nr,nc) > 1) & (length(v) > 1)  error('Cannot generate Jacobian of a matrix polynomial') end n = nr*nc; nv = length(v); d = p(:); for i = 2:nv % for each variable  d = [d d(:,1)]; end for ip = 1:n  vp = indvar(p(ip));  cp = p(ip).coef;  pp = p(ip).pow;  for iv = 1:nv   ic = find(vp == v(iv));   if isempty(ic) % not a variable    d(ip,iv) = mpol(0);   else % differentiate    ir = find(pp(:,ic) > 0);    if isempty(ir) % constant     d(ip,iv) = mpol(0);    else          d(ip,iv).coef = cp(ir).*pp(ir,ic);     d(ip,iv).pow = pp(ir,:);     d(ip,iv).pow(:,ic) = d(ip,iv).pow(:,ic)-1;     d(ip,iv) = reduce(d(ip,iv));    end   end  end end if min(nr,nc) > 1 % and hence nv = 1  d = reshape(d,nr,nc); % matrix endend 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -