pdepe/pde1dm's vectorized option

조회 수: 5 (최근 30일)
feynman feynman
feynman feynman 2024년 2월 4일
댓글: feynman feynman 2024년 3월 10일
In pdepe, when vectorized is turned on, the elapsed time is the same as that when vectorized is off. Why no improvement?
The doc of pde1dm says that for vectorized mode, we return coefficients at multiple x locations, so in the pdefunc function
nx=length(x); c = ones(1,nx);
need to replace the original
c=1
While pde1dm requires the above change in the pdefunc function code, when c and s in the pdefunc function aren't changed to their vector form, pdepe still allows vectorized to be turned on. Why such a difference?
  댓글 수: 18
Torsten
Torsten 2024년 3월 10일
편집: Torsten 2024년 3월 10일
Sure, if you can vectorize this loop in the "pdepe" code and rewrite "pdentrp" such that it accepts array inputs, you are done:
% Interior points
for ii = 2:nx-1
[U,Ux] = pdentrp(singular,m,xmesh(ii),u(:,ii),xmesh(ii+1),u(:,ii+1),xi(ii));
[cR,fR,sR] = feval(pde,xi(ii),tnow,U,Ux,varargin{:});
denom = zxmp1(ii) * cR + xzmp1(ii-1) * cL;
denom(denom == 0) = 1;
up(:,ii) = ((xim(ii) * fR - xim(ii-1) * fL) + ...
(zxmp1(ii) * sR + xzmp1(ii-1) * sL)) ./ denom;
cL = cR;
fL = fR;
sL = sR;
end
feynman feynman
feynman feynman 2024년 3월 10일
thank you very much for the hint!

댓글을 달려면 로그인하십시오.

답변 (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