필터 지우기
필터 지우기

Solve linear tensor equation

조회 수: 4 (최근 30일)
Dominique Gorissen
Dominique Gorissen 2023년 2월 12일
편집: Matt J 2023년 2월 12일
I am building a fem code and want to solve an equation of the form
f= tensorprod(A,u,[2,4],[1,2])
where:
size(A)= n by n by 2 by 2
Size(u) = n by 2
Size(F) = n by 2.
A and f are known, u is to be solved
please note that n is a large number e.g order of 1e4 and this equation has to be solved often
n=5;
A=rand(n,n,2,2);
u=rand(n,2); %u is actually the variable that is to be solved while f is known
f=tensorprod(A,u,[2 4],[1 2])
f = 5×2
2.2134 2.4372 1.8815 2.0397 2.8814 2.2488 2.5063 2.0120 3.1808 1.7589

채택된 답변

Matt J
Matt J 2023년 2월 12일
편집: Matt J 2023년 2월 12일
n=5;
A=rand(n,n,2,2);
utrue=rand(n,2);
f=tensorprod(A,utrue,[2 4],[1 2]);
A=permute(A,[1,3,2,4]);
A=reshape(A,2*n,2*n);
u=A\f(:); %solve
[u(:), utrue(:)]
ans = 10×2
0.2121 0.2121 0.7296 0.7296 0.3174 0.3174 0.5335 0.5335 0.6222 0.6222 0.8405 0.8405 0.3491 0.3491 0.2908 0.2908 0.8140 0.8140 0.1061 0.1061

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by