You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 lines
661 B

% I = eye(2,2);
% dP = u * (dF + dF') + l * trace(dF) * I;
function dP = dPdF_fast_linear(global_u, global_l, dF)
[~, lenout, m] = size(dF);
dF_expand = reshape(dF, 4, []);
dFT = dF([1,3,2,4], :, :);
%% dP1 = u * (dF + dF')
mu(1,1,:) = global_u(:);
dP1 = (dF + dFT) .* mu; % 4 * l * m
%% dP3 = l * trace(dF) * I;
lambda = global_l(:)'; % 1 * m
trF = reshape(dF_expand(1,:)+dF_expand(4,:), lenout, []); % l*m
lm_tr(1,:,:) = lambda .* trF; % 1*l*m
I = reshape(repmat([1;0;0;1], lenout, m), size(dF)); % expand eye(2) to 4*l*m
dP2 = lm_tr .* I;
dP = dP1 + dP2; % 4 * l * m
end