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.
 
 
 

45 lines
783 B

function tensor_compute()
% k=1;l=2;
A=rand(3,3,3,3);
lam=rand(1,1);
mu=rand(1,1);
I=eye(3);
% I4 = zeros(3,3,3,3);
% I2_2=zeros(3,3,3,3);
% for i=1:3
% I4(i,i,i,i)=1;
% end
% for i=1:3
% for j=1:3
% for k=1:3
% for l=1:3
% I2_2(i,j,k,l)=I(i,j)*I(k,l);
% end
% end
% end
% end
% A = lam.*I2_2+2*mu.*I4;
kk=1;ll=3;
ek=I(:,kk);el=I(ll,:);
ekl = kron(ek,el);
% ekl = (kron(ek,el)+kron(el.',ek.'))./2;
% ekl
P = zeros(3,3);
for i=1:3
for j=1:3
for k=1:3
for l=1:3
P(i,j) = P(i,j) + A(i,j,k,l)*ekl(k,l);
end
end
end
end
% sum(P,'all')
%
% sum(A(:,:,k,l),'all')
P
squeeze(A(:,:,kk,ll))
end